11 #include "clang/Basic/CharInfo.h" 12 #include "llvm/Support/Path.h" 19 SourceLocation
Loc,
const SourceManager &SM,
21 SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
23 HeaderFileExtensions);
27 SourceLocation
Loc, SourceManager &SM,
29 PresumedLoc PresumedLocation = SM.getPresumedLoc(Loc);
31 HeaderFileExtensions);
35 SourceLocation
Loc, SourceManager &SM,
37 SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
39 HeaderFileExtensions);
45 SmallVector<StringRef, 5> Suffixes;
46 AllHeaderFileExtensions.split(Suffixes, delimiter);
47 HeaderFileExtensions.clear();
48 for (StringRef Suffix : Suffixes) {
49 StringRef Extension = Suffix.trim();
50 for (StringRef::const_iterator it = Extension.begin();
51 it != Extension.end(); ++it) {
52 if (!isAlphanumeric(*it))
55 HeaderFileExtensions.insert(Extension);
62 StringRef extension = llvm::sys::path::extension(FileName);
63 if (extension.empty())
66 return HeaderFileExtensions.count(extension.substr(1)) > 0;
SourceLocation Loc
'#' location in the include directive
bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions, HeaderFileExtensionsSet &HeaderFileExtensions, char delimiter)
Parses header file extensions from a semicolon-separated list.
bool isSpellingLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether spelling location of Loc is in header file.
bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether presumed location of Loc is in header file.
bool isExpansionLocInHeaderFile(SourceLocation Loc, const SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether expansion location of Loc is in header file.
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
bool isHeaderFileExtension(StringRef FileName, const HeaderFileExtensionsSet &HeaderFileExtensions)
Decides whether a file has a header file extension.