20#define DEBUG_TYPE "Options"
31 auto StandardAttributes = [&]() {
33 setAttributeStandard();
36 setAttributeCoverage();
37 setAttributeDirectories();
38 setAttributeDiscriminator();
39 setAttributeFilename();
43 setAttributeProducer();
44 setAttributePublics();
46 setAttributeReference();
51 auto ExtendedAttributes = [&]() {
53 setAttributeExtended();
55 setAttributeArgument();
56 setAttributeDiscarded();
57 setAttributeEncoded();
59 setAttributeGenerated();
61 setAttributeInserted();
62 setAttributeLinkage();
64 setAttributeLocation();
66 setAttributePathname();
67 setAttributeQualified();
68 setAttributeQualifier();
69 setAttributeRegister();
70 setAttributeSubrange();
72 setAttributeTypename();
76 if (getAttributeStandard())
80 if (getAttributeExtended())
84 if (getAttributeAll()) {
90 if (getAttributePathname())
91 resetAttributeFilename();
94 if (!getOutputText() && !getOutputJson())
105 if (getOutputFolder().length())
109 if (getOutputSplit())
110 setAttributePathname();
113 if (getPrintElements()) {
114 setPrintInstructions();
123 setPrintInstructions();
134 if (getWarningAll()) {
135 setWarningCoverages();
137 setWarningLocations();
142 if (getInternalAll()) {
143 setInternalCmdline();
145 setInternalIntegrity();
151 if (getCompareAll()) {
159 if (getCompareLines() || getCompareSymbols() || getCompareTypes())
163 if (getCompareScopes())
167 if (getPrintInstructions() || getPrintLines())
171 if (getPrintAnyLine() || getPrintScopes() || getPrintSymbols() ||
173 setPrintAnyElement();
176 if (getPrintSizes() && getPrintSummary())
177 setPrintSizesSummary();
180 if (getPrintAll() || getPrintAnyElement() || getPrintSizesSummary() ||
185 if (getReportAll()) {
193 if (getReportView()) {
199 if (getReportParents() || getReportChildren() || getReportView())
203 if (getReportList() || getReportAnyView())
214 if (getCompareExecute()) {
219 setAttributeArgument();
220 setAttributeEncoded();
221 setAttributeInserted();
222 setAttributeMissing();
223 setAttributeQualified();
227 setPrintFormatting();
230 if (getAttributeCoverage() || getAttributeGaps() || getAttributeRegister())
231 setAttributeLocation();
234 if (!getPrintSymbols()) {
235 resetAttributeCoverage();
236 resetAttributeGaps();
237 resetAttributeLocation();
238 resetAttributeRegister();
242 if (getAttributeFilename() || getAttributePathname())
243 setAttributeAnySource();
246 if (getAttributeLocation() || getAttributeRange())
247 setAttributeAnyLocation();
249 if (getAttributeRange() || getPrintAnyLine())
250 setGeneralCollectRanges();
252 calculateIndentationSize();
258void LVOptions::calculateIndentationSize() {
260 if (getInternalID()) {
262 IndentationSize +=
String.length();
265 if (getCompareExecute() && (getAttributeAdded() || getAttributeMissing()))
267 if (getAttributeOffset()) {
269 IndentationSize +=
String.length();
271 if (getAttributeLevel()) {
272 std::stringstream Stream;
273 Stream.str(std::string());
274 Stream <<
"[" << std::setfill(
'0') << std::setw(3) << 0 <<
"]";
275 IndentationSize += Stream.tellp();
277 if (getAttributeGlobal())
285 OS <<
"** Attributes **\n"
286 <<
"All: " << getAttributeAll() <<
", "
287 <<
"Argument: " << getAttributeArgument() <<
", "
288 <<
"Base: " << getAttributeBase() <<
", "
289 <<
"Coverage: " << getAttributeCoverage() <<
"\n"
290 <<
"Directories: " << getAttributeDirectories() <<
", "
291 <<
"Discarded: " << getAttributeDiscarded() <<
", "
292 <<
"Discriminator: " << getAttributeDiscriminator() <<
", "
293 <<
"Encoded: " << getAttributeEncoded() <<
"\n"
294 <<
"Extended: " << getAttributeExtended() <<
", "
295 <<
"Filename: " << getAttributeFilename() <<
", "
296 <<
"Files: " << getAttributeFiles() <<
", "
297 <<
"Format: " << getAttributeFormat() <<
"\n"
298 <<
"Gaps: " << getAttributeGaps() <<
", "
299 <<
"Generated: " << getAttributeGenerated() <<
", "
300 <<
"Global: " << getAttributeGlobal() <<
", "
301 <<
"Inserted: " << getAttributeInserted() <<
"\n"
302 <<
"Level: " << getAttributeLevel() <<
", "
303 <<
"Linkage: " << getAttributeLinkage() <<
", "
304 <<
"Local: " << getAttributeLocal() <<
", "
305 <<
"Location: " << getAttributeLocation() <<
"\n"
306 <<
"Offset: " << getAttributeOffset() <<
", "
307 <<
"Pathname: " << getAttributePathname() <<
", "
308 <<
"Producer: " << getAttributeProducer() <<
", "
309 <<
"Publics: " << getAttributePublics() <<
"\n"
310 <<
"Qualified: " << getAttributeQualified() <<
", "
311 <<
"Qualifier: " << getAttributeQualifier() <<
", "
312 <<
"Range: " << getAttributeRange() <<
", "
313 <<
"Reference: " << getAttributeReference() <<
"\n"
314 <<
"Register: " << getAttributeRegister() <<
", "
315 <<
"Standard: " << getAttributeStandard() <<
", "
316 <<
"Subrange: " << getAttributeSubrange() <<
", "
317 <<
"System: " << getAttributeSystem() <<
"\n"
318 <<
"Typename: " << getAttributeTypename() <<
", "
319 <<
"Underlying: " << getAttributeUnderlying() <<
", "
320 <<
"Zero: " << getAttributeZero() <<
"\n";
321 OS <<
"Added: " << getAttributeAdded() <<
", "
322 <<
"AnyLocation: " << getAttributeAnyLocation() <<
", "
323 <<
"AnySource: " << getAttributeAnySource() <<
", "
324 <<
"Missing: " << getAttributeMissing() <<
"\n"
328 OS <<
"** Compare **\n"
329 <<
"All: " << getCompareAll() <<
", "
330 <<
"Lines: " << getCompareLines() <<
", "
331 <<
"Scopes: " << getCompareScopes() <<
", "
332 <<
"Symbols: " << getCompareSymbols() <<
", "
333 <<
"Types: " << getCompareTypes() <<
"\n";
334 OS <<
"Context: " << getCompareContext() <<
", "
335 <<
"Execute: " << getCompareExecute() <<
", "
336 <<
"Print: " << getComparePrint() <<
"\n"
340 OS <<
"** Print **\n"
341 <<
"All: " << getPrintAll() <<
", "
342 <<
"Elements: " << getPrintElements() <<
", "
343 <<
"Instructions: " << getPrintInstructions() <<
", "
344 <<
"Lines: " << getPrintLines() <<
"\n"
345 <<
"Scopes: " << getPrintScopes() <<
", "
346 <<
"Sizes: " << getPrintSizes() <<
", "
347 <<
"Summary: " << getPrintSummary() <<
", "
348 <<
"Symbols: " << getPrintSymbols() <<
"\n"
349 <<
"Types: " << getPrintTypes() <<
", "
350 <<
"Warnings: " << getPrintWarnings() <<
"\n";
351 OS <<
"AnyElemeny: " << getPrintAnyElement() <<
", "
352 <<
"AnyLine: " << getPrintAnyLine() <<
", "
353 <<
"Execute: " << getPrintExecute() <<
", "
354 <<
"Formatting: " << getPrintFormatting() <<
"\n"
355 <<
"Offset: " << getPrintOffset() <<
", "
356 <<
"SizesSummary: " << getPrintSizesSummary() <<
"\n"
360 OS <<
"** Report **\n"
361 <<
"All: " << getReportAll() <<
", "
362 <<
"Children: " << getReportChildren() <<
", "
363 <<
"List: " << getReportList() <<
", "
364 <<
"Parents: " << getReportParents() <<
", "
365 <<
"View: " << getReportView() <<
"\n";
366 OS <<
"AnyView: " << getReportAnyView() <<
", "
367 <<
"Execute: " << getReportExecute() <<
"\n"
371 OS <<
"** Select **\n"
372 <<
"IgnoreCase: " << getSelectIgnoreCase() <<
", "
373 <<
"UseRegex: " << getSelectUseRegex() <<
", "
374 <<
"Execute: " << getSelectExecute() <<
", "
375 <<
"GenericKind: " << getSelectGenericKind() <<
"\n"
376 <<
"GenericPattern: " << getSelectGenericPattern() <<
", "
377 <<
"OffsetPattern: " << getSelectOffsetPattern() <<
"\n"
381 OS <<
"** Warning **\n"
382 <<
"All: " << getWarningAll() <<
", "
383 <<
"Coverage: " << getWarningCoverages() <<
", "
384 <<
"Lines: " << getWarningLines() <<
", "
385 <<
"Locations: " << getWarningLocations() <<
", "
386 <<
"Ranges: " << getWarningRanges() <<
"\n"
390 OS <<
"** Internal **\n"
391 <<
"All: " <<
Options.getInternalAll() <<
", "
392 <<
"Cmdline: " <<
Options.getInternalCmdline() <<
", "
393 <<
"ID: " <<
Options.getInternalID() <<
", "
394 <<
"Integrity: " <<
Options.getInternalIntegrity() <<
", "
395 <<
"None: " <<
Options.getInternalNone() <<
"\n"
396 <<
"Tag: " <<
Options.getInternalTag() <<
"\n"
409 bool IgnoreCase,
bool UseRegex) {
420 "Error in regular expression: %s",
423 Match.Mode = LVMatchMode::Regex;
424 Filters.push_back(Match);
431 if (
Match.Pattern.size()) {
432 Match.Mode = IgnoreCase ? LVMatchMode::NoCase : LVMatchMode::Match;
433 Filters.push_back(Match);
441 if (GenericMatchInfo.size()) {
442 options().setSelectGenericPattern();
448 for (
const LVOffset &Entry : Patterns)
449 OffsetMatchInfo.push_back(Entry);
450 if (OffsetMatchInfo.size()) {
451 options().setSelectOffsetPattern();
457 bool IgnoreCase =
options().getSelectIgnoreCase();
458 bool UseRegex =
options().getSelectUseRegex();
461 if (
Error Err = createMatchEntry(Filters,
Pattern, IgnoreCase, UseRegex))
466 dbgs() <<
"\nPattern Information:\n";
467 for (LVMatch &
Match : Filters)
469 << (
Match.Mode == LVMatchMode::Match ?
"Match" :
"Regex")
470 <<
" Pattern: '" <<
Match.Pattern <<
"'\n";
474void LVPatterns::addElement(
LVElement *Element) {
476 Element->setIsMatched();
480 if (
options().getReportAnyView()) {
482 ?
static_cast<LVScope *
>(Element)
485 if (!Element->getIsScope())
486 Element->setHasPattern();
491 if (ElementRequest.size() || LineRequest.size() || ScopeRequest.size() ||
492 SymbolRequest.size() || TypeRequest.size()) {
493 options().setSelectGenericKind();
499 if (
options().getSelectExecute() && !
options().getReportExecute()) {
507 bool Matched =
false;
512 for (
const LVMatch &
Match : MatchInfo) {
513 switch (
Match.Mode) {
514 case LVMatchMode::Match:
515 Matched = Input ==
Match.Pattern;
517 case LVMatchMode::NoCase:
520 case LVMatchMode::Regex:
521 Matched =
Match.RE->match(Input);
534 return (
options().getPrintLines() &&
Line->getIsLineDebug()) ||
535 (
options().getPrintInstructions() &&
Line->getIsLineAssembler());
539 if (
options().getAttributeAll())
541 bool DoPrint =
options().getAttributeAnyLocation();
544 DoPrint =
options().getAttributeGaps();
554 return options().getPrintScopes() ||
555 (
options().getPrintSymbols() && Scope->getHasSymbols()) ||
556 (
options().getPrintAnyLine() && Scope->getHasLines()) ||
557 (
options().getPrintTypes() && Scope->getHasTypes()) ||
558 ((
options().getPrintSizesSummary() ||
options().getPrintWarnings()) &&
559 (Scope->getIsRoot() || Scope->getIsCompileUnit()));
564 if (Symbol->getIsArtificial())
565 return options().getAttributeGenerated() &&
options().getPrintSymbols();
566 return options().getPrintSymbols();
571 if (
Type->getIsSubrange())
572 return options().getAttributeSubrange() &&
options().getPrintTypes();
573 return options().getPrintTypes();
577 OS <<
"LVPatterns\n";
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
@ IgnoreCase
Compile for matching that ignores upper/lower case distinctions.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
StringSet - A wrapper for StringMap that provides set-like functionality.
The instances of the Type class are immutable: once they are created, they are never changed.
LVScope * getParentScope() const
static void setOptions(LVOptions *Options)
void resolveDependencies()
static LVOptions * getOptions()
void print(raw_ostream &OS) const
void setSortMode(LVSortMode SortMode)
void addGenericPatterns(StringSet<> &Patterns)
bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo)
bool printObject(const LVLocation *Location) const
void print(raw_ostream &OS) const
bool printElement(const LVLine *Line) const
void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters)
void updateReportOptions()
void addOffsetPatterns(const LVOffsetSet &Patterns)
static LVPatterns * getPatterns()
void addMatched(LVElement *Element)
This class implements an extremely fast bulk output stream that can only output to a stream.
std::set< uint64_t > LVOffsetSet
LVScopeCompileUnit * getReaderCompileUnit()
std::string hexSquareString(uint64_t Value)
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void consumeError(Error Err)
Consume a Error without doing anything.