aboutsummaryrefslogtreecommitdiffstats
path: root/testing/creduce/204.patch
blob: 1c02a36553e7006db0e3de02f09c4c314c2e194c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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!";