diff options
author | David Blaikie <dblaikie@gmail.com> | 2018-12-19 19:34:24 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2018-12-19 19:34:24 +0000 |
commit | ac69af7ad6560978883ce08ebf837b49046778c8 (patch) | |
tree | 99e73ff33e407568e433bd5e4e6bd9e00736579b /llvm/lib/BinaryFormat/Dwarf.cpp | |
parent | 0da49a7ef14b4f0d6fa343b7876209d37f5fe56b (diff) | |
download | bcm5719-llvm-ac69af7ad6560978883ce08ebf837b49046778c8.tar.gz bcm5719-llvm-ac69af7ad6560978883ce08ebf837b49046778c8.zip |
llvm-dwarfdump: Improve/fix pretty printing of array dimensions
This is to address post-commit feedback from Paul Robinson on r348954.
The original commit misinterprets count and upper bound as the same thing (I thought I saw GCC producing an upper bound the same as Clang's count, but GCC correctly produces an upper bound that's one less than the count (in C, that is, where arrays are zero indexed)).
I want to preserve the C-like output for the common case, so in the absence of a lower bound the count (or one greater than the upper bound) is rendered between []. In the trickier cases, where a lower bound is specified, a half-open range is used (eg: lower bound 1, count 2 would be "[1, 3)" and an unknown parts use a '?' (eg: "[1, ?)" or "[?, 7)" or "[?, ? + 3)").
Reviewers: aprantl, probinson, JDevlieghere
Differential Revision: https://reviews.llvm.org/D55721
llvm-svn: 349670
Diffstat (limited to 'llvm/lib/BinaryFormat/Dwarf.cpp')
-rw-r--r-- | llvm/lib/BinaryFormat/Dwarf.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp index fe8ce2bd7aa..46f8056774b 100644 --- a/llvm/lib/BinaryFormat/Dwarf.cpp +++ b/llvm/lib/BinaryFormat/Dwarf.cpp @@ -301,7 +301,7 @@ StringRef llvm::dwarf::LanguageString(unsigned Language) { switch (Language) { default: return StringRef(); -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) \ +#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ case DW_LANG_##NAME: \ return "DW_LANG_" #NAME; #include "llvm/BinaryFormat/Dwarf.def" @@ -310,7 +310,7 @@ StringRef llvm::dwarf::LanguageString(unsigned Language) { unsigned llvm::dwarf::getLanguage(StringRef LanguageString) { return StringSwitch<unsigned>(LanguageString) -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) \ +#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ .Case("DW_LANG_" #NAME, DW_LANG_##NAME) #include "llvm/BinaryFormat/Dwarf.def" .Default(0); @@ -320,7 +320,7 @@ unsigned llvm::dwarf::LanguageVersion(dwarf::SourceLanguage Lang) { switch (Lang) { default: return 0; -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) \ +#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ case DW_LANG_##NAME: \ return VERSION; #include "llvm/BinaryFormat/Dwarf.def" @@ -331,13 +331,24 @@ unsigned llvm::dwarf::LanguageVendor(dwarf::SourceLanguage Lang) { switch (Lang) { default: return 0; -#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) \ +#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ case DW_LANG_##NAME: \ return DWARF_VENDOR_##VENDOR; #include "llvm/BinaryFormat/Dwarf.def" } } +Optional<unsigned> llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) { + switch (Lang) { + default: + return None; +#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \ + case DW_LANG_##NAME: \ + return LOWER_BOUND; +#include "llvm/BinaryFormat/Dwarf.def" + } +} + StringRef llvm::dwarf::CaseString(unsigned Case) { switch (Case) { case DW_ID_case_sensitive: |