mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-25 21:11:25 +00:00
bugprone-argument-comment: SourceLocation valid judgment avoid emitting coredump in isInSystemHeader
If the Node has an invalid location, it will trigger assert in isInSystemHeader(...). void test() { __builtin_va_list __args; // __builtin_va_list has no defination in any source file and its // CXXConstructorDecl has invalid sourcelocation } coredump with "Assertion `Loc.isValid() && "Can't get file characteristic of invalid loc!"' failed." in getFileCharacteristic(SourceLocation).
This commit is contained in:
parent
24c9016574
commit
ea72b55b5c
@ -24,6 +24,8 @@ AST_MATCHER(Decl, isFromStdNamespaceOrSystemHeader) {
|
||||
if (const auto *D = Node.getDeclContext()->getEnclosingNamespaceContext())
|
||||
if (D->isStdNamespace())
|
||||
return true;
|
||||
if (Node.getLocation().isInvalid())
|
||||
return false;
|
||||
return Node.getASTContext().getSourceManager().isInSystemHeader(
|
||||
Node.getLocation());
|
||||
}
|
||||
|
@ -151,3 +151,8 @@ void test() {
|
||||
my_system_header_function(/*not_arg=*/1);
|
||||
}
|
||||
} // namespace system_header
|
||||
|
||||
void testInvalidSlocCxxConstructExpr() {
|
||||
__builtin_va_list __args;
|
||||
// __builtin_va_list has no defination in any source file
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user