This is an archive of the discontinued LLVM Phabricator instance.

[AST] No longer visiting CXXMethodDecl bodies created by compiler when method was default created.
ClosedPublic

Authored by jvikstrom on Aug 8 2019, 4:10 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

jvikstrom created this revision.Aug 8 2019, 4:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2019, 4:10 AM
hokein accepted this revision.Aug 8 2019, 5:42 AM

looks good from my side.

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
262 ↗(On Diff #214109)

nit: the indent should be 2 spaces.

clang/include/clang/AST/RecursiveASTVisitor.h
2033 ↗(On Diff #214109)

nit: use auto, as type in RHS is obvious.

This revision is now accepted and ready to land.Aug 8 2019, 5:42 AM
gribozavr accepted this revision.Aug 8 2019, 6:38 AM
This revision was automatically updated to reflect the committed changes.
jvikstrom marked 2 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2019, 12:32 AM