Author: Timm Bäder
Date: 2024-02-19T09:23:53+01:00
New Revision: d61864f813e33b4228e56f391ec53566aab9efda

URL: 
https://github.com/llvm/llvm-project/commit/d61864f813e33b4228e56f391ec53566aab9efda
DIFF: 
https://github.com/llvm/llvm-project/commit/d61864f813e33b4228e56f391ec53566aab9efda.diff

LOG: [clang][Interp] Don't create Records for incomplete decls

We would previously create the Record instance with 0 fields,
which is incorrect. We later see it again with 1 field.

Fixes #82203

Added: 
    

Modified: 
    clang/lib/AST/Interp/Program.cpp
    clang/test/AST/Interp/lambda.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Program.cpp 
b/clang/lib/AST/Interp/Program.cpp
index ec6cdebcd820fa..61293a3fef4709 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -232,6 +232,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
   if (!RD)
     return nullptr;
 
+  if (!RD->isCompleteDefinition())
+    return nullptr;
+
   // Deduplicate records.
   if (auto It = Records.find(RD); It != Records.end())
     return It->second;

diff  --git a/clang/test/AST/Interp/lambda.cpp 
b/clang/test/AST/Interp/lambda.cpp
index 3040e6a1e386c7..a5e0d0f1fd9f48 100644
--- a/clang/test/AST/Interp/lambda.cpp
+++ b/clang/test/AST/Interp/lambda.cpp
@@ -222,3 +222,16 @@ namespace GH62611 {
     return 0;
   }
 }
+
+namespace LambdaToAPValue {
+  void wrapper() {
+    constexpr auto f = []() constexpr {
+      return 0;
+    };
+
+    constexpr auto g = [f]() constexpr {
+      return f();
+    };
+    static_assert(g() == f(), "");
+  }
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to