clang-tools 20.0.0git
|
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 , IS_Google_ObjC } |
Supported include styles. More... | |
enum | IncludeKinds { IK_MainTUInclude = 0 , IK_CSystemInclude = 1 , IK_CXXSystemInclude = 2 , IK_NonSystemInclude = 3 , IK_GeneratedInclude = 4 , IK_InvalidInclude = 5 } |
The classifications of inclusions, in the order they should be sorted. More... | |
Public Member Functions | |
IncludeSorter (const SourceManager *SourceMgr, const FileID FileID, StringRef FileName, IncludeStyle Style) | |
IncludeSorter constructor; takes the FileID and name of the file to be processed by the sorter. | |
void | addInclude (StringRef FileName, bool IsAngled, SourceLocation HashLocation, SourceLocation EndLocation) |
Adds the given include directive to the sorter. | |
std::optional< FixItHint > | createIncludeInsertion (StringRef FileName, bool IsAngled) |
Creates a quoted inclusion directive in the right sort order. | |
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 29 of file IncludeSorter.h.
Supported include styles.
Enumerator | |
---|---|
IS_LLVM | |
IS_Google | |
IS_Google_ObjC |
Definition at line 26 of file IncludeSorter.h.
clang::tidy::utils::IncludeSorter::IncludeSorter | ( | const SourceManager * | SourceMgr, |
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 125 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 131 of file IncludeSorter.cpp.
References FileName, IK_InvalidInclude, IsAngled, Kind, and Offset.
std::optional< FixItHint > clang::tidy::utils::IncludeSorter::createIncludeInsertion | ( | StringRef | FileName, |
bool | IsAngled | ||
) |
Creates a quoted inclusion directive in the right sort order.
Returns std::nullopt on error or if header inclusion directive for header already exists.
Definition at line 154 of file IncludeSorter.cpp.
References FileName, IK_InvalidInclude, IS_Google_ObjC, and IsAngled.
Referenced by clang::tidy::utils::IncludeInserter::createIncludeInsertion().