[cfe-commits] r41631 - in /cfe/trunk/include/clang/AST: Builtins.def Builtins.h
Chris Lattner
sabre at nondot.org
Thu Aug 30 20:44:21 PDT 2007
Author: lattner
Date: Thu Aug 30 22:44:20 2007
New Revision: 41631
URL: http://llvm.org/viewvc/llvm-project?rev=41631&view=rev
Log:
add some accessors for querying attributes of builtins. Add the new 'F' attribute.
Modified:
cfe/trunk/include/clang/AST/Builtins.def
cfe/trunk/include/clang/AST/Builtins.h
Modified: cfe/trunk/include/clang/AST/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=41631&r1=41630&r2=41631&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.def (original)
+++ cfe/trunk/include/clang/AST/Builtins.def Thu Aug 30 22:44:20 2007
@@ -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")
Modified: cfe/trunk/include/clang/AST/Builtins.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.h?rev=41631&r1=41630&r2=41631&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.h (original)
+++ cfe/trunk/include/clang/AST/Builtins.h Thu Aug 30 22:44:20 2007
@@ -61,6 +61,23 @@
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:
More information about the cfe-commits
mailing list