[clang] 7dfb6f5 - [clang][Interp] Fix ignored RequiresExprs

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Thu May 2 06:47:43 PDT 2024


Author: Timm Bäder
Date: 2024-05-02T15:47:15+02:00
New Revision: 7dfb6f571c8090803a32b5611e519b77ae74de30

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

LOG: [clang][Interp] Fix ignored RequiresExprs

Also ConceptSpecializationExpr, although I don't have a test case
at hand for those.

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/test/AST/Interp/literals.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index b096d4ddd88246..9fd6e2dd06991f 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2440,6 +2440,8 @@ bool ByteCodeExprGen<Emitter>::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {
 template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitRequiresExpr(const RequiresExpr *E) {
   assert(classifyPrim(E->getType()) == PT_Bool);
+  if (DiscardResult)
+    return true;
   return this->emitConstBool(E->isSatisfied(), E);
 }
 
@@ -2447,6 +2449,8 @@ template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitConceptSpecializationExpr(
     const ConceptSpecializationExpr *E) {
   assert(classifyPrim(E->getType()) == PT_Bool);
+  if (DiscardResult)
+    return true;
   return this->emitConstBool(E->isSatisfied(), E);
 }
 

diff  --git a/clang/test/AST/Interp/literals.cpp b/clang/test/AST/Interp/literals.cpp
index 2688b53adde248..c160be06dd241c 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -985,6 +985,8 @@ namespace DiscardExprs {
     __uuidof(GuidType);
     __uuidof(number); // both-error {{cannot call operator __uuidof on a type with no GUID}}
 
+    requires{false;};
+
     return 0;
   }
   static_assert(ignoredExprs() == 0, "");


        


More information about the cfe-commits mailing list