return Result;
}
+// By default, we blacklist C++ standard symbols and protobuf symbols as rename
+// these symbols would change system/generated files which are unlikely to be
+// modified.
bool isBlacklisted(const NamedDecl &RenameDecl) {
+ if (isProtoFile(RenameDecl.getLocation(),
+ RenameDecl.getASTContext().getSourceManager()))
+ return true;
static const auto *StdSymbols = new llvm::DenseSet<llvm::StringRef>({
#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
#include "StdSymbolMap.inc"
expectedResult(Code, NewName));
}
+TEST(RenameTest, ProtobufSymbolIsBlacklisted) {
+ Annotations Code("Prot^obuf buf;");
+ auto TU = TestTU::withCode(Code.code());
+ TU.HeaderCode =
+ R"cpp(// Generated by the protocol buffer compiler. DO NOT EDIT!
+ class Protobuf {};
+ )cpp";
+ TU.HeaderFilename = "protobuf.pb.h";
+ auto AST = TU.build();
+ auto Results = rename({Code.point(), "newName", AST, testPath(TU.Filename)});
+ EXPECT_FALSE(Results);
+ EXPECT_THAT(llvm::toString(Results.takeError()),
+ testing::HasSubstr("not a supported kind"));
+}
+
TEST(CrossFileRenameTests, DirtyBuffer) {
Annotations FooCode("class [[Foo]] {};");
std::string FooPath = testPath("foo.cc");