Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:43

0001 //===-- LVOptions.h ---------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the LVOptions class, which is used to record the command
0010 // line options.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
0015 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H
0016 
0017 #include "llvm/ADT/StringSet.h"
0018 #include "llvm/DebugInfo/LogicalView/Core/LVLine.h"
0019 #include "llvm/DebugInfo/LogicalView/Core/LVScope.h"
0020 #include "llvm/DebugInfo/LogicalView/Core/LVSymbol.h"
0021 #include "llvm/DebugInfo/LogicalView/Core/LVType.h"
0022 #include "llvm/Support/Regex.h"
0023 #include <set>
0024 #include <string>
0025 
0026 namespace llvm {
0027 namespace logicalview {
0028 
0029 // Generate get and set 'bool' functions.
0030 #define BOOL_FUNCTION(FAMILY, FIELD)                                           \
0031   bool get##FAMILY##FIELD() const { return FAMILY.FIELD; }                     \
0032   void set##FAMILY##FIELD() { FAMILY.FIELD = true; }                           \
0033   void reset##FAMILY##FIELD() { FAMILY.FIELD = false; }
0034 
0035 // Generate get and set 'unsigned' functions.
0036 #define UNSIGNED_FUNCTION(FAMILY, FIELD)                                       \
0037   unsigned get##FAMILY##FIELD() const { return FAMILY.FIELD; }                 \
0038   void set##FAMILY##FIELD(unsigned Value) { FAMILY.FIELD = Value; }            \
0039   void reset##FAMILY##FIELD() { FAMILY.FIELD = -1U; }
0040 
0041 // Generate get and set 'std::string' functions.
0042 #define STD_STRING_FUNCTION(FAMILY, FIELD)                                     \
0043   std::string get##FAMILY##FIELD() const { return FAMILY.FIELD; }              \
0044   void set##FAMILY##FIELD(std::string FIELD) { FAMILY.FIELD = FIELD; }         \
0045   void reset##FAMILY##FIELD() { FAMILY.FIELD = ""; }
0046 
0047 // Generate get and set 'std::set' functions.
0048 #define STDSET_FUNCTION_4(FAMILY, FIELD, TYPE, SET)                            \
0049   bool get##FAMILY##FIELD() const {                                            \
0050     return FAMILY.SET.find(TYPE::FIELD) != FAMILY.SET.end();                   \
0051   }                                                                            \
0052   void set##FAMILY##FIELD() { FAMILY.SET.insert(TYPE::FIELD); }                \
0053   void reset##FAMILY##FIELD() {                                                \
0054     std::set<TYPE>::iterator Iter = FAMILY.SET.find(TYPE::FIELD);              \
0055     if (Iter != FAMILY.SET.end())                                              \
0056       FAMILY.SET.erase(Iter);                                                  \
0057   }
0058 
0059 #define STDSET_FUNCTION_5(FAMILY, FIELD, ENTRY, TYPE, SET)                     \
0060   bool get##FAMILY##FIELD##ENTRY() const {                                     \
0061     return FAMILY.SET.find(TYPE::ENTRY) != FAMILY.SET.end();                   \
0062   }                                                                            \
0063   void set##FAMILY##FIELD##ENTRY() { FAMILY.SET.insert(TYPE::ENTRY); }
0064 
0065 // Generate get and set functions for '--attribute'
0066 #define ATTRIBUTE_OPTION(FIELD)                                                \
0067   STDSET_FUNCTION_4(Attribute, FIELD, LVAttributeKind, Kinds)
0068 
0069 // Generate get and set functions for '--output'
0070 #define OUTPUT_OPTION(FIELD)                                                   \
0071   STDSET_FUNCTION_4(Output, FIELD, LVOutputKind, Kinds)
0072 
0073 // Generate get and set functions for '--print'
0074 #define PRINT_OPTION(FIELD) STDSET_FUNCTION_4(Print, FIELD, LVPrintKind, Kinds)
0075 
0076 // Generate get and set functions for '--warning'
0077 #define WARNING_OPTION(FIELD)                                                  \
0078   STDSET_FUNCTION_4(Warning, FIELD, LVWarningKind, Kinds)
0079 
0080 // Generate get and set functions for '--compare'
0081 #define COMPARE_OPTION(FIELD)                                                  \
0082   STDSET_FUNCTION_4(Compare, FIELD, LVCompareKind, Elements)
0083 
0084 // Generate get and set functions for '--report'
0085 #define REPORT_OPTION(FIELD)                                                   \
0086   STDSET_FUNCTION_4(Report, FIELD, LVReportKind, Kinds)
0087 
0088 // Generate get and set functions for '--internal'
0089 #define INTERNAL_OPTION(FIELD)                                                 \
0090   STDSET_FUNCTION_4(Internal, FIELD, LVInternalKind, Kinds)
0091 
0092 using LVOffsetSet = std::set<uint64_t>;
0093 
0094 enum class LVAttributeKind {
0095   All,           // --attribute=all
0096   Argument,      // --attribute=argument
0097   Base,          // --attribute=base
0098   Coverage,      // --attribute=coverage
0099   Directories,   // --attribute=directories
0100   Discarded,     // --attribute=discarded
0101   Discriminator, // --attribute=discriminator
0102   Encoded,       // --attribute=encoded
0103   Extended,      // --attribute=extended
0104   Filename,      // --attribute=filename
0105   Files,         // --attribute=files
0106   Format,        // --attribute=format
0107   Gaps,          // --attribute=gaps
0108   Generated,     // --attribute=generated
0109   Global,        // --attribute=global
0110   Inserted,      // --attribute=inserted
0111   Level,         // --attribute=level
0112   Linkage,       // --attribute=linkage
0113   Local,         // --attribute=local
0114   Location,      // --attribute=location
0115   Offset,        // --attribute=offset
0116   Pathname,      // --attribute=pathname
0117   Producer,      // --attribute=producer
0118   Publics,       // --attribute=publics
0119   Qualified,     // --attribute=qualified
0120   Qualifier,     // --attribute=qualifier
0121   Range,         // --attribute=range
0122   Reference,     // --attribute=reference
0123   Register,      // --attribute=register
0124   Standard,      // --attribute=standard
0125   Subrange,      // --attribute=subrange
0126   System,        // --attribute=system
0127   Typename,      // --attribute=typename
0128   Underlying,    // --attribute=underlying
0129   Zero           // --attribute=zero
0130 };
0131 using LVAttributeKindSet = std::set<LVAttributeKind>;
0132 
0133 enum class LVCompareKind {
0134   All,     // --compare=all
0135   Lines,   // --compare=lines
0136   Scopes,  // --compare=scopes
0137   Symbols, // --compare=symbols
0138   Types    // --compare=types
0139 };
0140 using LVCompareKindSet = std::set<LVCompareKind>;
0141 
0142 enum class LVOutputKind {
0143   All,   // --output=all
0144   Split, // --output=split
0145   Json,  // --output=json
0146   Text   // --output=text
0147 };
0148 using LVOutputKindSet = std::set<LVOutputKind>;
0149 
0150 enum class LVPrintKind {
0151   All,          // --print=all
0152   Elements,     // --print=elements
0153   Instructions, // --print=instructions
0154   Lines,        // --print=lines
0155   Scopes,       // --print=scopes
0156   Sizes,        // --print=sizes
0157   Symbols,      // --print=symbols
0158   Summary,      // --print=summary
0159   Types,        // --print=types
0160   Warnings      // --print=warnings
0161 };
0162 using LVPrintKindSet = std::set<LVPrintKind>;
0163 
0164 enum class LVReportKind {
0165   All,      // --report=all
0166   Children, // --report=children
0167   List,     // --report=list
0168   Parents,  // --report=parents
0169   View      // --report=view
0170 };
0171 using LVReportKindSet = std::set<LVReportKind>;
0172 
0173 enum class LVWarningKind {
0174   All,       // --warning=all
0175   Coverages, // --warning=coverages
0176   Lines,     // --warning=lines
0177   Locations, // --warning=locations
0178   Ranges     // --warning=ranges
0179 };
0180 using LVWarningKindSet = std::set<LVWarningKind>;
0181 
0182 enum class LVInternalKind {
0183   All,       // --internal=all
0184   Cmdline,   // --internal=cmdline
0185   ID,        // --internal=id
0186   Integrity, // --internal=integrity
0187   None,      // --internal=none
0188   Tag        // --internal=tag
0189 };
0190 using LVInternalKindSet = std::set<LVInternalKind>;
0191 
0192 // The 'Kinds' members are a one-to-one mapping to the associated command
0193 // options that supports comma separated values. There are other 'bool'
0194 // members that in very few cases point to a command option (see associated
0195 // comment). Other cases for 'bool' refers to internal values derivated from
0196 // the command options.
0197 class LVOptions {
0198   class LVAttribute {
0199   public:
0200     LVAttributeKindSet Kinds; // --attribute=<Kind>
0201     bool Added = false;       // Added elements found during comparison.
0202     bool AnyLocation = false; // Any kind of location information.
0203     bool AnySource = false;   // Any kind of source information.
0204     bool Missing = false;     // Missing elements found during comparison.
0205   };
0206 
0207   class LVCompare {
0208   public:
0209     LVCompareKindSet Elements; // --compare=<kind>
0210     bool Context = false;      // --compare-context
0211     bool Execute = false;      // Compare requested.
0212     bool Print = false;        // Enable any printing.
0213   };
0214 
0215   class LVPrint {
0216   public:
0217     LVPrintKindSet Kinds;      // --print=<Kind>
0218     bool AnyElement = false;   // Request to print any element.
0219     bool AnyLine = false;      // Print 'lines' or 'instructions'.
0220     bool Execute = false;      // Print requested.
0221     bool Formatting = true;    // Disable formatting during printing.
0222     bool Offset = false;       // Print offsets while formatting is disabled.
0223     bool SizesSummary = false; // Print 'sizes' or 'summary'.
0224   };
0225 
0226   class LVReport {
0227   public:
0228     LVReportKindSet Kinds; // --report=<kind>
0229     bool AnyView = false;  // View, Parents or Children.
0230     bool Execute = false;  // Report requested.
0231   };
0232 
0233   class LVSelect {
0234   public:
0235     bool IgnoreCase = false;     // --select-ignore-case
0236     bool UseRegex = false;       // --select-use-regex
0237     bool Execute = false;        // Select requested.
0238     bool GenericKind = false;    // We have collected generic kinds.
0239     bool GenericPattern = false; // We have collected generic patterns.
0240     bool OffsetPattern = false;  // We have collected offset patterns.
0241     StringSet<> Generic;         // --select=<Pattern>
0242     LVOffsetSet Offsets;         // --select-offset=<Offset>
0243     LVElementKindSet Elements;   // --select-elements=<Kind>
0244     LVLineKindSet Lines;         // --select-lines=<Kind>
0245     LVScopeKindSet Scopes;       // --select-scopes=<Kind>
0246     LVSymbolKindSet Symbols;     // --select-symbols=<Kind>
0247     LVTypeKindSelection Types;   // --select-types=<Kind>
0248   };
0249 
0250   class LVOutput {
0251   public:
0252     LVOutputKindSet Kinds;                  // --output=<kind>
0253     LVSortMode SortMode = LVSortMode::None; // --output-sort=<SortMode>
0254     std::string Folder;                     // --output-folder=<Folder>
0255     unsigned Level = -1U;                   // --output-level=<level>
0256   };
0257 
0258   class LVWarning {
0259   public:
0260     LVWarningKindSet Kinds; // --warning=<Kind>
0261   };
0262 
0263   class LVInternal {
0264   public:
0265     LVInternalKindSet Kinds; // --internal=<Kind>
0266   };
0267 
0268   class LVGeneral {
0269   public:
0270     bool CollectRanges = false; // Collect ranges information.
0271   };
0272 
0273   // Filters the output of the filename associated with the element being
0274   // printed in order to see clearly which logical elements belongs to
0275   // a particular filename. It is value is reset after the element
0276   // that represents the Compile Unit is printed.
0277   size_t LastFilenameIndex = 0;
0278 
0279   // Controls the amount of additional spaces to insert when printing
0280   // object attributes, in order to get a consistent printing layout.
0281   size_t IndentationSize = 0;
0282 
0283   // Calculate the indentation size, so we can use that value when printing
0284   // additional attributes to objects, such as location.
0285   void calculateIndentationSize();
0286 
0287 public:
0288   void resetFilenameIndex() { LastFilenameIndex = 0; }
0289   bool changeFilenameIndex(size_t Index) {
0290     bool IndexChanged = (Index != LastFilenameIndex);
0291     if (IndexChanged)
0292       LastFilenameIndex = Index;
0293     return IndexChanged;
0294   }
0295 
0296   // Access to command line options, pattern and printing information.
0297   static LVOptions *getOptions();
0298   static void setOptions(LVOptions *Options);
0299 
0300   LVOptions() = default;
0301   LVOptions(const LVOptions &) = default;
0302   LVOptions &operator=(const LVOptions &) = default;
0303   ~LVOptions() = default;
0304 
0305   // Some command line options support shortcuts. For example:
0306   // The command line option '--print=elements' is a shortcut for:
0307   // '--print=instructions,lines,scopes,symbols,types'.
0308   // In the case of logical view comparison, some options related to
0309   // attributes must be set or reset for a proper comparison.
0310   // Resolve any dependencies between command line options.
0311   void resolveDependencies();
0312   size_t indentationSize() const { return IndentationSize; }
0313 
0314   LVAttribute Attribute;
0315   LVCompare Compare;
0316   LVOutput Output;
0317   LVPrint Print;
0318   LVReport Report;
0319   LVSelect Select;
0320   LVWarning Warning;
0321   LVInternal Internal;
0322   LVGeneral General;
0323 
0324   // --attribute.
0325   ATTRIBUTE_OPTION(All);
0326   ATTRIBUTE_OPTION(Argument);
0327   ATTRIBUTE_OPTION(Base);
0328   ATTRIBUTE_OPTION(Coverage);
0329   ATTRIBUTE_OPTION(Directories);
0330   ATTRIBUTE_OPTION(Discarded);
0331   ATTRIBUTE_OPTION(Discriminator);
0332   ATTRIBUTE_OPTION(Encoded);
0333   ATTRIBUTE_OPTION(Extended);
0334   ATTRIBUTE_OPTION(Filename);
0335   ATTRIBUTE_OPTION(Files);
0336   ATTRIBUTE_OPTION(Format);
0337   ATTRIBUTE_OPTION(Gaps);
0338   ATTRIBUTE_OPTION(Generated);
0339   ATTRIBUTE_OPTION(Global);
0340   ATTRIBUTE_OPTION(Inserted);
0341   ATTRIBUTE_OPTION(Level);
0342   ATTRIBUTE_OPTION(Linkage);
0343   ATTRIBUTE_OPTION(Location);
0344   ATTRIBUTE_OPTION(Local);
0345   ATTRIBUTE_OPTION(Offset);
0346   ATTRIBUTE_OPTION(Pathname);
0347   ATTRIBUTE_OPTION(Producer);
0348   ATTRIBUTE_OPTION(Publics);
0349   ATTRIBUTE_OPTION(Qualified);
0350   ATTRIBUTE_OPTION(Qualifier);
0351   ATTRIBUTE_OPTION(Range);
0352   ATTRIBUTE_OPTION(Reference);
0353   ATTRIBUTE_OPTION(Register);
0354   ATTRIBUTE_OPTION(Standard);
0355   ATTRIBUTE_OPTION(Subrange);
0356   ATTRIBUTE_OPTION(System);
0357   ATTRIBUTE_OPTION(Typename);
0358   ATTRIBUTE_OPTION(Underlying);
0359   ATTRIBUTE_OPTION(Zero);
0360   BOOL_FUNCTION(Attribute, Added);
0361   BOOL_FUNCTION(Attribute, AnyLocation);
0362   BOOL_FUNCTION(Attribute, AnySource);
0363   BOOL_FUNCTION(Attribute, Missing);
0364 
0365   // --compare.
0366   COMPARE_OPTION(All);
0367   COMPARE_OPTION(Lines);
0368   COMPARE_OPTION(Scopes);
0369   COMPARE_OPTION(Symbols);
0370   COMPARE_OPTION(Types);
0371   BOOL_FUNCTION(Compare, Context);
0372   BOOL_FUNCTION(Compare, Execute);
0373   BOOL_FUNCTION(Compare, Print);
0374 
0375   // --output.
0376   OUTPUT_OPTION(All);
0377   OUTPUT_OPTION(Split);
0378   OUTPUT_OPTION(Text);
0379   OUTPUT_OPTION(Json);
0380   STD_STRING_FUNCTION(Output, Folder);
0381   UNSIGNED_FUNCTION(Output, Level);
0382   LVSortMode getSortMode() const { return Output.SortMode; }
0383   void setSortMode(LVSortMode SortMode) { Output.SortMode = SortMode; }
0384 
0385   // --print.
0386   PRINT_OPTION(All);
0387   PRINT_OPTION(Elements);
0388   PRINT_OPTION(Instructions);
0389   PRINT_OPTION(Lines);
0390   PRINT_OPTION(Scopes);
0391   PRINT_OPTION(Sizes);
0392   PRINT_OPTION(Symbols);
0393   PRINT_OPTION(Summary);
0394   PRINT_OPTION(Types);
0395   PRINT_OPTION(Warnings);
0396   BOOL_FUNCTION(Print, AnyElement);
0397   BOOL_FUNCTION(Print, AnyLine);
0398   BOOL_FUNCTION(Print, Execute);
0399   BOOL_FUNCTION(Print, Formatting);
0400   BOOL_FUNCTION(Print, Offset);
0401   BOOL_FUNCTION(Print, SizesSummary);
0402 
0403   // --report.
0404   REPORT_OPTION(All);
0405   REPORT_OPTION(Children);
0406   REPORT_OPTION(List);
0407   REPORT_OPTION(Parents);
0408   REPORT_OPTION(View);
0409   BOOL_FUNCTION(Report, AnyView);
0410   BOOL_FUNCTION(Report, Execute);
0411 
0412   // --select.
0413   BOOL_FUNCTION(Select, IgnoreCase);
0414   BOOL_FUNCTION(Select, UseRegex);
0415   BOOL_FUNCTION(Select, Execute);
0416   BOOL_FUNCTION(Select, GenericKind);
0417   BOOL_FUNCTION(Select, GenericPattern);
0418   BOOL_FUNCTION(Select, OffsetPattern);
0419 
0420   // --warning.
0421   WARNING_OPTION(All);
0422   WARNING_OPTION(Coverages);
0423   WARNING_OPTION(Lines);
0424   WARNING_OPTION(Locations);
0425   WARNING_OPTION(Ranges);
0426 
0427   // --internal.
0428   INTERNAL_OPTION(All);
0429   INTERNAL_OPTION(Cmdline);
0430   INTERNAL_OPTION(ID);
0431   INTERNAL_OPTION(Integrity);
0432   INTERNAL_OPTION(None);
0433   INTERNAL_OPTION(Tag);
0434 
0435   // General shortcuts to some combinations.
0436   BOOL_FUNCTION(General, CollectRanges);
0437 
0438   void print(raw_ostream &OS) const;
0439 
0440 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0441   void dump() const { print(dbgs()); }
0442 #endif
0443 };
0444 
0445 inline LVOptions &options() { return (*LVOptions::getOptions()); }
0446 inline void setOptions(LVOptions *Options) { LVOptions::setOptions(Options); }
0447 
0448 class LVPatterns final {
0449   // Pattern Mode.
0450   enum class LVMatchMode {
0451     None = 0, // No given pattern.
0452     Match,    // Perfect match.
0453     NoCase,   // Ignore case.
0454     Regex     // Regular expression.
0455   };
0456 
0457   // Keep the search pattern information.
0458   struct LVMatch {
0459     std::string Pattern;                  // Normal pattern.
0460     std::shared_ptr<Regex> RE;            // Regular Expression Pattern.
0461     LVMatchMode Mode = LVMatchMode::None; // Match mode.
0462   };
0463 
0464   using LVMatchInfo = std::vector<LVMatch>;
0465   LVMatchInfo GenericMatchInfo;
0466   using LVMatchOffsets = std::vector<uint64_t>;
0467   LVMatchOffsets OffsetMatchInfo;
0468 
0469   // Element selection.
0470   LVElementDispatch ElementDispatch;
0471   LVLineDispatch LineDispatch;
0472   LVScopeDispatch ScopeDispatch;
0473   LVSymbolDispatch SymbolDispatch;
0474   LVTypeDispatch TypeDispatch;
0475 
0476   // Element selection request.
0477   LVElementRequest ElementRequest;
0478   LVLineRequest LineRequest;
0479   LVScopeRequest ScopeRequest;
0480   LVSymbolRequest SymbolRequest;
0481   LVTypeRequest TypeRequest;
0482 
0483   // Check an element printing Request.
0484   template <typename T, typename U>
0485   bool checkElementRequest(const T *Element, const U &Requests) const {
0486     assert(Element && "Element must not be nullptr");
0487     for (const auto &Request : Requests)
0488       if ((Element->*Request)())
0489         return true;
0490     // Check generic element requests.
0491     for (const LVElementGetFunction &Request : ElementRequest)
0492       if ((Element->*Request)())
0493         return true;
0494     return false;
0495   }
0496 
0497   // Add an element printing request based on its kind.
0498   template <typename T, typename U, typename V>
0499   void addRequest(const T &Selection, const U &Dispatch, V &Request) const {
0500     for (const auto &Entry : Selection) {
0501       // Find target function to fullfit request.
0502       typename U::const_iterator Iter = Dispatch.find(Entry);
0503       if (Iter != Dispatch.end())
0504         Request.push_back(Iter->second);
0505     }
0506   }
0507 
0508   void addElement(LVElement *Element);
0509 
0510   template <typename T, typename U>
0511   void resolveGenericPatternMatch(T *Element, const U &Requests) {
0512     assert(Element && "Element must not be nullptr");
0513     auto CheckPattern = [this, Element]() -> bool {
0514       return (Element->isNamed() &&
0515               (matchGenericPattern(Element->getName()) ||
0516                matchGenericPattern(Element->getLinkageName()))) ||
0517              (Element->isTyped() &&
0518               matchGenericPattern(Element->getTypeName()));
0519     };
0520     auto CheckOffset = [this, Element]() -> bool {
0521       return matchOffsetPattern(Element->getOffset());
0522     };
0523     if ((options().getSelectGenericPattern() && CheckPattern()) ||
0524         (options().getSelectOffsetPattern() && CheckOffset()) ||
0525         ((Requests.size() || ElementRequest.size()) &&
0526          checkElementRequest(Element, Requests)))
0527       addElement(Element);
0528   }
0529 
0530   template <typename U>
0531   void resolveGenericPatternMatch(LVLine *Line, const U &Requests) {
0532     assert(Line && "Line must not be nullptr");
0533     auto CheckPattern = [this, Line]() -> bool {
0534       return matchGenericPattern(Line->lineNumberAsStringStripped()) ||
0535              matchGenericPattern(Line->getName()) ||
0536              matchGenericPattern(Line->getPathname());
0537     };
0538     auto CheckOffset = [this, Line]() -> bool {
0539       return matchOffsetPattern(Line->getAddress());
0540     };
0541     if ((options().getSelectGenericPattern() && CheckPattern()) ||
0542         (options().getSelectOffsetPattern() && CheckOffset()) ||
0543         (Requests.size() && checkElementRequest(Line, Requests)))
0544       addElement(Line);
0545   }
0546 
0547   Error createMatchEntry(LVMatchInfo &Filters, StringRef Pattern,
0548                          bool IgnoreCase, bool UseRegex);
0549 
0550 public:
0551   static LVPatterns *getPatterns();
0552 
0553   LVPatterns() {
0554     ElementDispatch = LVElement::getDispatch();
0555     LineDispatch = LVLine::getDispatch();
0556     ScopeDispatch = LVScope::getDispatch();
0557     SymbolDispatch = LVSymbol::getDispatch();
0558     TypeDispatch = LVType::getDispatch();
0559   }
0560   LVPatterns(const LVPatterns &) = delete;
0561   LVPatterns &operator=(const LVPatterns &) = delete;
0562   ~LVPatterns() = default;
0563 
0564   // Clear any existing patterns.
0565   void clear() {
0566     GenericMatchInfo.clear();
0567     OffsetMatchInfo.clear();
0568     ElementRequest.clear();
0569     LineRequest.clear();
0570     ScopeRequest.clear();
0571     SymbolRequest.clear();
0572     TypeRequest.clear();
0573 
0574     options().resetSelectGenericKind();
0575     options().resetSelectGenericPattern();
0576     options().resetSelectOffsetPattern();
0577   }
0578 
0579   void addRequest(LVElementKindSet &Selection) {
0580     addRequest(Selection, ElementDispatch, ElementRequest);
0581   }
0582   void addRequest(LVLineKindSet &Selection) {
0583     addRequest(Selection, LineDispatch, LineRequest);
0584   }
0585   void addRequest(LVScopeKindSet &Selection) {
0586     addRequest(Selection, ScopeDispatch, ScopeRequest);
0587   }
0588   void addRequest(LVSymbolKindSet &Selection) {
0589     addRequest(Selection, SymbolDispatch, SymbolRequest);
0590   }
0591   void addRequest(LVTypeKindSelection &Selection) {
0592     addRequest(Selection, TypeDispatch, TypeRequest);
0593   }
0594 
0595   void updateReportOptions();
0596 
0597   bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo);
0598   // Match a pattern (--select='pattern').
0599   bool matchGenericPattern(StringRef Input) {
0600     return matchPattern(Input, GenericMatchInfo);
0601   }
0602   bool matchOffsetPattern(LVOffset Offset) {
0603     return llvm::is_contained(OffsetMatchInfo, Offset);
0604   }
0605 
0606   void resolvePatternMatch(LVLine *Line) {
0607     resolveGenericPatternMatch(Line, LineRequest);
0608   }
0609 
0610   void resolvePatternMatch(LVScope *Scope) {
0611     resolveGenericPatternMatch(Scope, ScopeRequest);
0612   }
0613 
0614   void resolvePatternMatch(LVSymbol *Symbol) {
0615     resolveGenericPatternMatch(Symbol, SymbolRequest);
0616   }
0617 
0618   void resolvePatternMatch(LVType *Type) {
0619     resolveGenericPatternMatch(Type, TypeRequest);
0620   }
0621 
0622   void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters);
0623 
0624   // Add generic and offset patterns info.
0625   void addGenericPatterns(StringSet<> &Patterns);
0626   void addOffsetPatterns(const LVOffsetSet &Patterns);
0627 
0628   // Conditions to print an object.
0629   bool printElement(const LVLine *Line) const;
0630   bool printObject(const LVLocation *Location) const;
0631   bool printElement(const LVScope *Scope) const;
0632   bool printElement(const LVSymbol *Symbol) const;
0633   bool printElement(const LVType *Type) const;
0634 
0635   void print(raw_ostream &OS) const;
0636 
0637 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0638   void dump() const { print(dbgs()); }
0639 #endif
0640 };
0641 
0642 inline LVPatterns &patterns() { return *LVPatterns::getPatterns(); }
0643 
0644 } // namespace logicalview
0645 } // namespace llvm
0646 
0647 #endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVOPTIONS_H