template <RewriteDescriptor::Type DT, typename ValueType,
ValueType *(llvm::Module::*Get)(StringRef) const,
- iterator_range<typename iplist<ValueType>::iterator> (llvm::Module::*Iterator)()>
+ iterator_range<typename iplist<ValueType>::iterator>
+ (llvm::Module::*Iterator)()>
class PatternRewriteDescriptor : public RewriteDescriptor {
public:
const std::string Pattern;
template <RewriteDescriptor::Type DT, typename ValueType,
ValueType *(llvm::Module::*Get)(StringRef) const,
- iterator_range<typename iplist<ValueType>::iterator> (llvm::Module::*Iterator)()>
+ iterator_range<typename iplist<ValueType>::iterator>
+ (llvm::Module::*Iterator)()>
bool PatternRewriteDescriptor<DT, ValueType, Get, Iterator>::
performOnModule(Module &M) {
bool Changed = false;
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;
}
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");
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;
}
KeyValue = Key->getValue(KeyStorage);
- if (KeyValue == kDescriptorFieldSource) {
+ if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
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);
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;
}
KeyValue = Key->getValue(KeyStorage);
- if (KeyValue == kDescriptorFieldSource) {
+ if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
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");
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;
}
KeyValue = Key->getValue(KeyStorage);
- if (KeyValue == kDescriptorFieldSource) {
+ if (KeyValue.equals("source")) {
std::string Error;
Source = Value->getValue(ValueStorage);
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");
RewriteSymbols();
RewriteSymbols(SymbolRewriter::RewriteDescriptorList &DL);
- virtual bool runOnModule(Module &M) override;
+ bool runOnModule(Module &M) override;
private:
void loadAndParseMapFiles();
RewriteSymbols::RewriteSymbols(SymbolRewriter::RewriteDescriptorList &DL)
: ModulePass(ID) {
- std::swap(Descriptors, DL);
+ Descriptors.splice(Descriptors.begin(), DL);
}
bool RewriteSymbols::runOnModule(Module &M) {
}
INITIALIZE_PASS(RewriteSymbols, "rewrite-symbols", "Rewrite Symbols", false,
- false);
+ false)
ModulePass *llvm::createRewriteSymbolsPass() { return new RewriteSymbols(); }