summaryrefslogtreecommitdiff
path: root/tools/llvm-objdump
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-03-18 18:58:51 +0000
committerRui Ueyama <ruiu@google.com>2014-03-18 18:58:51 +0000
commit172c31844b3b8216313bcb7b7e20ad8ecbc71d5f (patch)
tree8b38b992299c3e3822bbb8df23ae23e590a319c4 /tools/llvm-objdump
parent50e4d56b9f782b79154c7bab09fcddcf35cb4029 (diff)
downloadllvm-172c31844b3b8216313bcb7b7e20ad8ecbc71d5f.tar.gz
llvm-172c31844b3b8216313bcb7b7e20ad8ecbc71d5f.tar.bz2
llvm-172c31844b3b8216313bcb7b7e20ad8ecbc71d5f.tar.xz
Use early returns to reduce nesting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objdump')
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index dab242cf65..3f871471bc 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -699,79 +699,79 @@ static void PrintCOFFSymbolTable(const COFFObjectFile *coff) {
static void PrintSymbolTable(const ObjectFile *o) {
outs() << "SYMBOL TABLE:\n";
- if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o))
+ if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) {
PrintCOFFSymbolTable(coff);
- else {
- for (const SymbolRef &Symbol : o->symbols()) {
- StringRef Name;
- uint64_t Address;
- SymbolRef::Type Type;
- uint64_t Size;
- uint32_t Flags = Symbol.getFlags();
- section_iterator Section = o->section_end();
- if (error(Symbol.getName(Name)))
- continue;
- if (error(Symbol.getAddress(Address)))
- continue;
- if (error(Symbol.getType(Type)))
- continue;
- if (error(Symbol.getSize(Size)))
- continue;
- if (error(Symbol.getSection(Section)))
- continue;
+ return;
+ }
+ for (const SymbolRef &Symbol : o->symbols()) {
+ StringRef Name;
+ uint64_t Address;
+ SymbolRef::Type Type;
+ uint64_t Size;
+ uint32_t Flags = Symbol.getFlags();
+ section_iterator Section = o->section_end();
+ if (error(Symbol.getName(Name)))
+ continue;
+ if (error(Symbol.getAddress(Address)))
+ continue;
+ if (error(Symbol.getType(Type)))
+ continue;
+ if (error(Symbol.getSize(Size)))
+ continue;
+ if (error(Symbol.getSection(Section)))
+ continue;
- bool Global = Flags & SymbolRef::SF_Global;
- bool Weak = Flags & SymbolRef::SF_Weak;
- bool Absolute = Flags & SymbolRef::SF_Absolute;
-
- if (Address == UnknownAddressOrSize)
- Address = 0;
- if (Size == UnknownAddressOrSize)
- Size = 0;
- char GlobLoc = ' ';
- if (Type != SymbolRef::ST_Unknown)
- GlobLoc = Global ? 'g' : 'l';
- char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
- ? 'd' : ' ';
- char FileFunc = ' ';
- if (Type == SymbolRef::ST_File)
- FileFunc = 'f';
- else if (Type == SymbolRef::ST_Function)
- FileFunc = 'F';
-
- const char *Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 :
- "%08" PRIx64;
-
- outs() << format(Fmt, Address) << " "
- << GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
- << (Weak ? 'w' : ' ') // Weak?
- << ' ' // Constructor. Not supported yet.
- << ' ' // Warning. Not supported yet.
- << ' ' // Indirect reference to another symbol.
- << Debug // Debugging (d) or dynamic (D) symbol.
- << FileFunc // Name of function (F), file (f) or object (O).
- << ' ';
- if (Absolute)
- outs() << "*ABS*";
- else if (Section == o->section_end())
- outs() << "*UND*";
- else {
- if (const MachOObjectFile *MachO =
- dyn_cast<const MachOObjectFile>(o)) {
- DataRefImpl DR = Section->getRawDataRefImpl();
- StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
- outs() << SegmentName << ",";
- }
- StringRef SectionName;
- if (error(Section->getName(SectionName)))
- SectionName = "";
- outs() << SectionName;
+ bool Global = Flags & SymbolRef::SF_Global;
+ bool Weak = Flags & SymbolRef::SF_Weak;
+ bool Absolute = Flags & SymbolRef::SF_Absolute;
+
+ if (Address == UnknownAddressOrSize)
+ Address = 0;
+ if (Size == UnknownAddressOrSize)
+ Size = 0;
+ char GlobLoc = ' ';
+ if (Type != SymbolRef::ST_Unknown)
+ GlobLoc = Global ? 'g' : 'l';
+ char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
+ ? 'd' : ' ';
+ char FileFunc = ' ';
+ if (Type == SymbolRef::ST_File)
+ FileFunc = 'f';
+ else if (Type == SymbolRef::ST_Function)
+ FileFunc = 'F';
+
+ const char *Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 :
+ "%08" PRIx64;
+
+ outs() << format(Fmt, Address) << " "
+ << GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
+ << (Weak ? 'w' : ' ') // Weak?
+ << ' ' // Constructor. Not supported yet.
+ << ' ' // Warning. Not supported yet.
+ << ' ' // Indirect reference to another symbol.
+ << Debug // Debugging (d) or dynamic (D) symbol.
+ << FileFunc // Name of function (F), file (f) or object (O).
+ << ' ';
+ if (Absolute) {
+ outs() << "*ABS*";
+ } else if (Section == o->section_end()) {
+ outs() << "*UND*";
+ } else {
+ if (const MachOObjectFile *MachO =
+ dyn_cast<const MachOObjectFile>(o)) {
+ DataRefImpl DR = Section->getRawDataRefImpl();
+ StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
+ outs() << SegmentName << ",";
}
- outs() << '\t'
- << format("%08" PRIx64 " ", Size)
- << Name
- << '\n';
+ StringRef SectionName;
+ if (error(Section->getName(SectionName)))
+ SectionName = "";
+ outs() << SectionName;
}
+ outs() << '\t'
+ << format("%08" PRIx64 " ", Size)
+ << Name
+ << '\n';
}
}