Transforms: address some late comments

We already use the llvm namespace.  Remove the unnecessary prefix.  Use the
StringRef::equals method to compare with C strings rather than instantiating
std::strings.

Addresses late review comments from David Majnemer.

llvm-svn: 221564
This commit is contained in:
Saleem Abdulrasool 2014-11-08 00:00:50 +00:00
parent 92b13aac04
commit d2c5d7f6da
2 changed files with 14 additions and 31 deletions

View File

@ -446,7 +446,7 @@ void TargetPassConfig::addPassesToHandleExceptions() {
void TargetPassConfig::addCodeGenPrepare() {
if (getOptLevel() != CodeGenOpt::None && !DisableCGP)
addPass(createCodeGenPreparePass(TM));
addPass(llvm::createRewriteSymbolsPass());
addPass(createRewriteSymbolsPass());
}
/// Add common passes that perform LLVM IR to IR transforms in preparation for

View File

@ -245,10 +245,6 @@ bool RewriteMapParser::parse(std::unique_ptr<MemoryBuffer> &MapFile,
bool RewriteMapParser::parseEntry(yaml::Stream &YS, yaml::KeyValueNode &Entry,
RewriteDescriptorList *DL) {
const std::string kRewriteTypeFunction = "function";
const std::string kRewriteTypeGlobalVariable = "global variable";
const std::string kRewriteTypeGlobalAlias = "global alias";
yaml::ScalarNode *Key;
yaml::MappingNode *Value;
SmallString<32> KeyStorage;
@ -267,11 +263,11 @@ bool RewriteMapParser::parseEntry(yaml::Stream &YS, yaml::KeyValueNode &Entry,
}
RewriteType = Key->getValue(KeyStorage);
if (RewriteType == kRewriteTypeFunction)
if (RewriteType.equals("function"))
return parseRewriteFunctionDescriptor(YS, Key, Value, DL);
else if (RewriteType == kRewriteTypeGlobalVariable)
else if (RewriteType.equals("global variable"))
return parseRewriteGlobalVariableDescriptor(YS, Key, Value, DL);
else if (RewriteType == kRewriteTypeGlobalAlias)
else if (RewriteType.equals("global alias"))
return parseRewriteGlobalAliasDescriptor(YS, Key, Value, DL);
YS.printError(Entry.getKey(), "unknown rewrite type");
@ -282,11 +278,6 @@ bool RewriteMapParser::
parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
yaml::MappingNode *Descriptor,
RewriteDescriptorList *DL) {
const std::string kDescriptorFieldSource = "source";
const std::string kDescriptorFieldTarget = "target";
const std::string kDescriptorFieldTransform = "transform";
const std::string kDescriptorFieldNaked = "naked";
bool Naked = false;
std::string Source;
std::string Target;
@ -312,7 +303,7 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}
KeyValue = Key->getValue(KeyStorage);
if (KeyValue == kDescriptorFieldSource) {
if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
@ -320,11 +311,11 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue == kDescriptorFieldTarget) {
} else if (KeyValue.equals("target")) {
Target = Value->getValue(ValueStorage);
} else if (KeyValue == kDescriptorFieldTransform) {
} else if (KeyValue.equals("transform")) {
Transform = Value->getValue(ValueStorage);
} else if (KeyValue == kDescriptorFieldNaked) {
} else if (KeyValue.equals("naked")) {
std::string Undecorated;
Undecorated = Value->getValue(ValueStorage);
@ -355,10 +346,6 @@ bool RewriteMapParser::
parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
yaml::MappingNode *Descriptor,
RewriteDescriptorList *DL) {
const std::string kDescriptorFieldSource = "source";
const std::string kDescriptorFieldTarget = "target";
const std::string kDescriptorFieldTransform = "transform";
std::string Source;
std::string Target;
std::string Transform;
@ -383,7 +370,7 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}
KeyValue = Key->getValue(KeyStorage);
if (KeyValue == kDescriptorFieldSource) {
if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
@ -391,9 +378,9 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue == kDescriptorFieldTarget) {
} else if (KeyValue.equals("target")) {
Target = Value->getValue(ValueStorage);
} else if (KeyValue == kDescriptorFieldTransform) {
} else if (KeyValue.equals("transform")) {
Transform = Value->getValue(ValueStorage);
} else {
YS.printError(Field.getKey(), "unknown Key for Global Variable");
@ -421,10 +408,6 @@ bool RewriteMapParser::
parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
yaml::MappingNode *Descriptor,
RewriteDescriptorList *DL) {
const std::string kDescriptorFieldSource = "source";
const std::string kDescriptorFieldTarget = "target";
const std::string kDescriptorFieldTransform = "transform";
std::string Source;
std::string Target;
std::string Transform;
@ -449,7 +432,7 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
}
KeyValue = Key->getValue(KeyStorage);
if (KeyValue == kDescriptorFieldSource) {
if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
@ -457,9 +440,9 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
YS.printError(Field.getKey(), "invalid regex: " + Error);
return false;
}
} else if (KeyValue == kDescriptorFieldTarget) {
} else if (KeyValue.equals("target")) {
Target = Value->getValue(ValueStorage);
} else if (KeyValue == kDescriptorFieldTransform) {
} else if (KeyValue.equals("transform")) {
Transform = Value->getValue(ValueStorage);
} else {
YS.printError(Field.getKey(), "unknown key for Global Alias");