Граф коммитов

56 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 27c8dc06f6 Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 00:13:59 +00:00
Argyrios Kyrtzidis 971c4fae60 -Add support for cv-qualifiers after function declarators.
-Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58120 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 21:46:40 +00:00
Chris Lattner c46d1a1f8a implement a couple fixme's by implementing __extension__ properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57806 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20 06:45:43 +00:00
Chris Lattner aab740af64 Support attributes in *yet another* place. Is there any place you
can't stick an attributes?


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57795 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20 04:57:38 +00:00
Chris Lattner 7399ee0aa6 Fix a parser bug where we let attributes interfere with our disambiguation
of whether a '(' was a grouping paren or the start of a function declarator.
This is PR2796.

Now we eat the attribute before deciding whether the paren is grouping or
not, then apply it to the resultant decl or to the first argument as needed.

One somewhat surprising aspect of this is that attributes interact with
implicit int in cases like this:

void a(x, y) // k&r style function
void b(__attribute__(()) x, y); // function with two implicit int arguments
void c(x, __attribute__(()) y); // error, can't have attr in identifier list.

Fun stuff.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57790 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20 02:05:46 +00:00
Chris Lattner 7c186be767 Remove an implemented fixme, only treat < as a type specifier
when ObjC is turned on.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57787 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20 00:25:30 +00:00
Argyrios Kyrtzidis e75d849d91 Just do a diagIfAmbiguous -> warnIfAmbiguous rename.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57746 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 23:23:35 +00:00
Argyrios Kyrtzidis 259b0d91f2 Issue a warning when there's an ambiguous function declarator (that could be a direct initializer for a variable defition).
Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57609 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-15 23:21:32 +00:00
Argyrios Kyrtzidis 3f2a8a0de5 In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
  int (x)(0); // error, expected function declarator where the '(0)' initializer is

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57241 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 10:21:57 +00:00
Argyrios Kyrtzidis 73a0d889ed Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

e.g, for "int x(1);":
-VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr).
-hasCXXDirectInitializer() of VarDecl 'x' returns true.

A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code.
Note that codegening works now for "int x(1);" without any changes to CodeGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 17:10:33 +00:00
Argyrios Kyrtzidis e25d270b4d Allow variadic arguments without named ones for C++, e.g. "void(...);"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57143 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 00:07:55 +00:00
Argyrios Kyrtzidis 78c8d80f19 Handle ambiguities between expressions and type-ids that occur inside parentheses, e.g.:
sizeof(int()) -> "int()" is type-id
sizeof(int()+1) -> "int()+1" is expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57131 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:56:22 +00:00
Daniel Dunbar 5e592d8890 Remove a FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57015 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 16:42:10 +00:00
Daniel Dunbar 1bfe1c2129 Pass postfix attributes to ActOnFields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 02:03:53 +00:00
Steve Naroff 4f9b9f1e68 Fix http://llvm.org/bugs/show_bug.cgi?id=2816.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56433 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-22 10:28:57 +00:00
Argyrios Kyrtzidis e281b4cb3c Fold Parser::ParseTag into Parser::ParseEnumSpecifier, as suggested in this post:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-September/002721.html

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56081 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 00:21:41 +00:00
Argyrios Kyrtzidis 0f07203293 Support "typeof unary-expression" (GNU C++ extension).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55833 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 11:26:19 +00:00
Steve Naroff 4ef1c99433 Fix Parser::ParseDeclaratorInternal(): add langopts test when recognizing blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55468 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 10:07:06 +00:00
Steve Naroff 5618bd4a52 First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55417 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-27 16:04:49 +00:00
Argyrios Kyrtzidis 0919f9e800 Set the SourceRange ending of DeclSpec, when Parser::ParseTypeofSpecifier finishes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54840 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-16 10:21:33 +00:00
Daniel Dunbar e4858a65a9 More #include cleaning
- Drop Diagnostic.h from DeclSpec.h, move utility Diag methods into
   implementation .cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54626 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 03:45:03 +00:00
Argyrios Kyrtzidis 64c438a4be Implement support for the 'wchar_t' C++ type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54585 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-09 16:51:54 +00:00
Daniel Dunbar 914701ed49 Move AsmLabel into Declarator instead of just a parameter to
ActOnDeclarator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 16:28:08 +00:00
Daniel Dunbar a80f8749f2 Add more Parser/Sema support for GCC asm-label extension.
- ActOnDeclarator now takes an additional parameter which is the
   AsmLabel if used. Its unfortunate that this bubbles up this high,
   but we cannot just lump it in as an attribute without mistakenly
   *accepting* it as an attribute.
 - The actual asm-label itself is, however, encoded as an AsmLabelAttr
   on the FunctionDecl.
 - Slightly improved parser error recovery on malformed asm-labels.
 - CodeGen support still missing...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54339 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 01:35:17 +00:00
