mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[clang-tidy] Fix false positive in readability-redundant-typename (#170034)
Closes #169166 --------- Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
This commit is contained in:
@@ -47,6 +47,9 @@ void RedundantTypenameCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
const SourceLocation ElaboratedKeywordLoc = [&] {
|
||||
if (const auto *NonDependentTypeLoc =
|
||||
Result.Nodes.getNodeAs<TypeLoc>("nonDependentTypeLoc")) {
|
||||
if (NonDependentTypeLoc->getType()->isDependentType())
|
||||
return SourceLocation();
|
||||
|
||||
if (const auto TL = NonDependentTypeLoc->getAs<TypedefTypeLoc>())
|
||||
return TL.getElaboratedKeywordLoc();
|
||||
|
||||
@@ -59,8 +62,7 @@ void RedundantTypenameCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
if (const auto TL =
|
||||
NonDependentTypeLoc->getAs<TemplateSpecializationTypeLoc>())
|
||||
if (!TL.getType()->isDependentType())
|
||||
return TL.getElaboratedKeywordLoc();
|
||||
return TL.getElaboratedKeywordLoc();
|
||||
} else {
|
||||
TypeLoc InnermostTypeLoc =
|
||||
*Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
|
||||
|
||||
@@ -267,3 +267,27 @@ WHOLE_TYPE_IN_MACRO Macro2;
|
||||
|
||||
#define WHOLE_DECLARATION_IN_MACRO typename NotDependent::R Macro3
|
||||
WHOLE_DECLARATION_IN_MACRO;
|
||||
|
||||
template <typename T> struct Wrapper {};
|
||||
template <typename T>
|
||||
struct ClassWrapper {
|
||||
using R = T;
|
||||
Wrapper<R> f();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
Wrapper<typename ClassWrapper<T>::R> ClassWrapper<T>::f() {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename T> struct StructWrapper {};
|
||||
template <typename T>
|
||||
class ClassWithNestedStruct {
|
||||
struct Nested {};
|
||||
StructWrapper<Nested> f();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
StructWrapper<typename ClassWithNestedStruct<T>::Nested> ClassWithNestedStruct<T>::f() {
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user