aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-05 02:43:38 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-05 02:43:38 +0000
commitc1212a39e0a00f2e41d266949f1b28de087ad6ff (patch)
tree432a9fa8359be5606d7a3af699c34d86db897933
parenta6f80ef997f0363386749087b325607eaa5adcfc (diff)
ccc: Translate -O to -O1 for clang, and only pass last -O option.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63816 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/ccc/ccclib/Tools.py9
-rw-r--r--tools/ccc/test/ccc/O.c4
2 files changed, 12 insertions, 1 deletions
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index 13d4a54d85..4b600af448 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -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
index 0000000000..7ef0aba61d
--- /dev/null
+++ b/tools/ccc/test/ccc/O.c
@@ -0,0 +1,4 @@
+// Just check that clang accepts these.
+
+// RUN: xcc -fsyntax-only -O1 -O2 %s &&
+// RUN: xcc -fsyntax-only -O %s