summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/ClangTidy.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-02-05 11:23:59 +0000
committerHaojian Wu <hokein@google.com>2016-02-05 11:23:59 +0000
commitc2d7577cc552b248857253f99a401800bc010100 (patch)
tree1146fd04b4d6781a76196f3e3aacad3006722396 /clang-tools-extra/clang-tidy/ClangTidy.cpp
parent5990cd5a0c8fde4baceea0734ae9e086e987f577 (diff)
downloadbcm5719-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/ClangTidy.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 66ab56a77a1..b2dd7e7c74f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -344,13 +344,25 @@ OptionsView::OptionsView(StringRef CheckName,
const ClangTidyOptions::OptionMap &CheckOptions)
: NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions) {}
-std::string OptionsView::get(StringRef LocalName, std::string Default) const {
+std::string OptionsView::get(StringRef LocalName, StringRef Default) const {
const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
if (Iter != CheckOptions.end())
return Iter->second;
return Default;
}
+std::string OptionsView::getLocalOrGlobal(StringRef LocalName,
+ StringRef Default) const {
+ auto Iter = CheckOptions.find(NamePrefix + LocalName.str());
+ if (Iter != CheckOptions.end())
+ return Iter->second;
+ // Fallback to global setting, if present.
+ Iter = CheckOptions.find(LocalName.str());
+ if (Iter != CheckOptions.end())
+ return Iter->second;
+ return Default;
+}
+
void OptionsView::store(ClangTidyOptions::OptionMap &Options,
StringRef LocalName, StringRef Value) const {
Options[NamePrefix + LocalName.str()] = Value;
OpenPOWER on IntegriCloud