summaryrefslogtreecommitdiffstats
path: root/clang/include/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include/clang')
-rw-r--r--clang/include/clang/AST/Builtins.def12
-rw-r--r--clang/include/clang/AST/Builtins.h8
-rw-r--r--clang/include/clang/Basic/LangOptions.h4
3 files changed, 23 insertions, 1 deletions
diff --git a/clang/include/clang/AST/Builtins.def b/clang/include/clang/AST/Builtins.def
index bdcdab15b4a..94696e8174f 100644
--- a/clang/include/clang/AST/Builtins.def
+++ b/clang/include/clang/AST/Builtins.def
@@ -63,6 +63,7 @@
// P:N: -> similar to the p:N: attribute, but the function is like vprintf
// in that it accepts its arguments as a va_list rather than
// through an ellipsis
+// e -> const, but only when -fmath-errno=0
// FIXME: gcc has nonnull
#if defined(BUILTIN) && !defined(LIBBUILTIN)
@@ -176,7 +177,7 @@ BUILTIN(__sync_fetch_and_min,"ii*i", "n")
BUILTIN(__sync_fetch_and_max,"ii*i", "n")
BUILTIN(__sync_fetch_and_umin,"UiUi*Ui", "n")
BUILTIN(__sync_fetch_and_umax,"UiUi*Ui", "n")
-BUILTIN(__sync_fetch_and_and,"ii*i", "n")
+BUILTIN(__sync_fetch_and_and,"ii*i", "n")
BUILTIN(__sync_fetch_and_or,"ii*i", "n")
BUILTIN(__sync_fetch_and_xor,"ii*i", "n")
BUILTIN(__sync_lock_test_and_set,"ii*i", "n")
@@ -216,5 +217,14 @@ LIBBUILTIN(vsprintf, "ic*cC*a", "fP:1:", "stdio.h")
// FIXME: asprintf and vasprintf aren't C99 functions. Should they be
// target-specific builtins, perhaps?
+// Builtin math library functions
+LIBBUILTIN(pow, "ddd", "fe", "math.h")
+LIBBUILTIN(powl, "LdLdLd", "fe", "math.h")
+LIBBUILTIN(powf, "fff", "fe", "math.h")
+
+LIBBUILTIN(sqrt, "dd", "fe", "math.h")
+LIBBUILTIN(sqrtl, "LdLd", "fe", "math.h")
+LIBBUILTIN(sqrtf, "ff", "fe", "math.h")
+
#undef BUILTIN
#undef LIBBUILTIN
diff --git a/clang/include/clang/AST/Builtins.h b/clang/include/clang/AST/Builtins.h
index 6af8d750a46..ad71375ebac 100644
--- a/clang/include/clang/AST/Builtins.h
+++ b/clang/include/clang/AST/Builtins.h
@@ -105,6 +105,14 @@ public:
return strpbrk(GetRecord(ID).Type, "Aa") != 0;
}
+ /// isConstWithoutErrno - Return true if this function has no side
+ /// effects and doesn't read memory, except for possibly errno. Such
+ /// functions can be const when the MathErrno lang option is
+ /// disabled.
+ bool isConstWithoutErrno(unsigned ID) const {
+ return strchr(GetRecord(ID).Attributes, 'e') != 0;
+ }
+
/// GetBuiltinType - Return the type for the specified builtin.
enum GetBuiltinTypeError {
GE_None, //< No error
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 12fffb332d4..0124b04aa92 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -54,6 +54,9 @@ public:
unsigned Blocks : 1; // block extension to C
unsigned EmitAllDecls : 1; // Emit all declarations, even if
// they are unused.
+ unsigned MathErrno : 1; // Math functions must respect errno
+ // (modulo the platform support).
+
private:
unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
// this enum as unsigned because MSVC insists on making enums
@@ -76,6 +79,7 @@ public:
ThreadsafeStatics = 0;
Blocks = 0;
EmitAllDecls = 0;
+ MathErrno = 1;
}
GCMode getGCMode() const { return (GCMode) GC; }
OpenPOWER on IntegriCloud