[PATCH] D62404: [clang-tidy] Fix null pointer dereference in readability-identifier-naming
Haojian Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 04:51:09 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361809: [clang-tidy] Fix null pointer dereference in readability-identifier-naming (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D62404?vs=201401&id=201639#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62404/new/
https://reviews.llvm.org/D62404
Files:
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-bugfix.cpp
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -800,10 +800,11 @@
// Fix type aliases in value declarations
if (const auto *Value = Result.Nodes.getNodeAs<ValueDecl>("decl")) {
- if (const auto *Typedef =
- Value->getType().getTypePtr()->getAs<TypedefType>()) {
- addUsage(NamingCheckFailures, Typedef->getDecl(),
- Value->getSourceRange());
+ if (const auto *TypePtr = Value->getType().getTypePtrOrNull()) {
+ if (const auto *Typedef = TypePtr->getAs<TypedefType>()) {
+ addUsage(NamingCheckFailures, Typedef->getDecl(),
+ Value->getSourceRange());
+ }
}
}
Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-bugfix.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming-bugfix.cpp
+++ clang-tools-extra/trunk/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'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62404.201639.patch
Type: text/x-patch
Size: 1515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190528/e88826c5/attachment.bin>
More information about the llvm-commits
mailing list