]> granicus.if.org Git - clang/commitdiff
wire up a new -fno-builtin option, make it control things like simplifylibcalls,
authorChris Lattner <sabre@nondot.org>
Fri, 13 Mar 2009 22:38:49 +0000 (22:38 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 13 Mar 2009 22:38:49 +0000 (22:38 +0000)
etc and make freestanding imply it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66972 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
include/clang/AST/Builtins.h
include/clang/Basic/LangOptions.h
lib/AST/ASTContext.cpp
lib/AST/Builtins.cpp

index b33f3443e52e89a9e9cac50b79107cf4668a6458..6d9aaa7f75be913fdc20897e955af1dfb232a620 100644 (file)
@@ -230,6 +230,11 @@ Freestanding("ffreestanding",
              llvm::cl::desc("Assert that the compilation takes place in a "
                             "freestanding environment"));
 
+static llvm::cl::opt<bool>
+NoBuiltin("fno-builtin",
+          llvm::cl::desc("Disable implicit builtin knowledge of functions"));
+
+
 static llvm::cl::opt<bool>
 MathErrno("fmath-errno", 
           llvm::cl::desc("Require math functions to respect errno"),
@@ -650,8 +655,11 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
   if (EnableBlocks.getPosition())
     Options.Blocks = EnableBlocks;
 
+  if (NoBuiltin)
+    Options.NoBuiltin = 1;
   if (Freestanding)
-    Options.Freestanding = 1;
+    Options.Freestanding = Options.NoBuiltin = 1;
+  
   if (EnableHeinousExtensions)
     Options.HeinousExtensions = 1;
 
@@ -1195,7 +1203,7 @@ static void InitializeCompileOptions(CompileOptions &Opts) {
   // FIXME: There are llvm-gcc options to control these selectively.
   Opts.InlineFunctions = (Opts.OptimizationLevel > 1);
   Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
-  Opts.SimplifyLibCalls = !Freestanding;
+  Opts.SimplifyLibCalls = !NoBuiltin;
 
 #ifdef NDEBUG
   Opts.VerifyModule = 0;
index ad71375ebac45d654a7762f0824cd779f0b3fa0c..2eabd88927a1b4d57a55c924a42b0ea61f9c2ae2 100644 (file)
@@ -56,7 +56,7 @@ public:
   /// appropriate builtin ID # and mark any non-portable builtin identifiers as
   /// such.
   void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target,
-                          bool Freestanding = false);
+                          bool NoBuiltins = false);
   
   /// Builtin::GetName - Return the identifier name for the specified builtin,
   /// e.g. "__builtin_abs".
index f0a583c3d3d3dcbe135121ca20c95df2ff408d5f..ee04439cadd50c245ed26bf7929847d369fd8ed3 100644 (file)
@@ -48,6 +48,7 @@ public:
 
   unsigned NeXTRuntime       : 1; // Use NeXT runtime.
   unsigned Freestanding      : 1; // Freestanding implementation
+  unsigned NoBuiltin         : 1; // Do not use builtin functions (-fno-builtin)
 
   unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
                                   // by locks.
@@ -75,7 +76,7 @@ public:
     GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0;
     C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
     CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0;
-    Exceptions = NeXTRuntime = Freestanding = 0;
+    Exceptions = NeXTRuntime = Freestanding = NoBuiltin = 0;
     LaxVectorConversions = 1;
     HeinousExtensions = 0;
     
index a51f432880ec214c2d554e0f2ec601acbeddbcdd..80e17746bbe6673d52d99b8ac32e948e8dcdbe5d 100644 (file)
@@ -39,7 +39,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
 {  
   if (size_reserve > 0) Types.reserve(size_reserve);    
   InitBuiltinTypes();
-  BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.Freestanding);
+  BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.NoBuiltin);
   TUDecl = TranslationUnitDecl::Create(*this);
 }
 
index 46b0346ca462ae0d520c2376064299c87554764b..4655cf392d7384b20ef1add20ce632c26084d64a 100644 (file)
@@ -38,12 +38,11 @@ const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const {
 /// such.
 void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
                                           const TargetInfo &Target,
-                                          bool Freestanding) {
+                                          bool NoBuiltins) {
   // Step #1: mark all target-independent builtins with their ID's.
   for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
     if (!BuiltinInfo[i].Suppressed &&
-        (!Freestanding || 
-         !strchr(BuiltinInfo[i].Attributes, 'f')))
+        (!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f')))
       Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
   
   // Step #2: Get target builtins.
@@ -52,7 +51,7 @@ void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
   // Step #3: Register target-specific builtins.
   for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
     if (!TSRecords[i].Suppressed &&
-        (!Freestanding || 
+        (!NoBuiltins || 
          (TSRecords[i].Attributes && 
           !strchr(TSRecords[i].Attributes, 'f'))))
       Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);