1 //===-- LVOptions.h ---------------------------------------------*- C++ -*-===//
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 file defines the LVOptions class, which is used to record the command
10 // line options.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
15 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
16
17 #include "llvm/ADT/StringSet.h"
18 #include "llvm/DebugInfo/LogicalView/Core/LVLine.h"
19 #include "llvm/DebugInfo/LogicalView/Core/LVScope.h"
20 #include "llvm/DebugInfo/LogicalView/Core/LVSymbol.h"
21 #include "llvm/DebugInfo/LogicalView/Core/LVType.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/Regex.h"
24 #include <set>
25 #include <string>
26
27 namespace llvm {
28 namespace logicalview {
29
30 // Generate get and set 'bool' functions.
31 #define BOOL_FUNCTION(FAMILY, FIELD) \
32 bool get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
33 void set##FAMILY##FIELD() { FAMILY.FIELD = true; } \
34 void reset##FAMILY##FIELD() { FAMILY.FIELD = false; }
35
36 // Generate get and set 'unsigned' functions.
37 #define UNSIGNED_FUNCTION(FAMILY, FIELD) \
38 unsigned get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
39 void set##FAMILY##FIELD(unsigned Value) { FAMILY.FIELD = Value; } \
40 void reset##FAMILY##FIELD() { FAMILY.FIELD = -1U; }
41
42 // Generate get and set 'std::string' functions.
43 #define STD_STRING_FUNCTION(FAMILY, FIELD) \
44 std::string get##FAMILY##FIELD() const { return FAMILY.FIELD; } \
45 void set##FAMILY##FIELD(std::string FIELD) { \
46 FAMILY.FIELD = std::move(FIELD); \
47 } \
48 void reset##FAMILY##FIELD() { FAMILY.FIELD = ""; }
49
50 // Generate get and set 'std::set' functions.
51 #define STDSET_FUNCTION_4(FAMILY, FIELD, TYPE, SET) \
52 bool get##FAMILY##FIELD() const { \
53 return FAMILY.SET.find(TYPE::FIELD) != FAMILY.SET.end(); \
54 } \
55 void set##FAMILY##FIELD() { FAMILY.SET.insert(TYPE::FIELD); } \
56 void reset##FAMILY##FIELD() { FAMILY.SET.erase(TYPE::FIELD); }
57
58 #define STDSET_FUNCTION_5(FAMILY, FIELD, ENTRY, TYPE, SET) \
59 bool get##FAMILY##FIELD##ENTRY() const { \
60 return FAMILY.SET.find(TYPE::ENTRY) != FAMILY.SET.end(); \
61 } \
62 void set##FAMILY##FIELD##ENTRY() { FAMILY.SET.insert(TYPE::ENTRY); }
63
64 // Generate get and set functions for '--attribute'
65 #define ATTRIBUTE_OPTION(FIELD) \
66 STDSET_FUNCTION_4(Attribute, FIELD, LVAttributeKind, Kinds)
67
68 // Generate get and set functions for '--output'
69 #define OUTPUT_OPTION(FIELD) \
70 STDSET_FUNCTION_4(Output, FIELD, LVOutputKind, Kinds)
71
72 // Generate get and set functions for '--print'
73 #define PRINT_OPTION(FIELD) STDSET_FUNCTION_4(Print, FIELD, LVPrintKind, Kinds)
74
75 // Generate get and set functions for '--warning'
76 #define WARNING_OPTION(FIELD) \
77 STDSET_FUNCTION_4(Warning, FIELD, LVWarningKind, Kinds)
78
79 // Generate get and set functions for '--compare'
80 #define COMPARE_OPTION(FIELD) \
81 STDSET_FUNCTION_4(Compare, FIELD, LVCompareKind, Elements)
82
83 // Generate get and set functions for '--report'
84 #define REPORT_OPTION(FIELD) \
85 STDSET_FUNCTION_4(Report, FIELD, LVReportKind, Kinds)
86
87 // Generate get and set functions for '--internal'
88 #define INTERNAL_OPTION(FIELD) \
89 STDSET_FUNCTION_4(Internal, FIELD, LVInternalKind, Kinds)
90
91 using LVOffsetSet = std::set<uint64_t>;
92
93 enum class LVAttributeKind {
94 All, // --attribute=all
95 Argument, // --attribute=argument
96 Base, // --attribute=base
97 Coverage, // --attribute=coverage
98 Directories, // --attribute=directories
99 Discarded, // --attribute=discarded
100 Discriminator, // --attribute=discriminator
101 Encoded, // --attribute=encoded
102 Extended, // --attribute=extended
103 Filename, // --attribute=filename
104 Files, // --attribute=files
105 Format, // --attribute=format
106 Gaps, // --attribute=gaps
107 Generated, // --attribute=generated
108 Global, // --attribute=global
109 Inserted, // --attribute=inserted
110 Language, // --attribute=language
111 Level, // --attribute=level
112 Linkage, // --attribute=linkage
113 Local, // --attribute=local
114 Location, // --attribute=location
115 Offset, // --attribute=offset
116 Pathname, // --attribute=pathname
117 Producer, // --attribute=producer
118 Publics, // --attribute=publics
119 Qualified, // --attribute=qualified
120 Qualifier, // --attribute=qualifier
121 Range, // --attribute=range
122 Reference, // --attribute=reference
123 Register, // --attribute=register
124 Size, // --attribute=size
125 Standard, // --attribute=standard
126 Subrange, // --attribute=subrange
127 System, // --attribute=system
128 Typename, // --attribute=typename
129 Underlying, // --attribute=underlying
130 Zero // --attribute=zero
131 };
132 using LVAttributeKindSet = std::set<LVAttributeKind>;
133
134 enum class LVCompareKind {
135 All, // --compare=all
136 Lines, // --compare=lines
137 Scopes, // --compare=scopes
138 Symbols, // --compare=symbols
139 Types // --compare=types
140 };
141 using LVCompareKindSet = std::set<LVCompareKind>;
142
143 enum class LVOutputKind {
144 All, // --output=all
145 Split, // --output=split
146 Json, // --output=json
147 Text // --output=text
148 };
149 using LVOutputKindSet = std::set<LVOutputKind>;
150
151 enum class LVPrintKind {
152 All, // --print=all
153 Elements, // --print=elements
154 Instructions, // --print=instructions
155 Lines, // --print=lines
156 Scopes, // --print=scopes
157 Sizes, // --print=sizes
158 Symbols, // --print=symbols
159 Summary, // --print=summary
160 Types, // --print=types
161 Warnings // --print=warnings
162 };
163 using LVPrintKindSet = std::set<LVPrintKind>;
164
165 enum class LVReportKind {
166 All, // --report=all
167 Children, // --report=children
168 List, // --report=list
169 Parents, // --report=parents
170 View // --report=view
171 };
172 using LVReportKindSet = std::set<LVReportKind>;
173
174 enum class LVWarningKind {
175 All, // --warning=all
176 Coverages, // --warning=coverages
177 Lines, // --warning=lines
178 Locations, // --warning=locations
179 Ranges // --warning=ranges
180 };
181 using LVWarningKindSet = std::set<LVWarningKind>;
182
183 enum class LVInternalKind {
184 All, // --internal=all
185 Cmdline, // --internal=cmdline
186 ID, // --internal=id
187 Integrity, // --internal=integrity
188 None, // --internal=none
189 Tag // --internal=tag
190 };
191 using LVInternalKindSet = std::set<LVInternalKind>;
192
193 // The 'Kinds' members are a one-to-one mapping to the associated command
194 // options that supports comma separated values. There are other 'bool'
195 // members that in very few cases point to a command option (see associated
196 // comment). Other cases for 'bool' refers to internal values derivated from
197 // the command options.
198 class LVOptions {
199 class LVAttribute {
200 public:
201 LVAttributeKindSet Kinds; // --attribute=<Kind>
202 bool Added = false; // Added elements found during comparison.
203 bool AnyLocation = false; // Any kind of location information.
204 bool AnySource = false; // Any kind of source information.
205 bool Missing = false; // Missing elements found during comparison.
206 };
207
208 class LVCompare {
209 public:
210 LVCompareKindSet Elements; // --compare=<kind>
211 bool Context = false; // --compare-context
212 bool Execute = false; // Compare requested.
213 bool Print = false; // Enable any printing.
214 };
215
216 class LVPrint {
217 public:
218 LVPrintKindSet Kinds; // --print=<Kind>
219 bool AnyElement = false; // Request to print any element.
220 bool AnyLine = false; // Print 'lines' or 'instructions'.
221 bool Execute = false; // Print requested.
222 bool Formatting = true; // Disable formatting during printing.
223 bool Offset = false; // Print offsets while formatting is disabled.
224 bool SizesSummary = false; // Print 'sizes' or 'summary'.
225 };
226
227 class LVReport {
228 public:
229 LVReportKindSet Kinds; // --report=<kind>
230 bool AnyView = false; // View, Parents or Children.
231 bool Execute = false; // Report requested.
232 };
233
234 class LVSelect {
235 public:
236 bool IgnoreCase = false; // --select-ignore-case
237 bool UseRegex = false; // --select-use-regex
238 bool Execute = false; // Select requested.
239 bool GenericKind = false; // We have collected generic kinds.
240 bool GenericPattern = false; // We have collected generic patterns.
241 bool OffsetPattern = false; // We have collected offset patterns.
242 StringSet<> Generic; // --select=<Pattern>
243 LVOffsetSet Offsets; // --select-offset=<Offset>
244 LVElementKindSet Elements; // --select-elements=<Kind>
245 LVLineKindSet Lines; // --select-lines=<Kind>
246 LVScopeKindSet Scopes; // --select-scopes=<Kind>
247 LVSymbolKindSet Symbols; // --select-symbols=<Kind>
248 LVTypeKindSelection Types; // --select-types=<Kind>
249 };
250
251 class LVOutput {
252 public:
253 LVOutputKindSet Kinds; // --output=<kind>
254 LVSortMode SortMode = LVSortMode::None; // --output-sort=<SortMode>
255 std::string Folder; // --output-folder=<Folder>
256 unsigned Level = -1U; // --output-level=<level>
257 };
258
259 class LVWarning {
260 public:
261 LVWarningKindSet Kinds; // --warning=<Kind>
262 };
263
264 class LVInternal {
265 public:
266 LVInternalKindSet Kinds; // --internal=<Kind>
267 };
268
269 class LVGeneral {
270 public:
271 bool CollectRanges = false; // Collect ranges information.
272 };
273
274 // Filters the output of the filename associated with the element being
275 // printed in order to see clearly which logical elements belongs to
276 // a particular filename. It is value is reset after the element
277 // that represents the Compile Unit is printed.
278 size_t LastFilenameIndex = 0;
279
280 // Controls the amount of additional spaces to insert when printing
281 // object attributes, in order to get a consistent printing layout.
282 size_t IndentationSize = 0;
283
284 // Calculate the indentation size, so we can use that value when printing
285 // additional attributes to objects, such as location.
286 void calculateIndentationSize();
287
288 public:
resetFilenameIndex()289 void resetFilenameIndex() { LastFilenameIndex = 0; }
changeFilenameIndex(size_t Index)290 bool changeFilenameIndex(size_t Index) {
291 bool IndexChanged = (Index != LastFilenameIndex);
292 if (IndexChanged)
293 LastFilenameIndex = Index;
294 return IndexChanged;
295 }
296
297 // Access to command line options, pattern and printing information.
298 LLVM_ABI static LVOptions *getOptions();
299 LLVM_ABI static void setOptions(LVOptions *Options);
300
301 LVOptions() = default;
302 LVOptions(const LVOptions &) = default;
303 LVOptions &operator=(const LVOptions &) = default;
304 ~LVOptions() = default;
305
306 // Some command line options support shortcuts. For example:
307 // The command line option '--print=elements' is a shortcut for:
308 // '--print=instructions,lines,scopes,symbols,types'.
309 // In the case of logical view comparison, some options related to
310 // attributes must be set or reset for a proper comparison.
311 // Resolve any dependencies between command line options.
312 LLVM_ABI void resolveDependencies();
indentationSize()313 size_t indentationSize() const { return IndentationSize; }
314
315 LVAttribute Attribute;
316 LVCompare Compare;
317 LVOutput Output;
318 LVPrint Print;
319 LVReport Report;
320 LVSelect Select;
321 LVWarning Warning;
322 LVInternal Internal;
323 LVGeneral General;
324
325 // --attribute.
326 ATTRIBUTE_OPTION(All);
327 ATTRIBUTE_OPTION(Argument);
328 ATTRIBUTE_OPTION(Base);
329 ATTRIBUTE_OPTION(Coverage);
330 ATTRIBUTE_OPTION(Directories);
331 ATTRIBUTE_OPTION(Discarded);
332 ATTRIBUTE_OPTION(Discriminator);
333 ATTRIBUTE_OPTION(Encoded);
334 ATTRIBUTE_OPTION(Extended);
335 ATTRIBUTE_OPTION(Filename);
336 ATTRIBUTE_OPTION(Files);
337 ATTRIBUTE_OPTION(Format);
338 ATTRIBUTE_OPTION(Gaps);
339 ATTRIBUTE_OPTION(Generated);
340 ATTRIBUTE_OPTION(Global);
341 ATTRIBUTE_OPTION(Inserted);
342 ATTRIBUTE_OPTION(Language);
343 ATTRIBUTE_OPTION(Level);
344 ATTRIBUTE_OPTION(Linkage);
345 ATTRIBUTE_OPTION(Location);
346 ATTRIBUTE_OPTION(Local);
347 ATTRIBUTE_OPTION(Offset);
348 ATTRIBUTE_OPTION(Pathname);
349 ATTRIBUTE_OPTION(Producer);
350 ATTRIBUTE_OPTION(Publics);
351 ATTRIBUTE_OPTION(Qualified);
352 ATTRIBUTE_OPTION(Qualifier);
353 ATTRIBUTE_OPTION(Range);
354 ATTRIBUTE_OPTION(Reference);
355 ATTRIBUTE_OPTION(Register);
356 ATTRIBUTE_OPTION(Size);
357 ATTRIBUTE_OPTION(Standard);
358 ATTRIBUTE_OPTION(Subrange);
359 ATTRIBUTE_OPTION(System);
360 ATTRIBUTE_OPTION(Typename);
361 ATTRIBUTE_OPTION(Underlying);
362 ATTRIBUTE_OPTION(Zero);
363 BOOL_FUNCTION(Attribute, Added);
364 BOOL_FUNCTION(Attribute, AnyLocation);
365 BOOL_FUNCTION(Attribute, AnySource);
366 BOOL_FUNCTION(Attribute, Missing);
367
368 // --compare.
369 COMPARE_OPTION(All);
370 COMPARE_OPTION(Lines);
371 COMPARE_OPTION(Scopes);
372 COMPARE_OPTION(Symbols);
373 COMPARE_OPTION(Types);
374 BOOL_FUNCTION(Compare, Context);
375 BOOL_FUNCTION(Compare, Execute);
376 BOOL_FUNCTION(Compare, Print);
377
378 // --output.
379 OUTPUT_OPTION(All);
380 OUTPUT_OPTION(Split);
381 OUTPUT_OPTION(Text);
382 OUTPUT_OPTION(Json);
383 STD_STRING_FUNCTION(Output, Folder);
384 UNSIGNED_FUNCTION(Output, Level);
getSortMode()385 LVSortMode getSortMode() const { return Output.SortMode; }
setSortMode(LVSortMode SortMode)386 void setSortMode(LVSortMode SortMode) { Output.SortMode = SortMode; }
387
388 // --print.
389 PRINT_OPTION(All);
390 PRINT_OPTION(Elements);
391 PRINT_OPTION(Instructions);
392 PRINT_OPTION(Lines);
393 PRINT_OPTION(Scopes);
394 PRINT_OPTION(Sizes);
395 PRINT_OPTION(Symbols);
396 PRINT_OPTION(Summary);
397 PRINT_OPTION(Types);
398 PRINT_OPTION(Warnings);
399 BOOL_FUNCTION(Print, AnyElement);
400 BOOL_FUNCTION(Print, AnyLine);
401 BOOL_FUNCTION(Print, Execute);
402 BOOL_FUNCTION(Print, Formatting);
403 BOOL_FUNCTION(Print, Offset);
404 BOOL_FUNCTION(Print, SizesSummary);
405
406 // --report.
407 REPORT_OPTION(All);
408 REPORT_OPTION(Children);
409 REPORT_OPTION(List);
410 REPORT_OPTION(Parents);
411 REPORT_OPTION(View);
412 BOOL_FUNCTION(Report, AnyView);
413 BOOL_FUNCTION(Report, Execute);
414
415 // --select.
416 BOOL_FUNCTION(Select, IgnoreCase);
417 BOOL_FUNCTION(Select, UseRegex);
418 BOOL_FUNCTION(Select, Execute);
419 BOOL_FUNCTION(Select, GenericKind);
420 BOOL_FUNCTION(Select, GenericPattern);
421 BOOL_FUNCTION(Select, OffsetPattern);
422
423 // --warning.
424 WARNING_OPTION(All);
425 WARNING_OPTION(Coverages);
426 WARNING_OPTION(Lines);
427 WARNING_OPTION(Locations);
428 WARNING_OPTION(Ranges);
429
430 // --internal.
431 INTERNAL_OPTION(All);
432 INTERNAL_OPTION(Cmdline);
433 INTERNAL_OPTION(ID);
434 INTERNAL_OPTION(Integrity);
435 INTERNAL_OPTION(None);
436 INTERNAL_OPTION(Tag);
437
438 // General shortcuts to some combinations.
439 BOOL_FUNCTION(General, CollectRanges);
440
441 LLVM_ABI void print(raw_ostream &OS) const;
442
443 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dump()444 void dump() const { print(dbgs()); }
445 #endif
446 };
447
options()448 inline LVOptions &options() { return (*LVOptions::getOptions()); }
setOptions(LVOptions * Options)449 inline void setOptions(LVOptions *Options) { LVOptions::setOptions(Options); }
450
451 class LVPatterns final {
452 // Pattern Mode.
453 enum class LVMatchMode {
454 None = 0, // No given pattern.
455 Match, // Perfect match.
456 NoCase, // Ignore case.
457 Regex // Regular expression.
458 };
459
460 // Keep the search pattern information.
461 struct LVMatch {
462 std::string Pattern; // Normal pattern.
463 std::shared_ptr<Regex> RE; // Regular Expression Pattern.
464 LVMatchMode Mode = LVMatchMode::None; // Match mode.
465 };
466
467 using LVMatchInfo = std::vector<LVMatch>;
468 LVMatchInfo GenericMatchInfo;
469 using LVMatchOffsets = std::vector<uint64_t>;
470 LVMatchOffsets OffsetMatchInfo;
471
472 // Element selection.
473 LVElementDispatch ElementDispatch;
474 LVLineDispatch LineDispatch;
475 LVScopeDispatch ScopeDispatch;
476 LVSymbolDispatch SymbolDispatch;
477 LVTypeDispatch TypeDispatch;
478
479 // Element selection request.
480 LVElementRequest ElementRequest;
481 LVLineRequest LineRequest;
482 LVScopeRequest ScopeRequest;
483 LVSymbolRequest SymbolRequest;
484 LVTypeRequest TypeRequest;
485
486 // Check an element printing Request.
487 template <typename T, typename U>
checkElementRequest(const T * Element,const U & Requests)488 bool checkElementRequest(const T *Element, const U &Requests) const {
489 assert(Element && "Element must not be nullptr");
490 for (const auto &Request : Requests)
491 if ((Element->*Request)())
492 return true;
493 // Check generic element requests.
494 for (const LVElementGetFunction &Request : ElementRequest)
495 if ((Element->*Request)())
496 return true;
497 return false;
498 }
499
500 // Add an element printing request based on its kind.
501 template <typename T, typename U, typename V>
addRequest(const T & Selection,const U & Dispatch,V & Request)502 void addRequest(const T &Selection, const U &Dispatch, V &Request) const {
503 for (const auto &Entry : Selection) {
504 // Find target function to fullfit request.
505 typename U::const_iterator Iter = Dispatch.find(Entry);
506 if (Iter != Dispatch.end())
507 Request.push_back(Iter->second);
508 }
509 }
510
511 LLVM_ABI void addElement(LVElement *Element);
512
513 template <typename T, typename U>
resolveGenericPatternMatch(T * Element,const U & Requests)514 void resolveGenericPatternMatch(T *Element, const U &Requests) {
515 assert(Element && "Element must not be nullptr");
516 auto CheckPattern = [this, Element]() -> bool {
517 return (Element->isNamed() &&
518 (matchGenericPattern(Element->getName()) ||
519 matchGenericPattern(Element->getLinkageName()))) ||
520 (Element->isTyped() &&
521 matchGenericPattern(Element->getTypeName()));
522 };
523 auto CheckOffset = [this, Element]() -> bool {
524 return matchOffsetPattern(Element->getOffset());
525 };
526 if ((options().getSelectGenericPattern() && CheckPattern()) ||
527 (options().getSelectOffsetPattern() && CheckOffset()) ||
528 ((Requests.size() || ElementRequest.size()) &&
529 checkElementRequest(Element, Requests)))
530 addElement(Element);
531 }
532
533 template <typename U>
resolveGenericPatternMatch(LVLine * Line,const U & Requests)534 void resolveGenericPatternMatch(LVLine *Line, const U &Requests) {
535 assert(Line && "Line must not be nullptr");
536 auto CheckPattern = [this, Line]() -> bool {
537 return matchGenericPattern(Line->lineNumberAsStringStripped()) ||
538 matchGenericPattern(Line->getName()) ||
539 matchGenericPattern(Line->getPathname());
540 };
541 auto CheckOffset = [this, Line]() -> bool {
542 return matchOffsetPattern(Line->getAddress());
543 };
544 if ((options().getSelectGenericPattern() && CheckPattern()) ||
545 (options().getSelectOffsetPattern() && CheckOffset()) ||
546 (Requests.size() && checkElementRequest(Line, Requests)))
547 addElement(Line);
548 }
549
550 Error createMatchEntry(LVMatchInfo &Filters, StringRef Pattern,
551 bool IgnoreCase, bool UseRegex);
552
553 public:
554 LLVM_ABI static LVPatterns *getPatterns();
555
LVPatterns()556 LVPatterns() {
557 ElementDispatch = LVElement::getDispatch();
558 LineDispatch = LVLine::getDispatch();
559 ScopeDispatch = LVScope::getDispatch();
560 SymbolDispatch = LVSymbol::getDispatch();
561 TypeDispatch = LVType::getDispatch();
562 }
563 LVPatterns(const LVPatterns &) = delete;
564 LVPatterns &operator=(const LVPatterns &) = delete;
565 ~LVPatterns() = default;
566
567 // Clear any existing patterns.
clear()568 void clear() {
569 GenericMatchInfo.clear();
570 OffsetMatchInfo.clear();
571 ElementRequest.clear();
572 LineRequest.clear();
573 ScopeRequest.clear();
574 SymbolRequest.clear();
575 TypeRequest.clear();
576
577 options().resetSelectGenericKind();
578 options().resetSelectGenericPattern();
579 options().resetSelectOffsetPattern();
580 }
581
addRequest(LVElementKindSet & Selection)582 void addRequest(LVElementKindSet &Selection) {
583 addRequest(Selection, ElementDispatch, ElementRequest);
584 }
addRequest(LVLineKindSet & Selection)585 void addRequest(LVLineKindSet &Selection) {
586 addRequest(Selection, LineDispatch, LineRequest);
587 }
addRequest(LVScopeKindSet & Selection)588 void addRequest(LVScopeKindSet &Selection) {
589 addRequest(Selection, ScopeDispatch, ScopeRequest);
590 }
addRequest(LVSymbolKindSet & Selection)591 void addRequest(LVSymbolKindSet &Selection) {
592 addRequest(Selection, SymbolDispatch, SymbolRequest);
593 }
addRequest(LVTypeKindSelection & Selection)594 void addRequest(LVTypeKindSelection &Selection) {
595 addRequest(Selection, TypeDispatch, TypeRequest);
596 }
597
598 LLVM_ABI void updateReportOptions();
599
600 LLVM_ABI bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo);
601 // Match a pattern (--select='pattern').
matchGenericPattern(StringRef Input)602 bool matchGenericPattern(StringRef Input) {
603 return matchPattern(Input, GenericMatchInfo);
604 }
matchOffsetPattern(LVOffset Offset)605 bool matchOffsetPattern(LVOffset Offset) {
606 return llvm::is_contained(OffsetMatchInfo, Offset);
607 }
608
resolvePatternMatch(LVLine * Line)609 void resolvePatternMatch(LVLine *Line) {
610 resolveGenericPatternMatch(Line, LineRequest);
611 }
612
resolvePatternMatch(LVScope * Scope)613 void resolvePatternMatch(LVScope *Scope) {
614 resolveGenericPatternMatch(Scope, ScopeRequest);
615 }
616
resolvePatternMatch(LVSymbol * Symbol)617 void resolvePatternMatch(LVSymbol *Symbol) {
618 resolveGenericPatternMatch(Symbol, SymbolRequest);
619 }
620
resolvePatternMatch(LVType * Type)621 void resolvePatternMatch(LVType *Type) {
622 resolveGenericPatternMatch(Type, TypeRequest);
623 }
624
625 LLVM_ABI void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters);
626
627 // Add generic and offset patterns info.
628 LLVM_ABI void addGenericPatterns(StringSet<> &Patterns);
629 LLVM_ABI void addOffsetPatterns(const LVOffsetSet &Patterns);
630
631 // Conditions to print an object.
632 LLVM_ABI bool printElement(const LVLine *Line) const;
633 LLVM_ABI bool printObject(const LVLocation *Location) const;
634 LLVM_ABI bool printElement(const LVScope *Scope) const;
635 LLVM_ABI bool printElement(const LVSymbol *Symbol) const;
636 LLVM_ABI bool printElement(const LVType *Type) const;
637
638 LLVM_ABI void print(raw_ostream &OS) const;
639
640 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
dump()641 void dump() const { print(dbgs()); }
642 #endif
643 };
644
patterns()645 inline LVPatterns &patterns() { return *LVPatterns::getPatterns(); }
646
647 } // namespace logicalview
648 } // namespace llvm
649
650 #endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
651