diff options
| author | Haojian Wu <hokein@google.com> | 2016-02-05 11:23:59 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2016-02-05 11:23:59 +0000 |
| commit | c2d7577cc552b248857253f99a401800bc010100 (patch) | |
| tree | 1146fd04b4d6781a76196f3e3aacad3006722396 /clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h | |
| parent | 5990cd5a0c8fde4baceea0734ae9e086e987f577 (diff) | |
| download | bcm5719-llvm-c2d7577cc552b248857253f99a401800bc010100.tar.gz bcm5719-llvm-c2d7577cc552b248857253f99a401800bc010100.zip | |
[clang-tdiy] Add header file extension configuration support.
Summary: * Add a `HeaderFileExtensions` check option in misc-definitions-in-headers, google-build-namespaces and google-global-names-in-headers.
Reviewers: aaron.ballman, alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16113
llvm-svn: 259879
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h')
| -rw-r--r-- | clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h b/clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h new file mode 100644 index 00000000000..4b0f3b552b6 --- /dev/null +++ b/clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h @@ -0,0 +1,51 @@ +//===--- HeaderFileExtensionsUtils.h - clang-tidy----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H + +#include <string> + +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/SourceManager.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/Support/Path.h" + +namespace clang { +namespace tidy { +namespace utils { + +typedef llvm::SmallSet<llvm::StringRef, 5> HeaderFileExtensionsSet; + +/// \brief Checks whether expansion location of Loc is in header file. +bool isExpansionLocInHeaderFile( + SourceLocation Loc, const SourceManager &SM, + const HeaderFileExtensionsSet &HeaderFileExtensions); + +/// \brief Checks whether presumed location of Loc is in header file. +bool isPresumedLocInHeaderFile( + SourceLocation Loc, SourceManager &SM, + const HeaderFileExtensionsSet &HeaderFileExtensions); + +/// \brief Checks whether spelling location of Loc is in header file. +bool isSpellingLocInHeaderFile( + SourceLocation Loc, SourceManager &SM, + const HeaderFileExtensionsSet &HeaderFileExtensions); + +/// \brief Parses header file extensions from a semicolon-separated list. +bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions, + HeaderFileExtensionsSet &HeaderFileExtensions, + char delimiter); + +} // namespace utils +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H |

