[clang] [Clang] SemaFunctionEffects: When verifying a function, ignore any conditional noexcept expression. (PR #115342)

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 09:17:45 PST 2024


================
@@ -986,9 +987,22 @@ class Analyzer {
       if (auto *Dtor = dyn_cast<CXXDestructorDecl>(CurrentCaller.CDecl))
         followDestructor(dyn_cast<CXXRecordDecl>(Dtor->getParent()), Dtor);
 
-      if (auto *FD = dyn_cast<FunctionDecl>(CurrentCaller.CDecl))
+      if (auto *FD = dyn_cast<FunctionDecl>(CurrentCaller.CDecl)) {
         TrailingRequiresClause = FD->getTrailingRequiresClause();
 
+        // Note that FD->getType->getAs<FunctionProtoType>() can yield a
+        // noexcept Expr which has been boiled down to a constant expression.
+        // Going through the TypeSourceInfo obtains the actual expression which
+        // will be traversed as part of the function -- unless we capture it
+        // here and have TraverseStmt skip it.
+        if (TypeSourceInfo *TSI = FD->getTypeSourceInfo()) {
+          FunctionProtoTypeLoc TL =
+              TSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
+          if (const FunctionProtoType *FPT = TL.getTypePtr())
----------------
dougsonos wrote:

Yup indeed the C no-prototype test was crashing :/

https://github.com/llvm/llvm-project/pull/115342


More information about the cfe-commits mailing list