ChangeNamespaceTool::ChangeNamespaceTool(
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
- llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
+ llvm::ArrayRef<std::string> AllowedSymbolPatterns,
std::map<std::string, tooling::Replacements> *FileToReplacements,
llvm::StringRef FallbackStyle)
: FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
DiffOldNamespace = joinNamespaces(OldNsSplitted);
DiffNewNamespace = joinNamespaces(NewNsSplitted);
- for (const auto &Pattern : WhiteListedSymbolPatterns)
- WhiteListedSymbolRegexes.emplace_back(Pattern);
+ for (const auto &Pattern : AllowedSymbolPatterns)
+ AllowedSymbolRegexes.emplace_back(Pattern);
}
void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
Result.SourceManager->getSpellingLoc(End)),
*Result.SourceManager, Result.Context->getLangOpts());
std::string FromDeclName = FromDecl->getQualifiedNameAsString();
- for (llvm::Regex &RE : WhiteListedSymbolRegexes)
+ for (llvm::Regex &RE : AllowedSymbolRegexes)
if (RE.match(FromDeclName))
return;
std::string ReplaceName =
// files matching `FilePattern`.
ChangeNamespaceTool(
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
- llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
+ llvm::ArrayRef<std::string> AllowedSymbolPatterns,
std::map<std::string, tooling::Replacements> *FileToReplacements,
llvm::StringRef FallbackStyle = "LLVM");
llvm::SmallPtrSet<const clang::DeclRefExpr*, 16> ProcessedFuncRefs;
// Patterns of symbol names whose references are not expected to be updated
// when changing namespaces around them.
- std::vector<llvm::Regex> WhiteListedSymbolRegexes;
+ std::vector<llvm::Regex> AllowedSymbolRegexes;
};
} // namespace change_namespace
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
-cl::opt<std::string> WhiteListFile(
- "whitelist_file",
+cl::opt<std::string> AllowedFile(
+ "allowed_file",
cl::desc("A file containing regexes of symbol names that are not expected "
"to be updated when changing namespaces around them."),
cl::init(""), cl::cat(ChangeNamespaceCategory));
-llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
+llvm::ErrorOr<std::vector<std::string>> GetAllowedSymbolPatterns() {
std::vector<std::string> Patterns;
- if (WhiteListFile.empty())
+ if (AllowedFile.empty())
return Patterns;
llvm::SmallVector<StringRef, 8> Lines;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
- llvm::MemoryBuffer::getFile(WhiteListFile);
+ llvm::MemoryBuffer::getFile(AllowedFile);
if (!File)
return File.getError();
llvm::StringRef Content = File.get()->getBuffer();
ChangeNamespaceCategory);
const auto &Files = OptionsParser.getSourcePathList();
tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
- llvm::ErrorOr<std::vector<std::string>> WhiteListPatterns =
- GetWhiteListedSymbolPatterns();
- if (!WhiteListPatterns) {
- llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
- << WhiteListPatterns.getError().message() << "\n";
+ llvm::ErrorOr<std::vector<std::string>> AllowedPatterns =
+ GetAllowedSymbolPatterns();
+ if (!AllowedPatterns) {
+ llvm::errs() << "Failed to open Allowed file " << AllowedFile << ". "
+ << AllowedPatterns.getError().message() << "\n";
return 1;
}
change_namespace::ChangeNamespaceTool NamespaceTool(
- OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
+ OldNamespace, NewNamespace, FilePattern, *AllowedPatterns,
&Tool.getReplacements(), Style);
ast_matchers::MatchFinder Finder;
NamespaceTool.registerMatchers(&Finder);
-// RUN: echo "^std::.*$" > %T/white-list.txt
-// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --whitelist_file %T/white-list.txt %s -- | sed 's,// CHECK.*,,' | FileCheck %s
+// RUN: echo "^std::.*$" > %T/allowed-list.txt
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --allowed_file %T/white-list.txt %s -- | sed 's,// CHECK.*,,' | FileCheck %s
#include "Inputs/fake-std.h"
std::map<std::string, tooling::Replacements> FileToReplacements;
change_namespace::ChangeNamespaceTool NamespaceTool(
OldNamespace, NewNamespace, FilePattern,
- /*WhiteListedSymbolPatterns*/ {}, &FileToReplacements);
+ /*AllowedSymbolPatterns*/ {}, &FileToReplacements);
ast_matchers::MatchFinder Finder;
NamespaceTool.registerMatchers(&Finder);
std::unique_ptr<tooling::FrontendActionFactory> Factory =