This patch was originally submitted by @mizvekov, then reverted because
it caused crashes on Arm and AArch64. This has since been debugged as a
problem in the DontModifyStdNamespaceCheck.cpp Tidy check exposed by
Arm and AArch64 architectures defining va_list in the std namespace. The
Tidy check was fixed by excluding the implicit cases. See D136886 for
original patch and notes. This patch takes changes from D136886, adds
the fix and LIT cases to cover the fix.
Original description from @mizvekov for the base portion of this fix.
This fixes a problem where __va_list_tag was not correctly imported,
possibly leading to multiple definitions with different types.
This adds __va_list_tag to it's proper scope, so that the ASTImporter
can find it.
Crash seen in original fix, addressed by improvements.
$ clang-tidy crash.cpp -checks="cert-dcl58-cpp" -- -target arm clang-tidy: <root>/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:178: clang::DiagnosticBuilder clang::tidy::ClangTidyContext::diag(llvm::StringRef, clang::SourceLocation, llvm::StringRef, clang::DiagnosticIDs::Level): Assertion `Loc.isValid()' failed. Stack dump: 0. Program arguments: clang-tidy crash.cpp -checks=cert-dcl58-cpp -- -target arm 1. <eof> parser at end of file 2. ASTMatcher: Processing 'cert-dcl58-cpp' against: CXXRecordDecl std::__va_list : <<invalid sloc>> --- Bound Nodes Begin --- decl - { CXXRecordDecl std::__va_list : <<invalid sloc>> } nmspc - { NamespaceDecl std : <<invalid sloc>> } --- Bound Nodes End --- #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) <root>/llvm/lib/Support/Unix/Signals.inc:567:22 #1 PrintStackTraceSignalHandler(void*) <root>/llvm/lib/Support/Unix/Signals.inc:641:1 ... #9 clang::tidy::ClangTidyContext::diag(llvm::StringRef, clang::SourceLocation, llvm::StringRef, clang::DiagnosticIDs::Level) <root>/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:179:17 clang::DiagnosticIDs::Level) <root>/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:27:54 clang::ast_matchers::MatchFinder::MatchResultconst&) <root>/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:121:10
I am not sure if these platform specific should be added. A problem was discovered on this platform but this could be true for all other tests.