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 add the pointer we want to print itself to the `Levels` array anyway, but 
then we print it once via `printDesc(P.getDeclDesc())` and in the loop again 
via `printDesc(It.getFieldDesc())`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141831

Files:
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp


Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===================================================================
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -6,9 +6,6 @@
 /// Board constructors.
 /// This tests that InterpFrame::describe().
 
-// FIXME: With the new interpreter, most of the described frames are
-//  currently broken in one way or another.
-
 typedef unsigned long uint64_t;
 
 struct Board {
@@ -52,17 +49,17 @@
   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 '&Board().Board()->addQueen(0, 0)}}
+                                                                       // 
expected-note {{in call to '&Board()->addQueen(0, 0)}}
                   N, Col, Row+1, B) :
          buildBoardScan(N, Col, Row + 1, B);
 }
 constexpr Board buildBoardRecurse(int N, int Col, const Board &B) {
   return Col == N ? B : buildBoardScan(N, Col, 0, B); // ref-note {{in call to 
'buildBoardScan(8, 0, 0, Board())'}} \
-                                                      // expected-note {{in 
call to 'buildBoardScan(8, 0, 0, Board().Board())}}
+                                                      // expected-note {{in 
call to 'buildBoardScan(8, 0, 0, Board())}}
 }
 constexpr Board buildBoard(int N) {
   return buildBoardRecurse(N, 0, Board()); // ref-note {{in call to 
'buildBoardRecurse(8, 0, Board())'}} \
-                                           // expected-note {{in call to 
'buildBoardRecurse(8, 0, Board().Board())'}}
+                                           // expected-note {{in call to 
'buildBoardRecurse(8, 0, Board())'}}
 }
 
 constexpr Board q8 = buildBoard(8); // ref-error {{must be initialized by a 
constant expression}} \
Index: clang/lib/AST/Interp/InterpFrame.cpp
===================================================================
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -120,6 +120,9 @@
     F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
   }
 
+  // Drop the first pointer since we print it unconditionally anyway.
+  Levels.erase(Levels.begin());
+
   printDesc(P.getDeclDesc());
   for (const auto &It : Levels) {
     if (It.inArray()) {


Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===================================================================
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -6,9 +6,6 @@
 /// Board constructors.
 /// This tests that InterpFrame::describe().
 
-// FIXME: With the new interpreter, most of the described frames are
-//  currently broken in one way or another.
-
 typedef unsigned long uint64_t;
 
 struct Board {
@@ -52,17 +49,17 @@
   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 '&Board().Board()->addQueen(0, 0)}}
+                                                                       // expected-note {{in call to '&Board()->addQueen(0, 0)}}
                   N, Col, Row+1, B) :
          buildBoardScan(N, Col, Row + 1, B);
 }
 constexpr Board buildBoardRecurse(int N, int Col, const Board &B) {
   return Col == N ? B : buildBoardScan(N, Col, 0, B); // ref-note {{in call to 'buildBoardScan(8, 0, 0, Board())'}} \
-                                                      // expected-note {{in call to 'buildBoardScan(8, 0, 0, Board().Board())}}
+                                                      // expected-note {{in call to 'buildBoardScan(8, 0, 0, Board())}}
 }
 constexpr Board buildBoard(int N) {
   return buildBoardRecurse(N, 0, Board()); // ref-note {{in call to 'buildBoardRecurse(8, 0, Board())'}} \
-                                           // expected-note {{in call to 'buildBoardRecurse(8, 0, Board().Board())'}}
+                                           // expected-note {{in call to 'buildBoardRecurse(8, 0, Board())'}}
 }
 
 constexpr Board q8 = buildBoard(8); // ref-error {{must be initialized by a constant expression}} \
Index: clang/lib/AST/Interp/InterpFrame.cpp
===================================================================
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -120,6 +120,9 @@
     F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
   }
 
+  // Drop the first pointer since we print it unconditionally anyway.
+  Levels.erase(Levels.begin());
+
   printDesc(P.getDeclDesc());
   for (const auto &It : Levels) {
     if (It.inArray()) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to