diff options
author | Sergio Martins <smartins@kde.org> | 2017-10-05 00:40:17 +0100 |
---|---|---|
committer | Sergio Martins <iamsergio@gmail.com> | 2017-10-05 00:46:39 +0100 |
commit | 5e8c4a8647179b056b1cee0600f900987ebdc889 (patch) | |
tree | dd62ec8f08ab24b024a8c3a2e9dfc525315c4a2d /src | |
parent | f3229edff7232b52523ca3bec34c84dfe907e45c (diff) |
unused-non-trivial-variable: Fix false positive when decl begins with macro
We check if the variable is used after the location where it was declared,
but it the expression begins with a macro, it was using the location of where
the macro was written, and where it was used.
Diffstat (limited to 'src')
-rw-r--r-- | src/checks/level0/unused-non-trivial-variable.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/checks/level0/unused-non-trivial-variable.cpp b/src/checks/level0/unused-non-trivial-variable.cpp index 1450224b..a05ee2a3 100644 --- a/src/checks/level0/unused-non-trivial-variable.cpp +++ b/src/checks/level0/unused-non-trivial-variable.cpp @@ -90,6 +90,7 @@ void UnusedNonTrivialVariable::handleVarDecl(VarDecl *varDecl) return; SourceLocation locStart = varDecl->getLocStart(); + locStart = sm().getExpansionLoc(locStart); auto declRefs = HierarchyUtils::getStatements<DeclRefExpr>(body, &sm(), locStart); auto pred = [varDecl] (DeclRefExpr *declRef) { |