clang-tools
9.0.0
|
Class used by IncludeInserterCallback
to record the names of the inclusions in a given source file being processed and generate the necessary commands to sort the inclusions according to the precedence encoded in IncludeKinds
.
More...
#include <IncludeSorter.h>
Public Types | |
enum | IncludeStyle { IS_LLVM = 0, IS_Google = 1 } |
Supported include styles. More... | |
enum | IncludeKinds { IK_MainTUInclude = 0, IK_CSystemInclude = 1, IK_CXXSystemInclude = 2, IK_NonSystemInclude = 3, IK_InvalidInclude = 4 } |
The classifications of inclusions, in the order they should be sorted. More... | |
Public Member Functions | |
IncludeSorter (const SourceManager *SourceMgr, const LangOptions *LangOpts, const FileID FileID, StringRef FileName, IncludeStyle Style) | |
IncludeSorter constructor; takes the FileID and name of the file to be processed by the sorter. More... | |
const FileID | current_FileID () const |
Returns the SourceManager -specific file ID for the file being handled by the sorter. More... | |
void | AddInclude (StringRef FileName, bool IsAngled, SourceLocation HashLocation, SourceLocation EndLocation) |
Adds the given include directive to the sorter. More... | |
std::vector< FixItHint > | GetEdits () |
Returns the edits needed to sort the current set of includes and reset the internal state (so that different blocks of includes are sorted separately within the same file). More... | |
Optional< FixItHint > | CreateIncludeInsertion (StringRef FileName, bool IsAngled) |
Creates a quoted inclusion directive in the right sort order. More... | |
Static Public Member Functions | |
static IncludeStyle | parseIncludeStyle (const std::string &Value) |
Converts "llvm" to IS_LLVM , otherwise returns IS_Google . More... | |
static StringRef | toString (IncludeStyle Style) |
Converts IncludeStyle to string representation. More... | |
Class used by IncludeInserterCallback
to record the names of the inclusions in a given source file being processed and generate the necessary commands to sort the inclusions according to the precedence encoded in IncludeKinds
.
Definition at line 23 of file IncludeSorter.h.
The classifications of inclusions, in the order they should be sorted.
Definition at line 35 of file IncludeSorter.h.
Supported include styles.
Enumerator | |
---|---|
IS_LLVM | |
IS_Google |
Definition at line 26 of file IncludeSorter.h.
clang::tidy::utils::IncludeSorter::IncludeSorter | ( | const SourceManager * | SourceMgr, |
const LangOptions * | LangOpts, | ||
const FileID | FileID, | ||
StringRef | FileName, | ||
IncludeStyle | Style | ||
) |
IncludeSorter
constructor; takes the FileID and name of the file to be processed by the sorter.
Definition at line 85 of file IncludeSorter.cpp.
void clang::tidy::utils::IncludeSorter::AddInclude | ( | StringRef | FileName, |
bool | IsAngled, | ||
SourceLocation | HashLocation, | ||
SourceLocation | EndLocation | ||
) |
Adds the given include directive to the sorter.
Definition at line 92 of file IncludeSorter.cpp.
References FileName, IK_InvalidInclude, Kind, and Offset.
Referenced by current_FileID().
Optional< FixItHint > clang::tidy::utils::IncludeSorter::CreateIncludeInsertion | ( | StringRef | FileName, |
bool | IsAngled | ||
) |
Creates a quoted inclusion directive in the right sort order.
Returns None on error or if header inclusion directive for header already exists.
Definition at line 113 of file IncludeSorter.cpp.
References IK_InvalidInclude.
Referenced by current_FileID().
|
inline |
Returns the SourceManager
-specific file ID for the file being handled by the sorter.
Definition at line 50 of file IncludeSorter.h.
References AddInclude(), CreateIncludeInsertion(), FileName, GetEdits(), IK_InvalidInclude, and IsAngled.
std::vector< FixItHint > clang::tidy::utils::IncludeSorter::GetEdits | ( | ) |
Returns the edits needed to sort the current set of includes and reset the internal state (so that different blocks of includes are sorted separately within the same file).
Definition at line 178 of file IncludeSorter.cpp.
References IK_InvalidInclude.
Referenced by current_FileID().
|
static |
Converts "llvm" to IS_LLVM
, otherwise returns IS_Google
.
Definition at line 279 of file IncludeSorter.cpp.
|
static |
Converts IncludeStyle
to string representation.
Definition at line 283 of file IncludeSorter.cpp.
References IS_LLVM.