]> granicus.if.org Git - clang/commit
[AST] No longer visiting CXXMethodDecl bodies created by compiler when method was...
authorJohan Vikstrom <jvikstrom@google.com>
Fri, 9 Aug 2019 07:30:28 +0000 (07:30 +0000)
committerJohan Vikstrom <jvikstrom@google.com>
Fri, 9 Aug 2019 07:30:28 +0000 (07:30 +0000)
commit8c6a98b5d86a5a4951eb8bc0afe65b1a34b11c73
tree8dfb0f68fc15cd9a78c576c63637d58bf6e0d6bb
parent63cf32acf90e5499f4ba651faa05025845f71e7d
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368402 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/RecursiveASTVisitor.h
unittests/Tooling/CMakeLists.txt
unittests/Tooling/RecursiveASTVisitorTests/CXXMethodDecl.cpp [new file with mode: 0644]