diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp index c36fb60b6d3d6e..3836e4cf3990da 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -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()); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp index cb4eac84c6916a..22dcd74b5c4fdd 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp @@ -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 +}