[llvm] r212141 - Run clang-format on llvm-size.cpp to tidy things up. No functional changes.
Kevin Enderby
enderby at apple.com
Tue Jul 1 15:26:31 PDT 2014
Author: enderby
Date: Tue Jul 1 17:26:31 2014
New Revision: 212141
URL: http://llvm.org/viewvc/llvm-project?rev=212141&view=rev
Log:
Run clang-format on llvm-size.cpp to tidy things up. No functional changes.
Modified:
llvm/trunk/tools/llvm-size/llvm-size.cpp
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=212141&r1=212140&r2=212141&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Tue Jul 1 17:26:31 2014
@@ -33,59 +33,55 @@
using namespace llvm;
using namespace object;
-enum OutputFormatTy {berkeley, sysv, darwin};
+enum OutputFormatTy { berkeley, sysv, darwin };
static cl::opt<OutputFormatTy>
- OutputFormat("format",
- cl::desc("Specify output format"),
- cl::values(clEnumVal(sysv, "System V format"),
- clEnumVal(berkeley, "Berkeley format"),
- clEnumVal(darwin, "Darwin -m format"), clEnumValEnd),
- cl::init(berkeley));
-
-static cl::opt<OutputFormatTy>
- OutputFormatShort(cl::desc("Specify output format"),
- cl::values(clEnumValN(sysv, "A", "System V format"),
- clEnumValN(berkeley, "B", "Berkeley format"),
- clEnumValN(darwin, "m", "Darwin -m format"),
- clEnumValEnd),
- cl::init(berkeley));
+OutputFormat("format", cl::desc("Specify output format"),
+ cl::values(clEnumVal(sysv, "System V format"),
+ clEnumVal(berkeley, "Berkeley format"),
+ clEnumVal(darwin, "Darwin -m format"), clEnumValEnd),
+ cl::init(berkeley));
+
+static cl::opt<OutputFormatTy> OutputFormatShort(
+ cl::desc("Specify output format"),
+ cl::values(clEnumValN(sysv, "A", "System V format"),
+ clEnumValN(berkeley, "B", "Berkeley format"),
+ clEnumValN(darwin, "m", "Darwin -m format"), clEnumValEnd),
+ cl::init(berkeley));
static bool berkeleyHeaderPrinted = false;
static bool moreThanOneFile = false;
-cl::opt<bool> DarwinLongFormat("l",
- cl::desc("When format is darwin, use long format "
- "to include addresses and offsets."));
+cl::opt<bool>
+DarwinLongFormat("l", cl::desc("When format is darwin, use long format "
+ "to include addresses and offsets."));
static cl::list<std::string>
- ArchFlags("arch",
- cl::desc("architecture(s) from a Mach-O file to dump"),
- cl::ZeroOrMore);
+ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
+ cl::ZeroOrMore);
bool ArchAll = false;
-enum RadixTy {octal = 8, decimal = 10, hexadecimal = 16};
+enum RadixTy { octal = 8, decimal = 10, hexadecimal = 16 };
static cl::opt<unsigned int>
- Radix("-radix",
- cl::desc("Print size in radix. Only 8, 10, and 16 are valid"),
- cl::init(decimal));
+Radix("-radix", cl::desc("Print size in radix. Only 8, 10, and 16 are valid"),
+ cl::init(decimal));
static cl::opt<RadixTy>
- RadixShort(cl::desc("Print size in radix:"),
- cl::values(clEnumValN(octal, "o", "Print size in octal"),
- clEnumValN(decimal, "d", "Print size in decimal"),
- clEnumValN(hexadecimal, "x", "Print size in hexadecimal"),
- clEnumValEnd),
- cl::init(decimal));
+RadixShort(cl::desc("Print size in radix:"),
+ cl::values(clEnumValN(octal, "o", "Print size in octal"),
+ clEnumValN(decimal, "d", "Print size in decimal"),
+ clEnumValN(hexadecimal, "x", "Print size in hexadecimal"),
+ clEnumValEnd),
+ cl::init(decimal));
static cl::list<std::string>
- InputFilenames(cl::Positional, cl::desc("<input files>"),
- cl::ZeroOrMore);
+InputFilenames(cl::Positional, cl::desc("<input files>"), cl::ZeroOrMore);
static std::string ToolName;
/// @brief If ec is not success, print the error and return true.
static bool error(std::error_code ec) {
- if (!ec) return false;
+ if (!ec)
+ return false;
outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
outs().flush();
@@ -102,7 +98,7 @@ static size_t getNumLengthAsString(uint6
}
/// @brief Return the the printing format for the Radix.
-static const char * getRadixFmt(void) {
+static const char *getRadixFmt(void) {
switch (Radix) {
case octal:
return PRIo64;
@@ -131,14 +127,14 @@ static void PrintDarwinSectionSizes(Mach
MachOObjectFile::LoadCommandInfo Load = MachO->getFirstLoadCommandInfo();
uint64_t total = 0;
- for (unsigned I = 0; ; ++I) {
+ for (unsigned I = 0;; ++I) {
if (Load.C.cmd == MachO::LC_SEGMENT_64) {
MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load);
outs() << "Segment " << Seg.segname << ": "
<< format(fmt.str().c_str(), Seg.vmsize);
if (DarwinLongFormat)
- outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr)
- << " fileoff " << Seg.fileoff << ")";
+ outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr) << " fileoff "
+ << Seg.fileoff << ")";
outs() << "\n";
total += Seg.vmsize;
uint64_t sec_total = 0;
@@ -151,21 +147,20 @@ static void PrintDarwinSectionSizes(Mach
outs() << "\tSection " << format("%.16s", &Sec.sectname) << ": ";
outs() << format(fmt.str().c_str(), Sec.size);
if (DarwinLongFormat)
- outs() << " (addr 0x" << format("%" PRIx64, Sec.addr)
- << " offset " << Sec.offset << ")";
+ outs() << " (addr 0x" << format("%" PRIx64, Sec.addr) << " offset "
+ << Sec.offset << ")";
outs() << "\n";
sec_total += Sec.size;
}
if (Seg.nsects != 0)
outs() << "\ttotal " << format(fmt.str().c_str(), sec_total) << "\n";
- }
- else if (Load.C.cmd == MachO::LC_SEGMENT) {
+ } else if (Load.C.cmd == MachO::LC_SEGMENT) {
MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load);
outs() << "Segment " << Seg.segname << ": "
<< format(fmt.str().c_str(), Seg.vmsize);
if (DarwinLongFormat)
- outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr)
- << " fileoff " << Seg.fileoff << ")";
+ outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr) << " fileoff "
+ << Seg.fileoff << ")";
outs() << "\n";
total += Seg.vmsize;
uint64_t sec_total = 0;
@@ -178,8 +173,8 @@ static void PrintDarwinSectionSizes(Mach
outs() << "\tSection " << format("%.16s", &Sec.sectname) << ": ";
outs() << format(fmt.str().c_str(), Sec.size);
if (DarwinLongFormat)
- outs() << " (addr 0x" << format("%" PRIx64, Sec.addr)
- << " offset " << Sec.offset << ")";
+ outs() << " (addr 0x" << format("%" PRIx64, Sec.addr) << " offset "
+ << Sec.offset << ")";
outs() << "\n";
sec_total += Sec.size;
}
@@ -206,7 +201,7 @@ static void PrintDarwinSegmentSizes(Mach
uint64_t total_data = 0;
uint64_t total_objc = 0;
uint64_t total_others = 0;
- for (unsigned I = 0; ; ++I) {
+ for (unsigned I = 0;; ++I) {
if (Load.C.cmd == MachO::LC_SEGMENT_64) {
MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load);
if (MachO->getHeader().filetype == MachO::MH_OBJECT) {
@@ -221,7 +216,7 @@ static void PrintDarwinSegmentSizes(Mach
total_objc += Sec.size;
else
total_others += Sec.size;
- }
+ }
} else {
StringRef SegmentName = StringRef(Seg.segname);
if (SegmentName == "__TEXT")
@@ -233,8 +228,7 @@ static void PrintDarwinSegmentSizes(Mach
else
total_others += Seg.vmsize;
}
- }
- else if (Load.C.cmd == MachO::LC_SEGMENT) {
+ } else if (Load.C.cmd == MachO::LC_SEGMENT) {
MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load);
if (MachO->getHeader().filetype == MachO::MH_OBJECT) {
for (unsigned J = 0; J < Seg.nsects; ++J) {
@@ -248,7 +242,7 @@ static void PrintDarwinSegmentSizes(Mach
total_objc += Sec.size;
else
total_others += Sec.size;
- }
+ }
} else {
StringRef SegmentName = StringRef(Seg.segname);
if (SegmentName == "__TEXT")
@@ -330,10 +324,9 @@ static void PrintObjectSectionSizes(Obje
<< "%" << max_addr_len << "s\n";
// Print header
- outs() << format(fmt.str().c_str(),
- static_cast<const char*>("section"),
- static_cast<const char*>("size"),
- static_cast<const char*>("addr"));
+ outs() << format(fmt.str().c_str(), static_cast<const char *>("section"),
+ static_cast<const char *>("size"),
+ static_cast<const char *>("addr"));
fmtbuf.clear();
// Setup per section format.
@@ -361,8 +354,7 @@ static void PrintObjectSectionSizes(Obje
fmtbuf.clear();
fmt << "%-" << max_name_len << "s "
<< "%#" << max_size_len << radix_fmt << "\n";
- outs() << format(fmt.str().c_str(),
- static_cast<const char*>("Total"),
+ outs() << format(fmt.str().c_str(), static_cast<const char *>("Total"),
total);
} else {
// The Berkeley format does not display individual section sizes. It
@@ -397,8 +389,7 @@ static void PrintObjectSectionSizes(Obje
if (!berkeleyHeaderPrinted) {
outs() << " text data bss "
- << (Radix == octal ? "oct" : "dec")
- << " hex filename\n";
+ << (Radix == octal ? "oct" : "dec") << " hex filename\n";
berkeleyHeaderPrinted = true;
}
@@ -406,16 +397,11 @@ static void PrintObjectSectionSizes(Obje
fmt << "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " ";
- outs() << format(fmt.str().c_str(),
- total_text,
- total_data,
- total_bss);
+ outs() << format(fmt.str().c_str(), total_text, total_data, total_bss);
fmtbuf.clear();
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " "
<< "%7" PRIx64 " ";
- outs() << format(fmt.str().c_str(),
- total,
- total);
+ outs() << format(fmt.str().c_str(), total, total);
}
}
@@ -439,7 +425,7 @@ static bool checkMachOAndArchFlags(Objec
T = MachOObjectFile::getArch(H.cputype, H.cpusubtype);
}
unsigned i;
- for (i = 0; i < ArchFlags.size(); ++i){
+ for (i = 0; i < ArchFlags.size(); ++i) {
if (ArchFlags[i] == T.getArchName())
ArchFound = true;
break;
@@ -460,7 +446,8 @@ static void PrintFileSectionSizes(String
if (file != "-") {
bool exists;
if (sys::fs::exists(file, exists) || !exists) {
- errs() << ToolName << ": '" << file << "': " << "No such file\n";
+ errs() << ToolName << ": '" << file << "': "
+ << "No such file\n";
return;
}
}
@@ -476,7 +463,8 @@ static void PrintFileSectionSizes(String
if (Archive *a = dyn_cast<Archive>(binary.get())) {
// This is an archive. Iterate over each member and display its sizes.
for (object::Archive::child_iterator i = a->child_begin(),
- e = a->child_end(); i != e; ++i) {
+ e = a->child_end();
+ i != e; ++i) {
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
@@ -487,10 +475,9 @@ static void PrintFileSectionSizes(String
if (!checkMachOAndArchFlags(o, file))
return;
if (OutputFormat == sysv)
- outs() << o->getFileName() << " (ex " << a->getFileName()
- << "):\n";
- else if(MachO && OutputFormat == darwin)
- outs() << a->getFileName() << "(" << o->getFileName() << "):\n";
+ outs() << o->getFileName() << " (ex " << a->getFileName() << "):\n";
+ else if (MachO && OutputFormat == darwin)
+ outs() << a->getFileName() << "(" << o->getFileName() << "):\n";
PrintObjectSectionSizes(o);
if (OutputFormat == berkeley) {
if (MachO)
@@ -501,17 +488,17 @@ static void PrintFileSectionSizes(String
}
}
} else if (MachOUniversalBinary *UB =
- dyn_cast<MachOUniversalBinary>(binary.get())) {
+ dyn_cast<MachOUniversalBinary>(binary.get())) {
// If we have a list of architecture flags specified dump only those.
if (!ArchAll && ArchFlags.size() != 0) {
// Look for a slice in the universal binary that matches each ArchFlag.
bool ArchFound;
- for (unsigned i = 0; i < ArchFlags.size(); ++i){
+ for (unsigned i = 0; i < ArchFlags.size(); ++i) {
ArchFound = false;
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
E = UB->end_objects();
I != E; ++I) {
- if (ArchFlags[i] == I->getArchTypeName()){
+ if (ArchFlags[i] == I->getArchTypeName()) {
ArchFound = true;
ErrorOr<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile();
std::unique_ptr<Archive> UA;
@@ -520,7 +507,7 @@ static void PrintFileSectionSizes(String
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o);
if (OutputFormat == sysv)
outs() << o->getFileName() << " :\n";
- else if(MachO && OutputFormat == darwin) {
+ else if (MachO && OutputFormat == darwin) {
if (moreThanOneFile || ArchFlags.size() > 1)
outs() << o->getFileName() << " (for architecture "
<< I->getArchTypeName() << "): \n";
@@ -533,13 +520,12 @@ static void PrintFileSectionSizes(String
outs() << "\n";
}
}
- }
- else if (!I->getAsArchive(UA)) {
+ } else if (!I->getAsArchive(UA)) {
// This is an archive. Iterate over each member and display its
- //sizes.
+ // sizes.
for (object::Archive::child_iterator i = UA->child_begin(),
e = UA->child_end();
- i != e; ++i) {
+ i != e; ++i) {
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message()
@@ -551,21 +537,21 @@ static void PrintFileSectionSizes(String
if (OutputFormat == sysv)
outs() << o->getFileName() << " (ex " << UA->getFileName()
<< "):\n";
- else if(MachO && OutputFormat == darwin)
+ else if (MachO && OutputFormat == darwin)
outs() << UA->getFileName() << "(" << o->getFileName()
- << ")" << " (for architecture "
- << I->getArchTypeName() << "):\n";
+ << ")"
+ << " (for architecture " << I->getArchTypeName()
+ << "):\n";
PrintObjectSectionSizes(o);
if (OutputFormat == berkeley) {
if (MachO) {
outs() << UA->getFileName() << "(" << o->getFileName()
<< ")";
if (ArchFlags.size() > 1)
- outs() << " (for architecture "
- << I->getArchTypeName() << ")";
+ outs() << " (for architecture " << I->getArchTypeName()
+ << ")";
outs() << "\n";
- }
- else
+ } else
outs() << o->getFileName() << " (ex " << UA->getFileName()
<< ")\n";
}
@@ -585,12 +571,11 @@ static void PrintFileSectionSizes(String
// No architecture flags were specified so if this contains a slice that
// matches the host architecture dump only that.
if (!ArchAll) {
- StringRef HostArchName =
- MachOObjectFile::getHostArch().getArchName();
+ StringRef HostArchName = MachOObjectFile::getHostArch().getArchName();
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
E = UB->end_objects();
I != E; ++I) {
- if (HostArchName == I->getArchTypeName()){
+ if (HostArchName == I->getArchTypeName()) {
ErrorOr<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile();
std::unique_ptr<Archive> UA;
if (UO) {
@@ -598,7 +583,7 @@ static void PrintFileSectionSizes(String
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o);
if (OutputFormat == sysv)
outs() << o->getFileName() << " :\n";
- else if(MachO && OutputFormat == darwin) {
+ else if (MachO && OutputFormat == darwin) {
if (moreThanOneFile)
outs() << o->getFileName() << " (for architecture "
<< I->getArchTypeName() << "):\n";
@@ -611,13 +596,12 @@ static void PrintFileSectionSizes(String
outs() << "\n";
}
}
- }
- else if (!I->getAsArchive(UA)) {
+ } else if (!I->getAsArchive(UA)) {
// This is an archive. Iterate over each member and display its
// sizes.
for (object::Archive::child_iterator i = UA->child_begin(),
e = UA->child_end();
- i != e; ++i) {
+ i != e; ++i) {
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message()
@@ -629,7 +613,7 @@ static void PrintFileSectionSizes(String
if (OutputFormat == sysv)
outs() << o->getFileName() << " (ex " << UA->getFileName()
<< "):\n";
- else if(MachO && OutputFormat == darwin)
+ else if (MachO && OutputFormat == darwin)
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
<< " (for architecture " << I->getArchTypeName()
<< "):\n";
@@ -662,7 +646,7 @@ static void PrintFileSectionSizes(String
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o);
if (OutputFormat == sysv)
outs() << o->getFileName() << " :\n";
- else if(MachO && OutputFormat == darwin) {
+ else if (MachO && OutputFormat == darwin) {
if (moreThanOneFile || moreThanOneArch)
outs() << o->getFileName() << " (for architecture "
<< I->getArchTypeName() << "):";
@@ -676,11 +660,11 @@ static void PrintFileSectionSizes(String
outs() << "\n";
}
}
- }
- else if (!I->getAsArchive(UA)) {
+ } else if (!I->getAsArchive(UA)) {
// This is an archive. Iterate over each member and display its sizes.
for (object::Archive::child_iterator i = UA->child_begin(),
- e = UA->child_end(); i != e; ++i) {
+ e = UA->child_end();
+ i != e; ++i) {
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = i->getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
@@ -691,10 +675,9 @@ static void PrintFileSectionSizes(String
if (OutputFormat == sysv)
outs() << o->getFileName() << " (ex " << UA->getFileName()
<< "):\n";
- else if(MachO && OutputFormat == darwin)
+ else if (MachO && OutputFormat == darwin)
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
- << " (for architecture " << I->getArchTypeName()
- << "):\n";
+ << " (for architecture " << I->getArchTypeName() << "):\n";
PrintObjectSectionSizes(o);
if (OutputFormat == berkeley) {
if (MachO)
@@ -722,7 +705,8 @@ static void PrintFileSectionSizes(String
outs() << "\n";
}
} else {
- errs() << ToolName << ": " << file << ": " << "Unrecognized file type.\n";
+ errs() << ToolName << ": " << file << ": "
+ << "Unrecognized file type.\n";
}
// System V adds an extra newline at the end of each file.
if (OutputFormat == sysv)
@@ -734,7 +718,7 @@ int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
- llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm object size dumper\n");
ToolName = argv[0];
@@ -743,13 +727,12 @@ int main(int argc, char **argv) {
if (RadixShort.getNumOccurrences())
Radix = RadixShort;
- for (unsigned i = 0; i < ArchFlags.size(); ++i){
+ for (unsigned i = 0; i < ArchFlags.size(); ++i) {
if (ArchFlags[i] == "all") {
ArchAll = true;
- }
- else {
+ } else {
Triple T = MachOObjectFile::getArch(ArchFlags[i]);
- if (T.getArch() == Triple::UnknownArch){
+ if (T.getArch() == Triple::UnknownArch) {
outs() << ToolName << ": for the -arch option: Unknown architecture "
<< "named '" << ArchFlags[i] << "'";
return 1;
More information about the llvm-commits
mailing list