summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Remove `//------...` horizontal separator commentsBrad King2016-11-105-101/+0
| | | | | Modern editors provide plenty of ways to visually separate functions. Drop the explicit comments that previously served this purpose.
* Protect hand-formatted blocks from clang-formatBrad King2016-11-102-0/+36
|
* Add a script to run clang-format on the entire source treeBrad King2016-11-101-0/+116
| | | | | | List all sources in version control and filter out those that we should not format for various reasons. Then run the clang-format tool to do an in-place update.
* Output: Exclude C++11 user defined literal operators from gccxml formatBrad King2016-10-061-0/+4
| | | | | | | CastXML documents that the `--castxml-gccxml` output format excludes non-c++98 constructs. Closes: #76
* Output: Avoid assertion failure on a FunctionDecl with no identifierBrad King2016-10-061-2/+6
| | | | | | | | | | 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
* Port to LLVM/Clang SVN r280011 (trunk) and 3.9Brad King2016-08-312-0/+23
| | | | | | | | | Since LLVM/Clang SVN r275507 (Frontend: Simplify ownership model for clang's output streams, 2016-07-15) the createDefaultOutputFile method returns ownership of the stream via unique_ptr. Also on Windows we now must link to `version.lib` because LLVM/Clang now uses the GetFileVersionInfoW symbol.
* RunClang: Convert 0 => nullptrBrad King2016-08-311-2/+2
|
* Output: Desugar typedefs whose context is a templateBrad King2016-08-161-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+4
| | | | | | | | | | 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-20/+12
| | | | | | | | | | | | | | | 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
* Utils: Add a function to perform string replacementBrad King2016-05-102-0/+15
|
* RunClang: Provide `__make_integer_seq` builtin when Clang does notBrad King2016-04-211-0/+36
| | | | | | | | | 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-9/+7
| | | | | | | | | | | | | | | 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
* RunClang: Provide `__is_assignable` builtin when simulating MSVC >= 1900Brad King2016-04-181-0/+18
| | | | | | | | Visual Studio 2015 Update 2 (cl 19.00.23918) added an `__is_assignable` builtin. It also started using the builtin in the `<type_traits>` header. Clang as of version 3.8 does not support this builtin so CastXML cannot parse it. Work around this problem by adding our own implementation of the builtin.
* Output: Generalize exclusion of internal `__castxml` builtinsBrad King2016-04-181-9/+9
| | | | | | Generalize exclusion of our internal `__castxml__float128` structure to exclude all translation-unit-level named declarations whose names contain `__castxml`. This will support other future internal builtins.
* Output: Update `cvs_revision` number to indicate output changeMichka Popoff2016-04-131-1/+1
| | | | | | | Update the file format revision number so tools can distinguish the new content from that produced by older CastXML versions. GitHub-Issues: CastXML/CastXML#52, CastXML/CastXML#55, CastXML/CastXML#56
* Output: Fix access specifier of class template instantiationsBrad King2016-04-121-7/+28
| | | | | | | | | | | | | | | | | | 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
* RunClang: Remove unused variableBrad King2016-04-121-2/+1
|
* RunClang: Force semantic check of implicit default constructorBrad King2016-04-121-2/+10
| | | | | | | | | | | | | | | | | For a struct like `struct foo { int const bar; };` Clang in C++98 mode does not delete the invalid implicit default constructor. It also does not semantically check such trivial constructors until they are actually used. This causes our `AddImplicitMembers` logic to incorrectly add the default constructor and not mark it invalid. Clang itself encounters this situation when compiling a call to such a trivial default constructor. Its `PerformConstructorInitialization` function in `lib/Sema/SemaInit.cpp` explicitly checks for this case and forces semantic checking since `Sema::MarkFunctionReferenced` skipped it. Teach `AddImplicitMembers` to do the same and convert the "broken" test case to expect success. GitHub-Issue: CastXML/CastXML#55
* castxml: Support -std=c99 and -std=c11 with --castxml-gccxmlBrad King2016-03-251-8/+0
| | | | | | | | | Drop the rejection of `-std={c99,c11}` and `--castxml-gccxml` together. Extend the test suite to run all gccxml C output format tests in `-std=c99` and `-std=c11` modes to verify the behavior of the mode is as close as possible to other modes. GitHub-Issue: CastXML/CastXML#54
* Output: Fix unnamed enum value references in default argumentsBrad King2016-03-211-1/+15
| | | | | | | | | | | | | | | | 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: Update `cvs_revision` number to indicate output changeBrad King2016-03-171-1/+1
| | | | | | | | | | Our recent changes to argument `default=""` and variable `init=""` content mean tools need to interpret the values differently. Update the file format revision number so tools can distinguish the new content from that produced by older CastXML versions. GitHub-Issue: CastXML/CastXML#51 Suggested-by: Michka Popoff <michkapopoff@gmail.com>
* Output: Print fully qualified names in variable initializersBrad King2016-03-161-1/+2
| | | | | | | | | | | | | | | | | | | 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-161-0/+30
| | | | | | | | | | | | | | | | | | | | | 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: Refactor ASTVisitor::PrintHelpStmt dispatchBrad King2016-03-161-1/+6
| | | | | Use a switch over the statement class and then statically downcast to avoid repeated dynamic cast attempts when we add more cases.
* Output: Constify ASTVisitor::PrintHelpStmt input argumentBrad King2016-03-161-2/+2
| | | | We operate without modifying the Clang AST. Enforce this with `const`.
* Output: Print fully qualified declarations named in default argumentsBrad King2016-03-161-1/+28
| | | | | | | | | | | | | | | | | | 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-5/+16
| | | | | | | | | | | | | | | | | 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: Avoid GNU extensions in glibc math headers on i386Brad King2016-02-091-0/+14
| | | | | | | | On i386 with optimizations enabled, the `bits/mathinline.h` header may use a GNU extension not implemented by Clang. Avoid parsing this code by defining `__NO_MATH_INLINES` so it will be preprocessed out. GitHub-Issue: #47
* RunClang: Tolerate __builtin_va_arg_pack during parsingBrad King2016-02-011-0/+14
| | | | | | | | | 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
* RunClang: Factor out helper for detecting actual GNU compilerBrad King2016-02-011-2/+6
| | | | | Other predefine checks may need to detect the actual GNU compiler too. While at it, make these check methods `const`.
* castxml: Fix `__float128` simulation with `-std=gnu++{11,14}`Brad King2016-01-262-5/+18
| | | | | | | | | | | | | | | | | | | | | Since LLVM/Clang does not natively support the `__float128` GNU extension CastXML inserts its own preamble declaring the name as a typedef to a struct that we handle specially during output. This allows us to support `--castxml-cc-gnu g++` preprocessor conditions that cause code to use `__float128`. However, when Clang has GNU extensions enabled with C++11 or later it adds its own fake `__float128` builtin type in order to tolerate the type while parsing. These two workarounds conflict, leading to: error: typedef redefinition with different types ('struct __castxml__float128' vs '__float128') Fix this by skipping our own typedef for `__float128` when we expect Clang to provide its own fake builtin type. Then teach our output code to recognize the Clang builtin and replace it with FundamentalType just as we do for or own struct `__castxml__float128`. GitHub-Issue: 44
* Output: Fix `__float128` mangled name suppression with MSVC manglingBrad King2016-01-262-4/+4
| | | | | | | Suppress mangled name output for any name containing `__float128` so it works for both GNU and MSVC mangling conventions. Rename the struct `__castxml_float128` to `__castxml__float128` so that the full name of the type always appears.
* Output: Factor out a helper to print our fake __float128 FundamentalTypeBrad King2016-01-251-3/+11
|
* RunClang: Pass CompilerInstance to UpdatePredefinesBrad King2016-01-251-3/+4
| | | | | | Teach UpdatePredefines to ask the CompilerInstance for the predefines. This will allow it to ask the CompilerInstance for other information too.
* RunClang: Adopt logic to add fake __float128 builtinBrad King2016-01-252-16/+21
| | | | | | Delay the decision until we are constructing the final list of builtins when the Clang CompilerInstance is available. This will allow us to adapt based on the compiler language mode.
* RunClang: Refactor preprocessor definition searchesBrad King2016-01-251-8/+9
| | | | | Use std::string::find instead of strstr when we do not actually need to extract the found content as a C string.
* Output: Fix references to types whose declaration is invalidBrad King2015-12-141-8/+9
| | | | | | | | | | | | 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: Clarify name of method adding a decl for a typeBrad King2015-12-141-8/+10
| | | | | Rename the AddDeclDumpNode that is used to add declarations for a type to AddDeclDumpNodeForType for clarity.
* Output: Skip C++11 type alias declarationsBrad King2015-12-101-0/+8
| | | | The gccxml output format may contain only C++98 constructs.
* Output: Skip Typedef elements that refer to rvalue referencesBrad King2015-12-101-0/+7
| | | | The gccxml output format may contain only C++98 constructs.
* Output: Generate Base element offset="" attributeBrad King2015-12-031-1/+10
| | | | | | | | 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
* Add predefined macros for versions of CastXML and internal ClangBrad King2015-12-031-0/+23
| | | | | | | Some translation units may need to know the real tool that is performing the preprocessing even when --castxml-cc-<id> switches predefined macros to those from another compiler. Provide dedicated version macros for both CastXML and the internal Clang against which it is built.
* RunClang: Refactor built-in predefines substitutionBrad King2015-12-031-13/+19
| | | | | | Always split the predefines string into a prefix, body of actual builtins, and suffix. Replace the body with builtins detected from --castxml-cc-<id>, if given.
* Utils: Add function to get version value encoded as an integerBrad King2015-12-032-0/+11
|
* Version: Add macros for individual version componentsBrad King2015-12-032-0/+15
|
* Version: Clarify name of version string macroBrad King2015-12-032-2/+2
|
* castxml: Link to LLVMSupport libraryBrad King2015-09-231-0/+1
| | | | | | | | We include LLVM support headers and use the APIs, so we should link to the corresponding library directly instead of depending on a transitive dependency through other libraries we use. GitHub-Issue: 30
* RunClang: Detect C and C++ std level from --castxml-cc-<id>Brad King2015-09-183-2/+95
| | | | | | | | If no -std= option is explicitly given then parse the __cplusplus or __STDC_VERSION__ preprocessor definition from the compiler output and add the corresponding -std= flag. For MSVC we need to map _MSC_VER to -std= ourselves because the compiler does not define __cplusplus to standard values and each version hard-codes its C++ standard level.
* castxml: Allow --castxml-cc-<id> to detect C language settingsBrad King2015-09-182-12/+20
| | | | | | If the "<id>" is "gnu-c" or "msvc-c" then run the given compiler command line on a C source file instead of C++. This allows C language settings of the given compiler to be detected.