Commit Graph

34178 Commits

Author SHA1 Message Date
Chris Lattner 058b4b6b41 run .cpp files as tests
llvm-svn: 39213
2006-11-21 17:22:28 +00:00
Chris Lattner d6775fa217 add note in the output
llvm-svn: 39212
2006-11-21 06:36:58 +00:00
Chris Lattner 00348acace clear file info after processing one file, it shouldn't carry over to the
next.

llvm-svn: 39211
2006-11-21 06:34:57 +00:00
Chris Lattner 2ea9dd7fc0 ProcessInputFile no longer mutates LangInfo.
llvm-svn: 39210
2006-11-21 06:18:11 +00:00
Chris Lattner b352e3edb5 Change KeepComments/KeepMacroComments modes to be facets of the preprocessor
state, not aspects of the language standard being parsed.

llvm-svn: 39209
2006-11-21 06:17:10 +00:00
Chris Lattner ad7cdd37b3 simplify the Preprocessor ctor.
llvm-svn: 39208
2006-11-21 06:08:20 +00:00
Chris Lattner 96327eaa52 first step refactoring driver so that it can process multiple input files
at once.

llvm-svn: 39207
2006-11-21 05:52:55 +00:00
Chris Lattner a92809b1ab add an accessor
llvm-svn: 39206
2006-11-21 05:52:33 +00:00
Chris Lattner 87f267ef4e eliminate global variables now that PPCallbacks can have state
llvm-svn: 39205
2006-11-21 05:02:33 +00:00
Chris Lattner 09d5804683 Make it easier to run tests from the top level with a helper target
llvm-svn: 39204
2006-11-21 05:01:56 +00:00
Chris Lattner b8d6d5a81d Formalize preprocessor callbacks together into a PPCallbacks structure, instead
of having a loose collection of function pointers.  This also allows clients to
maintain state, and reduces the size of the Preprocessor.h interface.

llvm-svn: 39203
2006-11-21 04:09:30 +00:00
Chris Lattner 38495cb2e7 -fsyntax-only is synonym for -parse-ast for now.
llvm-svn: 39202
2006-11-21 04:07:21 +00:00
Chris Lattner 017865fb62 adjust test
llvm-svn: 39201
2006-11-21 04:06:06 +00:00
Chris Lattner b0e7a06e53 Add some standard include paths for C++.
llvm-svn: 39200
2006-11-21 03:40:37 +00:00
Chris Lattner d8702cd845 Implement a TODO: properly invoke actions for the * in things like:
where P is a pointer.

  int A[*P];

llvm-svn: 39199
2006-11-21 03:12:15 +00:00
Chris Lattner a966bf6ebf fix a variable shadowing issue that caused us to misparse:
void B() {
  memcpy (3, 2, 1);
}

where memcpy is undeclared.

llvm-svn: 39198
2006-11-21 01:40:01 +00:00
Chris Lattner 740b2f30c7 When a decl is popped from its current scope, link it to the decl chain for
the containing function.  This avoids leaking decls.

llvm-svn: 39197
2006-11-21 01:32:20 +00:00
Chris Lattner 229ce60fc9 split the ParseFunctionDefinition action into two actions, one which is
called before and one which is called after function definition parsing.

llvm-svn: 39196
2006-11-21 01:21:07 +00:00
Chris Lattner eda517e456 new testcase
llvm-svn: 39195
2006-11-20 07:03:41 +00:00
Chris Lattner ac18be9ad2 Add support for C90 implicitly defined functions, e.g.:
int A() {
  return X();
}

llvm-svn: 39194
2006-11-20 06:49:47 +00:00
Chris Lattner 5efbb33a6b remember referenced decls in our AST's
llvm-svn: 39193
2006-11-20 05:01:40 +00:00
Chris Lattner 17ed487947 parse identifier expressions properly. This allows us diagnose this:
typedef int X;

int A() {
  return X;
}

int B() {
  return Y;
}

as:

/Users/sabre/test.c:5:10: error: unexpected type name 'X': expected expression
return X;
       ^
/Users/sabre/test.c:9:10: error: use of undeclared 'Y' value
return Y;
       ^

llvm-svn: 39192
2006-11-20 04:58:19 +00:00
Chris Lattner 0d8b1a1eff remember and pretty-print cast types
llvm-svn: 39191
2006-11-20 04:34:45 +00:00
Chris Lattner f0a40e7ef4 correctly handle stuff like:
typedef int G;
  X = sizeof(const G);
  X = sizeof(restrict G);

llvm-svn: 39190
2006-11-20 04:17:27 +00:00
Chris Lattner d0342e5989 Create a new TypeNameType class, which represents typedefs as types. This
allows us to handle stuff like:

typedef int G;
 ..
  X = sizeof(G);

