LLVM 20.0.0git
|
This is a utility class used to parse user-provided text files with "special case lists" for code sanitizers. More...
#include "llvm/Support/SpecialCaseList.h"
Classes | |
class | Matcher |
Represents a set of globs and their line numbers. More... | |
struct | Section |
Public Member Functions | |
~SpecialCaseList () | |
bool | inSection (StringRef Section, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const |
Returns true, if special case list contains a line. | |
unsigned | inSectionBlame (StringRef Section, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const |
Returns the line number corresponding to the special case list entry if the special case list contains a line. | |
Static Public Member Functions | |
static std::unique_ptr< SpecialCaseList > | create (const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS, std::string &Error) |
Parses the special case list entries from files. | |
static std::unique_ptr< SpecialCaseList > | create (const MemoryBuffer *MB, std::string &Error) |
Parses the special case list from a memory buffer. | |
static std::unique_ptr< SpecialCaseList > | createOrDie (const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS) |
Parses the special case list entries from files. | |
Protected Types | |
using | SectionEntries = StringMap< StringMap< Matcher > > |
Protected Member Functions | |
bool | createInternal (const std::vector< std::string > &Paths, vfs::FileSystem &VFS, std::string &Error) |
bool | createInternal (const MemoryBuffer *MB, std::string &Error) |
SpecialCaseList ()=default | |
SpecialCaseList (SpecialCaseList const &)=delete | |
SpecialCaseList & | operator= (SpecialCaseList const &)=delete |
Expected< Section * > | addSection (StringRef SectionStr, unsigned LineNo, bool UseGlobs=true) |
bool | parse (const MemoryBuffer *MB, std::string &Error) |
Parses just-constructed SpecialCaseList entries from a memory buffer. | |
unsigned | inSectionBlame (const SectionEntries &Entries, StringRef Prefix, StringRef Query, StringRef Category) const |
Protected Attributes | |
StringMap< Section > | Sections |
This is a utility class used to parse user-provided text files with "special case lists" for code sanitizers.
Such files are used to define an "ABI list" for DataFlowSanitizer and allow/exclusion lists for sanitizers like AddressSanitizer or UndefinedBehaviorSanitizer.
Empty lines and lines starting with "#" are ignored. Sections are defined using a '[section_name]' header and can be used to specify sanitizers the entries below it apply to. Section names are globs, and entries without a section header match all sections (e.g. an '[*]' header is assumed.) The remaining lines should have the form: prefix:glob_pattern[=category] If category is not specified, it is assumed to be empty string. Definitions of "prefix" and "category" are sanitizer-specific. For example, sanitizer exclusion support prefixes "src", "mainfile", "fun" and "global". "glob_pattern" defines source files, main files, functions or globals which shouldn't be instrumented. Examples of categories: "functional": used in DFSan to list functions with pure functional semantics. "init": used in ASan exclusion list to disable initialization-order bugs detection for certain globals or source files.
[address]
fun:*_ZN4base6subtle* global:global_with_bad_access_or_initialization global:global_with_initialization_issues=init type:Namespace::ClassName=init src:file_with_tricky_code.cc src:ignore-global-initializers-issues.cc=init mainfile:main_file.cc
[dataflow]
fun:cos=functional
Definition at line 69 of file SpecialCaseList.h.
|
protected |
Definition at line 129 of file SpecialCaseList.h.
|
default |
|
protecteddefault |
Referenced by create().
|
protecteddelete |
|
protected |
Definition at line 133 of file SpecialCaseList.cpp.
References llvm::createStringError(), llvm::invalid_argument, llvm::SpecialCaseList::Section::SectionMatcher, Sections, and llvm::toString().
Referenced by parse().
|
static |
Parses the special case list from a memory buffer.
On failure, returns 0 and writes an error message to string.
Definition at line 90 of file SpecialCaseList.cpp.
References SpecialCaseList().
|
static |
Parses the special case list entries from files.
On failure, returns 0 and writes an error message to string.
Definition at line 82 of file SpecialCaseList.cpp.
References SpecialCaseList().
Referenced by createOrDie().
|
protected |
Definition at line 125 of file SpecialCaseList.cpp.
|
protected |
Definition at line 107 of file SpecialCaseList.cpp.
References llvm::ErrorOr< T >::get(), llvm::vfs::FileSystem::getBufferForFile(), and llvm::ErrorOr< T >::getError().
|
static |
Parses the special case list entries from files.
On failure, reports a fatal error.
Definition at line 99 of file SpecialCaseList.cpp.
References create(), and llvm::report_fatal_error().
Referenced by llvm::SanitizerBinaryMetadataPass::run(), and llvm::SanitizerCoveragePass::SanitizerCoveragePass().
bool llvm::SpecialCaseList::inSection | ( | StringRef | Section, |
StringRef | Prefix, | ||
StringRef | Query, | ||
StringRef | Category = StringRef() |
||
) | const |
Returns true, if special case list contains a line.
where @Query satisfies the glob <E> in a given @Section.
Definition at line 207 of file SpecialCaseList.cpp.
References inSectionBlame().
|
protected |
Definition at line 226 of file SpecialCaseList.cpp.
unsigned llvm::SpecialCaseList::inSectionBlame | ( | StringRef | Section, |
StringRef | Prefix, | ||
StringRef | Query, | ||
StringRef | Category = StringRef() |
||
) | const |
Returns the line number corresponding to the special case list entry if the special case list contains a line.
where @Query satisfies the glob <E> in a given @Section. Returns zero if there is no exclusion entry corresponding to this expression.
Definition at line 212 of file SpecialCaseList.cpp.
References inSectionBlame(), and Sections.
Referenced by inSection(), and inSectionBlame().
|
protecteddelete |
|
protected |
Parses just-constructed SpecialCaseList entries from a memory buffer.
Definition at line 146 of file SpecialCaseList.cpp.
References addSection(), llvm::SpecialCaseList::Section::Entries, llvm::MemoryBuffer::getBuffer(), llvm::line_iterator::is_at_eof(), llvm::StringRef::starts_with(), and llvm::toString().
Definition at line 139 of file SpecialCaseList.h.
Referenced by addSection(), and inSectionBlame().