20#define DEBUG_TYPE "Options"
31 auto StandardAttributes = [&]() {
33 setAttributeStandard();
36 setAttributeCoverage();
37 setAttributeDirectories();
38 setAttributeDiscriminator();
39 setAttributeFilename();
42 setAttributeLanguage();
44 setAttributeProducer();
45 setAttributePublics();
47 setAttributeReference();
52 auto ExtendedAttributes = [&]() {
54 setAttributeExtended();
56 setAttributeArgument();
57 setAttributeDiscarded();
58 setAttributeEncoded();
60 setAttributeGenerated();
62 setAttributeInserted();
63 setAttributeLinkage();
65 setAttributeLocation();
67 setAttributePathname();
68 setAttributeQualified();
69 setAttributeQualifier();
70 setAttributeRegister();
72 setAttributeSubrange();
74 setAttributeTypename();
78 if (getAttributeStandard())
82 if (getAttributeExtended())
86 if (getAttributeAll()) {
92 if (getAttributePathname())
93 resetAttributeFilename();
96 if (!getOutputText() && !getOutputJson())
100 if (getOutputAll()) {
107 if (getOutputFolder().length())
111 if (getOutputSplit())
112 setAttributePathname();
115 if (getPrintElements()) {
116 setPrintInstructions();
125 setPrintInstructions();
136 if (getWarningAll()) {
137 setWarningCoverages();
139 setWarningLocations();
144 if (getInternalAll()) {
145 setInternalCmdline();
147 setInternalIntegrity();
153 if (getCompareAll()) {
161 if (getCompareLines() || getCompareSymbols() || getCompareTypes())
165 if (getCompareScopes())
169 if (getPrintInstructions() || getPrintLines())
173 if (getPrintAnyLine() || getPrintScopes() || getPrintSymbols() ||
175 setPrintAnyElement();
178 if (getPrintSizes() && getPrintSummary())
179 setPrintSizesSummary();
182 if (getPrintAll() || getPrintAnyElement() || getPrintSizesSummary() ||
187 if (getReportAll()) {
195 if (getReportView()) {
201 if (getReportParents() || getReportChildren() || getReportView())
205 if (getReportList() || getReportAnyView())
216 if (getCompareExecute()) {
221 setAttributeArgument();
222 setAttributeEncoded();
223 setAttributeInserted();
224 setAttributeMissing();
225 setAttributeQualified();
230 setPrintFormatting();
233 if (getAttributeCoverage() || getAttributeGaps() || getAttributeRegister())
234 setAttributeLocation();
237 if (!getPrintSymbols()) {
238 resetAttributeCoverage();
239 resetAttributeGaps();
240 resetAttributeLocation();
241 resetAttributeRegister();
245 if (getAttributeFilename() || getAttributePathname())
246 setAttributeAnySource();
249 if (getAttributeLocation() || getAttributeRange())
250 setAttributeAnyLocation();
252 if (getAttributeRange() || getPrintAnyLine())
253 setGeneralCollectRanges();
255 calculateIndentationSize();
261void LVOptions::calculateIndentationSize() {
262 if (getInternalID()) {
264 IndentationSize +=
String.length();
266 if (getCompareExecute() && (getAttributeAdded() || getAttributeMissing()))
268 if (getAttributeOffset()) {
270 IndentationSize +=
String.length();
272 if (getAttributeLevel()) {
273 std::stringstream Stream;
274 Stream.str(std::string());
275 Stream <<
"[" << std::setfill(
'0') << std::setw(3) << 0 <<
"]";
276 IndentationSize += Stream.tellp();
278 if (getAttributeGlobal())
286 OS <<
"** Attributes **\n"
287 <<
"All: " << getAttributeAll() <<
", "
288 <<
"Argument: " << getAttributeArgument() <<
", "
289 <<
"Base: " << getAttributeBase() <<
", "
290 <<
"Coverage: " << getAttributeCoverage() <<
"\n"
291 <<
"Directories: " << getAttributeDirectories() <<
", "
292 <<
"Discarded: " << getAttributeDiscarded() <<
", "
293 <<
"Discriminator: " << getAttributeDiscriminator() <<
", "
294 <<
"Encoded: " << getAttributeEncoded() <<
"\n"
295 <<
"Extended: " << getAttributeExtended() <<
", "
296 <<
"Filename: " << getAttributeFilename() <<
", "
297 <<
"Files: " << getAttributeFiles() <<
", "
298 <<
"Format: " << getAttributeFormat() <<
"\n"
299 <<
"Gaps: " << getAttributeGaps() <<
", "
300 <<
"Generated: " << getAttributeGenerated() <<
", "
301 <<
"Global: " << getAttributeGlobal() <<
", "
302 <<
"Inserted: " << getAttributeInserted() <<
"\n"
303 <<
"Level: " << getAttributeLevel() <<
", "
304 <<
"Linkage: " << getAttributeLinkage() <<
", "
305 <<
"Local: " << getAttributeLocal() <<
", "
306 <<
"Location: " << getAttributeLocation() <<
"\n"
307 <<
"Offset: " << getAttributeOffset() <<
", "
308 <<
"Pathname: " << getAttributePathname() <<
", "
309 <<
"Producer: " << getAttributeProducer() <<
", "
310 <<
"Publics: " << getAttributePublics() <<
"\n"
311 <<
"Qualified: " << getAttributeQualified() <<
", "
312 <<
"Qualifier: " << getAttributeQualifier() <<
", "
313 <<
"Range: " << getAttributeRange() <<
", "
314 <<
"Reference: " << getAttributeReference() <<
"\n"
315 <<
"Register: " << getAttributeRegister() <<
", "
316 <<
"Size: " << getAttributeSize() <<
", "
317 <<
"Standard: " << getAttributeStandard() <<
", "
318 <<
"Subrange: " << getAttributeSubrange() <<
"\n"
319 <<
"System: " << getAttributeSystem() <<
", "
320 <<
"Typename: " << getAttributeTypename() <<
", "
321 <<
"Underlying: " << getAttributeUnderlying() <<
", "
322 <<
"Zero: " << getAttributeZero() <<
"\n";
323 OS <<
"Added: " << getAttributeAdded() <<
", "
324 <<
"AnyLocation: " << getAttributeAnyLocation() <<
", "
325 <<
"AnySource: " << getAttributeAnySource() <<
", "
326 <<
"Missing: " << getAttributeMissing() <<
"\n"
330 OS <<
"** Compare **\n"
331 <<
"All: " << getCompareAll() <<
", "
332 <<
"Lines: " << getCompareLines() <<
", "
333 <<
"Scopes: " << getCompareScopes() <<
", "
334 <<
"Symbols: " << getCompareSymbols() <<
", "
335 <<
"Types: " << getCompareTypes() <<
"\n";
336 OS <<
"Context: " << getCompareContext() <<
", "
337 <<
"Execute: " << getCompareExecute() <<
", "
338 <<
"Print: " << getComparePrint() <<
"\n"
342 OS <<
"** Print **\n"
343 <<
"All: " << getPrintAll() <<
", "
344 <<
"Elements: " << getPrintElements() <<
", "
345 <<
"Instructions: " << getPrintInstructions() <<
", "
346 <<
"Lines: " << getPrintLines() <<
"\n"
347 <<
"Scopes: " << getPrintScopes() <<
", "
348 <<
"Sizes: " << getPrintSizes() <<
", "
349 <<
"Summary: " << getPrintSummary() <<
", "
350 <<
"Symbols: " << getPrintSymbols() <<
"\n"
351 <<
"Types: " << getPrintTypes() <<
", "
352 <<
"Warnings: " << getPrintWarnings() <<
"\n";
353 OS <<
"AnyElemeny: " << getPrintAnyElement() <<
", "
354 <<
"AnyLine: " << getPrintAnyLine() <<
", "
355 <<
"Execute: " << getPrintExecute() <<
", "
356 <<
"Formatting: " << getPrintFormatting() <<
"\n"
357 <<
"Offset: " << getPrintOffset() <<
", "
358 <<
"SizesSummary: " << getPrintSizesSummary() <<
"\n"
362 OS <<
"** Report **\n"
363 <<
"All: " << getReportAll() <<
", "
364 <<
"Children: " << getReportChildren() <<
", "
365 <<
"List: " << getReportList() <<
", "
366 <<
"Parents: " << getReportParents() <<
", "
367 <<
"View: " << getReportView() <<
"\n";
368 OS <<
"AnyView: " << getReportAnyView() <<
", "
369 <<
"Execute: " << getReportExecute() <<
"\n"
373 OS <<
"** Select **\n"
374 <<
"IgnoreCase: " << getSelectIgnoreCase() <<
", "
375 <<
"UseRegex: " << getSelectUseRegex() <<
", "
376 <<
"Execute: " << getSelectExecute() <<
", "
377 <<
"GenericKind: " << getSelectGenericKind() <<
"\n"
378 <<
"GenericPattern: " << getSelectGenericPattern() <<
", "
379 <<
"OffsetPattern: " << getSelectOffsetPattern() <<
"\n"
383 OS <<
"** Warning **\n"
384 <<
"All: " << getWarningAll() <<
", "
385 <<
"Coverage: " << getWarningCoverages() <<
", "
386 <<
"Lines: " << getWarningLines() <<
", "
387 <<
"Locations: " << getWarningLocations() <<
", "
388 <<
"Ranges: " << getWarningRanges() <<
"\n"
392 OS <<
"** Internal **\n"
393 <<
"All: " <<
Options.getInternalAll() <<
", "
394 <<
"Cmdline: " <<
Options.getInternalCmdline() <<
", "
395 <<
"ID: " <<
Options.getInternalID() <<
", "
396 <<
"Integrity: " <<
Options.getInternalIntegrity() <<
", "
397 <<
"None: " <<
Options.getInternalNone() <<
"\n"
398 <<
"Tag: " <<
Options.getInternalTag() <<
"\n"
411 bool IgnoreCase,
bool UseRegex) {
415 Match.Pattern = std::string(
Pattern);
420 if (!Match.RE->isValid(
Error))
422 "Error in regular expression: %s",
425 Match.Mode = LVMatchMode::Regex;
426 Filters.push_back(Match);
432 Match.Pattern = std::string(
Pattern);
433 if (Match.Pattern.size()) {
434 Match.Mode = IgnoreCase ? LVMatchMode::NoCase : LVMatchMode::Match;
435 Filters.push_back(Match);
443 if (GenericMatchInfo.size()) {
444 options().setSelectGenericPattern();
451 if (OffsetMatchInfo.size()) {
452 options().setSelectOffsetPattern();
458 bool IgnoreCase =
options().getSelectIgnoreCase();
459 bool UseRegex =
options().getSelectUseRegex();
462 if (
Error Err = createMatchEntry(Filters,
Pattern, IgnoreCase, UseRegex))
467 dbgs() <<
"\nPattern Information:\n";
468 for (LVMatch &Match : Filters)
470 << (Match.Mode == LVMatchMode::Match ?
"Match" :
"Regex")
471 <<
" Pattern: '" << Match.Pattern <<
"'\n";
475void LVPatterns::addElement(
LVElement *Element) {
477 Element->setIsMatched();
481 if (
options().getReportAnyView()) {
483 ?
static_cast<LVScope *
>(Element)
486 if (!Element->getIsScope())
487 Element->setHasPattern();
492 if (ElementRequest.size() || LineRequest.size() || ScopeRequest.size() ||
493 SymbolRequest.size() || TypeRequest.size()) {
494 options().setSelectGenericKind();
500 if (
options().getSelectExecute() && !
options().getReportExecute()) {
508 bool Matched =
false;
513 for (
const LVMatch &Match : MatchInfo) {
514 switch (Match.Mode) {
515 case LVMatchMode::Match:
516 Matched = Input == Match.Pattern;
518 case LVMatchMode::NoCase:
521 case LVMatchMode::Regex:
522 Matched = Match.RE->match(Input);
535 return (
options().getPrintLines() &&
Line->getIsLineDebug()) ||
536 (
options().getPrintInstructions() &&
Line->getIsLineAssembler());
540 if (
options().getAttributeAll())
542 bool DoPrint =
options().getAttributeAnyLocation();
545 DoPrint =
options().getAttributeGaps();
555 return options().getPrintScopes() ||
556 (
options().getPrintSymbols() && Scope->getHasSymbols()) ||
557 (
options().getPrintAnyLine() && Scope->getHasLines()) ||
558 (
options().getPrintTypes() && Scope->getHasTypes()) ||
559 ((
options().getPrintSizesSummary() ||
options().getPrintWarnings()) &&
560 (Scope->getIsRoot() || Scope->getIsCompileUnit()));
565 if (Symbol->getIsArtificial())
566 return options().getAttributeGenerated() &&
options().getPrintSymbols();
567 return options().getPrintSymbols();
572 if (
Type->getIsSubrange())
573 return options().getAttributeSubrange() &&
options().getPrintTypes();
574 return options().getPrintTypes();
578 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 LLVM_ABI void setOptions(LVOptions *Options)
LLVM_ABI void resolveDependencies()
static LLVM_ABI LVOptions * getOptions()
LLVM_ABI void print(raw_ostream &OS) const
void setSortMode(LVSortMode SortMode)
LLVM_ABI void addGenericPatterns(StringSet<> &Patterns)
LLVM_ABI bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo)
LLVM_ABI bool printObject(const LVLocation *Location) const
LLVM_ABI void print(raw_ostream &OS) const
LLVM_ABI bool printElement(const LVLine *Line) const
LLVM_ABI void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters)
LLVM_ABI void updateReportOptions()
LLVM_ABI void addOffsetPatterns(const LVOffsetSet &Patterns)
static LLVM_ABI 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.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_ABI 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.