]> granicus.if.org Git - llvm/commitdiff
Symbolize: Replace the Options constructor with in-class initialization. NFCI.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Jun 2019 02:31:54 +0000 (02:31 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 11 Jun 2019 02:31:54 +0000 (02:31 +0000)
This is not only less code but also clearer at the use site.

Differential Revision: https://reviews.llvm.org/D63113

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363024 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/Symbolize/Symbolize.h
tools/llvm-objdump/llvm-objdump.cpp
tools/llvm-symbolizer/llvm-symbolizer.cpp
tools/llvm-xray/xray-account.cpp
tools/llvm-xray/xray-converter.cpp
tools/llvm-xray/xray-extract.cpp
tools/llvm-xray/xray-graph.cpp
tools/llvm-xray/xray-stacks.cpp

index 3e194ef1a2b4a717f84f7a82696cd35e51cbf7a7..773b01c82124812fcbb094095076148edb77bd15 100644 (file)
@@ -35,25 +35,17 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
 class LLVMSymbolizer {
 public:
   struct Options {
-    FunctionNameKind PrintFunctions;
-    bool UseSymbolTable : 1;
-    bool Demangle : 1;
-    bool RelativeAddresses : 1;
+    FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName;
+    bool UseSymbolTable = true;
+    bool Demangle = true;
+    bool RelativeAddresses = false;
     std::string DefaultArch;
     std::vector<std::string> DsymHints;
     std::string FallbackDebugPath;
-
-    Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,
-            bool UseSymbolTable = true, bool Demangle = true,
-            bool RelativeAddresses = false, std::string DefaultArch = "",
-            std::string FallbackDebugPath = "")
-        : PrintFunctions(PrintFunctions), UseSymbolTable(UseSymbolTable),
-          Demangle(Demangle), RelativeAddresses(RelativeAddresses),
-          DefaultArch(std::move(DefaultArch)),
-          FallbackDebugPath(std::move(FallbackDebugPath)) {}
   };
 
-  LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}
+  LLVMSymbolizer() = default;
+  LLVMSymbolizer(const Options &Opts) : Opts(Opts) {}
 
   ~LLVMSymbolizer() {
     flush();
index 8f4acc792964f2d9a1f053d8b575106a6156b659..1d211d6161191b254880f33edca2981b982197cb 100644 (file)
@@ -529,9 +529,10 @@ private:
 public:
   SourcePrinter() = default;
   SourcePrinter(const ObjectFile *Obj, StringRef DefaultArch) : Obj(Obj) {
-    symbolize::LLVMSymbolizer::Options SymbolizerOpts(
-        DILineInfoSpecifier::FunctionNameKind::None, true, false, false,
-        DefaultArch);
+    symbolize::LLVMSymbolizer::Options SymbolizerOpts;
+    SymbolizerOpts.PrintFunctions = DILineInfoSpecifier::FunctionNameKind::None;
+    SymbolizerOpts.Demangle = false;
+    SymbolizerOpts.DefaultArch = DefaultArch;
     Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
   }
   virtual ~SourcePrinter() = default;
index 423ad077bd0991fb37170ecfe2907e6fbeaa27a8..93270e61b277793d3a960e3d0a80ab98ab7cda43 100644 (file)
@@ -268,9 +268,13 @@ int main(int argc, char **argv) {
   if (ClNoDemangle.getPosition() > ClDemangle.getPosition())
     ClDemangle = !ClNoDemangle;
 
-  LLVMSymbolizer::Options Opts(ClPrintFunctions, ClUseSymbolTable, ClDemangle,
-                               ClUseRelativeAddress, ClDefaultArch,
-                               ClFallbackDebugPath);
+  LLVMSymbolizer::Options Opts;
+  Opts.PrintFunctions = ClPrintFunctions;
+  Opts.UseSymbolTable = ClUseSymbolTable;
+  Opts.Demangle = ClDemangle;
+  Opts.RelativeAddresses = ClUseRelativeAddress;
+  Opts.DefaultArch = ClDefaultArch;
+  Opts.FallbackDebugPath = ClFallbackDebugPath;
 
   for (const auto &hint : ClDsymHint) {
     if (sys::path::extension(hint) == ".dSYM") {
index bc5354a849d60bcaef55ac2aff20fafd68b0a557..2b49a311d7e3061c2cabf815f15a777a79b540ca 100644 (file)
@@ -427,9 +427,7 @@ static CommandRegistration Unused(&Account, []() -> Error {
         Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
 
   const auto &FunctionAddresses = Map.getFunctionAddresses();
-  symbolize::LLVMSymbolizer::Options Opts(
-      symbolize::FunctionNameKind::LinkageName, true, true, false, "");
-  symbolize::LLVMSymbolizer Symbolizer(Opts);
+  symbolize::LLVMSymbolizer Symbolizer;
   llvm::xray::FuncIdConversionHelper FuncIdHelper(AccountInstrMap, Symbolizer,
                                                   FunctionAddresses);
   xray::LatencyAccountant FCA(FuncIdHelper, AccountDeduceSiblingCalls);
index d865a0b7a03e4ed156b8efa18730a6a76b342fab..dfc757e0f276262292e0357cb558793d7970b021 100644 (file)
@@ -380,9 +380,7 @@ static CommandRegistration Unused(&Convert, []() -> Error {
   }
 
   const auto &FunctionAddresses = Map.getFunctionAddresses();
-  symbolize::LLVMSymbolizer::Options Opts(
-      symbolize::FunctionNameKind::LinkageName, true, true, false, "");
-  symbolize::LLVMSymbolizer Symbolizer(Opts);
+  symbolize::LLVMSymbolizer Symbolizer;
   llvm::xray::FuncIdConversionHelper FuncIdHelper(ConvertInstrMap, Symbolizer,
                                                   FunctionAddresses);
   llvm::xray::TraceConverter TC(FuncIdHelper, ConvertSymbolize);
index b54bc143ed6ad01534eb7a9fdadf8a875ead4c4f..7c7d26b5a38986e9a89c36a917596555f9ba09f9 100644 (file)
@@ -86,9 +86,7 @@ static CommandRegistration Unused(&Extract, []() -> Error {
         Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC);
   const auto &FunctionAddresses =
       InstrumentationMapOrError->getFunctionAddresses();
-  symbolize::LLVMSymbolizer::Options Opts(
-      symbolize::FunctionNameKind::LinkageName, true, true, false, "");
-  symbolize::LLVMSymbolizer Symbolizer(Opts);
+  symbolize::LLVMSymbolizer Symbolizer;
   llvm::xray::FuncIdConversionHelper FuncIdHelper(ExtractInput, Symbolizer,
                                                   FunctionAddresses);
   exportAsYAML(*InstrumentationMapOrError, OS, FuncIdHelper);
index 2365ce56f921946f17bb5646738feea8baaf066e..c09357fcb5021fd897cc6abd06f0381d163a7876 100644 (file)
@@ -436,9 +436,7 @@ Expected<GraphRenderer> GraphRenderer::Factory::getGraphRenderer() {
 
   const auto &FunctionAddresses = Map.getFunctionAddresses();
 
-  symbolize::LLVMSymbolizer::Options Opts(
-      symbolize::FunctionNameKind::LinkageName, true, true, false, "");
-  symbolize::LLVMSymbolizer Symbolizer(Opts);
+  symbolize::LLVMSymbolizer Symbolizer;
   const auto &Header = Trace.getFileHeader();
 
   llvm::xray::FuncIdConversionHelper FuncIdHelper(InstrMap, Symbolizer,
index 1c5838339e1ca08ae4c48137d4676b7f256f04d6..66933d059cf3ccb816bdfd931b31200752e407a6 100644 (file)
@@ -720,9 +720,7 @@ static CommandRegistration Unused(&Stack, []() -> Error {
               "-all-stacks."),
         std::make_error_code(std::errc::invalid_argument));
 
-  symbolize::LLVMSymbolizer::Options Opts(
-      symbolize::FunctionNameKind::LinkageName, true, true, false, "");
-  symbolize::LLVMSymbolizer Symbolizer(Opts);
+  symbolize::LLVMSymbolizer Symbolizer;
   FuncIdConversionHelper FuncIdHelper(StacksInstrMap, Symbolizer,
                                       Map.getFunctionAddresses());
   // TODO: Someday, support output to files instead of just directly to