зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1606630 - For clang-tidy fix checkers `readability-misleading-indentation` and `readability-braces-around-statements`. r=sylvestre
The purpose of this patch is to add support for `if constexpr` statements for the above checkers. `readability-braces-around-statements` fix has been back-ported from <https://reviews.llvm.org/D71980> and the fix for `readability-misleading-indentation` uses the same logic as a principle. Differential Revision: https://phabricator.services.mozilla.com/D58825 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
55bdd37f7c
Коммит
c09d1d5ae3
|
@ -0,0 +1,33 @@
|
|||
diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
|
||||
index 117ef36d78f..da0bef32c09 100644
|
||||
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
|
||||
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
|
||||
@@ -123,7 +123,10 @@ void BracesAroundStatementsCheck::storeOptions(
|
||||
}
|
||||
|
||||
void BracesAroundStatementsCheck::registerMatchers(MatchFinder *Finder) {
|
||||
- Finder->addMatcher(ifStmt().bind("if"), this);
|
||||
+ Finder->addMatcher(
|
||||
+ ifStmt(unless(allOf(isConstexpr(), isInTemplateInstantiation())))
|
||||
+ .bind("if"),
|
||||
+ this);
|
||||
Finder->addMatcher(whileStmt().bind("while"), this);
|
||||
Finder->addMatcher(doStmt().bind("do"), this);
|
||||
Finder->addMatcher(forStmt().bind("for"), this);
|
||||
diff --git a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
|
||||
index 0fd5c1fc55c..3167d159b74 100644
|
||||
--- a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
|
||||
+++ b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
|
||||
@@ -106,7 +106,11 @@ void MisleadingIndentationCheck::missingBracesCheck(const SourceManager &SM,
|
||||
}
|
||||
|
||||
void MisleadingIndentationCheck::registerMatchers(MatchFinder *Finder) {
|
||||
- Finder->addMatcher(ifStmt(hasElse(stmt())).bind("if"), this);
|
||||
+ Finder->addMatcher(
|
||||
+ ifStmt(allOf(hasElse(stmt()),
|
||||
+ unless(allOf(isConstexpr(), isInTemplateInstantiation()))))
|
||||
+ .bind("if"),
|
||||
+ this);
|
||||
Finder->addMatcher(
|
||||
compoundStmt(has(stmt(anyOf(ifStmt(), forStmt(), whileStmt()))))
|
||||
.bind("compound"),
|
|
@ -12,6 +12,7 @@
|
|||
"patches": [
|
||||
"clang-tidy-ci.patch",
|
||||
"clang-tidy-no-errors.patch",
|
||||
"bug-1605181-isConstexpr.patch"
|
||||
"bug-1605181-isConstexpr.patch",
|
||||
"bug-1606630-if_constexpr.patch"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"clang-tidy-ci.patch",
|
||||
"clang-tidy-no-errors.patch",
|
||||
"compiler-rt-no-codesign.patch",
|
||||
"bug-1605181-isConstexpr.patch"
|
||||
"bug-1605181-isConstexpr.patch",
|
||||
"bug-1606630-if_constexpr.patch"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"patches": [
|
||||
"clang-tidy-ci.patch",
|
||||
"clang-tidy-no-errors.patch",
|
||||
"bug-1605181-isConstexpr.patch"
|
||||
"bug-1605181-isConstexpr.patch",
|
||||
"bug-1606630-if_constexpr.patch"
|
||||
]
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче