[cfe-commits] r64676 - in /cfe/trunk: include/clang/AST/Builtins.def include/clang/AST/Builtins.h lib/AST/Builtins.cpp lib/Basic/Targets.cpp lib/Sema/SemaDecl.cpp
Douglas Gregor
dgregor at apple.com
Mon Feb 16 13:58:21 PST 2009
Author: dgregor
Date: Mon Feb 16 15:58:21 2009
New Revision: 64676
URL: http://llvm.org/viewvc/llvm-project?rev=64676&view=rev
Log:
Supply the header corresponding to a library builtin as a separate argument to the LIBBUILTIN macro
Modified:
cfe/trunk/include/clang/AST/Builtins.def
cfe/trunk/include/clang/AST/Builtins.h
cfe/trunk/lib/AST/Builtins.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/AST/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=64676&r1=64675&r2=64676&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.def (original)
+++ cfe/trunk/include/clang/AST/Builtins.def Mon Feb 16 15:58:21 2009
@@ -66,7 +66,7 @@
// FIXME: gcc has nonnull
#if defined(BUILTIN) && !defined(LIBBUILTIN)
-# define LIBBUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
+# define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS)
#endif
// Standard libc/libm functions:
@@ -186,32 +186,32 @@
BUILTIN(__builtin_llvm_memory_barrier,"vbbbbb", "n")
// Builtin library functions
-LIBBUILTIN(alloca, "v*z", "f:stdlib.h:")
-LIBBUILTIN(calloc, "v*zz", "f:stdlib.h:")
-LIBBUILTIN(malloc, "v*z", "f:stdlib.h:")
-LIBBUILTIN(realloc, "v*v*z", "f:stdlib.h")
-LIBBUILTIN(memcpy, "v*v*vC*z", "f:string.h:")
-LIBBUILTIN(memmove, "v*v*vC*z", "f:string.h:")
-LIBBUILTIN(memset, "v*v*iz", "f:string.h:")
-LIBBUILTIN(strcat, "c*c*cC*", "f:string.h:")
-LIBBUILTIN(strchr, "c*cC*i", "f:string.h:")
-LIBBUILTIN(strcpy, "c*c*cC*", "f:string.h:")
-LIBBUILTIN(strcspn, "zcC*cC*", "f:string.h:")
-LIBBUILTIN(strlen, "zcC*", "f:string.h:")
-LIBBUILTIN(strncat, "c*c*cC*z", "f:string.h:")
-LIBBUILTIN(strncpy, "c*c*cC*z", "f:string.h:")
-LIBBUILTIN(strpbrk, "c*cC*cC*", "f:string.h:")
-LIBBUILTIN(strrchr, "c*cC*i", "f:string.h:")
-LIBBUILTIN(strspn, "zcC*cC*", "f:string.h:")
-LIBBUILTIN(strstr, "c*cC*cC*", "f:string.h:")
-LIBBUILTIN(printf, "icC*.", "f:stdio.h:p:0:")
-LIBBUILTIN(fprintf, "iP*cC*.", "f:stdio.h:p:1:")
-LIBBUILTIN(snprintf, "ic*zcC*.", "f:stdio.h:p:2:")
-LIBBUILTIN(sprintf, "ic*cC*.", "f:stdio.h:p:1:")
-LIBBUILTIN(vprintf, "icC*a", "f:stdio.h:P:0:")
-LIBBUILTIN(vfprintf, "iP*cC*a", "f:stdio.h:P:1:")
-LIBBUILTIN(vsnprintf, "ic*zcC*a", "f:stdio.h:P:2:")
-LIBBUILTIN(vsprintf, "ic*cC*a", "f:stdio.h:P:1:")
+LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")
+LIBBUILTIN(calloc, "v*zz", "f", "stdlib.h")
+LIBBUILTIN(malloc, "v*z", "f", "stdlib.h")
+LIBBUILTIN(realloc, "v*v*z", "f", "stdlib.h")
+LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h")
+LIBBUILTIN(memmove, "v*v*vC*z", "f", "string.h")
+LIBBUILTIN(memset, "v*v*iz", "f", "string.h")
+LIBBUILTIN(strcat, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(strchr, "c*cC*i", "f", "string.h")
+LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(strcspn, "zcC*cC*", "f", "string.h")
+LIBBUILTIN(strlen, "zcC*", "f", "string.h")
+LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h")
+LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h")
+LIBBUILTIN(strpbrk, "c*cC*cC*", "f", "string.h")
+LIBBUILTIN(strrchr, "c*cC*i", "f", "string.h")
+LIBBUILTIN(strspn, "zcC*cC*", "f", "string.h")
+LIBBUILTIN(strstr, "c*cC*cC*", "f", "string.h")
+LIBBUILTIN(printf, "icC*.", "fp:0:", "stdio.h")
+LIBBUILTIN(fprintf, "iP*cC*.", "fp:1:", "stdio.h")
+LIBBUILTIN(snprintf, "ic*zcC*.", "fp:2:", "stdio.h")
+LIBBUILTIN(sprintf, "ic*cC*.", "fp:1:", "stdio.h")
+LIBBUILTIN(vprintf, "icC*a", "fP:0:", "stdio.h")
+LIBBUILTIN(vfprintf, "iP*cC*a", "fP:1:", "stdio.h")
+LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h")
+LIBBUILTIN(vsprintf, "ic*cC*a", "fP:1:", "stdio.h")
// FIXME: asprintf and vasprintf aren't C99 functions. Should they be
// target-specific builtins, perhaps?
Modified: cfe/trunk/include/clang/AST/Builtins.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.h?rev=64676&r1=64675&r2=64676&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.h (original)
+++ cfe/trunk/include/clang/AST/Builtins.h Mon Feb 16 15:58:21 2009
@@ -33,7 +33,7 @@
};
struct Info {
- const char *Name, *Type, *Attributes;
+ const char *Name, *Type, *Attributes, *HeaderName;
bool Suppressed;
bool operator==(const Info &RHS) const {
@@ -90,7 +90,9 @@
/// \brief If this is a library function that comes from a specific
/// header, retrieve that header name.
- std::string getHeaderName(unsigned ID) const;
+ const char *getHeaderName(unsigned ID) const {
+ return GetRecord(ID).HeaderName;
+ }
/// \brief Determine whether this builtin is like printf in its
/// formatting rules and, if so, set the index to the format string
Modified: cfe/trunk/lib/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Builtins.cpp?rev=64676&r1=64675&r2=64676&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Builtins.cpp (original)
+++ cfe/trunk/lib/AST/Builtins.cpp Mon Feb 16 15:58:21 2009
@@ -19,8 +19,9 @@
using namespace clang;
static const Builtin::Info BuiltinInfo[] = {
- { "not a builtin function", 0, 0, false },
-#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, false },
+ { "not a builtin function", 0, 0, 0, false },
+#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false },
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false },
#include "clang/AST/Builtins.def"
};
@@ -57,21 +58,6 @@
Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);
}
-std::string Builtin::Context::getHeaderName(unsigned ID) const {
- const char *Name = strchr(GetRecord(ID).Attributes, 'f');
- if (!Name)
- return 0;
- ++Name;
-
- if (*Name != ':')
- return 0;
-
- ++Name;
- const char *NameEnd = strchr(Name, ':');
- assert(NameEnd && "Missing ':' after header name");
- return std::string(Name, NameEnd);
-}
-
bool
Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
bool &HasVAListArg) {
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=64676&r1=64675&r2=64676&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 16 15:58:21 2009
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+// FIXME: Layering violation
#include "clang/AST/Builtins.h"
#include "clang/AST/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
@@ -296,7 +297,8 @@
};
const Builtin::Info PPCTargetInfo::BuiltinInfo[] = {
-#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, false },
+#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false },
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false },
#include "clang/AST/PPCBuiltins.def"
};
@@ -438,7 +440,8 @@
namespace {
// Namespace for x86 abstract base class
const Builtin::Info BuiltinInfo[] = {
-#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, false },
+#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, false },
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER, false },
#include "clang/AST/X86Builtins.def"
};
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=64676&r1=64675&r2=64676&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Feb 16 15:58:21 2009
@@ -315,7 +315,7 @@
Diag(Loc, diag::ext_implicit_lib_function_decl)
<< Context.BuiltinInfo.GetName(BID)
<< R;
- if (!Context.BuiltinInfo.getHeaderName(BID).empty() &&
+ if (Context.BuiltinInfo.getHeaderName(BID) &&
Diags.getDiagnosticMapping(diag::ext_implicit_lib_function_decl)
!= diag::MAP_IGNORE)
Diag(Loc, diag::note_please_include_header)
More information about the cfe-commits
mailing list