[clang-tools-extra] r367178 - [clangd] Fix NDEBUG build problem introduced by rL366698
Bjorn Pettersson via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 27 10:09:16 PDT 2019
Author: bjope
Date: Sat Jul 27 10:09:15 2019
New Revision: 367178
URL: http://llvm.org/viewvc/llvm-project?rev=367178&view=rev
Log:
[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).
Modified:
clang-tools-extra/trunk/clangd/Selection.cpp
Modified: clang-tools-extra/trunk/clangd/Selection.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Selection.cpp?rev=367178&r1=367177&r2=367178&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Selection.cpp (original)
+++ clang-tools-extra/trunk/clangd/Selection.cpp Sat Jul 27 10:09:15 2019
@@ -77,6 +77,7 @@ void printNodeKind(llvm::raw_ostream &OS
}
}
+#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 DynT
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<Node *> Stack;
RangeSet Claimed;
std::deque<Node> Nodes; // Stable pointers as we add more nodes.
More information about the cfe-commits
mailing list