Skip to content

Commit f271361

Browse files
ksromanovPiotrZSL
andcommitted
Update clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeUnionAccessCheck.cpp
Co-authored-by: Piotr Zegar <[email protected]>
1 parent 31ed1cf commit f271361

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeUnionAccessCheck.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ void ProTypeUnionAccessCheck::registerMatchers(MatchFinder *Finder) {
2323

2424
void ProTypeUnionAccessCheck::check(const MatchFinder::MatchResult &Result) {
2525
const auto *Matched = Result.Nodes.getNodeAs<MemberExpr>("expr");
26-
if (auto MemberLoc = Matched->getMemberLoc(); MemberLoc.isValid())
27-
diag(MemberLoc,
28-
"do not access members of unions; use (boost::)variant instead");
29-
else
30-
diag(Matched->getBeginLoc(),
31-
"do not access members of unions; use (boost::)variant instead");
26+
SourceLocation Loc = Matched->getMemberLoc();
27+
if (Loc.isInvalid())
28+
Loc = Matched->getBeginLoc();
29+
diag(Loc, "do not access members of unions; use (boost::)variant instead");
3230
}
3331

3432
} // namespace clang::tidy::cppcoreguidelines

0 commit comments

Comments
 (0)