xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-debuginfo-analyzer/Options.cpp (revision ccfd87fe2ac0e2e6aeb1911a7d7cce6712a8564f)
1 //===-- options.cpp - Command line options for llvm-debuginfo-analyzer----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This handles the command line options for llvm-debuginfo-analyzer.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "Options.h"
14 #include "llvm/DebugInfo/LogicalView/Core/LVOptions.h"
15 #include "llvm/DebugInfo/LogicalView/Core/LVSort.h"
16 #include "llvm/Support/CommandLine.h"
17 
18 using namespace llvm;
19 using namespace llvm::logicalview;
20 using namespace llvm::logicalview::cmdline;
21 
22 /// @}
23 /// Command line options.
24 /// @{
25 
26 OffsetParser::OffsetParser(cl::Option &O) : parser<unsigned long long>(O) {}
27 OffsetParser::~OffsetParser() = default;
28 
29 bool OffsetParser::parse(cl::Option &O, StringRef ArgName, StringRef Arg,
30                          unsigned long long &Val) {
31   char *End;
32   std::string Argument(Arg);
33   Val = strtoull(Argument.c_str(), &End, 0);
34   if (*End)
35     // Print an error message if unrecognized character.
36     return O.error("'" + Arg + "' unrecognized character.");
37   return false;
38 }
39 
40 LVOptions cmdline::ReaderOptions;
41 
42 //===----------------------------------------------------------------------===//
43 // Specific options
44 //===----------------------------------------------------------------------===//
45 cl::list<std::string>
46     cmdline::InputFilenames(cl::desc("<input object files or .dSYM bundles>"),
47                             cl::Positional, cl::ZeroOrMore);
48 
49 //===----------------------------------------------------------------------===//
50 // '--attribute' options
51 //===----------------------------------------------------------------------===//
52 cl::OptionCategory
53     cmdline::AttributeCategory("Attribute Options",
54                                "These control extra attributes that are "
55                                "added when the element is printed.");
56 
57 // --attribute=<value>[,<value>,...]
58 cl::list<LVAttributeKind> cmdline::AttributeOptions(
59     "attribute", cl::cat(AttributeCategory), cl::desc("Element attributes."),
60     cl::Hidden, cl::CommaSeparated,
61     values(clEnumValN(LVAttributeKind::All, "all", "Include all attributes."),
62            clEnumValN(LVAttributeKind::Argument, "argument",
63                       "Template parameters replaced by its arguments."),
64            clEnumValN(LVAttributeKind::Base, "base",
65                       "Base types (int, bool, etc.)."),
66            clEnumValN(LVAttributeKind::Coverage, "coverage",
67                       "Symbol location coverage."),
68            clEnumValN(LVAttributeKind::Directories, "directories",
69                       "Directories referenced in the debug information."),
70            clEnumValN(LVAttributeKind::Discarded, "discarded",
71                       "Discarded elements by the linker."),
72            clEnumValN(LVAttributeKind::Discriminator, "discriminator",
73                       "Discriminators for inlined function instances."),
74            clEnumValN(LVAttributeKind::Encoded, "encoded",
75                       "Template arguments encoded in the template name."),
76            clEnumValN(LVAttributeKind::Extended, "extended",
77                       "Advanced attributes alias."),
78            clEnumValN(LVAttributeKind::Filename, "filename",
79                       "Filename where the element is defined."),
80            clEnumValN(LVAttributeKind::Files, "files",
81                       "Files referenced in the debug information."),
82            clEnumValN(LVAttributeKind::Format, "format",
83                       "Object file format name."),
84            clEnumValN(LVAttributeKind::Gaps, "gaps",
85                       "Missing debug location (gaps)."),
86            clEnumValN(LVAttributeKind::Generated, "generated",
87                       "Compiler generated elements."),
88            clEnumValN(LVAttributeKind::Global, "global",
89                       "Element referenced across Compile Units."),
90            clEnumValN(LVAttributeKind::Inserted, "inserted",
91                       "Generated inlined abstract references."),
92            clEnumValN(LVAttributeKind::Level, "level",
93                       "Lexical scope level (File=0, Compile Unit=1)."),
94            clEnumValN(LVAttributeKind::Linkage, "linkage", "Linkage name."),
95            clEnumValN(LVAttributeKind::Local, "local",
96                       "Element referenced only in the Compile Unit."),
97            clEnumValN(LVAttributeKind::Location, "location",
98                       "Element debug location."),
99            clEnumValN(LVAttributeKind::Offset, "offset",
100                       "Debug information offset."),
101            clEnumValN(LVAttributeKind::Pathname, "pathname",
102                       "Pathname where the element is defined."),
103            clEnumValN(LVAttributeKind::Producer, "producer",
104                       "Toolchain identification name."),
105            clEnumValN(LVAttributeKind::Publics, "publics",
106                       "Function names that are public."),
107            clEnumValN(LVAttributeKind::Qualified, "qualified",
108                       "The element type include parents in its name."),
109            clEnumValN(LVAttributeKind::Qualifier, "qualifier",
110                       "Line qualifiers (Newstatement, BasicBlock, etc.)."),
111            clEnumValN(LVAttributeKind::Range, "range",
112                       "Debug location ranges."),
113            clEnumValN(LVAttributeKind::Reference, "reference",
114                       "Element declaration and definition references."),
115            clEnumValN(LVAttributeKind::Register, "register",
116                       "Processor register names."),
117            clEnumValN(LVAttributeKind::Standard, "standard",
118                       "Basic attributes alias."),
119            clEnumValN(LVAttributeKind::Subrange, "subrange",
120                       "Subrange encoding information for arrays."),
121            clEnumValN(LVAttributeKind::System, "system",
122                       "Display PDB's MS system elements."),
123            clEnumValN(LVAttributeKind::Typename, "typename",
124                       "Include Parameters in templates."),
125            clEnumValN(LVAttributeKind::Underlying, "underlying",
126                       "Underlying type for type definitions."),
127            clEnumValN(LVAttributeKind::Zero, "zero", "Zero line numbers.")));
128 
129 //===----------------------------------------------------------------------===//
130 // '--compare' options
131 //===----------------------------------------------------------------------===//
132 cl::OptionCategory
133     cmdline::CompareCategory("Compare Options",
134                              "These control the view comparison.");
135 
136 // --compare-context
137 static cl::opt<bool, true>
138     CompareContext("compare-context", cl::cat(CompareCategory),
139                    cl::desc("Add the view as compare context."), cl::Hidden,
140                    cl::ZeroOrMore, cl::location(ReaderOptions.Compare.Context),
141                    cl::init(false));
142 
143 // --compare=<value>[,<value>,...]
144 cl::list<LVCompareKind> cmdline::CompareElements(
145     "compare", cl::cat(CompareCategory), cl::desc("Elements to compare."),
146     cl::Hidden, cl::CommaSeparated,
147     values(clEnumValN(LVCompareKind::All, "all", "Compare all elements."),
148            clEnumValN(LVCompareKind::Lines, "lines", "Lines."),
149            clEnumValN(LVCompareKind::Scopes, "scopes", "Scopes."),
150            clEnumValN(LVCompareKind::Symbols, "symbols", "Symbols."),
151            clEnumValN(LVCompareKind::Types, "types", "Types.")));
152 
153 //===----------------------------------------------------------------------===//
154 // '--output' options
155 //===----------------------------------------------------------------------===//
156 cl::OptionCategory
157     cmdline::OutputCategory("Output Options",
158                             "These control the output generated.");
159 
160 // --output-file=<filename>
161 cl::opt<std::string>
162     cmdline::OutputFilename("output-file", cl::cat(OutputCategory),
163                             cl::desc("Redirect output to the specified file."),
164                             cl::Hidden, cl::value_desc("filename"),
165                             cl::init("-"));
166 
167 // --output-folder=<path>
168 static cl::opt<std::string, true>
169     OutputFolder("output-folder", cl::cat(OutputCategory),
170                  cl::desc("Folder name for view splitting."),
171                  cl::value_desc("pathname"), cl::Hidden, cl::ZeroOrMore,
172                  cl::location(ReaderOptions.Output.Folder));
173 
174 // --output-level=<level>
175 static cl::opt<unsigned, true>
176     OutputLevel("output-level", cl::cat(OutputCategory),
177                 cl::desc("Only print to a depth of N elements."),
178                 cl::value_desc("N"), cl::Hidden, cl::ZeroOrMore,
179                 cl::location(ReaderOptions.Output.Level), cl::init(-1U));
180 
181 // --ouput=<value>[,<value>,...]
182 cl::list<LVOutputKind> cmdline::OutputOptions(
183     "output", cl::cat(OutputCategory), cl::desc("Outputs for view."),
184     cl::Hidden, cl::CommaSeparated,
185     values(clEnumValN(LVOutputKind::All, "all", "All outputs."),
186            clEnumValN(LVOutputKind::Split, "split",
187                       "Split the output by Compile Units."),
188            clEnumValN(LVOutputKind::Text, "text",
189                       "Use a free form text output."),
190            clEnumValN(LVOutputKind::Json, "json",
191                       "Use JSON as the output format.")));
192 
193 // --output-sort
194 static cl::opt<LVSortMode, true> OutputSort(
195     "output-sort", cl::cat(OutputCategory),
196     cl::desc("Primary key when ordering logical view (default: line)."),
197     cl::Hidden, cl::ZeroOrMore,
198     values(clEnumValN(LVSortMode::Kind, "kind", "Sort by element kind."),
199            clEnumValN(LVSortMode::Line, "line", "Sort by element line number."),
200            clEnumValN(LVSortMode::Name, "name", "Sort by element name."),
201            clEnumValN(LVSortMode::Offset, "offset", "Sort by element offset.")),
202     cl::location(ReaderOptions.Output.SortMode), cl::init(LVSortMode::Line));
203 
204 //===----------------------------------------------------------------------===//
205 // '--print' options
206 //===----------------------------------------------------------------------===//
207 cl::OptionCategory
208     cmdline::PrintCategory("Print Options",
209                            "These control which elements are printed.");
210 
211 // --print=<value>[,<value>,...]
212 cl::list<LVPrintKind> cmdline::PrintOptions(
213     "print", cl::cat(PrintCategory), cl::desc("Element to print."),
214     cl::CommaSeparated,
215     values(clEnumValN(LVPrintKind::All, "all", "All elements."),
216            clEnumValN(LVPrintKind::Elements, "elements",
217                       "Instructions, lines, scopes, symbols and types."),
218            clEnumValN(LVPrintKind::Instructions, "instructions",
219                       "Assembler instructions."),
220            clEnumValN(LVPrintKind::Lines, "lines",
221                       "Lines referenced in the debug information."),
222            clEnumValN(LVPrintKind::Scopes, "scopes",
223                       "A lexical block (Function, Class, etc.)."),
224            clEnumValN(LVPrintKind::Sizes, "sizes",
225                       "Scope contributions to the debug information."),
226            clEnumValN(LVPrintKind::Summary, "summary",
227                       "Summary of elements missing/added/matched/printed."),
228            clEnumValN(LVPrintKind::Symbols, "symbols",
229                       "Symbols (Variable, Members, etc.)."),
230            clEnumValN(LVPrintKind::Types, "types",
231                       "Types (Pointer, Reference, etc.)."),
232            clEnumValN(LVPrintKind::Warnings, "warnings",
233                       "Warnings detected.")));
234 
235 //===----------------------------------------------------------------------===//
236 // '--report' options
237 //===----------------------------------------------------------------------===//
238 cl::OptionCategory
239     cmdline::ReportCategory("Report Options",
240                             "These control how the elements are printed.");
241 
242 // --report=<value>[,<value>,...]
243 cl::list<LVReportKind> cmdline::ReportOptions(
244     "report", cl::cat(ReportCategory),
245     cl::desc("Reports layout used for print, compare and select."), cl::Hidden,
246     cl::CommaSeparated,
247     values(clEnumValN(LVReportKind::All, "all", "Generate all reports."),
248            clEnumValN(LVReportKind::Children, "children",
249                       "Selected elements are displayed in a tree view "
250                       "(Include children)"),
251            clEnumValN(LVReportKind::List, "list",
252                       "Selected elements are displayed in a tabular format."),
253            clEnumValN(LVReportKind::Parents, "parents",
254                       "Selected elements are displayed in a tree view. "
255                       "(Include parents)"),
256            clEnumValN(LVReportKind::View, "view",
257                       "Selected elements are displayed in a tree view "
258                       "(Include parents and children.")));
259 
260 //===----------------------------------------------------------------------===//
261 // '--select' options
262 //===----------------------------------------------------------------------===//
263 cl::OptionCategory
264     cmdline::SelectCategory("Select Options",
265                             "These control which elements are selected.");
266 
267 // --select-nocase
268 static cl::opt<bool, true>
269     SelectIgnoreCase("select-nocase", cl::cat(SelectCategory),
270                      cl::desc("Ignore case distinctions when searching."),
271                      cl::Hidden, cl::ZeroOrMore,
272                      cl::location(ReaderOptions.Select.IgnoreCase),
273                      cl::init(false));
274 
275 // --select-regex
276 static cl::opt<bool, true> SelectUseRegex(
277     "select-regex", cl::cat(SelectCategory),
278     cl::desc("Treat any <pattern> strings as regular expressions when "
279              "selecting instead of just as an exact string match."),
280     cl::Hidden, cl::ZeroOrMore, cl::location(ReaderOptions.Select.UseRegex),
281     cl::init(false));
282 
283 // --select=<pattern>
284 cl::list<std::string> cmdline::SelectPatterns(
285     "select", cl::cat(SelectCategory),
286     cl::desc("Search elements matching the given pattern."), cl::Hidden,
287     cl::value_desc("pattern"), cl::CommaSeparated);
288 
289 // --select-offsets=<value>[,<value>,...]
290 OffsetOptionList cmdline::SelectOffsets("select-offsets",
291                                         cl::cat(SelectCategory),
292                                         cl::desc("Offset element to print."),
293                                         cl::Hidden, cl::value_desc("offset"),
294                                         cl::CommaSeparated, cl::ZeroOrMore);
295 
296 // --select-elements=<value>[,<value>,...]
297 cl::list<LVElementKind> cmdline::SelectElements(
298     "select-elements", cl::cat(SelectCategory),
299     cl::desc("Conditions to use when printing elements."), cl::Hidden,
300     cl::CommaSeparated,
301     values(clEnumValN(LVElementKind::Discarded, "Discarded",
302                       "Discarded elements by the linker."),
303            clEnumValN(LVElementKind::Global, "Global",
304                       "Element referenced across Compile Units."),
305            clEnumValN(LVElementKind::Optimized, "Optimized",
306                       "Generated inlined abstract references.")));
307 
308 // --select-lines=<value>[,<value>,...]
309 cl::list<LVLineKind> cmdline::SelectLines(
310     "select-lines", cl::cat(SelectCategory),
311     cl::desc("Line kind to use when printing lines."), cl::Hidden,
312     cl::CommaSeparated,
313     values(
314         clEnumValN(LVLineKind::IsAlwaysStepInto, "AlwaysStepInto",
315                    "Always Step Into."),
316         clEnumValN(LVLineKind::IsBasicBlock, "BasicBlock", "Basic block."),
317         clEnumValN(LVLineKind::IsDiscriminator, "Discriminator",
318                    "Discriminator."),
319         clEnumValN(LVLineKind::IsEndSequence, "EndSequence", "End sequence."),
320         clEnumValN(LVLineKind::IsEpilogueBegin, "EpilogueBegin.",
321                    "Epilogue begin."),
322         clEnumValN(LVLineKind::IsLineDebug, "LineDebug", "Debug line."),
323         clEnumValN(LVLineKind::IsLineAssembler, "LineAssembler",
324                    "Assembler line."),
325         clEnumValN(LVLineKind::IsNeverStepInto, "NeverStepInto",
326                    "Never Step Into."),
327         clEnumValN(LVLineKind::IsNewStatement, "NewStatement",
328                    "New statement."),
329         clEnumValN(LVLineKind::IsPrologueEnd, "PrologueEnd", "Prologue end.")));
330 
331 // --select-scopes=<value>[,<value>,...]
332 cl::list<LVScopeKind> cmdline::SelectScopes(
333     "select-scopes", cl::cat(SelectCategory),
334     cl::desc("Scope kind to use when printing scopes."), cl::Hidden,
335     cl::CommaSeparated,
336     values(
337         clEnumValN(LVScopeKind::IsAggregate, "Aggregate",
338                    "Class, Structure or Union."),
339         clEnumValN(LVScopeKind::IsArray, "Array", "Array."),
340         clEnumValN(LVScopeKind::IsBlock, "Block", "Lexical block."),
341         clEnumValN(LVScopeKind::IsCallSite, "CallSite", "Call site block."),
342         clEnumValN(LVScopeKind::IsCatchBlock, "CatchBlock",
343                    "Exception catch block."),
344         clEnumValN(LVScopeKind::IsClass, "Class", "Class."),
345         clEnumValN(LVScopeKind::IsCompileUnit, "CompileUnit", "Compile unit."),
346         clEnumValN(LVScopeKind::IsEntryPoint, "EntryPoint",
347                    "Function entry point."),
348         clEnumValN(LVScopeKind::IsEnumeration, "Enumeration", "Enumeration."),
349         clEnumValN(LVScopeKind::IsFunction, "Function", "Function."),
350         clEnumValN(LVScopeKind::IsFunctionType, "FunctionType",
351                    "Function type."),
352         clEnumValN(LVScopeKind::IsInlinedFunction, "InlinedFunction",
353                    "Inlined function."),
354         clEnumValN(LVScopeKind::IsLabel, "Label", "Label."),
355         clEnumValN(LVScopeKind::IsLexicalBlock, "LexicalBlock",
356                    "Lexical block."),
357         clEnumValN(LVScopeKind::IsNamespace, "Namespace", "Namespace."),
358         clEnumValN(LVScopeKind::IsRoot, "Root", "Root."),
359         clEnumValN(LVScopeKind::IsStructure, "Structure", "Structure."),
360         clEnumValN(LVScopeKind::IsSubprogram, "Subprogram", "Subprogram."),
361         clEnumValN(LVScopeKind::IsTemplate, "Template", "Template."),
362         clEnumValN(LVScopeKind::IsTemplateAlias, "TemplateAlias",
363                    "Template alias."),
364         clEnumValN(LVScopeKind::IsTemplatePack, "TemplatePack",
365                    "Template pack."),
366         clEnumValN(LVScopeKind::IsTryBlock, "TryBlock", "Exception try block."),
367         clEnumValN(LVScopeKind::IsUnion, "Union", "Union.")));
368 
369 // --select-symbols=<value>[,<value>,...]
370 cl::list<LVSymbolKind> cmdline::SelectSymbols(
371     "select-symbols", cl::cat(SelectCategory),
372     cl::desc("Symbol kind to use when printing symbols."), cl::Hidden,
373     cl::CommaSeparated,
374     values(clEnumValN(LVSymbolKind::IsCallSiteParameter, "CallSiteParameter",
375                       "Call site parameter."),
376            clEnumValN(LVSymbolKind::IsConstant, "Constant", "Constant."),
377            clEnumValN(LVSymbolKind::IsInheritance, "Inheritance",
378                       "Inheritance."),
379            clEnumValN(LVSymbolKind::IsMember, "Member", "Member."),
380            clEnumValN(LVSymbolKind::IsParameter, "Parameter", "Parameter."),
381            clEnumValN(LVSymbolKind::IsUnspecified, "Unspecified",
382                       "Unspecified parameter."),
383            clEnumValN(LVSymbolKind::IsVariable, "Variable", "Variable.")));
384 
385 // --select-types=<value>[,<value>,...]
386 cl::list<LVTypeKind> cmdline::SelectTypes(
387     "select-types", cl::cat(SelectCategory),
388     cl::desc("Type kind to use when printing types."), cl::Hidden,
389     cl::CommaSeparated,
390     values(
391         clEnumValN(LVTypeKind::IsBase, "Base", "Base Type (int, bool, etc.)."),
392         clEnumValN(LVTypeKind::IsConst, "Const", "Constant specifier."),
393         clEnumValN(LVTypeKind::IsEnumerator, "Enumerator", "Enumerator."),
394         clEnumValN(LVTypeKind::IsImport, "Import", "Import."),
395         clEnumValN(LVTypeKind::IsImportDeclaration, "ImportDeclaration",
396                    "Import declaration."),
397         clEnumValN(LVTypeKind::IsImportModule, "ImportModule",
398                    "Import module."),
399         clEnumValN(LVTypeKind::IsPointer, "Pointer", "Pointer."),
400         clEnumValN(LVTypeKind::IsPointerMember, "PointerMember",
401                    "Pointer to member."),
402         clEnumValN(LVTypeKind::IsReference, "Reference", "Reference type."),
403         clEnumValN(LVTypeKind::IsRestrict, "Restrict", "Restrict specifier."),
404         clEnumValN(LVTypeKind::IsRvalueReference, "RvalueReference",
405                    "Rvalue reference."),
406         clEnumValN(LVTypeKind::IsSubrange, "Subrange", "Array subrange."),
407         clEnumValN(LVTypeKind::IsTemplateParam, "TemplateParam",
408                    "Template Parameter."),
409         clEnumValN(LVTypeKind::IsTemplateTemplateParam, "TemplateTemplateParam",
410                    "Template template parameter."),
411         clEnumValN(LVTypeKind::IsTemplateTypeParam, "TemplateTypeParam",
412                    "Template type parameter."),
413         clEnumValN(LVTypeKind::IsTemplateValueParam, "TemplateValueParam",
414                    "Template value parameter."),
415         clEnumValN(LVTypeKind::IsTypedef, "Typedef", "Type definition."),
416         clEnumValN(LVTypeKind::IsUnspecified, "Unspecified",
417                    "Unspecified type."),
418         clEnumValN(LVTypeKind::IsVolatile, "Volatile", "Volatile specifier.")));
419 
420 //===----------------------------------------------------------------------===//
421 // '--warning' options
422 //===----------------------------------------------------------------------===//
423 cl::OptionCategory
424     cmdline::WarningCategory("Warning Options",
425                              "These control the generated warnings.");
426 
427 // --warning=<value>[,<value>,...]
428 cl::list<LVWarningKind> cmdline::WarningOptions(
429     "warning", cl::cat(WarningCategory), cl::desc("Warnings to generate."),
430     cl::Hidden, cl::CommaSeparated,
431     values(
432         clEnumValN(LVWarningKind::All, "all", "All warnings."),
433         clEnumValN(LVWarningKind::Coverages, "coverages",
434                    "Invalid symbol coverages values."),
435         clEnumValN(LVWarningKind::Lines, "lines", "Debug lines that are zero."),
436         clEnumValN(LVWarningKind::Locations, "locations",
437                    "Invalid symbol locations."),
438         clEnumValN(LVWarningKind::Ranges, "ranges", "Invalid code ranges.")));
439 
440 //===----------------------------------------------------------------------===//
441 // '--internal' options
442 //===----------------------------------------------------------------------===//
443 cl::OptionCategory
444     cmdline::InternalCategory("Internal Options",
445                               "Internal traces and extra debugging code.");
446 
447 // --internal=<value>[,<value>,...]
448 cl::list<LVInternalKind> cmdline::InternalOptions(
449     "internal", cl::cat(InternalCategory), cl::desc("Traces to enable."),
450     cl::Hidden, cl::CommaSeparated,
451     values(
452         clEnumValN(LVInternalKind::All, "all", "Enable all traces."),
453         clEnumValN(LVInternalKind::Cmdline, "cmdline", "Print command line."),
454         clEnumValN(LVInternalKind::ID, "id", "Print unique element ID"),
455         clEnumValN(LVInternalKind::Integrity, "integrity",
456                    "Check elements integrity."),
457         clEnumValN(LVInternalKind::None, "none", "Ignore element line number."),
458         clEnumValN(LVInternalKind::Tag, "tag", "Debug information tags.")));
459 
460 /// @}
461 
462 // Copy local options into a globally accessible data structure.
463 void llvm::logicalview::cmdline::propagateOptions() {
464   // Traverse list of options and update the given set (Using case and Regex).
465   auto UpdatePattern = [&](auto &List, auto &Set, bool IgnoreCase,
466                            bool UseRegex) {
467     if (!List.empty())
468       for (std::string &Pattern : List)
469         Set.insert((IgnoreCase && !UseRegex) ? StringRef(Pattern).lower()
470                                              : Pattern);
471   };
472 
473   // Handle --select.
474   UpdatePattern(SelectPatterns, ReaderOptions.Select.Generic,
475                 ReaderOptions.Select.IgnoreCase, ReaderOptions.Select.UseRegex);
476 
477   // Traverse list of options and update the given set.
478   auto UpdateSet = [&](auto &List, auto &Set) {
479     std::copy(List.begin(), List.end(), std::inserter(Set, Set.begin()));
480   };
481 
482   // Handle options sets.
483   UpdateSet(AttributeOptions, ReaderOptions.Attribute.Kinds);
484   UpdateSet(PrintOptions, ReaderOptions.Print.Kinds);
485   UpdateSet(OutputOptions, ReaderOptions.Output.Kinds);
486   UpdateSet(ReportOptions, ReaderOptions.Report.Kinds);
487   UpdateSet(WarningOptions, ReaderOptions.Warning.Kinds);
488   UpdateSet(InternalOptions, ReaderOptions.Internal.Kinds);
489 
490   UpdateSet(SelectElements, ReaderOptions.Select.Elements);
491   UpdateSet(SelectLines, ReaderOptions.Select.Lines);
492   UpdateSet(SelectScopes, ReaderOptions.Select.Scopes);
493   UpdateSet(SelectSymbols, ReaderOptions.Select.Symbols);
494   UpdateSet(SelectTypes, ReaderOptions.Select.Types);
495   UpdateSet(SelectOffsets, ReaderOptions.Select.Offsets);
496   UpdateSet(CompareElements, ReaderOptions.Compare.Elements);
497 
498   // Resolve any options dependencies (ie. --print=all should set other
499   // print options, etc.).
500   ReaderOptions.resolveDependencies();
501 }
502