diff options
author | Sterling Augustine <saugustine@google.com> | 2019-12-05 16:16:08 -0800 |
---|---|---|
committer | Sterling Augustine <saugustine@google.com> | 2019-12-05 16:48:18 -0800 |
commit | 6470497817eafe3fe2d15e11ade78fd99753d7ca (patch) | |
tree | 68066d6f0898d7d66b2105dfbb4e6352008e0870 | |
parent | 54a3c2a81e1a0ff970705008e9285ea3ada4ef3e (diff) | |
download | bcm5719-llvm-6470497817eafe3fe2d15e11ade78fd99753d7ca.tar.gz bcm5719-llvm-6470497817eafe3fe2d15e11ade78fd99753d7ca.zip |
Revert "[AST] Traverse the class type loc inside the member type loc."
This reverts commit 7f93cb62280a73e3e899d49c45be8bfbac634b7d.
The assertion at RecursiveASTVisitor.h:1169 fails when passed a TypeLocNode.
Not sure if the correct fix is to use getTypeLocClass or something else.
4 files changed, 4 insertions, 53 deletions
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp index b353c0bdb4e..7b880faa554 100644 --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -407,8 +407,8 @@ TEST(SemanticHighlighting, GetsCorrectTokens) { } )cpp", R"cpp( - template<typename $TemplateParameter[[T]], - void ($TemplateParameter[[T]]::*$TemplateParameter[[method]])(int)> + template<typename $TemplateParameter[[T]], + void (T::*$TemplateParameter[[method]])(int)> struct $Class[[G]] { void $Method[[foo]]( $TemplateParameter[[T]] *$Parameter[[O]]) { diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index d2144efb58e..312f8bdf6bc 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1162,12 +1162,11 @@ DEF_TRAVERSE_TYPELOC(LValueReferenceType, DEF_TRAVERSE_TYPELOC(RValueReferenceType, { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); }) +// FIXME: location of base class? // We traverse this in the type case as well, but how is it not reached through // the pointee type? DEF_TRAVERSE_TYPELOC(MemberPointerType, { - auto *TSI = TL.getClassTInfo(); - assert(TSI); - TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); + TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0))); TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); }) diff --git a/clang/unittests/Tooling/CMakeLists.txt b/clang/unittests/Tooling/CMakeLists.txt index be641845558..5cef154926a 100644 --- a/clang/unittests/Tooling/CMakeLists.txt +++ b/clang/unittests/Tooling/CMakeLists.txt @@ -42,7 +42,6 @@ add_clang_unittest(ToolingTests RecursiveASTVisitorTests/LambdaDefaultCapture.cpp RecursiveASTVisitorTests/LambdaExpr.cpp RecursiveASTVisitorTests/LambdaTemplateParams.cpp - RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp RecursiveASTVisitorTests/NestedNameSpecifiers.cpp RecursiveASTVisitorTests/ParenExpr.cpp RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp deleted file mode 100644 index 851c33dcf5a..00000000000 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===- unittest/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp -===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "TestVisitor.h" - -using namespace clang; - -namespace { - -class MemberPointerTypeLocVisitor - : public ExpectedLocationVisitor<MemberPointerTypeLocVisitor> { -public: - bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { - if (!TL) - return true; - Match(TL.getDecl()->getName(), TL.getNameLoc()); - return true; - } - bool VisitRecordTypeLoc(RecordTypeLoc RTL) { - if (!RTL) - return true; - Match(RTL.getDecl()->getName(), RTL.getNameLoc()); - return true; - } -}; - -TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) { - MemberPointerTypeLocVisitor Visitor; - Visitor.ExpectMatch("Bar", 4, 36); - Visitor.ExpectMatch("T", 7, 23); - EXPECT_TRUE(Visitor.runOver(R"cpp( - class Bar { void func(int); }; - class Foo { - void bind(const char*, void(Bar::*Foo)(int)) {} - - template<typename T> - void test(void(T::*Foo)()); - }; - )cpp")); -} - -} // end anonymous namespace |