Skip to content

Commit

Permalink
Port to LLVM 12 (tested with 12.0.0 rc2).
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Mar 9, 2021
1 parent de9373b commit 977ff21
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion clang_delta/TransformationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
ClangInstance->createDiagnostics();

TargetOptions &TargetOpts = ClangInstance->getTargetOpts();
#if LLVM_VERSION_MAJOR < 12
PreprocessorOptions &PPOpts = ClangInstance->getPreprocessorOpts();
#endif
if (const char *env = getenv("CVISE_TARGET_TRIPLE")) {
TargetOpts.Triple = std::string(env);
} else {
Expand Down Expand Up @@ -138,7 +140,7 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind::CXX, T, PPOpts, LSTD);
}
else if(IK.getLanguage() == InputKind::OpenCL) {
#else
#elif LLVM_VERSION_MAJOR < 12
if (IK.getLanguage() == Language::C) {
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind(Language::C), T, PPOpts);
}
Expand All @@ -149,6 +151,18 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind(Language::CXX), T, PPOpts, LSTD);
}
else if(IK.getLanguage() == Language::OpenCL) {
#else
vector<string> includes;
if (IK.getLanguage() == Language::C) {
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind(Language::C), T, includes);
}
else if (IK.getLanguage() == Language::CXX) {
// ISSUE: it might cause some problems when building AST
// for a function which has a non-declared callee, e.g.,
// It results an empty AST for the caller.
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind(Language::CXX), T, includes, LSTD);
}
else if(IK.getLanguage() == Language::OpenCL) {
#endif
//Commandline parameters
std::vector<const char*> Args;
Expand Down Expand Up @@ -183,7 +197,12 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
#else
InputKind::OpenCL,
#endif

#if LLVM_VERSION_MAJOR < 12
T, PPOpts);
#else
T, includes);
#endif
}
else {
ErrorMsg = "Unsupported file type!";
Expand Down

0 comments on commit 977ff21

Please sign in to comment.