Permalink
Browse files

name correction

  • Loading branch information...
1 parent 69e318c commit bf072c97eb3a1b5d0694e3d7a26f58867501b71c @kripken committed Jul 20, 2012
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/Target/CppBackend/CPPBackend.cpp
@@ -431,9 +431,10 @@ std::string CppWriter::getCppName(const Value* val) {
if (I != ValueNames.end() && I->first == val)
return I->second;
- if (val->hasName())
+ if (val->hasName()) {
name = std::string("_") + val->getName().str();
- else {
+ sanitize(name);
+ } else {
if (const GlobalVariable* GV = dyn_cast<GlobalVariable>(val)) {
name = std::string("gvar_") +
getTypePrefix(GV->getType()->getElementType());
@@ -458,12 +459,12 @@ std::string CppWriter::getCppName(const Value* val) {
name = getTypePrefix(val->getType());
}
name += utostr(uniqueNum++);
+ sanitize(name);
+ NameSet::iterator NI = UsedNames.find(name);
+ if (NI != UsedNames.end())
+ name += std::string("_") + utostr(uniqueNum++);
+ UsedNames.insert(name);
}
- sanitize(name);
- NameSet::iterator NI = UsedNames.find(name);
- if (NI != UsedNames.end())
- name += std::string("_") + utostr(uniqueNum++);
- UsedNames.insert(name);
return ValueNames[val] = name;
}

0 comments on commit bf072c9

Please sign in to comment.