Fix a bug that caused opt and other tools to silently ignore
authorDan Gohman <gohman@apple.com>
Sat, 23 Feb 2008 01:55:25 +0000 (01:55 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 23 Feb 2008 01:55:25 +0000 (01:55 +0000)
invalid command-line options.

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

lib/Support/CommandLine.cpp
test/Other/invalid-commandline-option.ll [new file with mode: 0644]

index 4fe1aa1112cb9faa18d422ad070a793149927a93..486875210fd14735ae562996dd80b2e976dd4096 100644 (file)
@@ -127,7 +127,7 @@ static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
     // Remember information about positional options.
     if (O->getFormattingFlag() == cl::Positional)
       PositionalOpts.push_back(O);
     // Remember information about positional options.
     if (O->getFormattingFlag() == cl::Positional)
       PositionalOpts.push_back(O);
-    else if (O->getMiscFlags() && cl::Sink) // Remember sink options
+    else if (O->getMiscFlags() & cl::Sink) // Remember sink options
       SinkOpts.push_back(O);
     else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) {
       if (CAOpt)
       SinkOpts.push_back(O);
     else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) {
       if (CAOpt)
diff --git a/test/Other/invalid-commandline-option.ll b/test/Other/invalid-commandline-option.ll
new file mode 100644 (file)
index 0000000..b74c498
--- /dev/null
@@ -0,0 +1,3 @@
+; RUN: llvm-as < /dev/null | not opt --foo > /dev/null
+
+; there is no --foo