Skip to content

Commit a2048f8

Browse files
committed
Symbolize: Replace the Options constructor with in-class initialization. NFCI.
This is not only less code but also clearer at the use site. Differential Revision: https://reviews.llvm.org/D63113 llvm-svn: 363024
1 parent fc2b5c4 commit a2048f8

File tree

8 files changed

+22
-35
lines changed

8 files changed

+22
-35
lines changed

llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,17 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
3535
class LLVMSymbolizer {
3636
public:
3737
struct Options {
38-
FunctionNameKind PrintFunctions;
39-
bool UseSymbolTable : 1;
40-
bool Demangle : 1;
41-
bool RelativeAddresses : 1;
38+
FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName;
39+
bool UseSymbolTable = true;
40+
bool Demangle = true;
41+
bool RelativeAddresses = false;
4242
std::string DefaultArch;
4343
std::vector<std::string> DsymHints;
4444
std::string FallbackDebugPath;
45-
46-
Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,
47-
bool UseSymbolTable = true, bool Demangle = true,
48-
bool RelativeAddresses = false, std::string DefaultArch = "",
49-
std::string FallbackDebugPath = "")
50-
: PrintFunctions(PrintFunctions), UseSymbolTable(UseSymbolTable),
51-
Demangle(Demangle), RelativeAddresses(RelativeAddresses),
52-
DefaultArch(std::move(DefaultArch)),
53-
FallbackDebugPath(std::move(FallbackDebugPath)) {}
5445
};
5546

56-
LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}
47+
LLVMSymbolizer() = default;
48+
LLVMSymbolizer(const Options &Opts) : Opts(Opts) {}
5749

5850
~LLVMSymbolizer() {
5951
flush();

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,10 @@ class SourcePrinter {
529529
public:
530530
SourcePrinter() = default;
531531
SourcePrinter(const ObjectFile *Obj, StringRef DefaultArch) : Obj(Obj) {
532-
symbolize::LLVMSymbolizer::Options SymbolizerOpts(
533-
DILineInfoSpecifier::FunctionNameKind::None, true, false, false,
534-
DefaultArch);
532+
symbolize::LLVMSymbolizer::Options SymbolizerOpts;
533+
SymbolizerOpts.PrintFunctions = DILineInfoSpecifier::FunctionNameKind::None;
534+
SymbolizerOpts.Demangle = false;
535+
SymbolizerOpts.DefaultArch = DefaultArch;
535536
Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
536537
}
537538
virtual ~SourcePrinter() = default;

llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,13 @@ int main(int argc, char **argv) {
268268
if (ClNoDemangle.getPosition() > ClDemangle.getPosition())
269269
ClDemangle = !ClNoDemangle;
270270

271-
LLVMSymbolizer::Options Opts(ClPrintFunctions, ClUseSymbolTable, ClDemangle,
272-
ClUseRelativeAddress, ClDefaultArch,
273-
ClFallbackDebugPath);
271+
LLVMSymbolizer::Options Opts;
272+
Opts.PrintFunctions = ClPrintFunctions;
273+
Opts.UseSymbolTable = ClUseSymbolTable;
274+
Opts.Demangle = ClDemangle;
275+
Opts.RelativeAddresses = ClUseRelativeAddress;
276+
Opts.DefaultArch = ClDefaultArch;
277+
Opts.FallbackDebugPath = ClFallbackDebugPath;
274278

275279
for (const auto &hint : ClDsymHint) {
276280
if (sys::path::extension(hint) == ".dSYM") {

llvm/tools/llvm-xray/xray-account.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ static CommandRegistration Unused(&Account, []() -> Error {
427427
Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
428428

429429
const auto &FunctionAddresses = Map.getFunctionAddresses();
430-
symbolize::LLVMSymbolizer::Options Opts(
431-
symbolize::FunctionNameKind::LinkageName, true, true, false, "");
432-
symbolize::LLVMSymbolizer Symbolizer(Opts);
430+
symbolize::LLVMSymbolizer Symbolizer;
433431
llvm::xray::FuncIdConversionHelper FuncIdHelper(AccountInstrMap, Symbolizer,
434432
FunctionAddresses);
435433
xray::LatencyAccountant FCA(FuncIdHelper, AccountDeduceSiblingCalls);

llvm/tools/llvm-xray/xray-converter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ static CommandRegistration Unused(&Convert, []() -> Error {
380380
}
381381

382382
const auto &FunctionAddresses = Map.getFunctionAddresses();
383-
symbolize::LLVMSymbolizer::Options Opts(
384-
symbolize::FunctionNameKind::LinkageName, true, true, false, "");
385-
symbolize::LLVMSymbolizer Symbolizer(Opts);
383+
symbolize::LLVMSymbolizer Symbolizer;
386384
llvm::xray::FuncIdConversionHelper FuncIdHelper(ConvertInstrMap, Symbolizer,
387385
FunctionAddresses);
388386
llvm::xray::TraceConverter TC(FuncIdHelper, ConvertSymbolize);

llvm/tools/llvm-xray/xray-extract.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ static CommandRegistration Unused(&Extract, []() -> Error {
8686
Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
8787
const auto &FunctionAddresses =
8888
InstrumentationMapOrError->getFunctionAddresses();
89-
symbolize::LLVMSymbolizer::Options Opts(
90-
symbolize::FunctionNameKind::LinkageName, true, true, false, "");
91-
symbolize::LLVMSymbolizer Symbolizer(Opts);
89+
symbolize::LLVMSymbolizer Symbolizer;
9290
llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,
9391
FunctionAddresses);
9492
exportAsYAML(*InstrumentationMapOrError, OS, FuncIdHelper);

llvm/tools/llvm-xray/xray-graph.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ Expected<GraphRenderer> GraphRenderer::Factory::getGraphRenderer() {
436436

437437
const auto &FunctionAddresses = Map.getFunctionAddresses();
438438

439-
symbolize::LLVMSymbolizer::Options Opts(
440-
symbolize::FunctionNameKind::LinkageName, true, true, false, "");
441-
symbolize::LLVMSymbolizer Symbolizer(Opts);
439+
symbolize::LLVMSymbolizer Symbolizer;
442440
const auto &Header = Trace.getFileHeader();
443441

444442
llvm::xray::FuncIdConversionHelper FuncIdHelper(InstrMap, Symbolizer,

llvm/tools/llvm-xray/xray-stacks.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,7 @@ static CommandRegistration Unused(&Stack, []() -> Error {
720720
"-all-stacks."),
721721
std::make_error_code(std::errc::invalid_argument));
722722

723-
symbolize::LLVMSymbolizer::Options Opts(
724-
symbolize::FunctionNameKind::LinkageName, true, true, false, "");
725-
symbolize::LLVMSymbolizer Symbolizer(Opts);
723+
symbolize::LLVMSymbolizer Symbolizer;
726724
FuncIdConversionHelper FuncIdHelper(StacksInstrMap, Symbolizer,
727725
Map.getFunctionAddresses());
728726
// TODO: Someday, support output to files instead of just directly to

0 commit comments

Comments
 (0)