diff options
author | Brad King <brad.king@kitware.com> | 2016-03-16 18:50:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-03-16 19:11:28 (GMT) |
commit | 86c6385eee64dcd3107a59b443e5a89f854d9da9 (patch) | |
tree | 8f632be6db6b0d0be2b1f2f38f2a3b5919174d45 /test/input | |
parent | d49f98f75a252b1ce0382fa2e9e0345710b96ffb (diff) | |
download | CastXML-86c6385eee64dcd3107a59b443e5a89f854d9da9.zip CastXML-86c6385eee64dcd3107a59b443e5a89f854d9da9.tar.gz CastXML-86c6385eee64dcd3107a59b443e5a89f854d9da9.tar.bz2 |
Output: Print canonical form of types named in default arguments
In code like
namespace ns {
typedef unsigned int UI;
void f(UI = (UI)0);
}
we previously generated `default="(UI)0"` for the default argument of
`f` because Clang prints the expression as it was written in the source.
GCC-XML would generate the canonical typed value `default="0u"`.
Ideally we should generate `default="(ns::UI)0"` but Clang does not
offer hooks into its type printing API. Instead we can produce a value
which is useful to tools reading the output by printing the cast with a
canonical type like `default="(unsigned int)0"`. In the case that the
type names a struct or class the canonical type will be printed as the
fully qualified name.
GitHub-Issue: CastXML/CastXML#51
Diffstat (limited to 'test/input')
-rw-r--r-- | test/input/Function-Argument-default-cast.cxx | 13 | ||||
-rw-r--r-- | test/input/Method-Argument-default-cast.cxx | 8 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/input/Function-Argument-default-cast.cxx b/test/input/Function-Argument-default-cast.cxx new file mode 100644 index 0000000..09ff46b --- /dev/null +++ b/test/input/Function-Argument-default-cast.cxx @@ -0,0 +1,13 @@ +namespace start { + struct Base { Base(); virtual ~Base(); }; + struct Derived: public Base {}; + Base* b(); + Base const* bc(); + typedef int Int; + void f(Int = (Int)0, + Base* = (Base*)0, + Base* = static_cast<Base*>(0), + Base* = reinterpret_cast<Base*>(0), + Base* = const_cast<Base*>(bc()), + Derived* = dynamic_cast<Derived*>(b())); +} diff --git a/test/input/Method-Argument-default-cast.cxx b/test/input/Method-Argument-default-cast.cxx new file mode 100644 index 0000000..903b622 --- /dev/null +++ b/test/input/Method-Argument-default-cast.cxx @@ -0,0 +1,8 @@ +class start { + class Class; + typedef int Int; + int f(Int = (Int)0, + Class* = (Class*)0, + Class* = static_cast<Class*>(0), + Class* = reinterpret_cast<Class*>(0)); +}; |