diff options
author | Bill Wendling <isanbard@gmail.com> | 2009-03-09 05:04:40 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2009-03-09 05:04:40 +0000 |
commit | c6869f4695ee7dcaab1f67fa87a92546dd877cc6 (patch) | |
tree | a5f400f93e79c30c2838916922ce09afd92c5e18 /llvm/lib/Analysis | |
parent | 4a48815bd95d71ef6e367c3e650d033733481645 (diff) | |
download | bcm5719-llvm-c6869f4695ee7dcaab1f67fa87a92546dd877cc6.tar.gz bcm5719-llvm-c6869f4695ee7dcaab1f67fa87a92546dd877cc6.zip |
Pass in a std::string when getting the names of debugging things. This cuts down
on the number of times a std::string is created and copied.
llvm-svn: 66396
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/DbgInfoPrinter.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 49 |
2 files changed, 41 insertions, 18 deletions
diff --git a/llvm/lib/Analysis/DbgInfoPrinter.cpp b/llvm/lib/Analysis/DbgInfoPrinter.cpp index 522e98ff01b..127f931b6ed 100644 --- a/llvm/lib/Analysis/DbgInfoPrinter.cpp +++ b/llvm/lib/Analysis/DbgInfoPrinter.cpp @@ -59,8 +59,9 @@ void PrintDbgInfo::printVariableDeclaration(const Value *V) { if(const DbgDeclareInst* DDI = findDbgDeclare(V)) { DIVariable Var(cast<GlobalVariable>(DDI->getVariable())); - Out << "; variable " << Var.getName() - << " of type " << Var.getType().getName() + std::string Res1, Res2; + Out << "; variable " << Var.getName(Res1) + << " of type " << Var.getType().getName(Res2) << " at line " << Var.getLineNumber() << "\n"; } } @@ -83,8 +84,9 @@ void PrintDbgInfo::printStopPoint(const DbgStopPointInst *DSI) void PrintDbgInfo::printFuncStart(const DbgFuncStartInst *FS) { DISubprogram Subprogram(cast<GlobalVariable>(FS->getSubprogram())); - Out << ";fully qualified function name: " << Subprogram.getDisplayName() - << " return type: " << Subprogram.getType().getName() + std::string Res1, Res2; + Out << ";fully qualified function name: " << Subprogram.getDisplayName(Res1) + << " return type: " << Subprogram.getType().getName(Res2) << " at line " << Subprogram.getLineNumber() << "\n\n"; } diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index a063aa53ba4..4e229e96690 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -35,17 +35,23 @@ DIDescriptor::DIDescriptor(GlobalVariable *gv, unsigned RequiredTag) { GV = 0; } +const std::string & +DIDescriptor::getStringField(unsigned Elt, std::string &Result) const { + if (GV == 0) { + Result.clear(); + return Result; + } -std::string DIDescriptor::getStringField(unsigned Elt) const { - if (GV == 0) return ""; Constant *C = GV->getInitializer(); - if (C == 0 || Elt >= C->getNumOperands()) - return ""; + if (C == 0 || Elt >= C->getNumOperands()) { + Result.clear(); + return Result; + } - std::string Result; // Fills in the string if it succeeds if (!GetConstantStringInfo(C->getOperand(Elt), Result)) Result.clear(); + return Result; } @@ -59,7 +65,6 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const { return 0; } - DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const { if (GV == 0) return DIDescriptor(); Constant *C = GV->getInitializer(); @@ -185,7 +190,8 @@ unsigned DIArray::getNumElements() const { bool DICompileUnit::Verify() const { if (isNull()) return false; - if (getFilename().empty()) + std::string Res; + if (getFilename(Res).empty()) return false; // It is possible that directory and produce string is empty. return true; @@ -864,16 +870,22 @@ namespace llvm { void DICompileUnit::dump() const { if (getLanguage()) cerr << " [" << dwarf::LanguageString(getLanguage()) << "] "; - cerr << " [" << getDirectory() << "/" << getFilename() << " ]"; + + std::string Res1, Res2; + cerr << " [" << getDirectory(Res1) << "/" << getFilename(Res2) << " ]"; } /// dump - print type. void DIType::dump() const { if (isNull()) return; - if (!getName().empty()) - cerr << " [" << getName() << "] "; + + std::string Res; + if (!getName(Res).empty()) + cerr << " [" << Res << "] "; + unsigned Tag = getTag(); cerr << " [" << dwarf::TagString(Tag) << "] "; + // TODO : Print context getCompileUnit().dump(); cerr << " [" @@ -882,10 +894,12 @@ void DIType::dump() const { << getAlignInBits() << ", " << getOffsetInBits() << "] "; + if (isPrivate()) cerr << " [private] "; else if (isProtected()) cerr << " [protected] "; + if (isForwardDecl()) cerr << " [fwd] "; @@ -899,6 +913,7 @@ void DIType::dump() const { cerr << "Invalid DIType\n"; return; } + cerr << "\n"; } @@ -923,16 +938,20 @@ void DICompositeType::dump() const { /// dump - print global. void DIGlobal::dump() const { + std::string Res; + if (!getName(Res).empty()) + cerr << " [" << Res << "] "; - if (!getName().empty()) - cerr << " [" << getName() << "] "; unsigned Tag = getTag(); cerr << " [" << dwarf::TagString(Tag) << "] "; + // TODO : Print context getCompileUnit().dump(); cerr << " [" << getLineNumber() << "] "; + if (isLocalToUnit()) cerr << " [local] "; + if (isDefinition()) cerr << " [def] "; @@ -954,8 +973,10 @@ void DIGlobalVariable::dump() const { /// dump - print variable. void DIVariable::dump() const { - if (!getName().empty()) - cerr << " [" << getName() << "] "; + std::string Res; + if (!getName(Res).empty()) + cerr << " [" << Res << "] "; + getCompileUnit().dump(); cerr << " [" << getLineNumber() << "] "; getType().dump(); |