diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-06-08 22:00:50 +0000 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-06-08 22:00:50 +0000 |
commit | 6b87ef832eba600ca72655f462b6e3d5088ec375 (patch) | |
tree | f2549a96b51121d58432d00cd8e09c36768bceee /include/clang/ASTMatchers | |
parent | 1fc30fcae813617a5beb272c5abedc11fcce2e31 (diff) |
[ASTMatchers] Add support for floatLiterals
Summary:
Needed to support something like "floatLiteral(equals(1.0))". The
parser for floating point numbers is kept simple, so instead of ".1" you
have to use "0.1".
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D33135
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/ASTMatchers')
-rw-r--r-- | include/clang/ASTMatchers/Dynamic/Diagnostics.h | 2 | ||||
-rw-r--r-- | include/clang/ASTMatchers/Dynamic/Parser.h | 3 | ||||
-rw-r--r-- | include/clang/ASTMatchers/Dynamic/VariantValue.h | 10 |
3 files changed, 13 insertions, 2 deletions
diff --git a/include/clang/ASTMatchers/Dynamic/Diagnostics.h b/include/clang/ASTMatchers/Dynamic/Diagnostics.h index 2c76ddaa07..908fa0db62 100644 --- a/include/clang/ASTMatchers/Dynamic/Diagnostics.h +++ b/include/clang/ASTMatchers/Dynamic/Diagnostics.h @@ -76,7 +76,7 @@ public: ET_ParserInvalidToken = 106, ET_ParserMalformedBindExpr = 107, ET_ParserTrailingCode = 108, - ET_ParserUnsignedError = 109, + ET_ParserNumberError = 109, ET_ParserOverloadedType = 110 }; diff --git a/include/clang/ASTMatchers/Dynamic/Parser.h b/include/clang/ASTMatchers/Dynamic/Parser.h index cd3b30ab84..5ec4a9abf4 100644 --- a/include/clang/ASTMatchers/Dynamic/Parser.h +++ b/include/clang/ASTMatchers/Dynamic/Parser.h @@ -19,9 +19,10 @@ /// \code /// Grammar for the expressions supported: /// <Expression> := <Literal> | <NamedValue> | <MatcherExpression> -/// <Literal> := <StringLiteral> | <Boolean> | <Unsigned> +/// <Literal> := <StringLiteral> | <Boolean> | <Double> | <Unsigned> /// <StringLiteral> := "quoted string" /// <Boolean> := true | false +/// <Double> := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+ /// <Unsigned> := [0-9]+ /// <NamedValue> := <Identifier> /// <MatcherExpression> := <Identifier>(<ArgumentList>) | diff --git a/include/clang/ASTMatchers/Dynamic/VariantValue.h b/include/clang/ASTMatchers/Dynamic/VariantValue.h index ce00bf7fe2..f9efe0f16f 100644 --- a/include/clang/ASTMatchers/Dynamic/VariantValue.h +++ b/include/clang/ASTMatchers/Dynamic/VariantValue.h @@ -36,6 +36,7 @@ class ArgKind { enum Kind { AK_Matcher, AK_Boolean, + AK_Double, AK_Unsigned, AK_String }; @@ -243,6 +244,7 @@ struct VariantMatcher::TypedMatcherOps final : VariantMatcher::MatcherOps { /// /// Supported types: /// - \c bool +// - \c double /// - \c unsigned /// - \c llvm::StringRef /// - \c VariantMatcher (\c DynTypedMatcher / \c Matcher<T>) @@ -256,6 +258,7 @@ public: /// \brief Specific constructors for each supported type. VariantValue(bool Boolean); + VariantValue(double Double); VariantValue(unsigned Unsigned); VariantValue(StringRef String); VariantValue(const VariantMatcher &Matchers); @@ -272,6 +275,11 @@ public: bool getBoolean() const; void setBoolean(bool Boolean); + /// \brief Double value functions. + bool isDouble() const; + double getDouble() const; + void setDouble(double Double); + /// \brief Unsigned value functions. bool isUnsigned() const; unsigned getUnsigned() const; @@ -315,6 +323,7 @@ private: enum ValueType { VT_Nothing, VT_Boolean, + VT_Double, VT_Unsigned, VT_String, VT_Matcher @@ -323,6 +332,7 @@ private: /// \brief All supported value types. union AllValues { unsigned Unsigned; + double Double; bool Boolean; std::string *String; VariantMatcher *Matcher; |