1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "TestVisitor.h" |
10 | |
11 | using namespace clang; |
12 | |
13 | namespace { |
14 | |
15 | |
16 | class ImplicitCtorVisitor |
17 | : public ExpectedLocationVisitor<ImplicitCtorVisitor> { |
18 | public: |
19 | bool shouldVisitImplicitCode() const { return true; } |
20 | |
21 | bool VisitCXXConstructorDecl(CXXConstructorDecl* Ctor) { |
22 | if (Ctor->isImplicit()) { |
23 | if (const CXXRecordDecl* Class = Ctor->getParent()) { |
24 | Match(Class->getName(), Ctor->getLocation()); |
25 | } |
26 | } |
27 | return true; |
28 | } |
29 | }; |
30 | |
31 | TEST(RecursiveASTVisitor, VisitsImplicitCopyConstructors) { |
32 | ImplicitCtorVisitor Visitor; |
33 | Visitor.ExpectMatch("Simple", 2, 8); |
34 | |
35 | |
36 | EXPECT_TRUE(Visitor.runOver( |
37 | "struct WithCtor { WithCtor(); }; \n" |
38 | "struct Simple { Simple(); WithCtor w; }; \n" |
39 | "int main() { Simple s; Simple t(s); }\n")); |
40 | } |
41 | |
42 | } |
43 | |