summaryrefslogtreecommitdiffstats
path: root/test/input
Commit message (Collapse)AuthorAgeFilesLines
* test: Add case for __builtin_assume_aligned declaration in MSVC headerBrad King2020-04-031-0/+8
| | | | | | In commit f9a05da6 (RunClang: Tolerate __builtin_assume_aligned declaration in MSVC header, 2020-03-31, v0.3.2~1^2) we left out a test case. Add one now.
* Output: Indicate whether an Enumeration is scopedBrad King2019-08-191-0/+4
| | | | Fixes: #94
* RunClang: Improve predefined macros identifying castxmlBrad King2019-04-113-0/+32
| | | | | | | | Provide `__castxml_{major,minor,patch}__`. Re-purpose `__castxml__` to be for comparison with a `__castxml_check()` helper. Leave the actual encoding of the components unspecified. Ensure the integer version value of the encoding is larger than the only value of `1000` that `__castxml__` had previously.
* Output: Add the type of nullptr as a FundamentalTypeBrad King2019-04-091-0/+4
| | | | | | | | | Extend the `--castxml-output=1` format to support the nullptr type. The name of the type is `decltype(nullptr)`. Recognize types named exactly this way (as a literal) and treat them as a FundamentalType. This gives the `std::nullptr_t` typedef a meaningful representation even without full decltype support. Leave deeper nullptr-typed expressions like `decltype((nullptr))` unchanged.
* Revise C++ coding style using clang-format-6.0Kitware Robot2019-04-084-6/+14
| | | | | | | | | | | | Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`. Use `clang-format` version 6.0. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
* test: Add case covering multi-dimensional arrays in function argumentsBrad King2018-03-211-1/+1
| | | | Only the top-level decays.
* RunClang: Tolerate use of GNU builtin __has_unique_object_representationsBrad King2017-12-051-0/+3
| | | | | | | | | | | The builtin is used by the GNU type_traits header in modes aware of C++17, so we need to provide it in CastXML. LLVM/Clang SVN r316518 (implement __has_unique_object_representations, 2017-10-24), in development of Clang 6, added this GNU builtin. For older versions of LLVM/Clang, provide a minimum implementation that at least allows `type_traits` to parse. Fixes: #98
* Output: Add deprecated attributeBrad King2017-10-1314-0/+43
| | | | Fixes: #92
* test: Add cases for anonymous struct and union typesBrad King2017-10-034-0/+18
|
* Output: Treat lambda classes as anonymous and memberlessBrad King2017-09-292-0/+11
| | | | | | | | | | In C++11 the compiler synthesizes class types to represent lambda function objects. These types cannot be named directly, so treat them as anonymous. Leave out all their members for now too because they cannot be treated as normal C++98 classes represented by gccxml's format. Issue: #89
* Output: Add dllexport/dllimport attributesMark A Russell2017-09-2820-0/+66
|
* Output: Desugar 'auto' typesBrad King2017-09-281-0/+4
| | | | | | | When an `auto` type is encountered in an interface, desugar it through to the deduced type. Issue: #89
* test: Stabilize order of derived class implicitsBrad King2017-09-061-0/+4
| | | | | | | In the `Function-Argument-default-cast` case, spell out the special members explicitly so that the resulting order does not depend on the order that Clang adds them. The special methods are not the purpose of this test case.
* Run clang-format on sourcesBrad King2017-08-231-46/+51
| | | | This was forgotten when the elaborated type specifier changes were made.
* Output: Add support for elaborated type specifiersMichka Popoff2017-03-011-0/+49
| | | | | | | | | | | | Elaborated type specifiers refer to a class, struct, union, or enum name preceded by the corresponding keyword (e.g. `struct foo`). These type specifiers are important for C code, but are also sometimes relevant in the context of C++ code. Add an `ElaboratedType` XML element to the castxml output format to represent elaborated type specifiers. Increment the format *major* version number to indicate the addition of an element that will require clients to be updated.
* Revise C++ coding style using clang-formatKitware Robot2016-11-10112-251/+445
| | | | | | | | | | | | | Run the `src/clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. Fix expected test output for new line numbers. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
* Protect hand-formatted blocks from clang-formatBrad King2016-11-101-0/+2
|
* Output: Avoid assertion failure on a FunctionDecl with no identifierBrad King2016-10-061-0/+3
| | | | | | | | | | All C++98 function declarations have identifiers as names. Some C++11 function declarations, such as user defined literal operators, do not have identifiers. While we may implement support for these in a future non-gccxml output format, for now simply avoid an assertion failure by outputting such declarations as Unimplemented nodes. Issue: #76
* Output: Desugar typedefs whose context is a templateBrad King2016-08-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code template <typename> struct A { struct B { typedef int intermediate_type; typedef intermediate_type type; }; }; Clang represents `A<int>::B::type` as a typedef whose type is sugared to `A<>::B::intermediate_type` where `A<>::B` is a non-template whose context is an uninstantiated template `A<>` even though the original typedef's context `A<int>::B` is a non-template whose context is an instaniated template `A<int>`. Since CastXML's gccxml output format does not support uninstantiated templates we cannot represent the context of `intermediate_type` so we must desugar it instead. Otherwise we end up with an `Unimplemented` node or even a crash in Clang because we perform operations meant for non-templates on the template context. We previously did this for typedefs that appear directly in template contexts, but not for those whose contexts are nominally non-template but contained in a template context. Fix the logic to loop through all nested contexts to perform this check. Closes: #70
* Output: Fix assertion failure on translation-unit-level operatorsBrad King2016-06-171-0/+2
| | | | | | | | | | Refactoring in commit 917c646e (Output: Generalize exclusion of internal `__castxml` builtins, 2016-04-18) introduced an unconditional call to `clang::NamedDecl::getName`, but that method asserts that the name is a valid identifier. Instead call `getIdentifier` ourselves and check the name only if it is a valid identifier. GitHub-Issue: #62
* castxml: Fix `__float128` simulation with `-std=gnu++{11,14}` againBrad King2016-05-102-1/+7
| | | | | | | | | | | | | | | The approach used in commit 1414278259 (castxml: Fix `__float128` simulation with `-std=gnu++{11,14}`, 2016-01-25) allowed Clang to use its own builtin `__float128` type when it is available. However, Clang does not really implement this builtin and issues diagnostics when it is used in some contexts (e.g. as a data member). Instead we need to provide our own approximation of the builtin in all cases. Avoid a conflict with the Clang builtin by using the preprocessor to rename the type to `__castxml__float128`. Then replace this name with `__float128` during output. GitHub-Issue: CastXML/CastXML#59
* test: Split GNU-float128-nostart test inputsBrad King2016-05-102-0/+2
| | | | | Use explicit input source files for these tests so that we can later change the original test sources to cover more cases.
* RunClang: Provide `__make_integer_seq` builtin when Clang does notBrad King2016-04-211-0/+6
| | | | | | | | | Visual Studio 2015 Update 2 (cl 19.00.23918) adds a `__make_integer_seq` builtin. It also started using the builtin in the `<type_traits>` header. Clang version 3.8 and above provide this builtin but older versions do not, so CastXML fails when built against Clang 3.6 or 3.7. Work around this problem by adding our own implementation of the builtin when Clang does not provide it.
* Output: Fix access specifier of incomplete class template instantiationsBrad King2016-04-191-0/+2
| | | | | | | | | | | | | | | In code like class foo { template <typename> class bar {}; typedef bar<char> incomplete; }; template class foo::bar<int>; // complete the instantiations of `foo::bar<>` should have the same access as the original template whether they are fully instantiated or incomplete. GitHub-Issue: CastXML/CastXML#56
* Output: Fix access specifier of class template instantiationsBrad King2016-04-121-0/+4
| | | | | | | | | | | | | | | | | | In code like class foo { template <typename> class bar {}; }; the instantiations of `foo::bar<>` should have the same access as the original template. Clang generates access `AS_none` for member template instantiations because they have no meaningful access of their own. Previously we have misinterpreted this as `AS_public` because it is not `AS_private` or `AS_protected`. Instead we must detect when a class is a template instantiation and get the access specifier from its original template. GitHub-Issue: CastXML/CastXML#56
* test: Add case for implicit members of a const aggregate structBrad King2016-04-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | A struct like struct foo { int const bar; }; cannot have an implicit default constructor but can be initialized as an aggregate, e.g. foo f = {123}; Clang in C++11 mode and above correctly deletes the implicit default constructor. Add a test case covering this for C++11 and C++14. Unfortunately Clang in C++98 mode does not mark the implicit default constructor as invalid even after `Sema::MarkFunctionReferenced` has been called. Therefore CastXML incorrectly generates the member. Add a "broken" test case to record this limitation. GitHub-Issue: CastXML/CastXML#55
* Output: Fix unnamed enum value references in default argumentsBrad King2016-03-211-1/+2
| | | | | | | | | | | | | | | | In code like namespace ns { enum { E = 0 }; void f(int = E); } we use `clang::NamedDecl::printQualifiedName` to print the fully qualified name of the enum constant `E`. However, the method produces `ns::::E` when the enumeration type itself is not named. Work around this problem by removing one of the `::` from the result. GitHub-Issue: CastXML/CastXML#52
* Output: Print fully qualified names in variable initializersBrad King2016-03-162-0/+9
| | | | | | | | | | | | | | | | | | | In code like namespace ns { static int const C = 123; int v1 = C; typedef int Int; Int v2 = (Int)123; } we previously generated `init="C"` and `init="(Int)123"` for the variable initializers. Produce a value more useful to tools reading the output by using fully qualified names and/or canonical types. This is the same approach we already use for function default argument expressions. GitHub-Issue: CastXML/CastXML#51
* Output: Print canonical form of types named in default argumentsBrad King2016-03-162-0/+21
| | | | | | | | | | | | | | | | | | | | | 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
* Output: Print fully qualified declarations named in default argumentsBrad King2016-03-162-0/+8
| | | | | | | | | | | | | | | | | | In code like namespace ns { static int const C = 0; void f(int = C); } we previously generated `default="C"` for the default argument of `f` because Clang prints the expression as it was written in the source. GCC-XML would generate the fully qualified name `default="ns::C"` which is more useful to tools reading the output. Update our default argument printing to do this by hooking in to Clang's pretty printer and providing a custom implementation for `DeclRefExpr`. GitHub-Issue: CastXML/CastXML#51
* RunClang: Avoid infinite class template implicit member recursionBrad King2016-03-101-0/+11
| | | | | | | | | | | | | | | | | We force declaration of class implicit members in order to generate a full description of valid members. In the case that a class is a template instantiation the definition of the implicit member bodies may recursively create new template instantiations. We queue them and continue. However, it is possible that this process will produce an unbounded depth of template instantiations that is not diagnosed by Clang's template instantiation depth limit because that does not force implicit member definition. Avoid infinite class template recursion by enforcing an artificial limit on the depth through which we force definition of class implicit members. GitHub-Issue: CastXML/CastXML#50
* RunClang: Tolerate __builtin_va_arg_pack during parsingBrad King2016-02-012-0/+6
| | | | | | | | | When simulating preprocessing by a GNU compiler code (in the standard library) may try to use this builtin, but Clang does not support it. Provide a fake instance of the builtin using a preprocessor macro good enough to get through parsing references to it in function bodies. GitHub-Issue: #46
* Output: Fix references to types whose declaration is invalidBrad King2015-12-141-0/+7
| | | | | | | | | | | | We skip generating declarations that Clang has deemed invalid. Most callers of AddDeclDumpNode can check the return value and handle the lack of a valid decl. However, callers of AddDeclDumpNodeForType are generating references to types and expect to get a valid element to reference. We can get an invalid RecordDecl when it is a template instantation that fails (but does not otherwise produce a compilation error in Clang). References to types corresponding to the invalid RecordDecl must remain valid, so generate a Class/Struct/Union element anyway and simply leave out class members and bases.
* Output: Skip C++11 type alias declarationsBrad King2015-12-102-0/+7
| | | | The gccxml output format may contain only C++98 constructs.
* Output: Skip Typedef elements that refer to rvalue referencesBrad King2015-12-101-1/+3
| | | | The gccxml output format may contain only C++98 constructs.
* Output: Generate Base element offset="" attributeBrad King2015-12-031-0/+4
| | | | | | | | The gccxml output format had this attribute, defined by GCC as "The offset where this basetype appears in its containing type". This is well-defined only for non-virtual base classes. GitHub-Issue: 34
* Output: Add overrides="" attribute to methodsJörg Wollenschläger2015-08-251-0/+6
| | | | The gccxml output format had this attribute.
* Output: Add annotate() to more declaration attributes=""Jörg Wollenschläger2015-08-245-0/+9
| | | | | | | Extend the change from commit e73fba54 (Output: Add annotate() to function declaration attributes="", 2015-08-18) to support record, enum, field, variable, and typedef since gccxml also supported attributes in these.
* Output: Add annotate() to function argument attributes=""Michka Popoff2015-08-201-0/+1
| | | | | | Extend the change from commit e73fba54 (Output: Add annotate() to function declaration attributes="", 2015-08-18) to function arguments since gccxml also supported attributes there.
* Output: Add annotate() to function declaration attributes=""Brad King2015-08-188-0/+24
| | | | | | | | | While CastXML cannot support the `gccxml()` attribute because Clang does not define it, we can support the `annotate()` attribute that Clang provides for arbitrary string annotations. This should fill the same use case as the `gccxml()` attribute did for clients. GitHub-Issue: 25
* test: Add tests for Constructor, Destructor, and Converter elementsBrad King2015-08-183-0/+9
|
* test: Add case for nested namespacesBrad King2015-06-081-0/+11
|
* Output: Place inline namespace members in containing namespaceBrad King2015-05-153-0/+19
| | | | | | | | | | | | | | | | | | An inline namespace affects the linkage of its members but for APIs the members are effectively in the containing namespace. Generate output as if they were really in the containing namespace and do not generate a Namespace element for an inline namespace. If --castxml-start names an inline namespace simply ignore it to avoid dumping a Namespace element for it. One can argue this is valid since the inline namespace should not normally be named in API usage. Set our printing policy to avoid showing the inline namespace component automatically. Note that expressions in the source code that hard-code the inline namespace name will still be preserved and show the inline namespace when printed (e.g. Variable init="" attribute expressions). Suggested-by: Michka Popoff <michkapopoff@gmail.com>
* Output: Do not generate name="" attribute on anonymous namespacesBrad King2015-05-151-0/+5
| | | | Be consistent with gccxml which did not generate the attribute.
* Output: Refactor generation of CvQualifiedType elementsBrad King2015-04-282-0/+8
| | | | | | | | | | | | | | | | | | | | | Previously our handling of cv-qualified types did not account for multiple locally cv-qualified types encountered through multiple levels of desugaring. This could lead to CvQualifiedType elements that reference elements that are generated with a different id. Refactor our internal representation of dump nodes to keep cv-qualifiers in the node ids. Teach AddTypeDumpNode to collect cv-qualifiers from each level of desugaring and compute their union. Once the desugared unqualified type is found, generate one CvQualifiedType element for the qualified type, if any. Update the expected test output to account for the new ordering of nodes. Mark the Class-template-constructor-template test case as no longer broken because this approach fixes it. Add test cases covering cv-qualifiers added at different layers of desugaring (via "T const" where T is already a "const" type in a template instantiation). GitHub-Issue: 10
* Output: Handle function types with no prototypeBrad King2015-03-311-0/+1
| | | | | | | | | | | A FunctionType may be either FunctionProtoType or FunctionNoProtoType. Check that runtime downcasts to FunctionProtoType succeed before using them. For FunctionNoProtoType we will simply output the type "int()", which is compatible with gccxml format (gccxml never lacked prototypes because it always operates in C++ mode). In CastXML we can encounter functions with no prototype in C++ modes when traversing Clang buildins. GitHub-Issue: 1
* Output: Traverse namespace redeclarationsBrad King2015-03-232-0/+14
| | | | | | | | | | | | | | | A namespace may be redeclared to add more members: namespace ns { void f1(); } namespace ns { void f2(); } Fix our AST traversal to consider members from all redeclarations of each namespace instead of only the canonical (first) one. Previously we generated members from later redeclarations only if they were referenced from other declarations we happened to encounter. Reported-by: Michka Popoff <michkapopoff@gmail.com>
* Detect: Provide __float128 when simulating GNU compilersBrad King2015-02-252-0/+2
| | | | | | | GNU compilers provide a __float128 builtin type on Intel architectures. When simulating such GNU compiler preprocessing, define a __float128 type with the expected size and alignment in case the translation unit references it.
* test: Fix Function-template source to return from startBrad King2015-02-251-1/+1
| | | | | Fix the start() function in test/input/Function-template.cxx to actually return a value from its implementation.
* Output: Fix references to cv-qualified types encountered indirectlyBrad King2014-12-111-0/+6
| | | | | | | | | | | | Teach AddDumpNode to optionally report back the actual QualType that it selects after possibly unwrapping some layers of indirection in the Clang AST. Use this in GetTypeIdRef so that we check this actual QualType's cv qualifiers instead of the original QualType. Otherwise we may generate a dangling reference to the id number that is replaced by a CvQualifiedType id. Fix the expected output of existing test cases that exhibit this problem and add a new test case designed to cover the behavior explicitly.