[llvm] r314723 - llvm-dwarfdump: support the --ignore-case option.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 14:21:09 PDT 2017
Author: adrian
Date: Mon Oct 2 14:21:09 2017
New Revision: 314723
URL: http://llvm.org/viewvc/llvm-project?rev=314723&view=rev
Log:
llvm-dwarfdump: support the --ignore-case option.
Modified:
llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test
llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test?rev=314723&r1=314722&r2=314723&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test Mon Oct 2 14:21:09 2017
@@ -37,3 +37,10 @@ RUN: llvm-dwarfdump %S/../../dsymutil/In
RUN: -name="(anonymous namespace)" \
RUN: | FileCheck %s --check-prefix=EMPTY
+Test the -ignore-case option.
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -name=Main - | FileCheck %s -check-prefix=EMPTY
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -name=Main -i - | FileCheck %s
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -name=MAIN -ignore-case - | FileCheck %s
\ No newline at end of file
Modified: llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test?rev=314723&r1=314722&r2=314723&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test Mon Oct 2 14:21:09 2017
@@ -7,6 +7,7 @@ HELP: -debug-info - Dump the
HELP: -eh-frame
HELP: Specific Options
HELP: -find
+HELP: -ignore-case
HELP: -name
HELP: -recurse-depth=<N>
HELP: -show-children
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=314723&r1=314722&r2=314723&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Mon Oct 2 14:21:09 2017
@@ -143,6 +143,12 @@ static list<std::string>
"-name option can be used instead."),
value_desc("name"), cat(DwarfDumpCategory));
static alias FindAlias("f", desc("Alias for -find"), aliasopt(Find));
+static opt<bool>
+ IgnoreCase("ignore-case",
+ desc("Ignore case distinctions in when searching by name."),
+ value_desc("i"), cat(DwarfDumpCategory));
+static alias IgnoreCaseAlias("i", desc("Alias for -ignore-case"),
+ aliasopt(IgnoreCase));
static list<std::string>
Name("name",
desc("Find and print all debug info entries whose name (DW_AT_name "
@@ -265,8 +271,11 @@ static void filterByName(const StringSet
for (const auto &CU : CUs)
for (const auto &Entry : CU->dies()) {
DWARFDie Die = {CU.get(), &Entry};
- if (Names.count(Die.getName(DINameKind::ShortName)))
- Die.dump(OS, 0, getDumpOpts());
+ if (const char *NamePtr = Die.getName(DINameKind::ShortName)) {
+ std::string Name = IgnoreCase ? StringRef(NamePtr).lower() : NamePtr;
+ if (Names.count(Name))
+ Die.dump(OS, 0, getDumpOpts());
+ }
}
}
@@ -283,7 +292,7 @@ static bool dumpObjectFile(ObjectFile &O
if (!Name.empty()) {
StringSet<> Names;
for (auto name : Name)
- Names.insert(name);
+ Names.insert(IgnoreCase ? StringRef(name).lower() : name);
filterByName(Names, DICtx.compile_units(), OS);
filterByName(Names, DICtx.dwo_compile_units(), OS);
More information about the llvm-commits
mailing list