Skip to content

Commit 60800e1

Browse files
authored
Diagnostics: improve error message at attr diagnosis failure
Used to just crash: > Assertion failed: (loc.isValid() && "Diagnosing attribute with invalid location"), function diagnoseAndRemoveAttr but now includes at least information what attribute caused the crash: > Attribute '@actorIndependent ' has invalid location, failed to diagnose! Assertion failed: (false && "Diagnosing attribute with invalid location"), function diagnoseAndRemoveAttr
1 parent e5800f1 commit 60800e1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ namespace {
5151
assert(!D->hasClangNode() && "Clang importer propagated a bogus attribute");
5252
if (!D->hasClangNode()) {
5353
SourceLoc loc = attr->getLocation();
54-
assert(loc.isValid() && "Diagnosing attribute with invalid location");
54+
if (!loc.isValid()) {
55+
llvm::errs() << "Attribute '";
56+
attr->print(llvm::errs());
57+
llvm::errs() << "' has invalid location, failed to diagnose!\n";
58+
assert(false && "Diagnosing attribute with invalid location");
59+
}
5560
if (loc.isInvalid()) {
5661
loc = D->getLoc();
5762
}

0 commit comments

Comments
 (0)