markstegeman updated this revision to Diff 201401.
markstegeman added a comment.
Added a test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62404/new/
https://reviews.llvm.org/D62404
Files:
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
Index:
clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
@@ -0,0 +1,5 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s
readability-identifier-naming %t
+
+// This used to cause a null pointer dereference.
+auto [left] = right;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'right'
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -800,10 +800,11 @@
// Fix type aliases in value declarations
if (const auto *Value = Result.Nodes.getNodeAs("decl")) {
- if (const auto *Typedef =
- Value->getType().getTypePtr()->getAs()) {
-addUsage(NamingCheckFailures, Typedef->getDecl(),
- Value->getSourceRange());
+ if (const auto *TypePtr = Value->getType().getTypePtrOrNull()) {
+if (const auto *Typedef = TypePtr->getAs()) {
+ addUsage(NamingCheckFailures, Typedef->getDecl(),
+ Value->getSourceRange());
+}
}
}
Index: clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-identifier-naming-bugfix.cpp
@@ -0,0 +1,5 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s readability-identifier-naming %t
+
+// This used to cause a null pointer dereference.
+auto [left] = right;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'right'
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -800,10 +800,11 @@
// Fix type aliases in value declarations
if (const auto *Value = Result.Nodes.getNodeAs("decl")) {
- if (const auto *Typedef =
- Value->getType().getTypePtr()->getAs()) {
-addUsage(NamingCheckFailures, Typedef->getDecl(),
- Value->getSourceRange());
+ if (const auto *TypePtr = Value->getType().getTypePtrOrNull()) {
+if (const auto *Typedef = TypePtr->getAs()) {
+ addUsage(NamingCheckFailures, Typedef->getDecl(),
+ Value->getSourceRange());
+}
}
}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits