clang-tools 10.0.0

HeaderFileExtensionsUtils.h
Go to the documentation of this file.
1 //===--- HeaderFileExtensionsUtils.h - clang-tidy----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
11
12 #include "clang/Basic/SourceLocation.h"
13 #include "clang/Basic/SourceManager.h"
14 #include "llvm/ADT/SmallSet.h"
15 #include "llvm/ADT/StringRef.h"
16
17 namespace clang {
18 namespace tidy {
19 namespace utils {
20
21 typedef llvm::SmallSet<llvm::StringRef, 5> HeaderFileExtensionsSet;
22
23 /// Checks whether expansion location of \p Loc is in header file.
24 bool isExpansionLocInHeaderFile(
25 SourceLocation Loc, const SourceManager &SM,
26 const HeaderFileExtensionsSet &HeaderFileExtensions);
27
28 /// Checks whether presumed location of \p Loc is in header file.
29 bool isPresumedLocInHeaderFile(
30 SourceLocation Loc, SourceManager &SM,
31 const HeaderFileExtensionsSet &HeaderFileExtensions);
32
33 /// Checks whether spelling location of \p Loc is in header file.
34 bool isSpellingLocInHeaderFile(
35 SourceLocation Loc, SourceManager &SM,
36 const HeaderFileExtensionsSet &HeaderFileExtensions);
37
38 /// Returns recommended default value for the list of header file
39 /// extensions.
40 inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
41
42 /// Parses header file extensions from a semicolon-separated list.
43 bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions,
44 HeaderFileExtensionsSet &HeaderFileExtensions,
45 char delimiter);
46
47 /// Decides whether a file has a header file extension.
48 bool isHeaderFileExtension(StringRef FileName,
49 const HeaderFileExtensionsSet &HeaderFileExtensions);
50
51 } // namespace utils
52 } // namespace tidy
53 } // namespace clang
54
55 #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:37
clang::tidy::utils::parseHeaderFileExtensions
bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions, HeaderFileExtensionsSet &HeaderFileExtensions, char delimiter)
Parses header file extensions from a semicolon-separated list.
Definition: HeaderFileExtensionsUtils.cpp:41
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:33
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:25
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:17
clang::tidy::utils::defaultHeaderFileExtensions
StringRef defaultHeaderFileExtensions()
Returns recommended default value for the list of header file extensions.
Definition: HeaderFileExtensionsUtils.h:40
clang::tidy::utils::HeaderFileExtensionsSet
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
Definition: HeaderFileExtensionsUtils.h:21
FileName
PathRef FileName
Definition: CodeComplete.cpp:1018
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::utils::isHeaderFileExtension
bool isHeaderFileExtension(StringRef FileName, const HeaderFileExtensionsSet &HeaderFileExtensions)
Decides whether a file has a header file extension.
Definition: HeaderFileExtensionsUtils.cpp:59