Skip to content

Commit

Permalink
[clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.
Browse files Browse the repository at this point in the history
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM

Differential Revision: https://reviews.llvm.org/D44976

llvm-svn: 332371
  • Loading branch information
nzaghen committed May 15, 2018
1 parent 6043fd2 commit 0efd524
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
18 changes: 9 additions & 9 deletions clang-tools-extra/clang-move/ClangMove.cpp
Expand Up @@ -680,8 +680,8 @@ void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<clang::NamedDecl>("helper_decls")) {
MovedDecls.push_back(ND);
HelperDeclarations.push_back(ND);
DEBUG(llvm::dbgs() << "Add helper : "
<< ND->getNameAsString() << " (" << ND << ")\n");
LLVM_DEBUG(llvm::dbgs() << "Add helper : " << ND->getNameAsString() << " ("
<< ND << ")\n");
} else if (const auto *UD =
Result.Nodes.getNodeAs<clang::NamedDecl>("using_decl")) {
MovedDecls.push_back(UD);
Expand Down Expand Up @@ -741,12 +741,12 @@ void ClangMoveTool::removeDeclsInOldFiles() {
// We remove the helper declarations which are not used in the old.cc after
// moving the given declarations.
for (const auto *D : HelperDeclarations) {
DEBUG(llvm::dbgs() << "Check helper is used: "
<< D->getNameAsString() << " (" << D << ")\n");
LLVM_DEBUG(llvm::dbgs() << "Check helper is used: "
<< D->getNameAsString() << " (" << D << ")\n");
if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(
D->getCanonicalDecl()))) {
DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
<< D->getNameAsString() << " (" << D << ")\n");
LLVM_DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
<< D->getNameAsString() << " (" << D << ")\n");
RemovedDecls.push_back(D);
}
}
Expand Down Expand Up @@ -826,8 +826,8 @@ void ClangMoveTool::moveDeclsToNewFiles() {
D->getCanonicalDecl())))
continue;

DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString()
<< " " << D << "\n");
LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString()
<< " " << D << "\n");
ActualNewCCDecls.push_back(D);
}

