]> granicus.if.org Git - clang/commitdiff
Move char-is-signed defaulting to driver, instead of using
authorDaniel Dunbar <daniel@zuster.org>
Tue, 17 Nov 2009 06:37:03 +0000 (06:37 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 17 Nov 2009 06:37:03 +0000 (06:37 +0000)
getDefaultLangOptions.

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

lib/Basic/Targets.cpp
lib/Driver/Tools.cpp
test/Preprocessor/init.c

index 91ecf475e6efb236e28ee7216d0bc7d3ace345c4..07c9e37d1cf51d996a5f573463ac78a32b64454f 100644 (file)
@@ -160,9 +160,6 @@ static void GetDarwinLanguageOptions(LangOptions &Opts,
                                      const llvm::Triple &Triple) {
   Opts.NeXTRuntime = true;
 
-  if (Triple.getOS() != llvm::Triple::Darwin)
-    return;
-
   unsigned MajorVersion = Triple.getDarwinMajorNumber();
 
   // Blocks and stack protectors default to on for 10.6 (darwin10) and beyond.
@@ -192,7 +189,6 @@ protected:
   /// various language options.  These may be overridden by command line
   /// options.
   virtual void getDefaultLangOptions(LangOptions &Opts) {
-    TargetInfo::getDefaultLangOptions(Opts);
     GetDarwinLanguageOptions(Opts, TargetInfo::getTriple());
   }
 public:
@@ -436,10 +432,6 @@ public:
       return true;
     }
   }
-  virtual void getDefaultLangOptions(LangOptions &Opts) {
-    TargetInfo::getDefaultLangOptions(Opts);
-    Opts.CharIsSigned = false;
-  }
   virtual const char *getClobbers() const {
     return "";
   }
@@ -1676,11 +1668,6 @@ namespace {
       NumRecords = 0;
     }
 
-    virtual void getDefaultLangOptions(LangOptions &Opts) {
-      TargetInfo::getDefaultLangOptions(Opts);
-      Opts.CharIsSigned = false;
-    }
-
     virtual void getGCCRegNames(const char * const *&Names,
                                 unsigned &NumNames) const;
     virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
index 657ebee92499d8349672c4864f122bdd4599320f..d5088fe7b3f76f23f30dcba511ed9fe84884b8f6 100644 (file)
@@ -321,6 +321,23 @@ static std::string getLLVMTriple(const ToolChain &TC, const ArgList &Args) {
   }
 }
 
+// FIXME: Move to target hook.
+static bool isSignedCharDefault(const llvm::Triple &Triple) {
+  switch (Triple.getArch()) {
+  default:
+    return true;
+
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64:
+    if (Triple.getOS() == llvm::Triple::Darwin)
+      return true;
+    return false;
+
+  case llvm::Triple::systemz:
+    return false;
+  }
+}
+
 void Clang::AddARMTargetArgs(const ArgList &Args,
                              ArgStringList &CmdArgs) const {
   const Driver &D = getToolChain().getHost().getDriver();
@@ -927,15 +944,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti))
     CmdArgs.push_back("-frtti=0");
 
-  // -fsigned-char/-funsigned-char default varies depending on platform; only
-  // pass if specified.
-  if (Arg *A = Args.getLastArg(options::OPT_fsigned_char,
-                               options::OPT_funsigned_char)) {
-    if (A->getOption().matches(options::OPT_fsigned_char))
-      CmdArgs.push_back("-fsigned-char");
-    else
-      CmdArgs.push_back("-fsigned-char=0");
-  }
+  // -fsigned-char is default.
+  if (!Args.hasFlag(options::OPT_fsigned_char,
+                    options::OPT_funsigned_char,
+                    isSignedCharDefault(getToolChain().getTriple())))
+    CmdArgs.push_back("-fsigned-char=0");
 
   // -fshort-wchar default varies depending on platform; only
   // pass if specified.
index 100e27461c5184d769e9eb412edb520989041a77..6ba64e4896408fc0236a4f123d5d8055fcf7bd70 100644 (file)
 // PIC16:#define ram __attribute__((address_space(0)))
 // PIC16:#define rom __attribute__((address_space(1)))
 //
-// RUN: clang-cc -E -dM -ffreestanding -triple=powerpc64-none-none < /dev/null | FileCheck -check-prefix PPC64 %s
+// RUN: clang-cc -E -dM -ffreestanding -triple=powerpc64-none-none -fsigned-char=0 < /dev/null | FileCheck -check-prefix PPC64 %s
 //
 // PPC64:#define _ARCH_PPC 1
 // PPC64:#define _ARCH_PPC64 1
 // PPC64:#define __ppc64__ 1
 // PPC64:#define __ppc__ 1
 //
-// RUN: clang-cc -E -dM -ffreestanding -triple=powerpc-none-none < /dev/null | FileCheck -check-prefix PPC %s
+// RUN: clang-cc -E -dM -ffreestanding -triple=powerpc-none-none -fsigned-char=0 < /dev/null | FileCheck -check-prefix PPC %s
 //
 // PPC:#define _ARCH_PPC 1
 // PPC:#define _BIG_ENDIAN 1
 // PPC:#define __WINT_TYPE__ int
 // PPC:#define __ppc__ 1
 //
-// RUN: clang-cc -E -dM -ffreestanding -triple=s390x-none-none < /dev/null | FileCheck -check-prefix S390X %s
+// RUN: clang-cc -E -dM -ffreestanding -triple=s390x-none-none -fsigned-char=0 < /dev/null | FileCheck -check-prefix S390X %s
 //
 // S390X:#define __CHAR_BIT__ 8
 // S390X:#define __CHAR_UNSIGNED__ 1