[clang] f3753ad - [ASTImporter][NFC] Dump decl name at assertion violation
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 19 02:31:29 PST 2021
Author: Balazs Benics
Date: 2021-11-19T11:31:01+01:00
New Revision: f3753ad774506804ef5df065b48268712bdaa554
URL: https://github.com/llvm/llvm-project/commit/f3753ad774506804ef5df065b48268712bdaa554
DIFF: https://github.com/llvm/llvm-project/commit/f3753ad774506804ef5df065b48268712bdaa554.diff
LOG: [ASTImporter][NFC] Dump decl name at assertion violation
Sometimes it would be useful to see which Decl kind caused some issue,
along with the name of the concrete instance of the Decl in the source
code.
Reviewed By: martong
Differential Revision: https://reviews.llvm.org/D113668
Added:
Modified:
clang/lib/AST/ASTImporterLookupTable.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTImporterLookupTable.cpp b/clang/lib/AST/ASTImporterLookupTable.cpp
index bf772c20d32ee..ef42561c6f941 100644
--- a/clang/lib/AST/ASTImporterLookupTable.cpp
+++ b/clang/lib/AST/ASTImporterLookupTable.cpp
@@ -14,6 +14,7 @@
#include "clang/AST/ASTImporterLookupTable.h"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
+#include "llvm/Support/FormatVariadic.h"
namespace clang {
@@ -93,10 +94,19 @@ void ASTImporterLookupTable::add(DeclContext *DC, NamedDecl *ND) {
}
void ASTImporterLookupTable::remove(DeclContext *DC, NamedDecl *ND) {
- DeclList &Decls = LookupTable[DC][ND->getDeclName()];
+ const DeclarationName Name = ND->getDeclName();
+ DeclList &Decls = LookupTable[DC][Name];
bool EraseResult = Decls.remove(ND);
(void)EraseResult;
- assert(EraseResult == true && "Trying to remove not contained Decl");
+#ifndef NDEBUG
+ if (!EraseResult) {
+ std::string Message =
+ llvm::formatv("Trying to remove not contained Decl '{0}' of type {1}",
+ Name.getAsString(), DC->getDeclKindName())
+ .str();
+ llvm_unreachable(Message.c_str());
+ }
+#endif
}
void ASTImporterLookupTable::add(NamedDecl *ND) {
More information about the cfe-commits
mailing list