diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-08-31 03:44:20 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-08-31 03:44:20 +0000 |
| commit | 7e2e459c48169aebddfc82b4573a4ee288872e02 (patch) | |
| tree | 1efde534c4fb8714e14a8d9b50feca5590699cfe | |
| parent | 43b8f7fa4fee0171bc08b6c72606c74b509bfe26 (diff) | |
| download | bcm5719-llvm-7e2e459c48169aebddfc82b4573a4ee288872e02.tar.gz bcm5719-llvm-7e2e459c48169aebddfc82b4573a4ee288872e02.zip | |
add some accessors for querying attributes of builtins. Add the new 'F' attribute.
llvm-svn: 41631
| -rw-r--r-- | clang/include/clang/AST/Builtins.def | 16 | ||||
| -rw-r--r-- | clang/include/clang/AST/Builtins.h | 17 |
2 files changed, 26 insertions, 7 deletions
diff --git a/clang/include/clang/AST/Builtins.def b/clang/include/clang/AST/Builtins.def index 4ab98e8ad5b..a5e3138c858 100644 --- a/clang/include/clang/AST/Builtins.def +++ b/clang/include/clang/AST/Builtins.def @@ -43,16 +43,18 @@ // C -> const // The third value provided to the macro specifies information about attributes -// of the function. Currently we have: +// of the function. These must be kept in sync with the predicates in the +// Builtin::Context class. Currently we have: // n -> nothrow // c -> const +// F -> this is a libc/libm function with a '__builtin_' prefix added. -BUILTIN(__builtin_inf , "d" , "nc") -BUILTIN(__builtin_inff , "f" , "nc") -BUILTIN(__builtin_infl , "Ld" , "nc") -BUILTIN(__builtin_fabs , "dd" , "nc") -BUILTIN(__builtin_fabsf, "ff" , "nc") -BUILTIN(__builtin_fabsl, "LdLd", "nc") +BUILTIN(__builtin_inf , "d" , "ncF") +BUILTIN(__builtin_inff , "f" , "ncF") +BUILTIN(__builtin_infl , "Ld" , "ncF") +BUILTIN(__builtin_fabs , "dd" , "ncF") +BUILTIN(__builtin_fabsf, "ff" , "ncF") +BUILTIN(__builtin_fabsl, "LdLd", "ncF") BUILTIN(__builtin_constant_p, "UsUs", "nc") BUILTIN(__builtin_classify_type, "i.", "nc") BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc") diff --git a/clang/include/clang/AST/Builtins.h b/clang/include/clang/AST/Builtins.h index 682031f7be2..8f808306a65 100644 --- a/clang/include/clang/AST/Builtins.h +++ b/clang/include/clang/AST/Builtins.h @@ -61,6 +61,23 @@ public: return GetRecord(ID).Name; } + /// isConst - Return true if this function has no side effects and doesn't + /// read memory. + bool isConst(unsigned ID) const { + return strchr(GetRecord(ID).Attributes, 'c') != 0; + } + + /// isNoThrow - Return true if we know this builtin never throws an exception. + bool isNoThrow(unsigned ID) const { + return strchr(GetRecord(ID).Attributes, 'n') != 0; + } + + /// isLibFunction - Return true if this is a builtin for a libc/libm function, + /// with a "__builtin_" prefix (e.g. __builtin_inf). + bool isLibFunction(unsigned ID) const { + return strchr(GetRecord(ID).Attributes, 'F') != 0; + } + /// GetBuiltinType - Return the type for the specified builtin. QualType GetBuiltinType(unsigned ID, ASTContext &Context) const; private: |

