Index: llvm/include/llvm/Support/FileCheck.h =================================================================== --- llvm/include/llvm/Support/FileCheck.h +++ llvm/include/llvm/Support/FileCheck.h @@ -30,6 +30,7 @@ std::vector GlobalDefines; bool AllowEmptyInput = false; bool MatchFullLines = false; + bool IgnoreCase = false; bool EnableVarScope = false; bool AllowDeprecatedDagOverlap = false; bool Verbose = false; Index: llvm/lib/Support/FileCheck.cpp =================================================================== --- llvm/lib/Support/FileCheck.cpp +++ llvm/lib/Support/FileCheck.cpp @@ -320,6 +320,7 @@ SourceMgr &SM, const FileCheckRequest &Req) { bool MatchFullLinesHere = Req.MatchFullLines && CheckTy != Check::CheckNot; + IgnoreCase = Req.IgnoreCase; PatternLoc = SMLoc::getFromPointer(PatternStr.data()); @@ -619,7 +620,8 @@ // If this is a fixed string pattern, just match it now. if (!FixedStr.empty()) { MatchLen = FixedStr.size(); - size_t Pos = Buffer.find(FixedStr); + size_t Pos = IgnoreCase ? Buffer.find_lower(FixedStr) + : Buffer.find(FixedStr); if (Pos == StringRef::npos) return make_error(); return Pos; @@ -657,7 +659,10 @@ } SmallVector MatchInfo; - if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo)) + unsigned int Flags = Regex::Newline; + if (IgnoreCase) + Flags |= Regex::IgnoreCase; + if (!Regex(RegExToMatch, Flags).match(Buffer, &MatchInfo)) return make_error(); // Successful regex match. Index: llvm/lib/Support/FileCheckImpl.h =================================================================== --- llvm/lib/Support/FileCheckImpl.h +++ llvm/lib/Support/FileCheckImpl.h @@ -428,10 +428,13 @@ /// line to the one with this CHECK. Optional LineNumber; + /// Ignore case while matching if set to true. + bool IgnoreCase; + public: FileCheckPattern(Check::FileCheckType Ty, FileCheckPatternContext *Context, Optional Line = None) - : Context(Context), CheckTy(Ty), LineNumber(Line) {} + : Context(Context), CheckTy(Ty), LineNumber(Line), IgnoreCase(false) {} /// \returns the location in source code. SMLoc getLoc() const { return PatternLoc; } Index: llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test +++ llvm/test/tools/llvm-objcopy/ELF/basic-binary-copy.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t # RUN: llvm-objcopy -O binary %t %t2 -# RUN: od -t x2 -v %t2 | FileCheck %s +# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case # RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE !ELF Index: llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-no-paddr.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t # RUN: llvm-objcopy -O binary %t %t2 -# RUN: od -t x2 -v %t2 | FileCheck %s +# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case # RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE !ELF Index: llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t # RUN: llvm-objcopy -O binary %t %t2 -# RUN: od -t x2 %t2 | FileCheck %s +# RUN: od -t x2 %t2 | FileCheck %s --ignore-case # RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE !ELF Index: llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test +++ llvm/test/tools/llvm-objcopy/ELF/binary-segment-layout.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t # RUN: llvm-objcopy -O binary %t %t2 -# RUN: od -t x2 %t2 | FileCheck %s +# RUN: od -t x2 %t2 | FileCheck %s --ignore-case # RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE !ELF Index: llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test +++ llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t # RUN: llvm-objcopy -O binary %t %t2 -# RUN: od -t x1 %t2 | FileCheck %s +# RUN: od -t x1 %t2 | FileCheck %s --ignore-case !ELF FileHeader: Index: llvm/test/tools/llvm-objcopy/ELF/dump-section.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/dump-section.test +++ llvm/test/tools/llvm-objcopy/ELF/dump-section.test @@ -4,8 +4,8 @@ # RUN: llvm-objcopy --dump-section .text=%t4 %t %t5 # RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7 # RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t -# RUN: od -t x1 %t2 | FileCheck %s -# RUN: od -t x1 %t6 | FileCheck %s --check-prefix=NON-ALLOC +# RUN: od -t x1 %t2 | FileCheck %s --ignore-case +# RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC # RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE # RUN: diff %t2 %t3 # RUN: diff %t4 %t3 Index: llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test +++ llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test @@ -13,13 +13,13 @@ # RUN: llvm-objcopy %t.base %t.stripped --regex -R blob.* # Show that the removal leaves the bytes as zeroes, as desired, for all our # test cases. -# RUN: od -t x1 -j 0x2000 -N 24 %t.stripped | FileCheck %s --check-prefix=CHECK1 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x2100 -N 12 %t.stripped | FileCheck %s --check-prefix=CHECK2 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x2200 -N 4 %t.stripped | FileCheck %s --check-prefix=CHECK3 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x2300 -N 12 %t.stripped | FileCheck %s --check-prefix=CHECK4 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x3000 -N 68 %t.stripped | FileCheck %s --check-prefix=CHECK5 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x4000 -N 60 %t.stripped | FileCheck %s --check-prefix=CHECK6 -DPATTERN="00 00 00 00" -# RUN: od -t x1 -j 0x5000 -N 60 %t.stripped | FileCheck %s --check-prefix=CHECK7 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x2000 -N 24 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK1 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x2100 -N 12 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK2 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x2200 -N 4 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK3 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x2300 -N 12 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK4 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x3000 -N 68 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK5 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x4000 -N 60 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK6 -DPATTERN="00 00 00 00" +# RUN: od -t x1 -j 0x5000 -N 60 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK7 -DPATTERN="00 00 00 00" # RUN: cp %t.stripped %t.in # RUN: echo "with open('%/t.in', 'rb+') as input:" > %t.py @@ -32,13 +32,13 @@ # RUN: echo " input.write(bytearray.fromhex('DEADBEEF'))" >> %t.py # RUN: %python %t.py # RUN: llvm-objcopy %t.in %t.out -# RUN: od -t x1 -j 0x2000 -N 24 %t.out | FileCheck %s --check-prefix=CHECK1 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x2100 -N 12 %t.out | FileCheck %s --check-prefix=CHECK2 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x2200 -N 4 %t.out | FileCheck %s --check-prefix=CHECK3 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x2300 -N 12 %t.out | FileCheck %s --check-prefix=CHECK4 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x3000 -N 68 %t.out | FileCheck %s --check-prefix=CHECK5 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x4000 -N 60 %t.out | FileCheck %s --check-prefix=CHECK6 -DPATTERN="de ad be ef" -# RUN: od -t x1 -j 0x5000 -N 60 %t.out | FileCheck %s --check-prefix=CHECK7 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x2000 -N 24 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK1 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x2100 -N 12 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK2 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x2200 -N 4 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK3 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x2300 -N 12 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK4 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x3000 -N 68 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK5 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x4000 -N 60 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK6 -DPATTERN="de ad be ef" +# RUN: od -t x1 -j 0x5000 -N 60 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK7 -DPATTERN="de ad be ef" # CHECK1: [[PATTERN]] 11 22 33 44 [[PATTERN]] [[PATTERN]] # CHECK1-NEXT: 55 66 77 88 [[PATTERN]] Index: llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test @@ -7,8 +7,8 @@ # Show that the debug section in a segment was removed, to match GNU. # First validate that the offset in use is correct. # RUN: llvm-objcopy %t %t4 -# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --check-prefix=COPY-BYTES -# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --check-prefix=STRIP-BYTES +# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --ignore-case --check-prefix=COPY-BYTES +# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --ignore-case --check-prefix=STRIP-BYTES !ELF FileHeader: Index: llvm/test/tools/llvm-objcopy/ELF/strip-sections.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-sections.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-sections.test @@ -1,12 +1,12 @@ # RUN: yaml2obj %s > %t # RUN: llvm-objcopy --strip-sections %t %t2 # RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s -# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --check-prefix=DATA +# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --ignore-case --check-prefix=DATA ## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears ## if --strip-sections is not specified. # RUN: llvm-objcopy %t %t3 -# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --check-prefix=VALIDATE +# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --ignore-case --check-prefix=VALIDATE ## Check that llvm-strip --strip-sections is equivalent to ## llvm-objcopy --strip-sections. Index: llvm/test/tools/yaml2obj/elf-override-shoffset.yaml =================================================================== --- llvm/test/tools/yaml2obj/elf-override-shoffset.yaml +++ llvm/test/tools/yaml2obj/elf-override-shoffset.yaml @@ -75,7 +75,7 @@ # RUN: yaml2obj --docnum=3 %s -o %t3 # RUN: od -t x1 -v %t2 > %t.txt # RUN: od -t x1 -v %t3 >> %t.txt -# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2 +# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2 # CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe # CASE2: [[FILESIZE:.*]]{{$}} Index: llvm/test/tools/yaml2obj/elf-override-shsize.yaml =================================================================== --- llvm/test/tools/yaml2obj/elf-override-shsize.yaml +++ llvm/test/tools/yaml2obj/elf-override-shsize.yaml @@ -74,7 +74,7 @@ # RUN: yaml2obj --docnum=3 %s -o %t3 # RUN: od -t x1 -v %t2 > %t.txt # RUN: od -t x1 -v %t3 >> %t.txt -# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2 +# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2 # CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe # CASE2: [[FILESIZE:.*]]{{$}} @@ -136,7 +136,7 @@ ## bytes written is equal to Size in this case. # RUN: yaml2obj --docnum=5 %s -o %t5 -# RUN: od -t x1 -v %t5 | FileCheck %s --check-prefix=CASE5 +# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5 # CASE5: aa aa 00 00 bb bb Index: llvm/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/utils/FileCheck/FileCheck.cpp +++ llvm/utils/FileCheck/FileCheck.cpp @@ -48,6 +48,10 @@ "strict-whitespace", cl::desc("Do not treat all horizontal whitespace as equivalent")); +static cl::opt IgnoreCase( + "ignore-case", + cl::desc("Ignore case in comparisons")); + static cl::list ImplicitCheckNot( "implicit-check-not", cl::desc("Add an implicit negative check with this pattern to every\n" @@ -555,6 +559,7 @@ Req.VerboseVerbose = VerboseVerbose; Req.NoCanonicalizeWhiteSpace = NoCanonicalizeWhiteSpace; Req.MatchFullLines = MatchFullLines; + Req.IgnoreCase = IgnoreCase; if (VerboseVerbose) Req.Verbose = true;