[cfe-commits] r105763 - in /cfe/trunk: include/clang/Driver/Options.td lib/Driver/Option.cpp test/Driver/option-aliases.c
Daniel Dunbar
daniel at zuster.org
Wed Jun 9 15:44:34 PDT 2010
Author: ddunbar
Date: Wed Jun 9 17:44:34 2010
New Revision: 105763
URL: http://llvm.org/viewvc/llvm-project?rev=105763&view=rev
Log:
Driver: Change Option parsing to always create arguments referring to unaliased
options.
- This matches the intent of the .td files, and will simplify alias handling.
- PR7321.
Added:
cfe/trunk/test/Driver/option-aliases.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Option.cpp
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=105763&r1=105762&r2=105763&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jun 9 17:44:34 2010
@@ -713,4 +713,4 @@
def _warn_ : Joined<"--warn-">, Alias<W_Joined>, Flags<[Unsupported]>;
def _write_dependencies : Flag<"--write-dependencies">, Alias<MD>;
def _write_user_dependencies : Flag<"--write-user-dependencies">, Alias<MMD>;
-def _ : Joined<"--">, Alias<f>, Flags<[Unsupported]>;
+def _ : Joined<"--">, Flags<[Unsupported]>;
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=105763&r1=105762&r2=105763&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Jun 9 17:44:34 2010
@@ -147,7 +147,7 @@
if (strlen(getName()) != strlen(Args.getArgString(Index)))
return 0;
- return new Arg(this, Index++);
+ return new Arg(getUnaliasedOption(), Index++);
}
JoinedOption::JoinedOption(OptSpecifier ID, const char *Name,
@@ -158,7 +158,7 @@
Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const {
// Always matches.
const char *Value = Args.getArgString(Index) + strlen(getName());
- return new Arg(this, Index++, Value);
+ return new Arg(getUnaliasedOption(), Index++, Value);
}
CommaJoinedOption::CommaJoinedOption(OptSpecifier ID, const char *Name,
@@ -171,7 +171,7 @@
unsigned &Index) const {
// Always matches.
const char *Str = Args.getArgString(Index) + strlen(getName());
- Arg *A = new Arg(this, Index++);
+ Arg *A = new Arg(getUnaliasedOption(), Index++);
// Parse out the comma separated values.
const char *Prev = Str;
@@ -212,7 +212,7 @@
if (Index > Args.getNumInputArgStrings())
return 0;
- return new Arg(this, Index - 2, Args.getArgString(Index - 1));
+ return new Arg(getUnaliasedOption(), Index - 2, Args.getArgString(Index - 1));
}
MultiArgOption::MultiArgOption(OptSpecifier ID, const char *Name,
@@ -232,8 +232,8 @@
if (Index > Args.getNumInputArgStrings())
return 0;
- Arg *A = new Arg(this, Index - 1 - NumArgs,
- Args.getArgString(Index - NumArgs));
+ Arg *A = new Arg(getUnaliasedOption(), Index - 1 - NumArgs,
+ Args.getArgString(Index - NumArgs));
for (unsigned i = 1; i != NumArgs; ++i)
A->getValues().push_back(Args.getArgString(Index - NumArgs + i));
return A;
@@ -260,7 +260,7 @@
if (Index > Args.getNumInputArgStrings())
return 0;
- return new Arg(this, Index - 2, Args.getArgString(Index - 1));
+ return new Arg(getUnaliasedOption(), Index - 2, Args.getArgString(Index - 1));
}
JoinedAndSeparateOption::JoinedAndSeparateOption(OptSpecifier ID,
@@ -278,6 +278,7 @@
if (Index > Args.getNumInputArgStrings())
return 0;
- return new Arg(this, Index - 2, Args.getArgString(Index-2)+strlen(getName())
- , Args.getArgString(Index-1));
+ return new Arg(getUnaliasedOption(), Index - 2,
+ Args.getArgString(Index-2)+strlen(getName()),
+ Args.getArgString(Index-1));
}
Added: cfe/trunk/test/Driver/option-aliases.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/option-aliases.c?rev=105763&view=auto
==============================================================================
--- cfe/trunk/test/Driver/option-aliases.c (added)
+++ cfe/trunk/test/Driver/option-aliases.c Wed Jun 9 17:44:34 2010
@@ -0,0 +1,11 @@
+// RUN: %clang -ccc-print-options \
+// RUN: --save-temps --undefine-macro=FOO --undefine-macro FOO \
+// RUN: --param=FOO --output=FOO 2> %t
+// RUN: FileCheck --check-prefix=CHECK-OPTIONS < %t %s
+
+// CHECK-OPTIONS: Option 0 - Name: "-ccc-print-options", Values: {}
+// CHECK-OPTIONS: Option 1 - Name: "-save-temps", Values: {}
+// CHECK-OPTIONS: Option 2 - Name: "-U", Values: {"FOO"}
+// CHECK-OPTIONS: Option 3 - Name: "-U", Values: {"FOO"}
+// CHECK-OPTIONS: Option 4 - Name: "--param", Values: {"FOO"}
+// CHECK-OPTIONS: Option 5 - Name: "-o", Values: {"FOO"}
More information about the cfe-commits
mailing list