]> granicus.if.org Git - clang/commitdiff
add some accessors for querying attributes of builtins. Add the new 'F' attribute.
authorChris Lattner <sabre@nondot.org>
Fri, 31 Aug 2007 03:44:20 +0000 (03:44 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Aug 2007 03:44:20 +0000 (03:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41631 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Builtins.def
include/clang/AST/Builtins.h

index 4ab98e8ad5b5617513aaaee3541786f6e036e440..a5e3138c858e5dc10455501c8f4513354f7f699f 100644 (file)
 // 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")
index 682031f7be2d1e4f698008579f5db211063808ee..8f808306a65728c7f49ea7bc489eb62a3ad72e8c 100644 (file)
@@ -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: