Author: jvikstrom Date: Fri Aug 9 00:30:28 2019 New Revision: 368402 URL: http://llvm.org/viewvc/llvm-project?rev=368402&view=rev Log: [AST] No longer visiting CXXMethodDecl bodies created by compiler when method was default created.
Summary: Clang generates function bodies and puts them in the AST for default methods if it is defaulted outside the class definition. ` struct A { A &operator=(A &&O); }; A &A::operator=(A &&O) = default; ` This will generate a function body for the `A &A::operator=(A &&O)` and put it in the AST. This body should not be visited if implicit code is not visited as it is implicit. This was causing SemanticHighlighting in clangd to generate duplicate tokens and putting them in weird places. Reviewers: hokein, ilya-biryukov, gribozavr Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65938 Modified: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp Modified: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp?rev=368402&r1=368401&r2=368402&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp (original) +++ clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp Fri Aug 9 00:30:28 2019 @@ -55,7 +55,7 @@ void checkHighlightings(llvm::StringRef Annotations Test(Code); auto AST = TestTU::withCode(Test.code()).build(); std::vector<HighlightingToken> ActualTokens = getSemanticHighlightings(AST); - EXPECT_THAT(ActualTokens, getExpectedTokens(Test)); + EXPECT_THAT(ActualTokens, getExpectedTokens(Test)) << Code; } // Any annotations in OldCode and NewCode are converted into their corresponding @@ -276,6 +276,15 @@ TEST(SemanticHighlighting, GetsCorrectTo $Class[[Foo]] *$Variable[[FP]] = ($Class[[Foo]]*)$Variable[[B]]; $Primitive[[int]] $Variable[[I]] = ($Primitive[[int]])$Variable[[B]]; } + )cpp" + R"cpp( + struct $Class[[B]] {}; + struct $Class[[A]] { + $Class[[B]] $Field[[BB]]; + $Class[[A]] &operator=($Class[[A]] &&$Variable[[O]]); + }; + + $Class[[A]] &$Class[[A]]::operator=($Class[[A]] &&$Variable[[O]]) = default; )cpp"}; for (const auto &TestCase : TestCases) { checkHighlightings(TestCase); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits