Commit Graph

31 Commits

Author SHA1 Message Date
John McCall 1c70e99a2c Hack in some really terrible C++ record PCH support that I need right now.
This is required in order to test:

The ASTImporter should set base classes after formally entering the definition.

llvm-svn: 105401
2010-06-03 19:28:45 +00:00
Chris Lattner 198cb4df6e Instead of counting totally diagnostics, split the count into a count
of errors and warnings.  This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.

llvm-svn: 100675
2010-04-07 18:47:42 +00:00
Douglas Gregor f06027db65 Add test for AST importing of C++ namespaces, missing from a prior commit
llvm-svn: 97062
2010-02-24 21:53:36 +00:00
Douglas Gregor 5481d329a3 AST import for CStyleCastExpr. With this, we can import Cocoa.h into an empty context
llvm-svn: 96648
2010-02-19 01:32:14 +00:00
Douglas Gregor d8552cdc96 AST import for sizeof and alignof expressions
llvm-svn: 96647
2010-02-19 01:24:23 +00:00
Douglas Gregor 52f820ead4 AST import for DeclRefExprs
llvm-svn: 96646
2010-02-19 01:17:02 +00:00
Douglas Gregor c74247eddd AST import of parenthesized expressions, unary operators, binary
operators, and compound assignment operators.

llvm-svn: 96643
2010-02-19 01:07:06 +00:00
Douglas Gregor 623421d385 AST import for character literals
llvm-svn: 96557
2010-02-18 02:21:22 +00:00
Douglas Gregor 8661a72b48 AST import for forward declarations of Objective-C protocols
llvm-svn: 96555
2010-02-18 02:12:22 +00:00
Douglas Gregor 06537af873 Implement import of forward declarations of Objective-C classes
llvm-svn: 96554
2010-02-18 02:04:09 +00:00
Douglas Gregor 84c51c3581 AST import of Objective-C categories.
llvm-svn: 96551
2010-02-18 01:47:50 +00:00
Douglas Gregor a11c45866e Implement AST merging for Objective-C properties.
llvm-svn: 96483
2010-02-17 18:02:10 +00:00
Douglas Gregor 98d156a87e AST import for Objective-C protocols
llvm-svn: 96478
2010-02-17 16:12:00 +00:00
Douglas Gregor 43f54796ab Implement AST importing and checking for Objective-C method declarations.
llvm-svn: 96442
2010-02-17 02:12:47 +00:00
Douglas Gregor 7244b0bb86 Implement AST importing of Objective-C instance variables.
Check superclasses when merging two Objective-C @interfaces.

llvm-svn: 96420
2010-02-17 00:34:30 +00:00
Douglas Gregor 4563532043 Skeleton for importing Objective-C classes
llvm-svn: 96306
2010-02-16 01:20:57 +00:00
Douglas Gregor b4964f7705 Cope with anonymous tags defined within declarators by structurally
comparing their types under the assumption that they are equivalent,
rather than importing the types and then checking for compatibility. A
few minor tweaks here:
  - Teach structural matching to handle compatibility between
  function types with prototypes and those without prototypes.
  - Teach structural matching that an incomplete record decl is the
  same as any other record decl with the same name.
  - Keep track of pairs of declarations that we have already checked
  (but failed to find as structurally matching), so we don't emit
  diagnostics repeatedly.
  - When importing a typedef of an anonymous tag, be sure to link the
  imported tag type to its typedef.

With these changes, we survive a repeated import of <stdlib.h> and
<stdio.h>. Alas, the ASTNodeImporter is getting a little grotty.

llvm-svn: 96298
2010-02-15 23:54:17 +00:00
Douglas Gregor 3996e249ed Reimplement the structural-equality checks used to determine whether
two types in different AST contexts are equivalent. Rather than
transforming the type from one context into the other context, we
perform a deep structural comparison of the types. This change
addresses a serious problem with recursive data types like

  struct ListNode {
    int value;
    struct ListNode *Next;
  } xList;

