clang-tools 6.0.0

HeaderFileExtensionsUtils.h
Go to the documentation of this file.
1 //===--- HeaderFileExtensionsUtils.h - clang-tidy----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
12
13 #include "clang/Basic/SourceLocation.h"
14 #include "clang/Basic/SourceManager.h"
15 #include "llvm/ADT/SmallSet.h"
16 #include "llvm/ADT/StringRef.h"
17
18 namespace clang {
19 namespace tidy {
20 namespace utils {
21
22 typedef llvm::SmallSet<llvm::StringRef, 5> HeaderFileExtensionsSet;
23
24 /// \brief Checks whether expansion location of \p Loc is in header file.
25 bool isExpansionLocInHeaderFile(
26 SourceLocation Loc, const SourceManager &SM,
27 const HeaderFileExtensionsSet &HeaderFileExtensions);
28
29 /// \brief Checks whether presumed location of \p Loc is in header file.
30 bool isPresumedLocInHeaderFile(
31 SourceLocation Loc, SourceManager &SM,
32 const HeaderFileExtensionsSet &HeaderFileExtensions);
33
34 /// \brief Checks whether spelling location of \p Loc is in header file.
35 bool isSpellingLocInHeaderFile(
36 SourceLocation Loc, SourceManager &SM,
37 const HeaderFileExtensionsSet &HeaderFileExtensions);
38
39 /// \brief Returns recommended default value for the list of header file
40 /// extensions.
41 inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
42
43 /// \brief Parses header file extensions from a semicolon-separated list.
44 bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions,
45 HeaderFileExtensionsSet &HeaderFileExtensions,
46 char delimiter);
47
48 /// \brief Decides whether a file has a header file extension.
49 bool isHeaderFileExtension(StringRef FileName,
50 const HeaderFileExtensionsSet &HeaderFileExtensions);
51
52 } // namespace utils
53 } // namespace tidy
54 } // namespace clang
55
56 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
Loc
SourceLocation Loc
&#39;#&#39; location in the include directive
Definition: IncludeOrderCheck.cpp:36
clang::tidy::utils::parseHeaderFileExtensions
bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions, HeaderFileExtensionsSet &HeaderFileExtensions, char delimiter)
Parses header file extensions from a semicolon-separated list.
Definition: HeaderFileExtensionsUtils.cpp:42
clang::tidy::utils::isSpellingLocInHeaderFile
bool isSpellingLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether spelling location of Loc is in header file.
Definition: HeaderFileExtensionsUtils.cpp:34
clang::tidy::utils::isPresumedLocInHeaderFile
bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether presumed location of Loc is in header file.
Definition: HeaderFileExtensionsUtils.cpp:26
clang::tidy::utils::isExpansionLocInHeaderFile
bool isExpansionLocInHeaderFile(SourceLocation Loc, const SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether expansion location of Loc is in header file.
Definition: HeaderFileExtensionsUtils.cpp:18
clang::tidy::utils::defaultHeaderFileExtensions
StringRef defaultHeaderFileExtensions()
Returns recommended default value for the list of header file extensions.
Definition: HeaderFileExtensionsUtils.h:41
clang::tidy::utils::HeaderFileExtensionsSet
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
Definition: HeaderFileExtensionsUtils.h:22
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::utils::isHeaderFileExtension
bool isHeaderFileExtension(StringRef FileName, const HeaderFileExtensionsSet &HeaderFileExtensions)
Decides whether a file has a header file extension.
Definition: HeaderFileExtensionsUtils.cpp:60