[PATCH] D82924: [clang-tidy] fix cppcoreguidelines-init-variables with catch variables
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 05:55:31 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG669494e9c06c: [clang-tidy] fix cppcoreguidelines-init-variables with catch variables (authored by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82924/new/
https://reviews.llvm.org/D82924
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing -fexceptions
// Ensure that function declarations are not changed.
void some_func(int x, double d, bool b, const char *p);
@@ -84,3 +84,10 @@
for (char c : r) {
}
}
+
+void catch_variable_decl() {
+ // Expect no warning given here.
+ try {
+ } catch (int X) {
+ }
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -42,6 +42,7 @@
Finder->addMatcher(
varDecl(unless(hasInitializer(anything())), unless(isInstantiated()),
isLocalVarDecl(), unless(isStaticLocal()), isDefinition(),
+ unless(hasParent(cxxCatchStmt())),
optionally(hasParent(declStmt(hasParent(
cxxForRangeStmt(hasLoopVariable(varDecl().bind(BadDecl))))))),
unless(equalsBoundNode(BadDecl)))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82924.274776.patch
Type: text/x-patch
Size: 1547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200701/88858314/attachment-0001.bin>
More information about the cfe-commits
mailing list