aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/readability
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@vmiklos.hu>2018-12-24 17:47:32 +0000
committerMiklos Vajna <vmiklos@vmiklos.hu>2018-12-24 17:47:32 +0000
commit2b267985b2139f3970e93ea8dab77849dae2012f (patch)
tree1d18d2f51b963f746fcb78b3a754b5a03f98cc9e /clang-tidy/readability
parent6ec2e23f3e5097124f843ee2c501272788e4c7a9 (diff)
[clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix
And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth, lebedev.ri Differential Revision: https://reviews.llvm.org/D56025 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@350056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/readability')
-rw-r--r--clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp6
-rw-r--r--clang-tidy/readability/UppercaseLiteralSuffixCheck.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index eeaece11..588fb261 100644
--- a/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -183,12 +183,14 @@ UppercaseLiteralSuffixCheck::UppercaseLiteralSuffixCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
NewSuffixes(
- utils::options::parseStringList(Options.get("NewSuffixes", ""))) {}
+ utils::options::parseStringList(Options.get("NewSuffixes", ""))),
+ IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
void UppercaseLiteralSuffixCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "NewSuffixes",
utils::options::serializeStringList(NewSuffixes));
+ Options.store(Opts, "IgnoreMacros", IgnoreMacros);
}
void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
@@ -216,6 +218,8 @@ bool UppercaseLiteralSuffixCheck::checkBoundMatch(
// We might have a suffix that is already uppercase.
if (auto Details = shouldReplaceLiteralSuffix<LiteralType>(
*Literal, NewSuffixes, *Result.SourceManager, getLangOpts())) {
+ if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
+ return true;
auto Complaint = diag(Details->LiteralLocation.getBegin(),
"%0 literal has suffix '%1', which is not uppercase")
<< LiteralType::Name << Details->OldSuffix;
diff --git a/clang-tidy/readability/UppercaseLiteralSuffixCheck.h b/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
index 8d26e6c2..7aa631ae 100644
--- a/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
+++ b/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
@@ -35,6 +35,7 @@ private:
bool checkBoundMatch(const ast_matchers::MatchFinder::MatchResult &Result);
const std::vector<std::string> NewSuffixes;
+ const bool IgnoreMacros;
};
} // namespace readability