blob: c9fedf08749d87de03d4937825a85e6b3221cb3d [file] [log] [blame]
Haojian Wuc2d75772016-02-05 11:23:59 +00001//===--- 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
Haojian Wuc2d75772016-02-05 11:23:59 +000013#include "clang/Basic/SourceLocation.h"
14#include "clang/Basic/SourceManager.h"
Haojian Wuc2d75772016-02-05 11:23:59 +000015#include "llvm/ADT/SmallSet.h"
Mads Ravn041b8042016-08-26 05:59:53 +000016#include "llvm/ADT/StringRef.h"
Haojian Wuc2d75772016-02-05 11:23:59 +000017
18namespace clang {
19namespace tidy {
20namespace utils {
21
22typedef llvm::SmallSet<llvm::StringRef, 5> HeaderFileExtensionsSet;
23
Alexander Kornienkoc9c82902016-06-17 11:43:33 +000024/// \brief Checks whether expansion location of \p Loc is in header file.
Haojian Wuc2d75772016-02-05 11:23:59 +000025bool isExpansionLocInHeaderFile(
26 SourceLocation Loc, const SourceManager &SM,
27 const HeaderFileExtensionsSet &HeaderFileExtensions);
28
Alexander Kornienkoc9c82902016-06-17 11:43:33 +000029/// \brief Checks whether presumed location of \p Loc is in header file.
Haojian Wuc2d75772016-02-05 11:23:59 +000030bool isPresumedLocInHeaderFile(
31 SourceLocation Loc, SourceManager &SM,
32 const HeaderFileExtensionsSet &HeaderFileExtensions);
33
Alexander Kornienkoc9c82902016-06-17 11:43:33 +000034/// \brief Checks whether spelling location of \p Loc is in header file.
Haojian Wuc2d75772016-02-05 11:23:59 +000035bool isSpellingLocInHeaderFile(
36 SourceLocation Loc, SourceManager &SM,
37 const HeaderFileExtensionsSet &HeaderFileExtensions);
38
39/// \brief Parses header file extensions from a semicolon-separated list.
40bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions,
41 HeaderFileExtensionsSet &HeaderFileExtensions,
42 char delimiter);
43
Mads Ravn041b8042016-08-26 05:59:53 +000044/// \brief Decides whether a file has a header file extension.
45bool isHeaderFileExtension(StringRef FileName,
Haojian Wu0a198672016-08-26 11:15:38 +000046 const HeaderFileExtensionsSet &HeaderFileExtensions);
Mads Ravn041b8042016-08-26 05:59:53 +000047
Haojian Wuc2d75772016-02-05 11:23:59 +000048} // namespace utils
49} // namespace tidy
50} // namespace clang
51
52#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H