Add a comment about the DIDescriptor class hierarchy.

llvm-svn: 205358
This commit is contained in:
Adrian Prantl 2014-04-01 21:04:24 +00:00
parent 75ce62acef
commit 6b444c5c8e
2 changed files with 11 additions and 2 deletions

View File

@ -197,6 +197,13 @@ typedef DIRef<DIScope> DIScopeRef;
typedef DIRef<DIType> DITypeRef;
/// DIScope - A base class for various scopes.
///
/// Although, implementation-wise, DIScope is the parent class of most
/// other DIxxx classes, including DIType and its descendants, most of
/// DIScopes descendants are not a substitutable subtype of
/// DIScope. The DIDescriptor::isScope() method only is true for
/// DIScopes that are scopes in the strict lexical scope sense
/// (DICompileUnit, DISubprogram, etc.), but not for, e.g., a DIType.
class DIScope : public DIDescriptor {
protected:
friend class DIDescriptor;

View File

@ -429,8 +429,10 @@ static bool fieldIsTypeRef(const MDNode *DbgNode, unsigned Elt) {
/// Check if a value can be a ScopeRef.
static bool isScopeRef(const Value *Val) {
return !Val ||
(isa<MDString>(Val) && !cast<MDString>(Val)->getString().empty()) ||
isa<MDNode>(Val);
(isa<MDString>(Val) && !cast<MDString>(Val)->getString().empty()) ||
// Not checking for Val->isScope() here, because it would work
// only for lexical scopes and not all subclasses of DIScope.
isa<MDNode>(Val);
}
/// Check if a field at position Elt of a MDNode can be a ScopeRef.