aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
diff options
context:
space:
mode:
authorQizhi Hu <836744285@qq.com>2023-10-05 13:49:21 +0800
committerGitHub <noreply@github.com>2023-10-05 13:49:21 +0800
commiteef35c287ee093b3521c6c2b682d8da538ad28be (patch)
tree772a6fdfc98cf8c4b98b307d4f7af5417186ed4d /clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
parenta4765c6a028ae01fd67b15ac123d07a629997ffa (diff)
downloadllvm-eef35c287ee093b3521c6c2b682d8da538ad28be.zip
llvm-eef35c287ee093b3521c6c2b682d8da538ad28be.tar.gz
llvm-eef35c287ee093b3521c6c2b682d8da538ad28be.tar.bz2
[clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (#67639)
Fix issue 67529, [clang-tidy: modernize-use-using fails when type is implicitly forward declared](https://github.com/llvm/llvm-project/issues/67529) The problem is that using `Lexer` to get record declaration will lose the type information when its original type is pointer or reference. This patch fix this problem by skip adding the tag declaration when it's only a 'declaration' and not a 'definition'. Co-authored-by: huqizhi <836744285@qq.com>
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 22dc9e2..e6293ed 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -61,7 +61,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
// before the typedef will be the nested one (PR#50990). Therefore, we also
// keep track of the parent declaration, so that we can look up the last
// TagDecl that is a sibling of the typedef in the AST.
- LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
+ if (MatchedTagDecl->isThisDeclarationADefinition())
+ LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
return;
}