================
@@ -47,8 +47,10 @@ void RedundantTypenameCheck::check(const
MatchFinder::MatchResult &Result) {
const SourceLocation ElaboratedKeywordLoc = [&] {
if (const auto *NonDependentTypeLoc =
Result.Nodes.getNodeAs<TypeLoc>("nonDependentTypeLoc")) {
- if (const auto TL = NonDependentTypeLoc->getAs<TypedefTypeLoc>())
- return TL.getElaboratedKeywordLoc();
+ if (const auto TL = NonDependentTypeLoc->getAs<TypedefTypeLoc>()) {
+ if (!TL.getType()->isDependentType())
+ return TL.getElaboratedKeywordLoc();
+ }
if (const auto TL = NonDependentTypeLoc->getAs<TagTypeLoc>())
return TL.getElaboratedKeywordLoc();
----------------
localspook wrote:
I think we need the `!TL.getType()->isDependentType()` check here as well,
because it seems not only `TypedefTypeLoc`s have this problem, but
`TagTypeLoc`s too; here's a snippet that demonstrates that:
```cpp
template<typename T> struct ListWrapper {};
template<typename T>
class ClassWrapper {
public:
struct Argument {}; // Previously was: using Argument = ListWrapper<T>;
ListWrapper<Argument> arguments;
ListWrapper<Argument> getArguments() const;
};
template<typename T>
ListWrapper</*false positive*/typename ClassWrapper<T>::Argument>
ClassWrapper<T>::getArguments() const {
return arguments;
}
```
At that point, however, we're repeating ourselves 3 times, so I think it would
be better to wrap everything in the *outer* `if` with that check.
https://github.com/llvm/llvm-project/pull/170034
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits