diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/TypeLoc.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/TypeLoc.cpp | 8 | ||||
-rw-r--r-- | clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp | 11 |
3 files changed, 21 insertions, 0 deletions
diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index e28fe2dcd25..4f3c811ce27 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -1567,6 +1567,8 @@ public: void setUnderlyingTInfo(TypeSourceInfo* TI) const { this->getLocalData()->UnderlyingTInfo = TI; } + + void initializeLocal(ASTContext &Context, SourceLocation Loc); }; // FIXME: location of the 'decltype' and parens. diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp index 208d695632a..c069eb06173 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -312,6 +312,14 @@ TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) { return TL; } +void TypeOfTypeLoc::initializeLocal(ASTContext &Context, + SourceLocation Loc) { + TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> + ::initializeLocal(Context, Loc); + this->getLocalData()->UnderlyingTInfo = Context.getTrivialTypeSourceInfo( + getUnderlyingType(), Loc); +} + void ElaboratedTypeLoc::initializeLocal(ASTContext &Context, SourceLocation Loc) { setElaboratedKeywordLoc(Loc); diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp index 22c58836570..63e2e8b6024 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp @@ -79,4 +79,15 @@ TEST(RecursiveASTVisitor, VisitsObjCPropertyType) { TypeLocVisitor::Lang_OBJC)); } +TEST(RecursiveASTVisitor, VisitInvalidType) { + TypeLocVisitor Visitor; + // FIXME: It would be nice to have information about subtypes of invalid type + //Visitor.ExpectMatch("typeof(struct F *) []", 1, 1); + // Even if the full type is invalid, it should still find sub types + //Visitor.ExpectMatch("struct F", 1, 19); + EXPECT_FALSE(Visitor.runOver( + "__typeof__(struct F*) var[invalid];\n", + TypeLocVisitor::Lang_C)); +} + } // end anonymous namespace |