llvm-svn: 96278
2010-02-15 22:01:00 +00:00
Douglas Gregor 8cdbe64de4 Funnel changes to the ImportedDecls list in the ASTImporter through a
single Imported function, in preparation for fixing a serious design
flaw.

llvm-svn: 96044
2010-02-12 23:44:20 +00:00
Douglas Gregor 98c1018337 Implement AST importing and merging for enumeration types and
enumerators, along with ImplicitCastExprs to make it work.

llvm-svn: 96024
2010-02-12 22:17:39 +00:00
Douglas Gregor 2579105c4e Handle AST merges of incomplete class types.
llvm-svn: 95941
2010-02-12 00:09:27 +00:00
Douglas Gregor 7eeb59752a When AST merging for record declarations fails, warn about the
incompatibility and show where the structural differences are. For
example:

struct1.c:36:8: warning: type 'struct S7' has incompatible definitions
in different translation units
struct S7 { int i : 8; unsigned j : 8; } x7;
       ^
struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
struct S7 { int i : 8; unsigned j : 8; } x7;
                                ^
struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
struct S7 { int i : 8; unsigned j : 16; } x7;
                                ^

There are a few changes to make this work:
  - ASTImporter now has only a single Diagnostic object, not multiple
  diagnostic objects. Otherwise, having a warning/error printed via
  one Diagnostic and its note printed on the other Diagnostic could
  cause the note to be suppressed.
  - Implemented import functionality for IntegerLiteral (along with
  general support for statements and expressions)

llvm-svn: 95900
2010-02-11 19:21:55 +00:00
Douglas Gregor 69837bed2f Add missing test cases for AST merging of structures.
llvm-svn: 95886
2010-02-11 18:18:11 +00:00
Douglas Gregor bb7930c17e Implement basic support for merging function declarations across
translation units.

llvm-svn: 95794
2010-02-10 19:54:31 +00:00
Douglas Gregor fa7a0e5198 Implement AST importing and merging for typedefs. As part of this, provide a lame implementation for importing TypeSourceInfos.
llvm-svn: 95783
2010-02-10 17:47:19 +00:00
Douglas Gregor 2fbe558cfe Teach AST merging that variables with incomplete array types can be
merged with variables of constant array types. Also, make sure that we
call DiagnosticClient's BeginSourceFile/EndSourceFile, so that it has
a LangOptions to work with.

llvm-svn: 95782
2010-02-10 17:16:49 +00:00
Douglas Gregor 0f058c83a7 Add missing header file
llvm-svn: 95751
2010-02-10 01:35:04 +00:00
Douglas Gregor 811663eb11 Implement basic support for importing source locations from one AST
into another AST, including their include history. Here's an example
error that involves a conflict merging a variable with different types
in two translation units (diagnosed in the third AST context into
which everything is merged).

/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var2.c:3:5:
error: external variable 'x2' declared with incompatible types in
different translation units ('int' vs. 'double')
int x2;
    ^
In file included from
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.c:3:
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.h:1:8:
note: declared here with type 'double'
double x2;
       ^

Although we maintain include history, we do not maintain macro
instantiation history across a merge. Instead, we map down to the
spelling location (for now!).

llvm-svn: 95732
2010-02-10 00:15:17 +00:00
Douglas Gregor 44e16a3f4c Add in the LIT magic to avoid running AST merge test inputs as
separate tests. Thanks, Daniel!

llvm-svn: 95705
2010-02-09 22:40:03 +00:00
Douglas Gregor 6b2a474531 Hook up the diagnostics-argument printer when merging AST files, so
that we get readable diagnostics such as:

error: external variable 'x1' declared with incompatible types in
different translation units ('double *' vs. 'float **')

However, there is no translation of source locations, yet.

llvm-svn: 95704
2010-02-09 22:37:58 +00:00
Douglas Gregor 62d311fdf4 Introduce a testbed for merging multiple ASTs into a single AST
context with the AST importer. WIP, still useless but at least it has
a test.

llvm-svn: 95683
2010-02-09 19:21:46 +00:00