mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-19 09:15:30 +03:00
79 lines
3.2 KiB
Diff
79 lines
3.2 KiB
Diff
See: https://github.com/csmith-project/creduce/pull/204
|
|
From 37a8db44d97029e95f3ab9a728d23053eb82c1cd Mon Sep 17 00:00:00 2001
|
|
From: Bernhard Rosenkraenzer <bero@lindev.ch>
|
|
Date: Thu, 6 Feb 2020 15:02:35 +0100
|
|
Subject: [PATCH] Port to LLVM 10.0
|
|
|
|
---
|
|
clang_delta/TransformationManager.cpp | 27 +++++++++++++++++++++++++--
|
|
1 file changed, 25 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/clang_delta/TransformationManager.cpp b/clang_delta/TransformationManager.cpp
|
|
index ca2f2b48..acf82837 100644
|
|
--- a/clang_delta/TransformationManager.cpp
|
|
+++ b/clang_delta/TransformationManager.cpp
|
|
@@ -16,6 +16,7 @@
|
|
|
|
#include <sstream>
|
|
|
|
+#include "clang/Basic/Builtins.h"
|
|
#include "clang/Basic/Diagnostic.h"
|
|
#include "clang/Basic/TargetInfo.h"
|
|
#include "clang/Lex/Preprocessor.h"
|
|
@@ -101,6 +102,7 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
|
|
CompilerInvocation &Invocation = ClangInstance->getInvocation();
|
|
InputKind IK = FrontendOptions::getInputKindForExtension(
|
|
StringRef(SrcFileName).rsplit('.').second);
|
|
+#if LLVM_VERSION_MAJOR < 10
|
|
if (IK.getLanguage() == InputKind::C) {
|
|
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind::C, T, PPOpts);
|
|
}
|
|
@@ -111,6 +113,18 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
|
|
Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind::CXX, T, PPOpts);
|
|
}
|
|
else if(IK.getLanguage() == InputKind::OpenCL) {
|
|
+#else
|
|
+ if (IK.getLanguage() == Language::C) {
|
|
+ Invocation.setLangDefaults(ClangInstance->getLangOpts(), InputKind(Language::C), T, PPOpts);
|
|
+ }
|
|
+ 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, PPOpts);
|
|
+ }
|
|
+ else if(IK.getLanguage() == Language::OpenCL) {
|
|
+#endif
|
|
//Commandline parameters
|
|
std::vector<const char*> Args;
|
|
Args.push_back("-x");
|
|
@@ -122,7 +136,7 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
|
|
ClangInstance->createFileManager();
|
|
|
|
if(CLCPath != NULL && ClangInstance->hasFileManager() &&
|
|
- ClangInstance->getFileManager().getDirectory(CLCPath, false) != NULL) {
|
|
+ ClangInstance->getFileManager().getDirectory(CLCPath, false)) {
|
|
Args.push_back("-I");
|
|
Args.push_back(CLCPath);
|
|
}
|
|
@@ -132,10 +146,19 @@ bool TransformationManager::initializeCompilerInstance(std::string &ErrorMsg)
|
|
Args.push_back("-fno-builtin");
|
|
|
|
CompilerInvocation::CreateFromArgs(Invocation,
|
|
+#if LLVM_VERSION_MAJOR >= 10
|
|
+ Args,
|
|
+#else
|
|
&Args[0], &Args[0] + Args.size(),
|
|
+#endif
|
|
ClangInstance->getDiagnostics());
|
|
Invocation.setLangDefaults(ClangInstance->getLangOpts(),
|
|
- InputKind::OpenCL, T, PPOpts);
|
|
+#if LLVM_VERSION_MAJOR >= 10
|
|
+ InputKind(Language::OpenCL),
|
|
+#else
|
|
+ InputKind::OpenCL,
|
|
+#endif
|
|
+ T, PPOpts);
|
|
}
|
|
else {
|
|
ErrorMsg = "Unsupported file type!";
|