Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LLVM 19 #276

Open
lazka opened this issue Nov 13, 2024 · 0 comments
Open

Support LLVM 19 #276

lazka opened this issue Nov 13, 2024 · 0 comments
Assignees

Comments

@lazka
Copy link

lazka commented Nov 13, 2024

Current master doesn't build with LLVM 19. I've tried to track down some of the API changes in LLVM and adjusted the code so it builds again, but there are more warnings (unhandled switch case values.. maybe that was there before), and I don't know anything about all of this, so I hope this can be a starting point for someone more knowledgeable:

Relevant upstream API changes:

Here is a minimal patch to get it to build:

--- creduce/clang_delta/ExpressionDetector.cpp	2024-11-13 22:04:35.755591600 +0100
+++ creduce/clang_delta/ExpressionDetector.cpp	2024-11-13 22:01:03.336578100 +0100
@@ -64,7 +64,8 @@
                           StringRef FileName, bool IsAngled,
                           CharSourceRange FilenameRange, OptionalFileEntryRef File,
                           StringRef SearchPath, StringRef RelativePath,
-                          const Module *Imported,
+                          const Module *SuggestedModule,
+                          bool ModuleImported,
                           SrcMgr::CharacteristicKind FileType) override;
 
 private:
@@ -85,7 +86,8 @@
                                              OptionalFileEntryRef /*File*/,
                                              StringRef /*SearchPath*/,
                                              StringRef /*RelativePath*/,
-                                             const Module * /*Imported*/,
+                                             const Module * /*SuggestedModule*/,
+                                             bool /*ModuleImported*/,
                                              SrcMgr::CharacteristicKind /*FileType*/)
 {
   if (!SrcManager.isInMainFile(HashLoc))
@@ -118,7 +120,7 @@
   const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl());
   if (!VD)
     return true;
-  if (VD->getName().startswith(Prefix))
+  if (VD->getName().starts_with(Prefix))
     TmpVars.push_back(VD);
   return true;
 }
@@ -363,7 +365,7 @@
 {
   if (!VD)
     return;
-  if (!VD->getName().startswith(TmpVarNamePrefix))
+  if (!VD->getName().starts_with(TmpVarNamePrefix))
     return;
   if (const Expr *E = VD->getInit())
     ProcessedExprs[VD] = E->IgnoreParenImpCasts();
@@ -374,9 +376,9 @@
   StringRef Name = ND->getName();
   // We don't want to repeatly replace temporary variables
   // __creduce_expr_tmp_xxx, __creduce_printed_yy and __creduce_checked_zzz.
-  return Name.startswith(TmpVarNamePrefix) ||
-         Name.startswith(PrintedVarNamePrefix) ||
-         Name.startswith(CheckedVarNamePrefix);
+  return Name.starts_with(TmpVarNamePrefix) ||
+         Name.starts_with(PrintedVarNamePrefix) ||
+         Name.starts_with(CheckedVarNamePrefix);
 }
 
 // Reference: IdenticalExprChecker.cpp from Clang
@@ -524,8 +526,8 @@
       if (const DeclRefExpr *SubE =
           dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParenCasts())) {
         StringRef SubEName = SubE->getDecl()->getName();
-        if (SubEName.startswith(PrintedVarNamePrefix) ||
-            SubEName.startswith(CheckedVarNamePrefix))
+        if (SubEName.starts_with(PrintedVarNamePrefix) ||
+            SubEName.starts_with(CheckedVarNamePrefix))
           return false;
       }
     }
@@ -541,7 +543,7 @@
       bool IsLit = SC == Stmt::IntegerLiteralClass ||
                    SC == Stmt::FloatingLiteralClass;
       if (IsLit && DRE &&
-          DRE->getDecl()->getName().startswith(TmpVarNamePrefix) &&
+          DRE->getDecl()->getName().starts_with(TmpVarNamePrefix) &&
           S->getStmtClass() == Stmt::IfStmtClass) {
         return false;
       }
diff -Nur creduce/clang_delta/RemoveNamespace.cpp creduce/clang_delta/RemoveNamespace.cpp
--- creduce/clang_delta/RemoveNamespace.cpp	2024-11-13 22:04:35.771339900 +0100
+++ creduce/clang_delta/RemoveNamespace.cpp	2024-11-13 21:55:02.235178400 +0100
@@ -944,7 +944,7 @@
     TransAssert(IdInfo && "Invalid IdentifierInfo!");
     NewName += IdInfo->getName();
     // Make sure we have valid suffix for user literals
-    if (IsUserLiteral && IdInfo->getName().startswith("_")) {
+    if (IsUserLiteral && IdInfo->getName().starts_with("_")) {
       NewName = "_" + NewName;
     }
     NamedDeclToNewName[ND] = NewName;
diff -Nur creduce/clang_delta/RenameCXXMethod.cpp creduce/clang_delta/RenameCXXMethod.cpp
--- creduce/clang_delta/RenameCXXMethod.cpp	2024-11-13 22:04:35.787084600 +0100
+++ creduce/clang_delta/RenameCXXMethod.cpp	2024-11-13 22:03:22.949186100 +0100
@@ -426,7 +426,7 @@
 {
   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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants