diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /lib/AST/ASTTypeTraits.cpp | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'lib/AST/ASTTypeTraits.cpp')
-rw-r--r-- | lib/AST/ASTTypeTraits.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/AST/ASTTypeTraits.cpp b/lib/AST/ASTTypeTraits.cpp index ae47ea9..baa8e48 100644 --- a/lib/AST/ASTTypeTraits.cpp +++ b/lib/AST/ASTTypeTraits.cpp @@ -39,18 +39,24 @@ const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = { #include "clang/AST/TypeNodes.def" }; -bool ASTNodeKind::isBaseOf(ASTNodeKind Other) const { - return isBaseOf(KindId, Other.KindId); +bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const { + return isBaseOf(KindId, Other.KindId, Distance); } bool ASTNodeKind::isSame(ASTNodeKind Other) const { return KindId != NKI_None && KindId == Other.KindId; } -bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived) { +bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived, + unsigned *Distance) { if (Base == NKI_None || Derived == NKI_None) return false; - while (Derived != Base && Derived != NKI_None) + unsigned Dist = 0; + while (Derived != Base && Derived != NKI_None) { Derived = AllKindInfo[Derived].ParentId; + ++Dist; + } + if (Distance) + *Distance = Dist; return Derived == Base; } @@ -71,7 +77,7 @@ void DynTypedNode::print(llvm::raw_ostream &OS, else if (const Decl *D = get<Decl>()) D->print(OS, PP); else if (const Stmt *S = get<Stmt>()) - S->printPretty(OS, 0, PP); + S->printPretty(OS, nullptr, PP); else if (const Type *T = get<Type>()) QualType(T, 0).print(OS, PP); else |