// 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")
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: