diff options
-rw-r--r-- | include/clang/AST/TypeLoc.h | 5 | ||||
-rw-r--r-- | include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index d58b79af01..147643c1e5 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -44,6 +44,8 @@ protected: void *Data; public: + /// \brief Convert to the specified TypeLoc type, asserting that this TypeLoc + /// is of the desired type. template<typename T> T castAs() const { assert(T::isType(this)); @@ -52,6 +54,9 @@ public: tl = *this; return t; } + + /// \brief Convert to the specified TypeLoc type, returning a null TypeLoc if + /// this TypeLoc is not of the desired type. template<typename T> T getAs() const { if (!T::isType(this)) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index 2391d49c73..0e0108c2d5 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -69,6 +69,8 @@ protected: public: explicit SVal() : Data(0), Kind(0) {} + /// \brief Convert to the specified SVal type, asserting that this SVal is of + /// the desired type. template<typename T> T castAs() const { assert(T::isKind(*this)); @@ -78,6 +80,8 @@ public: return t; } + /// \brief Convert to the specified SVal type, returning None if this SVal is + /// not of the desired type. template<typename T> Optional<T> getAs() const { if (!T::isKind(*this)) |