mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[llvm-rc] Support '--' for delimiting options from input paths
This allows avoiding conflicts between paths that begin with the same chars as some llvm-rc options (which can be used with either slashes or dashes). Differential Revision: https://reviews.llvm.org/D56743 llvm-svn: 351305
This commit is contained in:
parent
5388943831
commit
49a0a38fd9
@ -1,3 +1,3 @@
|
||||
; RUN: touch %t.manifest
|
||||
; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
|
||||
; RUN: llvm-rc %t.rc
|
||||
; RUN: llvm-rc -- %t.rc
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /C 65001 /FO %t.utf8.res %p/Inputs/utf8.rc
|
||||
; RUN: llvm-rc /C 65001 /FO %t.utf8.res -- %p/Inputs/utf8.rc
|
||||
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
|
||||
|
||||
; UTF8: Resource type (int): 6
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/cpp-output.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/cpp-output.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 6
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /dry-run /FO %t %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
|
||||
; RUN: llvm-rc /dry-run /FO%t %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
|
||||
; RUN: llvm-rc /dry-run /FO %t -- %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
|
||||
; RUN: llvm-rc /dry-run /FO%t -- %p/Inputs/empty.rc 2>&1 | FileCheck %s --allow-empty --check-prefix=FO
|
||||
|
||||
; FO-NOT: Exactly one input file should be provided.
|
||||
|
@ -1,21 +1,21 @@
|
||||
; Should find the bitmap if it is in the same folder as the rc file.
|
||||
; RUN: rm -f %t.include.res
|
||||
; RUN: llvm-rc /FO %t.include.res %p/Inputs/include.rc
|
||||
; RUN: llvm-rc /FO %t.include.res -- %p/Inputs/include.rc
|
||||
; RUN: llvm-readobj %t.include.res | FileCheck --check-prefix=FOUND %s
|
||||
|
||||
; Try including files without quotes.
|
||||
; RUN: rm -f %t.noquotes.res
|
||||
; RUN: llvm-rc /FO %t.noquotes.res %p/Inputs/include-noquotes.rc
|
||||
; RUN: llvm-rc /FO %t.noquotes.res -- %p/Inputs/include-noquotes.rc
|
||||
; RUN: llvm-readobj %t.noquotes.res | FileCheck --check-prefix=FOUND %s
|
||||
|
||||
; Should find the bitmap if the folder is explicitly specified.
|
||||
; RUN: rm -f %t.nested-include.res
|
||||
; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested %p/Inputs/deep-include.rc
|
||||
; RUN: llvm-rc /FO %t.nested-include.res /I %p/Inputs/nested -- %p/Inputs/deep-include.rc
|
||||
; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
|
||||
|
||||
; Otherwise, it should not find the bitmap.
|
||||
; RUN: rm -f %t.nested-include.res
|
||||
; RUN: not llvm-rc /FO %t.nested-include.res %p/Inputs/deep-include.rc 2>&1 \
|
||||
; RUN: not llvm-rc /FO %t.nested-include.res -- %p/Inputs/deep-include.rc 2>&1 \
|
||||
; RUN: | FileCheck --check-prefix=MISSING %s
|
||||
|
||||
; Should find the bitmap if the process's current working directory
|
||||
@ -24,7 +24,7 @@
|
||||
; failure of other tests if run first.
|
||||
; RUN: rm -f %t.nested-include.res
|
||||
; RUN: cd %p/Inputs/nested
|
||||
; RUN: llvm-rc /FO %t.nested-include.res %p/Inputs/include.rc
|
||||
; RUN: llvm-rc /FO %t.nested-include.res -- %p/Inputs/include.rc
|
||||
; RUN: llvm-readobj %t.nested-include.res | FileCheck --check-prefix=FOUND %s
|
||||
|
||||
FOUND: Resource type (int): 2
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/memoryflags-stringtable.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/memoryflags-stringtable.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 6
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/memoryflags.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/memoryflags.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/not-expr.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/not-expr.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s --check-prefix=NOTEXPR
|
||||
|
||||
; NOTEXPR: Resource type (int): 5
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /dry-run /V %p/Inputs/parser-expr.rc | FileCheck %s
|
||||
; RUN: llvm-rc /dry-run /V -- %p/Inputs/parser-expr.rc | FileCheck %s
|
||||
|
||||
; CHECK: Language: 5, Sublanguage: 1
|
||||
; CHECK-NEXT: Language: 3, Sublanguage: 2
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /dry-run /V %p/Inputs/parser-correct-everything.rc | FileCheck %s --check-prefix PGOOD
|
||||
; RUN: llvm-rc /dry-run /V -- %p/Inputs/parser-correct-everything.rc | FileCheck %s --check-prefix PGOOD
|
||||
|
||||
; PGOOD: Icon (meh): "hello.bmp"
|
||||
; PGOOD-NEXT: Icon (Icon): "Icon"
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-accelerators.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-accelerators.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s --check-prefix=ACCELERATORS
|
||||
|
||||
; ACCELERATORS: Resource type (int): 9
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-dialog.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-dialog.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s --check-prefix=DIALOG
|
||||
|
||||
; DIALOG: Resource type (int): 5
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-escape.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-escape.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 4
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: rm -rf %t && mkdir %t && cd %t
|
||||
; RUN: cp %p/Inputs/webpage*.html .
|
||||
; RUN: llvm-rc /FO %t/tag-html.res %p/Inputs/tag-html.rc
|
||||
; RUN: llvm-rc /FO %t/tag-html.res -- %p/Inputs/tag-html.rc
|
||||
; RUN: llvm-readobj %t/tag-html.res | FileCheck %s --check-prefix HTML
|
||||
|
||||
; HTML: Resource type (int): 23
|
||||
|
@ -1,7 +1,7 @@
|
||||
; RUN: rm -rf %t
|
||||
; RUN: mkdir %t
|
||||
|
||||
; RUN: llvm-rc /FO %t/tag-icon-cursor.res %p/Inputs/tag-icon-cursor.rc
|
||||
; RUN: llvm-rc /FO %t/tag-icon-cursor.res -- %p/Inputs/tag-icon-cursor.rc
|
||||
; RUN: llvm-readobj %t/tag-icon-cursor.res | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 1
|
||||
|
@ -1,9 +1,9 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-menu.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-menu.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s --check-prefix=MENU
|
||||
|
||||
; Test running llvm-rc without an explicit output file.
|
||||
; RUN: cp %p/Inputs/tag-menu.rc %t.implicit.rc
|
||||
; RUN: llvm-rc %t.implicit.rc
|
||||
; RUN: llvm-rc -- %t.implicit.rc
|
||||
; RUN: llvm-readobj %t.implicit.res | FileCheck --check-prefix=MENU %s
|
||||
|
||||
; MENU: Resource type (int): 4
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-stringtable-basic.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-stringtable-basic.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 6
|
||||
|
@ -2,7 +2,7 @@
|
||||
; RUN: mkdir %t
|
||||
; RUN: cd %t
|
||||
; RUN: cp %p/Inputs/bitmap.bmp .
|
||||
; RUN: llvm-rc /FO %t/tag-user.res %p/Inputs/tag-user.rc
|
||||
; RUN: llvm-rc /FO %t/tag-user.res -- %p/Inputs/tag-user.rc
|
||||
; RUN: llvm-readobj %t/tag-user.res | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 500
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/tag-versioninfo.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/tag-versioninfo.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 16
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: not llvm-rc /V /FO %t.res %p/Inputs/tokens.rc | FileCheck %s
|
||||
; RUN: not llvm-rc /V /FO %t.res -- %p/Inputs/tokens.rc | FileCheck %s
|
||||
; llvm-rc fails now on this sample because it is an invalid resource file
|
||||
; script. We silence the error message and just analyze the output.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llvm-rc /FO %t %p/Inputs/versioninfo-padding.rc
|
||||
; RUN: llvm-rc /FO %t -- %p/Inputs/versioninfo-padding.rc
|
||||
; RUN: llvm-readobj %t | FileCheck %s
|
||||
|
||||
; CHECK: Resource type (int): 16
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "llvm/Support/Signals.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <system_error>
|
||||
|
||||
using namespace llvm;
|
||||
@ -85,7 +86,10 @@ int main(int Argc, const char **Argv) {
|
||||
|
||||
RcOptTable T;
|
||||
unsigned MAI, MAC;
|
||||
ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, Argc - 1);
|
||||
const char **DashDash = std::find_if(
|
||||
Argv + 1, Argv + Argc, [](StringRef Str) { return Str == "--"; });
|
||||
ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, DashDash);
|
||||
|
||||
opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
|
||||
|
||||
// The tool prints nothing when invoked with no command-line arguments.
|
||||
@ -97,6 +101,8 @@ int main(int Argc, const char **Argv) {
|
||||
const bool BeVerbose = InputArgs.hasArg(OPT_VERBOSE);
|
||||
|
||||
std::vector<std::string> InArgsInfo = InputArgs.getAllArgValues(OPT_INPUT);
|
||||
if (DashDash != Argv + Argc)
|
||||
InArgsInfo.insert(InArgsInfo.end(), DashDash + 1, Argv + Argc);
|
||||
if (InArgsInfo.size() != 1) {
|
||||
fatalError("Exactly one input file should be provided.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user