| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
CastXML documents that the `--castxml-gccxml` output format excludes
non-c++98 constructs.
Closes: #76
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
Use a switch over the statement class and then statically downcast
to avoid repeated dynamic cast attempts when we add more cases.
|
|
|
|
| |
We operate without modifying the Clang AST. Enforce this with `const`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
| |
Other predefine checks may need to detect the actual GNU compiler too.
While at it, make these check methods `const`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
Teach UpdatePredefines to ask the CompilerInstance for the predefines.
This will allow it to ask the CompilerInstance for other information
too.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Use std::string::find instead of strstr when we do not actually need
to extract the found content as a C string.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Rename the AddDeclDumpNode that is used to add declarations for a type
to AddDeclDumpNodeForType for clarity.
|
|
|
|
| |
The gccxml output format may contain only C++98 constructs.
|
|
|
|
| |
The gccxml output format may contain only C++98 constructs.
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|