[clangd] Respect clang-tidy SystemHeaders option if specified
authorSam McCall <sam.mccall@gmail.com>
Wed, 11 Jan 2023 17:03:58 +0000 (18:03 +0100)
committerSam McCall <sam.mccall@gmail.com>
Wed, 11 Jan 2023 17:04:42 +0000 (18:04 +0100)
(Previous commit assumed it was always off, which is the default)

clang-tools-extra/clangd/ParsedAST.cpp

index 637cada..d10da8c 100644 (file)
@@ -542,8 +542,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
             // NOLINT comments)?
             return DiagnosticsEngine::Ignored;
           }
-          // Match behavior for clang-tidy --system-headers=0 (the default).
-          if (Info.hasSourceManager() &&
+          if (!CTContext->getOptions().SystemHeaders.value_or(false) &&
+              Info.hasSourceManager() &&
               Info.getSourceManager().isInSystemMacro(Info.getLocation()))
             return DiagnosticsEngine::Ignored;