From f0f63cab7f5b1a30e4bf327b4b51c945e8d76487 Mon Sep 17 00:00:00 2001 From: Bjorn Pettersson Date: Sat, 27 Jul 2019 17:09:15 +0000 Subject: [PATCH] [clangd] Fix NDEBUG build problem introduced by rL366698 Sprinkled some #ifndef NDEBUG in Selection.cpp to make it possible to build with NDEBUG defined. The problem was introduced in rL366698 when using dlog for some debug printouts. The dlog macro expands to DEBUG_WITH_TYPE, which isn't using it's arguments in optimized builds (when NDEBUG is defined). llvm-svn: 367178 --- clang-tools-extra/clangd/Selection.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp index d7c6759..2853303 100644 --- a/clang-tools-extra/clangd/Selection.cpp +++ b/clang-tools-extra/clangd/Selection.cpp @@ -77,6 +77,7 @@ void printNodeKind(llvm::raw_ostream &OS, const DynTypedNode &N) { } } +#ifndef NDEBUG std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP) { std::string S; llvm::raw_string_ostream OS(S); @@ -84,6 +85,7 @@ std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP) { OS << " "; return std::move(OS.str()); } +#endif // We find the selection by visiting written nodes in the AST, looking for nodes // that intersect with the selected character range. @@ -177,7 +179,10 @@ private: SelectionVisitor(ASTContext &AST, const PrintingPolicy &PP, unsigned SelBegin, unsigned SelEnd, FileID SelFile) : SM(AST.getSourceManager()), LangOpts(AST.getLangOpts()), - PrintPolicy(PP), SelBegin(SelBegin), SelEnd(SelEnd), SelFile(SelFile), +#ifndef NDEBUG + PrintPolicy(PP), +#endif + SelBegin(SelBegin), SelEnd(SelEnd), SelFile(SelFile), SelBeginTokenStart(SM.getFileOffset(Lexer::GetBeginningOfToken( SM.getComposedLoc(SelFile, SelBegin), SM, LangOpts))) { // Ensure we have a node for the TU decl, regardless of traversal scope. @@ -348,7 +353,9 @@ private: SourceManager &SM; const LangOptions &LangOpts; +#ifndef NDEBUG const PrintingPolicy &PrintPolicy; +#endif std::stack Stack; RangeSet Claimed; std::deque Nodes; // Stable pointers as we add more nodes. -- 2.7.4