Skip to content

Commit 65f7f87

Browse files
committed
fixup! [clang-tidy] Improved modernize-use-using by fixing a false-negative
Fixed crash
1 parent e7dcbbc commit 65f7f87

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "UseUsingCheck.h"
1010
#include "clang/AST/ASTContext.h"
11+
#include "clang/AST/DeclGroup.h"
1112
#include "clang/Lex/Lexer.h"
1213

1314
using namespace clang::ast_matchers;
@@ -69,8 +70,14 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
6970

7071
if (!ParentDecl) {
7172
const auto *ParentDeclStmt = Result.Nodes.getNodeAs<DeclStmt>(DeclStmtName);
72-
if (ParentDeclStmt)
73-
ParentDecl = ParentDeclStmt->getSingleDecl();
73+
if (ParentDeclStmt) {
74+
if (ParentDeclStmt->isSingleDecl())
75+
ParentDecl = ParentDeclStmt->getSingleDecl();
76+
else
77+
ParentDecl =
78+
ParentDeclStmt->getDeclGroup().getDeclGroup()
79+
[ParentDeclStmt->getDeclGroup().getDeclGroup().size() - 1];
80+
}
7481
}
7582

7683
if (!ParentDecl)

0 commit comments

Comments
 (0)