Expand Down Expand Up @@ -937,7 +937,7 @@ void ClangMoveTool::onEndOfTranslationUnit() {
moveAll(SM, Context->Spec.OldCC, Context->Spec.NewCC);
return;
}
DEBUG(RGBuilder.getGraph()->dump());
LLVM_DEBUG(RGBuilder.getGraph()->dump());
moveDeclsToNewFiles();
removeDeclsInOldFiles();
}
Expand Down
12 changes: 6 additions & 6 deletions clang-tools-extra/clang-move/HelperDeclRefGraph.cpp
Expand Up @@ -116,19 +116,19 @@ void HelperDeclRGBuilder::run(
if (const auto *FuncRef = Result.Nodes.getNodeAs<DeclRefExpr>("func_ref")) {
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
assert(DC);
DEBUG(llvm::dbgs() << "Find helper function usage: "
<< FuncRef->getDecl()->getNameAsString() << " ("
<< FuncRef->getDecl() << ")\n");
LLVM_DEBUG(llvm::dbgs() << "Find helper function usage: "
<< FuncRef->getDecl()->getNameAsString() << " ("
<< FuncRef->getDecl() << ")\n");
RG->addEdge(
getOutmostClassOrFunDecl(DC->getCanonicalDecl()),
getOutmostClassOrFunDecl(FuncRef->getDecl()->getCanonicalDecl()));
} else if (const auto *UsedClass =
Result.Nodes.getNodeAs<CXXRecordDecl>("used_class")) {
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
assert(DC);
DEBUG(llvm::dbgs() << "Find helper class usage: "
<< UsedClass->getNameAsString() << " (" << UsedClass
<< ")\n");
LLVM_DEBUG(llvm::dbgs()
<< "Find helper class usage: " << UsedClass->getNameAsString()
<< " (" << UsedClass << ")\n");
RG->addEdge(getOutmostClassOrFunDecl(DC->getCanonicalDecl()), UsedClass);
}
}
Expand Down
9 changes: 5 additions & 4 deletions clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
Expand Up @@ -225,7 +225,8 @@ FileOptionsProvider::FileOptionsProvider(
// similar.
std::vector<OptionsSource>
FileOptionsProvider::getRawOptions(StringRef FileName) {
DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName
<< "...\n");
assert(FS && "FS must be set.");

llvm::SmallString<128> AbsoluteFilePath(FileName);
Expand Down Expand Up @@ -254,8 +255,8 @@ FileOptionsProvider::getRawOptions(StringRef FileName) {
if (Result) {
// Store cached value for all intermediate directories.
while (Path != CurrentPath) {
DEBUG(llvm::dbgs() << "Caching configuration for path " << Path
<< ".\n");
LLVM_DEBUG(llvm::dbgs()
<< "Caching configuration for path " << Path << ".\n");
CachedOptions[Path] = *Result;
Path = llvm::sys::path::parent_path(Path);
}
Expand All @@ -282,7 +283,7 @@ FileOptionsProvider::tryReadConfigFile(StringRef Directory) {
for (const ConfigFileHandler &ConfigHandler : ConfigHandlers) {
SmallString<128> ConfigFile(Directory);
llvm::sys::path::append(ConfigFile, ConfigHandler.first);
DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
LLVM_DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");

bool IsFile = false;
// Ignore errors from is_regular_file: we only need to know if we can read
Expand Down
Expand Up @@ -840,10 +840,10 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) {
std::string Fixup = fixupWithStyle(Name, Style);
if (StringRef(Fixup).equals(Name)) {
if (!IgnoreFailedSplit) {
DEBUG(llvm::dbgs()
<< Decl->getLocStart().printToString(*Result.SourceManager)
<< llvm::format(": unable to split words for %s '%s'\n",
KindName.c_str(), Name.str().c_str()));
LLVM_DEBUG(llvm::dbgs()
<< Decl->getLocStart().printToString(*Result.SourceManager)
<< llvm::format(": unable to split words for %s '%s'\n",
KindName.c_str(), Name.str().c_str()));
}
} else {
NamingCheckFailure &Failure = NamingCheckFailures[NamingCheckId(
Expand Down Expand Up @@ -877,10 +877,10 @@ void IdentifierNamingCheck::checkMacro(SourceManager &SourceMgr,
std::string Fixup = fixupWithStyle(Name, Style);
if (StringRef(Fixup).equals(Name)) {
if (!IgnoreFailedSplit) {
DEBUG(
llvm::dbgs() << MacroNameTok.getLocation().printToString(SourceMgr)
<< llvm::format(": unable to split words for %s '%s'\n",
KindName.c_str(), Name.str().c_str()));
LLVM_DEBUG(llvm::dbgs()
<< MacroNameTok.getLocation().printToString(SourceMgr)
<< llvm::format(": unable to split words for %s '%s'\n",
KindName.c_str(), Name.str().c_str()));
}
} else {
NamingCheckId ID(MI->getDefinitionLoc(), Name);
Expand Down
22 changes: 12 additions & 10 deletions clang-tools-extra/include-fixer/IncludeFixer.cpp
Expand Up @@ -156,7 +156,8 @@ bool IncludeFixerSemaSource::MaybeDiagnoseMissingCompleteType(
clang::ASTContext &context = CI->getASTContext();
std::string QueryString = QualType(T->getUnqualifiedDesugaredType(), 0)
.getAsString(context.getPrintingPolicy());
DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString << "'");
LLVM_DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString
<< "'");
// Pass an empty range here since we don't add qualifier in this case.
std::vector<find_all_symbols::SymbolInfo> MatchedSymbols =
query(QueryString, "", tooling::Range());
Expand Down Expand Up @@ -276,7 +277,8 @@ clang::TypoCorrection IncludeFixerSemaSource::CorrectTypo(
SymbolRange = CreateToolingRange(Typo.getLoc());
}

DEBUG(llvm::dbgs() << "TypoScopeQualifiers: " << TypoScopeString << "\n");
LLVM_DEBUG(llvm::dbgs() << "TypoScopeQualifiers: " << TypoScopeString
<< "\n");
std::vector<find_all_symbols::SymbolInfo> MatchedSymbols =
query(QueryString, TypoScopeString, SymbolRange);

Expand Down Expand Up @@ -357,12 +359,12 @@ IncludeFixerSemaSource::query(StringRef Query, StringRef ScopedQualifiers,
return {};
}

DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
DEBUG(CI->getSourceManager()
.getLocForStartOfFile(CI->getSourceManager().getMainFileID())
.getLocWithOffset(Range.getOffset())
.print(llvm::dbgs(), CI->getSourceManager()));
DEBUG(llvm::dbgs() << " ...");
LLVM_DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
LLVM_DEBUG(CI->getSourceManager()
.getLocForStartOfFile(CI->getSourceManager().getMainFileID())
.getLocWithOffset(Range.getOffset())
.print(llvm::dbgs(), CI->getSourceManager()));
LLVM_DEBUG(llvm::dbgs() << " ...");
llvm::StringRef FileName = CI->getSourceManager().getFilename(
CI->getSourceManager().getLocForStartOfFile(
CI->getSourceManager().getMainFileID()));
Expand Down Expand Up @@ -390,8 +392,8 @@ IncludeFixerSemaSource::query(StringRef Query, StringRef ScopedQualifiers,
if (MatchedSymbols.empty())
MatchedSymbols =
SymbolIndexMgr.search(Query, /*IsNestedSearch=*/true, FileName);
DEBUG(llvm::dbgs() << "Having found " << MatchedSymbols.size()
<< " symbols\n");
LLVM_DEBUG(llvm::dbgs() << "Having found " << MatchedSymbols.size()
<< " symbols\n");
// We store a copy of MatchedSymbols in a place where it's globally reachable.
// This is used by the standalone version of the tool.
this->MatchedSymbols = MatchedSymbols;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/include-fixer/SymbolIndexManager.cpp
Expand Up @@ -97,8 +97,8 @@ SymbolIndexManager::search(llvm::StringRef Identifier,
Symbols.insert(Symbols.end(), Res.begin(), Res.end());
}

DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got "
<< Symbols.size() << " results...\n");
LLVM_DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got "
<< Symbols.size() << " results...\n");

for (auto &SymAndSig : Symbols) {
const SymbolInfo &Symbol = SymAndSig.Symbol;
Expand Down

0 comments on commit 0efd524

Please sign in to comment.