[PATCH] D56395: [ASTMatchers] Improve assert message for broken parent map.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 7 23:33:33 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL350612: [ASTMatchers] Improve assert message for broken parent map. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56395/new/

https://reviews.llvm.org/D56395

Files:
  cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp


Index: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
===================================================================
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -676,13 +676,17 @@
       //  c) there is a bug in the AST, and the node is not reachable
       // Usually the traversal scope is the whole AST, which precludes b.
       // Bugs are common enough that it's worthwhile asserting when we can.
-      assert((Node.get<TranslationUnitDecl>() ||
-              /* Traversal scope is limited if none of the bounds are the TU */
-              llvm::none_of(ActiveASTContext->getTraversalScope(),
-                            [](Decl *D) {
-                              return D->getKind() == Decl::TranslationUnit;
-                            })) &&
-             "Found node that is not in the complete parent map!");
+#ifndef NDEBUG
+      if (!Node.get<TranslationUnitDecl>() &&
+          /* Traversal scope is full AST if any of the bounds are the TU */
+          llvm::any_of(ActiveASTContext->getTraversalScope(), [](Decl *D) {
+            return D->getKind() == Decl::TranslationUnit;
+          })) {
+        llvm::errs() << "Tried to match orphan node:\n";
+        Node.dump(llvm::errs(), ActiveASTContext->getSourceManager());
+        llvm_unreachable("Parent map should be complete!");
+      }
+#endif
       return false;
     }
     if (Parents.size() == 1) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56395.180619.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190108/99be7cae/attachment.bin>


More information about the cfe-commits mailing list