diff options
author | Brad King <brad.king@kitware.com> | 2014-03-20 16:54:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-24 18:18:54 (GMT) |
commit | 3bb8bd6662baf02caa6618fc271b5daaebfbab63 (patch) | |
tree | 34a4aafe84d38e17023937b913aee43ffefc3734 /test/input | |
parent | 25ff73764f1a54a0c3689df949f2d7e9ab41a014 (diff) | |
download | CastXML-3bb8bd6662baf02caa6618fc271b5daaebfbab63.zip CastXML-3bb8bd6662baf02caa6618fc271b5daaebfbab63.tar.gz CastXML-3bb8bd6662baf02caa6618fc271b5daaebfbab63.tar.bz2 |
Output: Skip implicit members that cannot be compiled
Implement the HandleTagDeclDefinition method in our ASTConsumer. Clang
calls this method during parsing on completion of each class definition.
This gives us a chance to modify class definitions.
Teach HandleTagDeclDefinition to add the implicit member declarations.
For each implicit member, ask Clang to try instantiating its definition
to see if a call to the member will actually work. Suppress errors
during this check using a clang::Sema::SFINAETrap and simply mark
the declaration as invalid if there were errors.
Add test cases for:
* implicit members that cannot be used due to access, const data members,
or reference data members.
* a POD array data member since Clang uses special logic when creating
implicit members that copy the data.
* a mutable data member since Clang adds implicit member declarations
itself (via clang::Sema::AddImplicitlyDeclaredMembersToClass),
but we still need to try defining them.
* a class that uses its implicit members so they are already defined.
Diffstat (limited to 'test/input')
-rw-r--r-- | test/input/Class-implicit-member-access-mutable.cxx | 10 | ||||
-rw-r--r-- | test/input/Class-implicit-member-access.cxx | 9 | ||||
-rw-r--r-- | test/input/Class-implicit-member-array.cxx | 3 | ||||
-rw-r--r-- | test/input/Class-implicit-member-const.cxx | 5 | ||||
-rw-r--r-- | test/input/Class-implicit-member-reference.cxx | 5 | ||||
-rw-r--r-- | test/input/Class-implicit-members.cxx | 7 |
6 files changed, 39 insertions, 0 deletions
diff --git a/test/input/Class-implicit-member-access-mutable.cxx b/test/input/Class-implicit-member-access-mutable.cxx new file mode 100644 index 0000000..8d9aaec --- /dev/null +++ b/test/input/Class-implicit-member-access-mutable.cxx @@ -0,0 +1,10 @@ +class base { +protected: + base(); + ~base(); +private: + base(base const&); + base& operator=(base const&); + mutable int data; +}; +class start: public base {}; diff --git a/test/input/Class-implicit-member-access.cxx b/test/input/Class-implicit-member-access.cxx new file mode 100644 index 0000000..d9992bc --- /dev/null +++ b/test/input/Class-implicit-member-access.cxx @@ -0,0 +1,9 @@ +class base { +protected: + base(); + ~base(); +private: + base(base const&); + base& operator=(base const&); +}; +class start: public base {}; diff --git a/test/input/Class-implicit-member-array.cxx b/test/input/Class-implicit-member-array.cxx new file mode 100644 index 0000000..44002dc --- /dev/null +++ b/test/input/Class-implicit-member-array.cxx @@ -0,0 +1,3 @@ +class start { + int data[2]; +}; diff --git a/test/input/Class-implicit-member-const.cxx b/test/input/Class-implicit-member-const.cxx new file mode 100644 index 0000000..59221af --- /dev/null +++ b/test/input/Class-implicit-member-const.cxx @@ -0,0 +1,5 @@ +class start { + int const data; +public: + start(); +}; diff --git a/test/input/Class-implicit-member-reference.cxx b/test/input/Class-implicit-member-reference.cxx new file mode 100644 index 0000000..67da21d --- /dev/null +++ b/test/input/Class-implicit-member-reference.cxx @@ -0,0 +1,5 @@ +class start { + int& ref; +public: + start(); +}; diff --git a/test/input/Class-implicit-members.cxx b/test/input/Class-implicit-members.cxx new file mode 100644 index 0000000..2d79ee5 --- /dev/null +++ b/test/input/Class-implicit-members.cxx @@ -0,0 +1,7 @@ +class start { + start method(start const& x) { + start s; + s = x; + return s; + } +}; |