]> granicus.if.org Git - clang/commitdiff
ccc: Translate -O to -O1 for clang, and only pass last -O option.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 5 Feb 2009 02:43:38 +0000 (02:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 5 Feb 2009 02:43:38 +0000 (02:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63816 91177308-0d34-0410-b5e6-96231b3b80d8

tools/ccc/ccclib/Tools.py
tools/ccc/test/ccc/O.c [new file with mode: 0644]

index 13d4a54d850140c39f4f0ef928940c69d203c899..4b600af4483718d76c84914e08e5d16ad56a398a 100644 (file)
@@ -307,7 +307,14 @@ class Clang_CompileTool(Tool):
 
         arglist.addAllArgs(cmd_args, arglist.parser.fblocksGroup)
 
-        arglist.addAllArgs(cmd_args, arglist.parser.OOption)
+        # Manually translate -O to -O1; let clang reject others.
+        arg = arglist.getLastArg(arglist.parser.OOption)
+        if arg:
+            if arglist.getValue(arg) == '':
+                cmd_args.append('-O1')
+            else:
+                cmd_args.extend(arglist.render(arg))
+
         arglist.addAllArgs2(cmd_args, arglist.parser.ClangWGroup, arglist.parser.pedanticGroup)
         arglist.addLastArg(cmd_args, arglist.parser.wOption)
         arglist.addAllArgs3(cmd_args, arglist.parser.stdOption, arglist.parser.ansiOption, arglist.parser.trigraphsOption)
diff --git a/tools/ccc/test/ccc/O.c b/tools/ccc/test/ccc/O.c
new file mode 100644 (file)
index 0000000..7ef0aba
--- /dev/null
@@ -0,0 +1,4 @@
+// Just check that clang accepts these.
+
+// RUN: xcc -fsyntax-only -O1 -O2 %s &&
+// RUN: xcc -fsyntax-only -O %s