Skip to content

Commit

Permalink
Merge branch 'sotoc-remove-static-vars' into 'aurora_offloading_proto…
Browse files Browse the repository at this point in the history
…type'

Remove 'static' from global vars.

Closes llvm#26

See merge request NEC-RWTH-Projects/clang!25
  • Loading branch information
manorom committed Jun 19, 2019
2 parents 72f2103 + 0145a0d commit 59e7294
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clang/tools/sotoc/src/TargetCodeFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,26 @@ std::string TargetCodeDecl::PrintPretty() {

TargetRegionPrinterHelper Helper(PP);

// This hack removes the 'static' keyword from globalVarDecls, because we
// cannot find variables from the host if they are static.
bool HasStaticKeyword = false;
if (auto *VarDeclNode = llvm::dyn_cast<clang::VarDecl>(DeclNode)) {
if (VarDeclNode->getStorageClass() == clang::SC_Static) {
HasStaticKeyword = true;
VarDeclNode->setStorageClass(clang::SC_None);
}
}

DeclNode->print(PrettyOS, LocalPP, 0, false, &Helper);

// Add static storage class back so (hopefully) this doesnt break anyting
// (but it totally will).
if (auto *VarDeclNode = llvm::dyn_cast<clang::VarDecl>(DeclNode)) {
if (HasStaticKeyword) {
VarDeclNode->setStorageClass(clang::SC_Static);
}
}

// This hack removes '#pragma omp declare target' from the output
std::string outString = PrettyOS.str();
const char *declareTargetPragma = "#pragma omp declare target";
Expand Down

0 comments on commit 59e7294

Please sign in to comment.