Argyrios Kyrtzidis 39caa08809 Wherever a type is used/returned from the Action module, use TypeTy instead of DeclTy or void.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54265 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-01 10:35:27 +00:00
Chris Lattner e13b9595dc pull protocol resolution out into ActOnStartProtocolInterface.
This temporarily duplicates ParseObjCProtocolReferences, but it
will be removed in the future.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54092 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 04:03:38 +00:00
Chris Lattner eacc39212e simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54091 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 03:47:43 +00:00
Chris Lattner f3948c41ca < only starts a declspec in objc mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54089 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 03:38:44 +00:00
Chris Lattner fc416a4e0d remove fixed fixme
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54088 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 01:56:46 +00:00
Chris Lattner ae4da6150b make DeclSpec manage its own protocol qualifier list memory instead of having
clients allocate the memory and it delete it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54087 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 01:53:50 +00:00
Chris Lattner 3bd934a624 Fix hte next wave of problems with protocol qualified ID:
1) reject stuff like "id<foo> short" and "<foo> short".  2) set
the declspec range correctly 3) only parse protocol qualifiers
when in objc mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54086 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 01:18:38 +00:00
Chris Lattner bce6135441 improve handling of the horrible GCC objc extension that treats "<foo>"
like "id<foo>".  This 1) fixes an infinite loop in the parser on things
like "short<foo>" 2) emits a warning about this bogus construct and 3)
changes the testcase to be substantially reduced.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54082 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-26 00:20:22 +00:00
Chris Lattner 7caeabd868 minor cleanup to the actions interface to pass around SmallVectorImpl instead
of a specific smallvector size.

Fix protocol lists to pass down proper location info, so we get diagnostics
like this:

t.m:3:35: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                  ^

instead of this:

t.m:3:44: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                           ^


Add a new IdentifierLocPair typedef which is just a pair<IdentifierInfo*, SourceLocation>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53883 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 22:17:28 +00:00
Chris Lattner 5a6ddbf295 add parser and sema support for the funny ObjC '@defs' thing.
Patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52586 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 19:39:06 +00:00
Steve Naroff d3ded1ffac Support "<p>" as a short-hand for "id<p>". Here's a comment from GCC (the only documentation I could find on it).
/* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" - nisse@lysator.liu.se.  */

This commit adds the parser magic. The type associated with <p> is still incorrect. Will discuss with Chris.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51972 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 00:02:44 +00:00
Argyrios Kyrtzidis 00bc645d15 -Implement proper name lookup for namespaces.
-identifierResolver exposes an iterator interface to get all decls through the scope chain.
-The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for all reachable decls of an identifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50923 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 23:39:43 +00:00
Douglas Gregor e37ac4ff16 This patch adds very basic support for parsing and type-checking class
inheritance in C++. It'll parse the base-specifier list, e.g.,

 class D : public B1, virtual public B2 { };

and do some of the simpler semantic checks (B1 and B2 are classes;
they aren't unions or incomplete types, etc).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49623 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-13 21:30:24 +00:00
Chris Lattner 99dc914221 This patch is just the easy part of the class names patch, which
allows the parsing of "class" in addition to "struct" and "union" to
declare a record.  So this patch allows:

 class C { };
 class C c1;

But it does not contain the lookup bits, so this won't work yet:

 C c2;

Patch by Doug Gregor!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49613 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-13 18:59:07 +00:00
Chris Lattner 9e979557ee Default argument cleanups and minor improvements, patch by
Doug Gregor!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49598 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-12 23:52:44 +00:00
Fariborz Jahanian 1d78cc4430 Patch for:
1) objc ivar processing is split out of ActOnField into its own ActOnIvar method.
2) the new objc ivar action takes visibility info directly, eliminating 
  AllVisibilities in ParseObjCClassInstanceVariables.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 23:32:45 +00:00
Chris Lattner ebe457c344 reduce the amount of 'C++ magic' this code depends on :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49489 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 16:37:40 +00:00
Chris Lattner e13594279a refactor Parser::ParseStructDeclaration to return a vector of uninterpreted
declarators.  This allows the clients (C structs, objc classes, objc 
properties, [future] C++ classes) etc, to do custom processing before invoking
an action.

This has two benefits in the short term:
1) objc ivar processing should be split out of ActOnField into its own ActOn method.
2) the new objc ivar action can take visibility info directly, eliminating 
   AllVisibilities in ParseObjCClassInstanceVariables.
3) objc properties can pass their own special sauce down to sema as well.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49468 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 06:46:29 +00:00
Chris Lattner 60b1e3ebe4 Simplify lifetime of location object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49467 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 06:15:14 +00:00
Chris Lattner 8123a95c33 Several improvements from Doug Gregor related to default
argument handling.  I'll fix up the c89 (void) thing next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49459 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 02:22:51 +00:00
Chris Lattner 0442108783 Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49369 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-08 04:40:51 +00:00
Chris Lattner 3420766281 move a semantic check out of the parser into sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49273 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 07:49:57 +00:00
Chris Lattner f97409f352 now that identifier list parsing is split out, simplify handling of
normal typed argument lists.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49272 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 06:57:35 +00:00
Chris Lattner 3825c2eb00 reject 'int test(x, x) int x; {}'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 06:50:56 +00:00
Chris Lattner aaf9ddbeab reject 'typedef int y; int test(x, y)'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49270 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 06:47:48 +00:00
Chris Lattner 50c6477a06 simplify Parser::ParseFunctionDeclaratorIdentifierList
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49269 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 06:39:19 +00:00