From 41ed251debe6c5fb09d724b79e081450c1b68c73 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 1 Dec 2018 01:43:05 +0000 Subject: [PATCH] [Basic] Move DiagnosticsEngine::dump from .h to .cpp The two LLVM_DUMP_METHOD methods have a undefined reference on clang::DiagnosticsEngine::DiagStateMap::dump. tools/clang/tools/extra/clangd/benchmarks/IndexBenchmark links in clangDaemon but does not link in clangBasic explicitly, which causes a linker error "undefined symbol" in !NDEBUG + -DBUILD_SHARED_LIBS=on builds. Move LLVM_DUMP_METHOD methods to .cpp to fix IndexBenchmark. They should be unconditionally defined as they are also used by non-dump-method #pragma clang __debug diag_mapping git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348065 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Diagnostic.h | 6 ++---- lib/Basic/Diagnostic.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index d30ac14e02..d7e1c62890 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -486,10 +486,8 @@ public: DiagnosticsEngine &operator=(const DiagnosticsEngine &) = delete; ~DiagnosticsEngine(); - LLVM_DUMP_METHOD void dump() const { DiagStatesByLoc.dump(*SourceMgr); } - LLVM_DUMP_METHOD void dump(StringRef DiagName) const { - DiagStatesByLoc.dump(*SourceMgr, DiagName); - } + LLVM_DUMP_METHOD void dump() const; + LLVM_DUMP_METHOD void dump(StringRef DiagName) const; const IntrusiveRefCntPtr &getDiagnosticIDs() const { return Diags; diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 88ee319b5c..ffe92e157e 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -89,6 +89,14 @@ DiagnosticsEngine::~DiagnosticsEngine() { setClient(nullptr); } +void DiagnosticsEngine::dump() const { + DiagStatesByLoc.dump(*SourceMgr); +} + +void DiagnosticsEngine::dump(StringRef DiagName) const { + DiagStatesByLoc.dump(*SourceMgr, DiagName); +} + void DiagnosticsEngine::setClient(DiagnosticConsumer *client, bool ShouldOwnClient) { Owner.reset(ShouldOwnClient ? client : nullptr); -- 2.40.0