[llvm-commits] [llvm] r133351 - /llvm/trunk/lib/Analysis/DebugInfo.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Jun 18 07:42:42 PDT 2011
Author: d0k
Date: Sat Jun 18 09:42:42 2011
New Revision: 133351
URL: http://llvm.org/viewvc/llvm-project?rev=133351&view=rev
Log:
Simplify code. No functionality change.
Modified:
llvm/trunk/lib/Analysis/DebugInfo.cpp
Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=133351&r1=133350&r2=133351&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Sat Jun 18 09:42:42 2011
@@ -727,37 +727,37 @@
/// fixupObjcLikeName - Replace contains special characters used
/// in a typical Objective-C names with '.' in a given string.
-static void fixupObjcLikeName(std::string &Str) {
+static void fixupObjcLikeName(StringRef Str, SmallVectorImpl<char> &Out) {
+ bool isObjCLike = false;
for (size_t i = 0, e = Str.size(); i < e; ++i) {
char C = Str[i];
- if (C == '[' || C == ']' || C == ' ' || C == ':' || C == '+' ||
- C == '(' || C == ')')
- Str[i] = '.';
+ if (C == '[')
+ isObjCLike = true;
+
+ if (isObjCLike && (C == '[' || C == ']' || C == ' ' || C == ':' ||
+ C == '+' || C == '(' || C == ')'))
+ Out.push_back('.');
+ else
+ Out.push_back(C);
}
}
/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
/// suitable to hold function specific information.
NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, StringRef FuncName) {
- if (FuncName.find('[') == StringRef::npos)
- return M.getNamedMetadata(Twine("llvm.dbg.lv.", FuncName));
- std::string Name = FuncName;
- fixupObjcLikeName(Name);
- return M.getNamedMetadata(Twine("llvm.dbg.lv.", Name));
+ SmallString<32> Name = StringRef("llvm.dbg.lv.");
+ fixupObjcLikeName(FuncName, Name);
+
+ return M.getNamedMetadata(Name.str());
}
/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
/// to hold function specific information.
NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, StringRef FuncName) {
- SmallString<32> Out;
- if (FuncName.find('[') == StringRef::npos)
- return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", FuncName)
- .toStringRef(Out));
-
- std::string Name = FuncName;
- fixupObjcLikeName(Name);
- return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", Name)
- .toStringRef(Out));
+ SmallString<32> Name = StringRef("llvm.dbg.lv.");
+ fixupObjcLikeName(FuncName, Name);
+
+ return M.getOrInsertNamedMetadata(Name.str());
}
More information about the llvm-commits
mailing list