llvm-svn: 39189
2006-11-20 04:02:15 +00:00
Chris Lattner 2ebe4bb64d when a typedef name is parsed as part of declspecs, remember the decl for the
typedef.

llvm-svn: 39188
2006-11-20 01:29:42 +00:00
Chris Lattner 5ca17df626 decls should all have types
llvm-svn: 39187
2006-11-19 23:32:49 +00:00
Chris Lattner 591a675b1c remove #include of clang/Parse/DeclSpec.h from clang/AST/Decl.h
llvm-svn: 39186
2006-11-19 23:16:18 +00:00
Chris Lattner da8aa7b3a8 implement RTTI for Decl objects, eliminate some hokey virtual methods.
llvm-svn: 39185
2006-11-19 23:12:30 +00:00
Chris Lattner 200bdc3b90 add an action method for declspecs without declarators, like "struct foo;".
llvm-svn: 39184
2006-11-19 02:43:37 +00:00
Chris Lattner 94c22cd5b9 rename ParsedClassDeclaration -> ParsedObjcClassDeclaration.
llvm-svn: 39183
2006-11-19 02:35:21 +00:00
Chris Lattner 302b4be4c2 build TypedefDecl objects when parsing typedefs.
Add a parsing fastpath for when we see typedef at the top-level.

llvm-svn: 39182
2006-11-19 02:31:38 +00:00
Chris Lattner 33e8a55ed0 Parse and remember types enough that we can pretty print:
void foo(int X) {
  X = __alignof(int);
  X = sizeof(const int** restrict ** volatile*);
}

as:

x = __alignof(int)
x = sizeof(int const **restrict **volatile *)

llvm-svn: 39181
2006-11-19 01:48:02 +00:00
Chris Lattner 558cb292da add an action for parsing type names.
llvm-svn: 39180
2006-11-19 01:31:06 +00:00
Chris Lattner 52f3dc1ee3 add a note
llvm-svn: 39179
2006-11-19 01:17:45 +00:00
Chris Lattner 9dfdb3c70d rearrange the type printing code so that we can do the horrible C "inside out"
thing properly.  This allows us to print types like:
int (*A)[restrict static 4][6];

properly, in addition to representing them properly. :)

llvm-svn: 39178
2006-11-13 07:38:09 +00:00
Chris Lattner d235d162d0 change print methods to render into a string, which is more useful for diagnostics
and for handling precedence of types more accurately

llvm-svn: 39177
2006-11-13 06:22:30 +00:00
Chris Lattner 7ccecb90d4 Implement parsing, printing and AST'ing of array types (except for the bounds).
This allows us to handle:

int (*A)[restrict static 4][6];

for example.

llvm-svn: 39176
2006-11-12 08:50:50 +00:00
Chris Lattner 47814666e1 Implement and use isa/dyncast/cast etc for Type classes.
llvm-svn: 39175
2006-11-12 00:56:20 +00:00
Chris Lattner d5973ebbe2 Teach ASTContext to delete all created types in its dtor.
Teach getPointerType to (stupidly) memoize all created pointers.
Give types an enum so we can implement classof.

llvm-svn: 39174
2006-11-12 00:53:46 +00:00
Chris Lattner 970e54e3ac Build ASTs for the pointer qualifiers on declarators. This allows us to
parse (and print) things like:

int* const* restrict* const volatile***

etc.

llvm-svn: 39173
2006-11-12 00:37:36 +00:00
Chris Lattner aecbefa519 We can now parse and remember the distinction between:
'unsigned char' and 'unsigned char const'.

-Chris

llvm-svn: 39172
2006-11-12 00:05:06 +00:00
Chris Lattner 8ddf65053e DeclSpec::TQ and TypeRef::TQ should stay in sync
llvm-svn: 39171
2006-11-11 23:59:23 +00:00
Chris Lattner b571a5cbdc implement conversion of simple declspec base types, and implement TypeRef::dump
llvm-svn: 39170
2006-11-11 23:56:48 +00:00
Chris Lattner 5983de06cd add note about eliminating DeclSpec.
Add TypeRef::dump method.

llvm-svn: 39169
2006-11-11 23:56:01 +00:00
Chris Lattner 96bff30868 fix comment
llvm-svn: 39168
2006-11-11 23:55:28 +00:00
Chris Lattner 288e86ff15 Rename SemaDeclSpec.{h|cpp} back to DeclSpec.{h|cpp} now that the distinction
between sema and parse is clear.

llvm-svn: 39167
2006-11-11 23:03:42 +00:00
Chris Lattner f84a79c4e9 restructure code to build the framework for creating types from declarators.
llvm-svn: 39166
2006-11-11 22:59:23 +00:00
Chris Lattner f391a3ba70 Expand TypeRef itf
llvm-svn: 39165
2006-11-10 07:21:44 +00:00
Chris Lattner ef51c20065 add the builtin types
llvm-svn: 39164
2006-11-10 07:17:23 +00:00