diff options
Diffstat (limited to 'lib/Sema/TypeLocBuilder.h')
-rw-r--r-- | lib/Sema/TypeLocBuilder.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Sema/TypeLocBuilder.h b/lib/Sema/TypeLocBuilder.h index 3570737d11bce..7a5e43e25dc99 100644 --- a/lib/Sema/TypeLocBuilder.h +++ b/lib/Sema/TypeLocBuilder.h @@ -16,7 +16,6 @@ #define LLVM_CLANG_SEMA_TYPELOCBUILDER_H #include "clang/AST/TypeLoc.h" -#include "llvm/ADT/SmallVector.h" #include "clang/AST/ASTContext.h" namespace clang { @@ -87,6 +86,14 @@ class TypeLocBuilder { Index = Capacity; } + /// \brief Tell the TypeLocBuilder that the type it is storing has been + /// modified in some safe way that doesn't affect type-location information. + void TypeWasModifiedSafely(QualType T) { +#ifndef NDEBUG + LastTy = T; +#endif + } + /// Pushes space for a new TypeLoc of the given type. Invalidates /// any TypeLocs previously retrieved from this builder. template <class TyLocType> TyLocType push(QualType T) { @@ -139,7 +146,7 @@ private: Index -= LocalSize; - return getTypeLoc(T); + return getTemporaryTypeLoc(T); } /// Grow to the given capacity. @@ -171,15 +178,17 @@ private: reserve(Size); Index -= Size; - return getTypeLoc(T); + return getTemporaryTypeLoc(T); } - - // This is private because, when we kill off TypeSourceInfo in favor - // of TypeLoc, we'll want an interface that creates a TypeLoc given - // an ASTContext, and we don't want people to think they can just - // use this as an equivalent. - TypeLoc getTypeLoc(QualType T) { +public: + /// \brief Retrieve a temporary TypeLoc that refers into this \c TypeLocBuilder + /// object. + /// + /// The resulting \c TypeLoc should only be used so long as the + /// \c TypeLocBuilder is active and has not had more type information + /// pushed into it. + TypeLoc getTemporaryTypeLoc(QualType T) { #ifndef NDEBUG assert(LastTy == T && "type doesn't match last type pushed!"); #endif |