hokein created this revision. hokein added a reviewer: sammccall. Herald added subscribers: kadircet, arphaman. Herald added a project: All. hokein requested review of this revision. Herald added projects: clang, clang-tools-extra.
It is revealed by the https://reviews.llvm.org/D141280. namespace ns { class Foo {}; } using ns::Foo; // Before the fix, the Location of UsingTypeLoc Foo points to the token "class", slection on ^Foo will result in the VarDecl abc. class Foo abc; Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142125 Files: clang-tools-extra/clangd/unittests/SelectionTests.cpp clang/lib/Sema/SemaType.cpp Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -6256,6 +6256,9 @@ void VisitTagTypeLoc(TagTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); } + void VisitUsingTypeLoc(UsingTypeLoc TL) { + TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); + } void VisitAtomicTypeLoc(AtomicTypeLoc TL) { // An AtomicTypeLoc can come from either an _Atomic(...) type specifier // or an _Atomic qualifier. Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -520,6 +520,13 @@ )cpp", "TypedefTypeLoc"}, + {R"cpp( + namespace ns { class Foo {}; } + using ns::Foo; + class [[^Foo]] foo; + )cpp", + "UsingTypeLoc"}, + // lambda captured var-decl {R"cpp( void test(int bar) {
Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -6256,6 +6256,9 @@ void VisitTagTypeLoc(TagTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); } + void VisitUsingTypeLoc(UsingTypeLoc TL) { + TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); + } void VisitAtomicTypeLoc(AtomicTypeLoc TL) { // An AtomicTypeLoc can come from either an _Atomic(...) type specifier // or an _Atomic qualifier. Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -520,6 +520,13 @@ )cpp", "TypedefTypeLoc"}, + {R"cpp( + namespace ns { class Foo {}; } + using ns::Foo; + class [[^Foo]] foo; + )cpp", + "UsingTypeLoc"}, + // lambda captured var-decl {R"cpp( void test(int bar) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits