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.

  We can't just use VisitCallExpr() here, as that doesn't handle CallExpr
  subclasses such as CXXMemberCallExpr.

I think the patch itself is mostly obvious, but I was wondering if it is the 
right time to add such RUN lines to existing test cases like I do here for 
`test/SemaCXX/constexpr-nqueens.cpp`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141772

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/AST/Interp/records.cpp
  clang/test/SemaCXX/constexpr-nqueens.cpp


Index: clang/test/SemaCXX/constexpr-nqueens.cpp
===================================================================
--- clang/test/SemaCXX/constexpr-nqueens.cpp
+++ clang/test/SemaCXX/constexpr-nqueens.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only 
-fexperimental-new-constant-interpreter %s
 
 typedef unsigned long uint64_t;
 
Index: clang/test/AST/Interp/records.cpp
===================================================================
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -98,12 +98,20 @@
     int b;
 
   constexpr C() : a(100), b(200) {}
+
+  constexpr C get() const {
+    return *this;
+  }
 };
 
 constexpr C c;
 static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
+constexpr C c2 = C().get();
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
 constexpr int getB() {
   C c;
   int &j = c.b;
Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===================================================================
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -52,7 +52,7 @@
   return Row == N ? Board(0, true) :
          B.ok(Row, Col) ?
          tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // 
ref-note {{in call to '&Board()->addQueen(0, 0)}} \
-                                                                       // 
expected-note {{in call to '&B.addQueen(Row, Col).B.addQueen(Row, 
Col)->addQueen(0, 0)}}
+                                                                       // 
expected-note {{in call to '&Board().Board()->addQueen(0, 0)}}
                   N, Col, Row+1, B) :
          buildBoardScan(N, Col, Row + 1, B);
 }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1421,7 +1421,7 @@
     if (!this->emitDupPtr(Initializer))
       return false;
 
-    return this->VisitCallExpr(CE);
+    return this->visit(CE);
   } else if (const auto *DIE = dyn_cast<CXXDefaultInitExpr>(Initializer)) {
     return this->visitInitializer(DIE->getExpr());
   } else if (const auto *CE = dyn_cast<CastExpr>(Initializer)) {


Index: clang/test/SemaCXX/constexpr-nqueens.cpp
===================================================================
--- clang/test/SemaCXX/constexpr-nqueens.cpp
+++ clang/test/SemaCXX/constexpr-nqueens.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fexperimental-new-constant-interpreter %s
 
 typedef unsigned long uint64_t;
 
Index: clang/test/AST/Interp/records.cpp
===================================================================
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -98,12 +98,20 @@
     int b;
 
   constexpr C() : a(100), b(200) {}
+
+  constexpr C get() const {
+    return *this;
+  }
 };
 
 constexpr C c;
 static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
+constexpr C c2 = C().get();
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
 constexpr int getB() {
   C c;
   int &j = c.b;
Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===================================================================
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -52,7 +52,7 @@
   return Row == N ? Board(0, true) :
          B.ok(Row, Col) ?
          tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // ref-note {{in call to '&Board()->addQueen(0, 0)}} \
-                                                                       // expected-note {{in call to '&B.addQueen(Row, Col).B.addQueen(Row, Col)->addQueen(0, 0)}}
+                                                                       // expected-note {{in call to '&Board().Board()->addQueen(0, 0)}}
                   N, Col, Row+1, B) :
          buildBoardScan(N, Col, Row + 1, B);
 }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1421,7 +1421,7 @@
     if (!this->emitDupPtr(Initializer))
       return false;
 
-    return this->VisitCallExpr(CE);
+    return this->visit(CE);
   } else if (const auto *DIE = dyn_cast<CXXDefaultInitExpr>(Initializer)) {
     return this->visitInitializer(DIE->getExpr());
   } else if (const auto *CE = dyn_cast<CastExpr>(Initializer)) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D141772: [clang][Int... Timm Bäder via Phabricator via cfe-commits

Reply via email to