Generalize DISubprogram element to encode various flags instead of just one boolean for isArtificial.

This is a backword compatible change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2010-09-29 21:04:46 +00:00
parent b0725316cd
commit 9dd2b47d44
4 changed files with 24 additions and 19 deletions

View File

@ -46,6 +46,16 @@ namespace llvm {
/// This should not be stored in a container, because underly MDNode may /// This should not be stored in a container, because underly MDNode may
/// change in certain situations. /// change in certain situations.
class DIDescriptor { class DIDescriptor {
public:
enum {
FlagPrivate = 1 << 0,
FlagProtected = 1 << 1,
FlagFwdDecl = 1 << 2,
FlagAppleBlock = 1 << 3,
FlagBlockByrefStruct = 1 << 4,
FlagVirtual = 1 << 5,
FlagArtificial = 1 << 6
};
protected: protected:
const MDNode *DbgNode; const MDNode *DbgNode;
@ -203,17 +213,6 @@ namespace llvm {
/// others do not require a huge and empty descriptor full of zeros. /// others do not require a huge and empty descriptor full of zeros.
class DIType : public DIScope { class DIType : public DIScope {
public: public:
enum {
FlagPrivate = 1 << 0,
FlagProtected = 1 << 1,
FlagFwdDecl = 1 << 2,
FlagAppleBlock = 1 << 3,
FlagBlockByrefStruct = 1 << 4,
FlagVirtual = 1 << 5,
FlagArtificial = 1 << 6 // To identify artificial arguments in
// a subroutine type. e.g. "this" in c++.
};
protected: protected:
// This ctor is used when the Tag has already been validated by a derived // This ctor is used when the Tag has already been validated by a derived
// ctor. // ctor.
@ -396,7 +395,12 @@ namespace llvm {
DICompositeType getContainingType() const { DICompositeType getContainingType() const {
return getFieldAs<DICompositeType>(13); return getFieldAs<DICompositeType>(13);
} }
unsigned isArtificial() const { return getUnsignedField(14); } unsigned isArtificial() const {
if (getVersion() <= llvm::LLVMDebugVersion8)
return getUnsignedField(14);
return (getUnsignedField(14) & FlagArtificial) != 0;
}
unsigned isOptimized() const; unsigned isOptimized() const;
StringRef getFilename() const { StringRef getFilename() const {
@ -691,7 +695,7 @@ namespace llvm {
unsigned VK = 0, unsigned VK = 0,
unsigned VIndex = 0, unsigned VIndex = 0,
DIType = DIType(), DIType = DIType(),
bool isArtificial = 0, unsigned Flags = 0,
bool isOptimized = false, bool isOptimized = false,
Function *Fn = 0); Function *Fn = 0);

View File

@ -22,7 +22,8 @@ namespace llvm {
// Debug info constants. // Debug info constants.
enum { enum {
LLVMDebugVersion = (8 << 16), // Current version of debug information. LLVMDebugVersion = (9 << 16), // Current version of debug information.
LLVMDebugVersion8 = (8 << 16), // Cconstant for version 8.
LLVMDebugVersion7 = (7 << 16), // Constant for version 7. LLVMDebugVersion7 = (7 << 16), // Constant for version 7.
LLVMDebugVersion6 = (6 << 16), // Constant for version 6. LLVMDebugVersion6 = (6 << 16), // Constant for version 6.
LLVMDebugVersion5 = (5 << 16), // Constant for version 5. LLVMDebugVersion5 = (5 << 16), // Constant for version 5.

View File

@ -1009,7 +1009,7 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
bool isDefinition, bool isDefinition,
unsigned VK, unsigned VIndex, unsigned VK, unsigned VIndex,
DIType ContainingType, DIType ContainingType,
bool isArtificial, unsigned Flags,
bool isOptimized, bool isOptimized,
Function *Fn) { Function *Fn) {
@ -1028,7 +1028,7 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK),
ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
ContainingType, ContainingType,
ConstantInt::get(Type::getInt1Ty(VMContext), isArtificial), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
Fn Fn
}; };
@ -1062,7 +1062,7 @@ DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration){
DeclNode->getOperand(11), // Virtuality DeclNode->getOperand(11), // Virtuality
DeclNode->getOperand(12), // VIndex DeclNode->getOperand(12), // VIndex
DeclNode->getOperand(13), // Containting Type DeclNode->getOperand(13), // Containting Type
DeclNode->getOperand(14), // isArtificial DeclNode->getOperand(14), // Flags
DeclNode->getOperand(15), // isOptimized DeclNode->getOperand(15), // isOptimized
SPDeclaration.getFunction() SPDeclaration.getFunction()
}; };

View File

@ -7,12 +7,12 @@ public:
}; };
int foo::bar(int x) { int foo::bar(int x) {
// CHECK: {{i1 false, i1 true(, i[0-9]+ [^\}]+[}]|[}]) ; \[ DW_TAG_subprogram \]}} // CHECK: {{i32 [0-9]+, i1 true(, i[0-9]+ [^\}]+[}]|[}]) ; \[ DW_TAG_subprogram \]}}
return x*4 + 1; return x*4 + 1;
} }
int foo::baz(int x) { int foo::baz(int x) {
// CHECK: {{i1 false, i1 true(, i[0-9]+ [^\},]+[}]|[}]) ; \[ DW_TAG_subprogram \]}} // CHECK: {{i32 [0-9]+, i1 true(, i[0-9]+ [^\},]+[}]|[}]) ; \[ DW_TAG_subprogram \]}}
return x*4 + 1; return x*4 + 1;
} }