summaryrefslogtreecommitdiffstats
path: root/test/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* Output: Add annotate() to function declaration attributes=""Brad King2015-08-181-0/+8
| | | | | | | | | 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-181-0/+3
|
* test: Fix message about GNU CXX compiler that we find for testingBrad King2015-08-181-2/+1
| | | | | Remove a stray line and fix a typo introduced by commit 5c8a1e73 (test: Add infrastructure to run tests against real GNU compilers, 2015-02-24).
* RunClang: Exit with error if compilation jobs fail to buildBrad King2015-08-071-0/+1
| | | | | | | | If an error occurs during Driver::BuildCompilation then exit with an error code immediately. This is important when an input file is missing, for example. GitHub-Issue: 23
* test: Run __float128 tests only if GNU compiler supports itBrad King2015-07-201-12/+34
| | | | | | | | | CastXML conditionally supports __float128 when asked to simulate a GNU compiler that supports it. The type is available only on certain architectures, so do not run the tests for __float128 if the GNU compiler does not support it for the current architecture. GitHub-Issue: 22
* Output: Further hide our __float128 struct from generated xmlBrad King2015-06-241-0/+10
| | | | | | | | | | | | | | | Give the our __float128 struct an internal '__castxml' name so that it can be identified during traversal of member lists. Do not report the struct as a member of the translation unit since the typedef will be generated as a FundamentalType directly. Also generate empty mangled="" attributes for mangled names involving our __float128 struct since the mangled names will not use the "g" that GCC would for the builtin type. Add test cases that do not use --castxml-start. Verify that no test case produces '__castxml' in its output to ensure we always hide such internal details from the generated output. GitHub-Issue: 18
* test: Add infrastructure to test without --castxml-start optionBrad King2015-06-231-1/+1
|
* castxml: Teach --castxml-start to support a comma-separated listMichka Popoff2015-06-081-0/+9
| | | | | | | In gccxml one could input a comma-separated list for the starting declarations to parse. Add support for this with tests for cases were a comma-separated list is used, and for the case where --castxml-start is used multiple times.
* test: Add infrastructure for custom test input and start optionsBrad King2015-06-081-2/+13
|
* test: Add case for nested namespacesBrad King2015-06-081-0/+1
|
* castxml: Allow -target option to override --castxml-cc-<id> detectionBrad King2015-05-281-0/+2
| | | | | | | If the command line contains an explicit '-target' option then do not consider the target platform detected from any --castxml-cc-<id> option. Instead simply honor the explicitly requested target. This will be particularly helpful for targets that CastXML has not learned to detect.
* test: Add cases covering --castxml-cc-<id> target triple detectionBrad King2015-05-281-0/+9
| | | | | Add test cases for the changes in commit 3c777ef360 (Detect: Improve target triple selection, 2015-04-16).
* Output: Place inline namespace members in containing namespaceBrad King2015-05-151-0/+3
| | | | | | | | | | | | | | | | | | 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/+1
| | | | Be consistent with gccxml which did not generate the attribute.
* Output: Refactor generation of CvQualifiedType elementsBrad King2015-04-281-1/+3
| | | | | | | | | | | | | | | | | | | | | 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-231-0/+2
| | | | | | | | | | | | | | | 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-251-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: Add infrastructure to run tests against real GNU compilersBrad King2015-02-251-0/+36
| | | | | Find gcc and g++ tools on the local system to use for running tests for simulating real compilers with --castxml-cc-gnu.
* Detect: Use Clang builtin include dir even with --castxml-cc-<id>Brad King2015-02-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We need implementation-provided headers to come from Clang to match what is really built in to the parser. When not using --castxml-cc-<id>, the Clang driver adds its builtin include directory in methods like Linux::AddClangSystemIncludeArgs MSVCToolChain::AddClangSystemIncludeArgs CrossWindowsToolChain::AddClangSystemIncludeArgs (see lib/Driver/*ToolChain*.cpp). When using --castxml-cc-<id>, we must add the Clang builtin include dir in the appropriate place. GNU-like compilers should have a builtin include directory too, providing files like <emmintrin.h>. The Clang driver does not add this directory from GCC toolchains and instead adds its own builtin include directory. In this case, replace the detected compiler builtin include directory with ours. MSVC-like compilers have no separate builtin include directory. The Clang driver simply places its own builtin include direcory before the system include directory read from the INCLUDE environment variable. In this case, do the same.
* test: Add a case to test that -c is ignoredGaëtan Lehmann2015-02-031-0/+1
| | | | | | | The '-c' option is required to use castxml with ccache to tell ccache that we are compiling rather than linking. In castxml we already ignore the option when used with --castxml-gccxml, so add a test case to ensure the behavior is preserved in the future.
* castxml: Allow -E to suppress --castxml-gccxml when used togetherGaëtan Lehmann2015-01-281-0/+1
| | | | | | | | | | | This helps make castxml usable with ccache. In its first pass, ccache drops the -o and the output file from the command line and add the -E option to get the preprocessed output. It does not now about --castxml-gccxml, so castxml must not produce an error when the options are used together. Instead make -E suppress --castxml-gccxml, much like compilers do for -E and -c together. Co-Author: Brad King <brad.king@kitware.com>
* Output: Fix references to cv-qualified types encountered indirectlyBrad King2014-12-111-0/+1
| | | | | | | | | | | | 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.
* RunClang: Refactor definition of implicit membersBrad King2014-12-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use clang::Sema::PerformPendingInstantiations before we attempt to add implicit member definitions so any real errors show up first. Then set SuppressAllDiagnostics to suppress errors caused by the following. Iterate over all members of one class at a time in order of completion of class definition (bases before derived classes). Force definition of each member using clang::Sema::MarkFunctionReferenced followed by another call to clang::Sema::PerformPendingInstantiations to ensure that members formed by implicitly instantiated templates are completed. Clang will mark any failed declaration as invalid, allowing us to exclude it from the output. This works both for implicit and explicit members. Update the test suite to mark test cases that are no longer 'broken'. According to discussion on the Clang cfe-commits mailing list: [PATCH] Add DiagnosticSuppressionScope RAII class http://thread.gmane.org/gmane.comp.compilers.clang.scm/110832/focus=111112 this approach may depend on non-guaranteed behavior. By iterating over members in order of class definition, we mark any bad special members invalid in base classes so that when Clang processes those in derived classes the invalid members are only one "step" away. Hopefully this behavior will be easier to preserve if Clang changes in the future.
* Port to LLVM/Clang SVN r216002 (trunk)Brad King2014-08-201-1/+1
| | | | Rename 'c++1y' to 'c++14'.
* test: Add cases for --castxml-cc-(gnu|msvc) detectionBrad King2014-04-161-0/+22
| | | | | | Create dummy gnu-like and msvc-like compiler binaries. Use them with the --castxml-cc-<id> options to verify that the preprocessor definitions and include directories are detected as expected.
* Output: Add function calling convention attributesBrad King2014-04-141-0/+1
| | | | | Add to Function-like and FunctionType elements an attributes="" attribute for the calling convention as gccxml does.
* Output: Generate location attributes for builtin declarationsBrad King2014-04-111-0/+1
| | | | | | Report a file id "f0" named "<builtin>" for declarations that are generated by the compiler and have no reference location in the source. Add a test case covering the MSVC builtin "size_t" typedef.
* Output: Traverse extern "C" namespace membersBrad King2014-04-111-0/+1
| | | | Teach AddDeclContextMembers to recurse on LinkageSpecDecl members.
* Output: Drop class template partial specializations from outputBrad King2014-04-111-0/+2
| | | | | | | Since gccxml format does not support uninstantiated templates we must not output any partial specializations either. Skip class template partial specializations when traversing context members. Desugar non-dependent typedef members of class template partial specializations.
* Output: Drop functions with rvalue reference types from gccxml outputBrad King2014-04-111-0/+2
| | | | | | | | | | | Improve support for -std=c++11 with --castxml-gccxml by dropping all functions and class methods whose signature contains a rvalue reference. This subsumes the previous check for implicit move constructors and implicit move assignment operators and extends it to explicitly written declarations too. Add test cases to verify that such declarations are excluded from the output.
* castxml: Register all LLVM target architectures and asm parsersBrad King2014-04-101-0/+7
| | | | | We need as parsers to support Visual Studio system header files that contain inline assembly.
* castxml: Support -std=c++11 with --castxml-gccxmlBrad King2014-04-101-0/+11
| | | | | | | | | | | | | | | | | | | | | Parsing standard library headers in Visual Studio 11 and above requires Clang to use -std=c++11 because the headers use C++11 constructs. While gccxml output format does not support these constructs, it is still useful to be able to output interfaces from C++98 project code while tolerating C++11 constructs in system headers. Drop the rejection of -std=c++11 and --castxml-gccxml together. Teach our ASTVisitor::AddDumpNode method to skip deleted member functions, implicit move constructors, and implicit move assignment operators. This should avoid encountering any C++11 constructs that are not written explicitly in the translation unit. Extend the test suite to run all gccxml output format tests in both -std=c++98 and -std=c++11 mode to verify the behavior of the two modes is as close as possible. Tweak the Class-implicit-members expected output to tolerate the empty throw specification missing in C++11 mode. Add a RValueReferenceType test to verify that the gccxml-format output contains an Unimplemented element for the rvalue-reference type.
* test: Split gccxml test macros by language and standardBrad King2014-04-091-3/+15
| | | | | Factor out macros to add tests by individual language standard from those that cover a group of language standards.
* test: Name expected results by language standardBrad King2014-04-091-5/+5
| | | | | | Name files "gccxml.<std>.<test>.(stdout|stderr|result|xml).txt" where "<std>" is either the language standard or "any" if the result works for any standard.
* test: Support zero or many alternative expected result file namesBrad King2014-04-091-2/+2
| | | | | | Teach test/run.cmake to loop over a list of possible expected result names. This will allow tests results to be specialized in certain cases without duplicating common results.
* test: Refactor castxml_test_gccxml_common 'std' argumentBrad King2014-04-091-4/+4
| | | | Pass just the standard name and hard-code '-std=' in the implementation.
* test: Show failure when implicit member needs bad template instantiationBrad King2014-04-091-0/+1
| | | | | | | | | | | | | | | | | | | When a function template (or member of a class template) is instantiated by an implicit class member definition, Clang delays the instantiation for later handling by clang::Sema::PerformPendingInstantiations during clang::Sema::ActOnEndOfTranslationUnit. If the instantiation causes errors they are not suppressed because our clang::Sema::SFINAETrap has gone out of scope. Even if we could keep a clang::Sema::SFINAETrap in scope, the clang::Sema::InstantiatingTemplate::Initialize method sets sema.InNonInstantiationSFINAEContext to false and adds an entry to sema.ActiveTemplateInstantiations. This prevents the clang::Sema::EmitCurrentDiagnostic call to isSFINAEContext from returning a valid SFINAE context, so errors are still not suppressed. Add a test case demonstrating this known failure, and mark it as "broken". This will require changes to Clang to fix.
* Output: Skip empty declarations in class or namespace membersBrad King2014-04-011-0/+1
| | | | Clang creates an "EmptyDecl" for a stray semicolon. Ignore it.
* castxml: Report help with '-help' and '--help'Brad King2014-04-011-0/+2
| | | | Also pass the flag through so Clang reports its help too.
* castxml: Use parentheses for '--castxml-cc-<id>' commandsBrad King2014-03-311-0/+4
| | | | | | | | Avoid requiring the option to be last by using the form --castxml-cc-<id> "(" <cc> <cc-opt>... ")" to specify compiler commands with arguments.
* Output: Skip through extern "C" contexts to enclosing namespaceBrad King2014-03-311-0/+1
| | | | | The gccxml output format has no representation for extern "C" declaration contexts, so simply report the enclosing namespace.
* Output: Skip friend function templatesBrad King2014-03-311-0/+1
| | | | | The gccxml output format does not support uninstantiated templates so we need to skip friend declarations referencing them.
* test: Use distinct output xml for every testBrad King2014-03-271-1/+2
| | | | | | | Use the castxml "-o" option to place the test output in a .xml file named for the test instead of the input file. This allows multiple tests to share the same input file base name and still run in parallel without conflict.
* test: Show duplication of reference-to-class-template-specialization typesBrad King2014-03-271-0/+7
| | | | | | | | | | | | | Clang generates a distinct TemplateSpecializationType for each appearance of A<T> for some template A<>. They are all sugar for an underlying RecordType. While they all share the same canonical type, LValueReferenceType instances that refer to them are also distinct and do not share the same canonical type because each has a different pointee type. Add tests demonstrating cases where this causes duplicate ReferenceType elements to be generated. Mark them as "broken" and add a note in the expected output that matches nothing but documents the problem.
* Output: Desugar non-dependent typedef members of class templatesBrad King2014-03-271-0/+1
| | | | | | Since gccxml does not output uninstantiated templates we must desugar typedef types that would refer to declarations whose context is a template. This is consistent with gccxml behavior.
* Output: Drop from Namespace members="" non-inline class membersBrad King2014-03-241-0/+3
| | | | | | Clang presents non-inline class members in the list of declarations in a namespace. Teach PrintMembersAttribute to skip declarations whose actual context is not the context that listed them.
* test: Add case for empty input source fileBrad King2014-03-241-0/+1
|
* Output: Skip implicit members that cannot be compiledBrad King2014-03-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Output: Report Typedef underlying typeBrad King2014-03-241-0/+1
| | | | | When a typedef is "moded" the underlying type may be different from the named type. Report the real type.