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 | ccbdc7ab82792ac5d7863ef086f11fb010d88073 (patch) | |
tree | 8fd761b3482c8df9272eac68f507776b394f2d32 /lib/Analysis/DebugInfo.cpp | |
parent | bce6091d95b7fd56d7c6760b0de54fb6c4300539 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DebugInfo.cpp')
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index a063aa53ba..4e229e9669 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/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(); |