[clang] a00d440 - [AST] Hide errors from the attempt to introspect nodes
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 16 16:46:58 PDT 2021
Author: Stephen Kelly
Date: 2021-03-16T23:46:31Z
New Revision: a00d44012820e9ed2eba623dd61ca9cf5a2ce115
URL: https://github.com/llvm/llvm-project/commit/a00d44012820e9ed2eba623dd61ca9cf5a2ce115
DIFF: https://github.com/llvm/llvm-project/commit/a00d44012820e9ed2eba623dd61ca9cf5a2ce115.diff
LOG: [AST] Hide errors from the attempt to introspect nodes
Added:
Modified:
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
index 6615f865221d..74ba70eefa04 100644
--- a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -92,7 +92,13 @@ int main(int argc, const char **argv) {
auto ParsedArgs = Opts.ParseArgs(llvm::makeArrayRef(Argv).slice(1),
MissingArgIndex, MissingArgCount);
ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
- TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts);
+
+ // Don't output diagnostics, because common scenarios such as
+ // cross-compiling fail with diagnostics. This is not fatal, but
+ // just causes attempts to use the introspection API to return no data.
+ std::string Str;
+ llvm::raw_string_ostream OS(Str);
+ TextDiagnosticPrinter DiagnosticPrinter(OS, &*DiagOpts);
DiagnosticsEngine Diagnostics(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,
&DiagnosticPrinter, false);
More information about the cfe-commits
mailing list