It is not a good idea to have data member's name match argument's name. In fact, it is a simple receipe to waste an hour or so.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74018 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-06-23 22:25:41 +00:00
parent d933803b51
commit 9af2fa879c
2 changed files with 32 additions and 32 deletions

View File

@ -36,7 +36,7 @@ namespace llvm {
class DIDescriptor { class DIDescriptor {
protected: protected:
GlobalVariable *GV; GlobalVariable *DbgGV;
/// DIDescriptor constructor. If the specified GV is non-null, this checks /// DIDescriptor constructor. If the specified GV is non-null, this checks
/// to make sure that the tag in the descriptor matches 'RequiredTag'. If /// to make sure that the tag in the descriptor matches 'RequiredTag'. If
@ -58,12 +58,12 @@ namespace llvm {
GlobalVariable *getGlobalVariableField(unsigned Elt) const; GlobalVariable *getGlobalVariableField(unsigned Elt) const;
public: public:
explicit DIDescriptor() : GV(0) {} explicit DIDescriptor() : DbgGV(0) {}
explicit DIDescriptor(GlobalVariable *gv) : GV(gv) {} explicit DIDescriptor(GlobalVariable *GV) : DbgGV(GV) {}
bool isNull() const { return GV == 0; } bool isNull() const { return DbgGV == 0; }
GlobalVariable *getGV() const { return GV; } GlobalVariable *getGV() const { return DbgGV; }
unsigned getVersion() const { unsigned getVersion() const {
return getUnsignedField(0) & LLVMDebugVersionMask; return getUnsignedField(0) & LLVMDebugVersionMask;
@ -245,7 +245,7 @@ namespace llvm {
explicit DIDerivedType(GlobalVariable *GV) explicit DIDerivedType(GlobalVariable *GV)
: DIType(GV, true, true) { : DIType(GV, true, true) {
if (GV && !isDerivedType(getTag())) if (GV && !isDerivedType(getTag()))
GV = 0; DbgGV = 0;
} }
DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); } DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
@ -265,7 +265,7 @@ namespace llvm {
explicit DICompositeType(GlobalVariable *GV) explicit DICompositeType(GlobalVariable *GV)
: DIDerivedType(GV, true, true) { : DIDerivedType(GV, true, true) {
if (GV && !isCompositeType(getTag())) if (GV && !isCompositeType(getTag()))
GV = 0; DbgGV = 0;
} }
DIArray getTypeArray() const { return getFieldAs<DIArray>(10); } DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
@ -373,10 +373,10 @@ namespace llvm {
/// global etc). /// global etc).
class DIVariable : public DIDescriptor { class DIVariable : public DIDescriptor {
public: public:
explicit DIVariable(GlobalVariable *gv = 0) explicit DIVariable(GlobalVariable *GV = 0)
: DIDescriptor(gv) { : DIDescriptor(GV) {
if (gv && !isVariable(getTag())) if (GV && !isVariable(getTag()))
GV = 0; DbgGV = 0;
} }
DIDescriptor getContext() const { return getDescriptorField(1); } DIDescriptor getContext() const { return getDescriptorField(1); }

View File

@ -73,22 +73,22 @@ bool DIDescriptor::ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel) {
return true; return true;
} }
DIDescriptor::DIDescriptor(GlobalVariable *gv, unsigned RequiredTag) { DIDescriptor::DIDescriptor(GlobalVariable *GV, unsigned RequiredTag) {
GV = gv; DbgGV = GV;
// If this is non-null, check to see if the Tag matches. If not, set to null. // If this is non-null, check to see if the Tag matches. If not, set to null.
if (GV && getTag() != RequiredTag) if (GV && getTag() != RequiredTag)
GV = 0; DbgGV = 0;
} }
const std::string & const std::string &
DIDescriptor::getStringField(unsigned Elt, std::string &Result) const { DIDescriptor::getStringField(unsigned Elt, std::string &Result) const {
if (GV == 0) { if (DbgGV == 0) {
Result.clear(); Result.clear();
return Result; return Result;
} }
Constant *C = GV->getInitializer(); Constant *C = DbgGV->getInitializer();
if (C == 0 || Elt >= C->getNumOperands()) { if (C == 0 || Elt >= C->getNumOperands()) {
Result.clear(); Result.clear();
return Result; return Result;
@ -102,9 +102,9 @@ DIDescriptor::getStringField(unsigned Elt, std::string &Result) const {
} }
uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const { uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
if (GV == 0) return 0; if (DbgGV == 0) return 0;
Constant *C = GV->getInitializer(); Constant *C = DbgGV->getInitializer();
if (C == 0 || Elt >= C->getNumOperands()) if (C == 0 || Elt >= C->getNumOperands())
return 0; return 0;
@ -114,9 +114,9 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
} }
DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const { DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
if (GV == 0) return DIDescriptor(); if (DbgGV == 0) return DIDescriptor();
Constant *C = GV->getInitializer(); Constant *C = DbgGV->getInitializer();
if (C == 0 || Elt >= C->getNumOperands()) if (C == 0 || Elt >= C->getNumOperands())
return DIDescriptor(); return DIDescriptor();
@ -125,9 +125,9 @@ DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
} }
GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const { GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
if (GV == 0) return 0; if (DbgGV == 0) return 0;
Constant *C = GV->getInitializer(); Constant *C = DbgGV->getInitializer();
if (C == 0 || Elt >= C->getNumOperands()) if (C == 0 || Elt >= C->getNumOperands())
return 0; return 0;
@ -140,12 +140,12 @@ GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Needed by DIVariable::getType(). // Needed by DIVariable::getType().
DIType::DIType(GlobalVariable *gv) : DIDescriptor(gv) { DIType::DIType(GlobalVariable *GV) : DIDescriptor(GV) {
if (!gv) return; if (!GV) return;
unsigned tag = getTag(); unsigned tag = getTag();
if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) && if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) &&
!DICompositeType::isCompositeType(tag)) !DICompositeType::isCompositeType(tag))
GV = 0; DbgGV = 0;
} }
/// isDerivedType - Return true if the specified tag is legal for /// isDerivedType - Return true if the specified tag is legal for
@ -198,8 +198,8 @@ bool DIVariable::isVariable(unsigned Tag) {
} }
unsigned DIArray::getNumElements() const { unsigned DIArray::getNumElements() const {
assert (GV && "Invalid DIArray"); assert (DbgGV && "Invalid DIArray");
Constant *C = GV->getInitializer(); Constant *C = DbgGV->getInitializer();
assert (C && "Invalid DIArray initializer"); assert (C && "Invalid DIArray initializer");
return C->getNumOperands(); return C->getNumOperands();
} }
@ -959,7 +959,7 @@ namespace llvm {
/// dump - Print descriptor. /// dump - Print descriptor.
void DIDescriptor::dump() const { void DIDescriptor::dump() const {
cerr << "[" << dwarf::TagString(getTag()) << "] "; cerr << "[" << dwarf::TagString(getTag()) << "] ";
cerr << std::hex << "[GV:" << GV << "]" << std::dec; cerr << std::hex << "[GV:" << DbgGV << "]" << std::dec;
} }
/// dump - Print compile unit. /// dump - Print compile unit.
@ -1000,11 +1000,11 @@ void DIType::dump() const {
cerr << " [fwd] "; cerr << " [fwd] ";
if (isBasicType(Tag)) if (isBasicType(Tag))
DIBasicType(GV).dump(); DIBasicType(DbgGV).dump();
else if (isDerivedType(Tag)) else if (isDerivedType(Tag))
DIDerivedType(GV).dump(); DIDerivedType(DbgGV).dump();
else if (isCompositeType(Tag)) else if (isCompositeType(Tag))
DICompositeType(GV).dump(); DICompositeType(DbgGV).dump();
else { else {
cerr << "Invalid DIType\n"; cerr << "Invalid DIType\n";
return; return;
@ -1051,7 +1051,7 @@ void DIGlobal::dump() const {
cerr << " [def] "; cerr << " [def] ";
if (isGlobalVariable(Tag)) if (isGlobalVariable(Tag))
DIGlobalVariable(GV).dump(); DIGlobalVariable(DbgGV).dump();
cerr << "\n"; cerr << "\n";
} }