9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
26 enum IncludeStyle { IS_LLVM = 0, IS_Google = 1, IS_Google_ObjC };
31 IK_CSystemInclude = 1,
32 IK_CXXSystemInclude = 2,
33 IK_NonSystemInclude = 3,
34 IK_GeneratedInclude = 4,
40 IncludeSorter(
const SourceManager *SourceMgr,
const FileID FileID,
41 StringRef FileName, IncludeStyle Style);
44 void addInclude(StringRef FileName,
bool IsAngled,
45 SourceLocation HashLocation, SourceLocation EndLocation);
54 using SourceRangeVector = SmallVector<SourceRange, 1>;
56 const SourceManager *SourceMgr;
57 const IncludeStyle Style;
60 StringRef CanonicalFile;
62 SourceRangeVector SourceLocations;
64 llvm::StringMap<SourceRangeVector> IncludeLocations;
66 SmallVector<std::string, 1> IncludeBucket[IK_InvalidInclude];
71template <>
struct OptionEnumMapping<utils::IncludeSorter::IncludeStyle> {
72 static ArrayRef<std::pair<utils::IncludeSorter::IncludeStyle, StringRef>>
IncludeSorter(const SourceManager *SourceMgr, const FileID FileID, StringRef FileName, IncludeStyle Style)
Class used by IncludeInserterCallback to record the names of the / inclusions in a given source file ...
std::optional< FixItHint > createIncludeInsertion(StringRef FileName, bool IsAngled)
Creates a quoted inclusion directive in the right sort order.
static ArrayRef< std::pair< utils::IncludeSorter::IncludeStyle, StringRef > > getEnumMapping()