tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Since we now handle functions without a body as well, we can't just use
  getHasBody() anymore. Funtions that haven't been defined yet are those
  that don't have a body *and* aren't valid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141591

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Function.h
  clang/test/AST/Interp/functions.cpp


Index: clang/test/AST/Interp/functions.cpp
===================================================================
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -154,3 +154,12 @@
 }
 
 }
+
+struct F {
+  constexpr bool ok() const {
+    return okRecurse();
+  }
+  constexpr bool okRecurse() const {
+    return true;
+  }
+};
Index: clang/lib/AST/Interp/Function.h
===================================================================
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,7 +157,7 @@
     SrcMap = std::move(NewSrcMap);
     Scopes = std::move(NewScopes);
     IsValid = true;
-    HasBody = true;
+    HasBody = NewCode.size() > 0;
   }
 
   void setIsFullyCompiled(bool FC) { IsFullyCompiled = FC; }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1484,7 +1484,7 @@
   assert(FD);
   const Function *Func = P.getFunction(FD);
   bool IsBeingCompiled = Func && !Func->isFullyCompiled();
-  bool WasNotDefined = Func && !Func->hasBody();
+  bool WasNotDefined = Func && !Func->isConstexpr() && !Func->hasBody();
 
   if (IsBeingCompiled)
     return Func;


Index: clang/test/AST/Interp/functions.cpp
===================================================================
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -154,3 +154,12 @@
 }
 
 }
+
+struct F {
+  constexpr bool ok() const {
+    return okRecurse();
+  }
+  constexpr bool okRecurse() const {
+    return true;
+  }
+};
Index: clang/lib/AST/Interp/Function.h
===================================================================
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,7 +157,7 @@
     SrcMap = std::move(NewSrcMap);
     Scopes = std::move(NewScopes);
     IsValid = true;
-    HasBody = true;
+    HasBody = NewCode.size() > 0;
   }
 
   void setIsFullyCompiled(bool FC) { IsFullyCompiled = FC; }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1484,7 +1484,7 @@
   assert(FD);
   const Function *Func = P.getFunction(FD);
   bool IsBeingCompiled = Func && !Func->isFullyCompiled();
-  bool WasNotDefined = Func && !Func->hasBody();
+  bool WasNotDefined = Func && !Func->isConstexpr() && !Func->hasBody();
 
   if (IsBeingCompiled)
     return Func;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to