clang-tools  10.0.0svn
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.
25  SourceLocation Loc, const SourceManager &SM,
26  const HeaderFileExtensionsSet &HeaderFileExtensions);
27 
28 /// Checks whether presumed location of \p Loc is in header file.
30  SourceLocation Loc, SourceManager &SM,
31  const HeaderFileExtensionsSet &HeaderFileExtensions);
32 
33 /// Checks whether spelling location of \p Loc is in header file.
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
SourceLocation Loc
&#39;#&#39; 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.
StringRef defaultHeaderFileExtensions()
Returns recommended default value for the list of header file extensions.
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
PathRef FileName
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool isHeaderFileExtension(StringRef FileName, const HeaderFileExtensionsSet &HeaderFileExtensions)
Decides whether a file has a header file extension.