File: llvm-19-fixes.diff

package info (click to toggle)
creduce 2.11.0~20240909-2.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 5,296 kB
  • sloc: cpp: 25,309; ansic: 7,233; sh: 4,918; perl: 3,003; makefile: 594; lex: 441
file content (152 lines) | stat: -rw-r--r-- 5,987 bytes parent folder | download | duplicates (2)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
--- a/clang_delta/ExpressionDetector.cpp
+++ b/clang_delta/ExpressionDetector.cpp
@@ -62,9 +62,20 @@ public:
   virtual void InclusionDirective(SourceLocation HashLoc,
                           const Token &IncludeTok,
                           StringRef FileName, bool IsAngled,
-                          CharSourceRange FilenameRange, OptionalFileEntryRef File,
+                          CharSourceRange FilenameRange,
+#if LLVM_VERSION_MAJOR < 15
+                          const FileEntry *File,
+#elif LLVM_VERSION_MAJOR < 16
+                          Optional<FileEntryRef> File,
+#else
+                          OptionalFileEntryRef File,
+#endif
                           StringRef SearchPath, StringRef RelativePath,
+#if LLVM_VERSION_MAJOR < 19
                           const Module *Imported,
+#else
+                          const Module *SuggestedModule, bool ModuleImported,
+#endif
                           SrcMgr::CharacteristicKind FileType) override;
 
 private:
@@ -80,12 +91,22 @@ private:
 void IncludesPPCallbacks::InclusionDirective(SourceLocation HashLoc,
                                              const Token &/*IncludeTok*/,
                                              StringRef FileName,
-                                            bool /*IsAngled*/,
+                                             bool /*IsAngled*/,
                                              CharSourceRange /*FilenameRange*/,
+#if LLVM_VERSION_MAJOR < 15
+                                             const FileEntry * /*File*/,
+#elif LLVM_VERSION_MAJOR < 16
+                                             Optional<FileEntryRef> /*File*/,
+#else
                                              OptionalFileEntryRef /*File*/,
+#endif
                                              StringRef /*SearchPath*/,
                                              StringRef /*RelativePath*/,
-                                             const Module * /*Imported*/,
+#if LLVM_VERSION_MAJOR < 19
+                                            const Module *Imported,
+#else
+                                            const Module *SuggestedModule, bool ModuleImported,
+#endif
                                              SrcMgr::CharacteristicKind /*FileType*/)
 {
   if (!SrcManager.isInMainFile(HashLoc))
@@ -118,7 +139,11 @@ bool LocalTmpVarCollector::VisitDeclRefE
   const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl());
   if (!VD)
     return true;
+#if LLVM_VERSION_MAJOR < 18
   if (VD->getName().startswith(Prefix))
+#else
+  if (VD->getName().starts_with(Prefix))
+#endif
     TmpVars.push_back(VD);
   return true;
 }
@@ -363,7 +388,11 @@ void ExpressionDetector::addOneTempVar(c
 {
   if (!VD)
     return;
+#if LLVM_VERSION_MAJOR < 18
   if (!VD->getName().startswith(TmpVarNamePrefix))
+#else
+  if (!VD->getName().starts_with(TmpVarNamePrefix))
+#endif
     return;
   if (const Expr *E = VD->getInit())
     ProcessedExprs[VD] = E->IgnoreParenImpCasts();
@@ -374,9 +403,15 @@ bool ExpressionDetector::refToTmpVar(con
   StringRef Name = ND->getName();
   // We don't want to repeatly replace temporary variables
   // __creduce_expr_tmp_xxx, __creduce_printed_yy and __creduce_checked_zzz.
+#if LLVM_VERSION_MAJOR < 18
   return Name.startswith(TmpVarNamePrefix) ||
          Name.startswith(PrintedVarNamePrefix) ||
          Name.startswith(CheckedVarNamePrefix);
+#else
+  return Name.starts_with(TmpVarNamePrefix) ||
+         Name.starts_with(PrintedVarNamePrefix) ||
+         Name.starts_with(CheckedVarNamePrefix);
+#endif
 }
 
 // Reference: IdenticalExprChecker.cpp from Clang
@@ -524,8 +559,13 @@ bool ExpressionDetector::isValidExpr(Stm
       if (const DeclRefExpr *SubE =
           dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParenCasts())) {
         StringRef SubEName = SubE->getDecl()->getName();
+#if LLVM_VERSION_MAJOR < 18
         if (SubEName.startswith(PrintedVarNamePrefix) ||
             SubEName.startswith(CheckedVarNamePrefix))
+#else
+        if (SubEName.starts_with(PrintedVarNamePrefix) ||
+            SubEName.starts_with(CheckedVarNamePrefix))
+#endif
           return false;
       }
     }
@@ -541,7 +581,11 @@ bool ExpressionDetector::isValidExpr(Stm
       bool IsLit = SC == Stmt::IntegerLiteralClass ||
                    SC == Stmt::FloatingLiteralClass;
       if (IsLit && DRE &&
+#if LLVM_VERSION_MAJOR < 18
           DRE->getDecl()->getName().startswith(TmpVarNamePrefix) &&
+#else
+          DRE->getDecl()->getName().starts_with(TmpVarNamePrefix) &&
+#endif
           S->getStmtClass() == Stmt::IfStmtClass) {
         return false;
       }
--- a/clang_delta/RemoveNamespace.cpp
+++ b/clang_delta/RemoveNamespace.cpp
@@ -944,7 +944,11 @@ void RemoveNamespace::handleOneNamedDecl
     TransAssert(IdInfo && "Invalid IdentifierInfo!");
     NewName += IdInfo->getName();
     // Make sure we have valid suffix for user literals
+#if LLVM_VERSION_MAJOR < 18
     if (IsUserLiteral && IdInfo->getName().startswith("_")) {
+#else
+    if (IsUserLiteral && IdInfo->getName().starts_with("_")) {
+#endif
       NewName = "_" + NewName;
     }
     NamedDeclToNewName[ND] = NewName;
--- a/clang_delta/CommonRenameClassRewriteVisitor.h
+++ b/clang_delta/CommonRenameClassRewriteVisitor.h
@@ -368,6 +368,9 @@ bool CommonRenameClassRewriteVisitor<T>:
   case TemplateArgument::Null:
   case TemplateArgument::Declaration:
   case TemplateArgument::Integral:
+#if LLVM_VERSION_MAJOR >= 18
+  case TemplateArgument::StructuralValue:
+#endif
     return true;
 
   case TemplateArgument::Type: {
--- a/clang_delta/RenameCXXMethod.cpp
+++ b/clang_delta/RenameCXXMethod.cpp
@@ -426,7 +426,7 @@ bool RenameCXXMethod::isValidName(const
 {
   size_t PrefixLen = MethodNamePrefix.length();
   StringRef NamePrefix = Name.substr(0, PrefixLen);
-  if (!NamePrefix.equals(MethodNamePrefix))
+  if (NamePrefix != MethodNamePrefix)
     return false;
   llvm::APInt Num;
   return !Name.drop_front(PrefixLen).getAsInteger(10, Num);