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

635 Коммитов

Автор SHA1 Сообщение Дата
Richard Smith 412e0cc52e When we see 'Class(X' or 'Class::Class(X' and we suspect that it names a
constructor, but X is not a known typename, check whether the tokens could
possibly match the syntax of a declarator before concluding that it isn't
a constructor. If it's definitely ill-formed, assume it is a constructor.

Empirical evidence suggests that this pattern is much more often a
constructor with a typoed (or not-yet-declared) type name than any of the
other possibilities, so the extra cost of the check is not expected to be
problematic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 00:56:56 +00:00
Richard Smith 1af83c444e Support for definitions of member enumerations of class templates outside the
class template's definition, and for explicit specializations of such enum
members.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-23 03:33:32 +00:00
Sebastian Redl 3e280b58db Add the missing compatibility warning for braced initializers as default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153026 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-18 22:25:45 +00:00
Richard Smith 6d96d3ad1d Small cleanup: move trailing-return-type special-casing into
getDeclSpecContextFromDeclaratorContext.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152766 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 01:02:11 +00:00
Sebastian Redl 84407ba82a Parse brace initializers as default arguments. PR12236.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152721 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-14 15:54:00 +00:00
Richard Smith 7796eb5643 Fix parsing of trailing-return-type. Types are syntactically prohibited from
being defined here: [] () -> struct S {} does not define struct S.

In passing, implement DR1318 (syntactic disambiguation of 'final').


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152551 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12 08:56:40 +00:00
Richard Smith 69730c115c Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so

  new struct S {};

is always ill-formed, even if there is a struct S in scope.

We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152549 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12 07:56:15 +00:00
David Blaikie 4e4d08403c Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 07:00:24 +00:00
Douglas Gregor 93a7067302 Document the availability attribute
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152531 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 04:53:21 +00:00
Richard Smith 36f5cfe4df Support for raw and template forms of numeric user-defined literals,
and lots of tidying up.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 08:00:36 +00:00
Douglas Gregor d78ef5b941 Streamline BalancedDelimiterTracker, by eliminating the duplicate
paren/brace/bracket tracking (the Consume* functions already did it),
removing the use of ConsumeAnyToken(), and moving the hot paths inline
with the error paths out-of-line.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152274 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 01:00:17 +00:00
Michael Han e53ac8aea2 Refactor Clang sema attribute handling.
This submission improves Clang sema handling by using Clang tablegen
to generate common boilerplate code. As a start, it implements AttributeList
enumerator generation and case statements for AttributeList::getKind.

A new field "SemaHandler" is introduced in Attr.td and by default set to 1
as most of attributes in Attr.td have semantic checking in Sema. For a small
number of attributes that don't appear in Sema, the value is set to 0.

Also there are a small number of attributes that only appear in Sema but not
in Attr.td. Currently these attributes are still hardcoded in Sema AttributeList.

Reviewed by Delesley Hutchins.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152169 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 00:12:16 +00:00
DeLesley Hutchins 7ec419aa8f Issue warning when late-parsed attributes have no declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151947 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 22:29:50 +00:00
DeLesley Hutchins 2287c5e235 Make late-parsed attributes follow the conventions of ordinary
GNU attributes to a better extent, by allowing them in more
places on a declator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151945 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 22:12:59 +00:00
Aaron Ballman 6454a02e7b Added support for parsing declspecs on enumerations. Fixes PR8783
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151798 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 04:09:28 +00:00
James Molloy 16f1f717af Reapply r151638 and r151641.
The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation.

These are now fixed, with regression tests added to catch them both (not Darwin-specific).

Original log:
====================

Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h

Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

====================




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151712 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 10:24:19 +00:00
Argyrios Kyrtzidis 32a9a7543f Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h
Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151667 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-28 23:39:14 +00:00
James Molloy fbcf0405b7 Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.
This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
  return 0;
}

This finally fixes PR5464 and PR5477.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151638 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-28 18:12:11 +00:00
Richard Smith d81e961f90 Update parser's disambiguation to cope with braced function-style casts in
C++11, and with braced-init-list initializers in conditions. This exposed an
ambiguity with enum underlying types versus bitfields, which we resolve by
treating 'enum E : T {' as always defining an enumeration (even if it would
only successfully parse as a bitfield). This appears to be g++ compatible.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151227 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-23 01:36:12 +00:00
Douglas Gregor ccc1b5eebc Implement name mangling for lambda expressions that occur within the
default arguments of function parameters. This simple-sounding task is
complicated greatly by two issues:

  (1) Default arguments aren't actually a real context, so we need to
  maintain extra state within lambda expressions to track when a
  lambda was actually in a default argument.
  (2) At the time that we parse a default argument, the FunctionDecl
  doesn't exist yet, so lambda closure types end up in the enclosing
  context. It's not clear that we ever want to change that, so instead
  we introduce the notion of the "effective" context of a declaration
  for the purposes of name mangling.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151011 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 00:37:24 +00:00
DeLesley Hutchins c24a233567 Allow thread safety attributes on function definitions.
For compatibility with gcc, clang will now parse gcc attributes on
function definitions, but issue a warning if the attribute is not a
thread safety attribute.  Warning controlled by -Wgcc-compat.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150698 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16 16:50:43 +00:00
Sebastian Redl 5b9cc5df25 Represent C++ direct initializers as ParenListExprs before semantic analysis
instead of having a special-purpose function.

- ActOnCXXDirectInitializer, which was mostly duplication of
  AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days
  ago), is dropped completely.
- MultiInitializer, which was an ugly hack I added, is dropped again.
- We now have the infrastructure in place to distinguish between
  int x = {1};
  int x({1});
  int x{1};
-- VarDecl now has getInitStyle(), which indicates which of the above was used.
-- CXXConstructExpr now has a flag to indicate that it represents list-
   initialization, although this is not yet used.
- InstantiateInitializer was renamed to SubstInitializer and simplified.
- ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which
  always produces a ParenListExpr. Placed that so far failed to convert that
  back to a ParenExpr containing comma operators have been fixed. I'm pretty
  sure I could have made a crashing test case before this.

The end result is a (I hope) considerably cleaner design of initializers.
More importantly, the fact that I can now distinguish between the various
initialization kinds means that I can get the tricky generalized initializer
test cases Johannes Schaub supplied to work. (This is not yet done.)

This commit passed self-host, with the resulting compiler passing the tests. I
hope it doesn't break more complicated code. It's a pretty big change, but one
that I feel is necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150318 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-11 23:51:47 +00:00
Sebastian Redl ecfcd56557 Drive-by fix of incorrect diagnostic, and a test case for said diagnostic. The double error is unfortunate, but I really don't see an alternative whose effort is worth it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-11 23:51:21 +00:00
Argyrios Kyrtzidis 849639d8b5 Make parsing of objc @implementations more robust.
Parsing of @implementations was based on modifying global state from
the parser; the logic for late parsing of methods was spread in multiple places
making it difficult to have a robust error recovery.

  -it was difficult to ensure that we don't neglect parsing the lexed methods.
  -it was difficult to setup the original objc container context for parsing the lexed methods
   after completing ParseObjCAtImplementationDeclaration and returning to top level context.

Enhance parsing of @implementations by centralizing it in Parser::ParseObjCAtImplementationDeclaration().
ParseObjCAtImplementationDeclaration now returns only after an @implementation is fully parsed;
all the data and logic for late parsing of methods is now in one place.

This allows us to provide code-completion for late parsed methods with mis-matched braces.
rdar://10775381

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149987 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-07 16:50:53 +00:00
Dylan Noblesmith f7ccbad5d9 Basic: import SmallString<> into clang namespace
(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05 02:13:05 +00:00
Benjamin Kramer 8fe83e1df9 Move a method from IdentifierTable.h out of line and remove the SmallString include.
Fix all the transitive include users.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149783 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-04 13:45:25 +00:00
Abramo Bagnara e4b92761b4 Added source location for the template keyword in AST template-id expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149127 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-27 09:46:47 +00:00
Abramo Bagnara fad03b75e0 Avoid redundant NNS qualification in constructor/destructor names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149124 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-27 08:46:19 +00:00
John McCall 6895a644ca Be sure to emit delayed diagnostics after parsing the declaration
of a for-range variable.  Fixes PR11793.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149109 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-27 01:29:43 +00:00
Fariborz Jahanian f96708d477 fixes location of "availability" attribute so warning is displayed at
its line. // rdar://10711037


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148747 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-23 23:38:32 +00:00
Eli Friedman 71b8fb5d42 Make clang's AST model sizeof and typeof with potentially-evaluated operands correctly, similar to what we already do with typeid.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148610 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-21 01:01:51 +00:00
DeLesley Hutchins 23323e0253 Delayed template instantiation of late-parsed attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148595 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20 22:50:54 +00:00
Richard Trieu fcaf27e185 Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148499 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-19 22:01:51 +00:00
Richard Trieu d6c7c67313 Change the error when a '+=' follows a declaration to suggest a fixit to '=' instead of just suggesting a ';'.
Old error:
plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration
  int x += 6;
       ^
       ;

New error:
plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you
      mean '='?
  int x += 6;
        ^~
        =



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148433 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-18 22:54:52 +00:00
Fariborz Jahanian 9baf39df74 objc parsing. Fixes a crash when parsing array initialization
inside a class implementation with parse errors. // rdar://10633434


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148074 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 00:14:12 +00:00
Richard Smith 7984de3564 Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
   another declarator and ended with a comma, then that comma was probably a
   typo for a semicolon:

   int n = 0, m = 1, l = 2, // k = 5;
   myImportantFunctionCall(); // oops!

 - If removing the parentheses would correctly initialize the object, then
   produce a note suggesting that fix.

 - Otherwise, if there is a simple initializer we can suggest which performs
   value-initialization, then provide a note suggesting a correction to that
   initializer.

Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12 23:53:29 +00:00
Richard Smith bdad7a2e21 Update C++11 scoped enumeration support to match the final proposal:
- reject definitions of enums within friend declarations
 - require 'enum', not 'enum class', for non-declaring references to scoped
   enumerations


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147824 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-10 01:33:14 +00:00
Richard Smith 1c94c16317 Extend the diagnostic for a ',' at the end of a declaration where a ';' was
intended to cover C++ class definitions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147808 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-09 22:31:44 +00:00
Abramo Bagnara 06284c1dc5 Fixed TypeofExpr AST and code generation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147730 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-07 10:52:36 +00:00
Richard Smith 1d7bcf4b35 Tweak to r147599 for PR10828: Move the check from the parser into sema, and use
the Semantic Powers to only warn on class types (or dependent types), where the
constructor or destructor could do something interesting.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147642 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-06 01:31:20 +00:00
Richard Smith cb7709c060 PR10828: Produce a warning when a no-arguments function is declared in block
scope, when no other indication is provided that the user intended to declare a
function rather than a variable.

Remove some false positives from the existing 'parentheses disambiguated as a
function' warning by suppressing it when the declaration is marked as 'typedef'
or 'extern'.

Add a new warning group -Wvexing-parse containing both of these warnings.

The new warning is enabled by default; despite a number of false positives (and
one bug) in clang's test-suite, I have only found genuine bugs with it when
running it over a significant quantity of real C++ code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147599 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-05 04:12:21 +00:00
Richard Smith d7c56e1114 Change the diagnostics which said 'accepted as an extension' to instead say
'is an extension'. The former is inappropriate and confusing when building with
-Werror/-pedantic-errors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-29 21:57:33 +00:00
Benjamin Kramer ffbe9b9c64 Mass rename C1x references to C11. The name hasn't proliferated like "C++0x" so this patch is surprisingly small.
Also drop -Wc1x-extensions in favor of -Wc11-extensions. I don't think we need to keep this around for compatibility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-23 17:00:35 +00:00
DeLesley Hutchins 4805f15820 Allow empty argument lists in thread safety attributes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-14 19:36:06 +00:00
Fariborz Jahanian 006e42f0c8 Add ability to supply additional message to availability macros,
// rdar://10095131


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146304 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-10 00:28:41 +00:00
Fariborz Jahanian 5a477dbf75 deprecated enum should not warn when used initializing another deprecated enumerator.
// rdar://10535640


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146218 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-09 01:15:54 +00:00
David Blaikie 42d6d0c91a Support decltype in nested-name-specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145785 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-04 05:04:18 +00:00
Richard Smith 58196dc06e Revert most of r145372 for now. Lookahead beyond the ';' in a function
declaration tickles a bug in the way we handle visibility pragmas.

The improvement to error recovery for template function definitions declared
with the 'typedef' specifier in r145372 is unrelated and not reverted here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145541 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-30 23:45:35 +00:00
Richard Smith 874d253668 PR10101: Recover better from a common copy-paste error: if a function
declaration at namespace scope is followed by a semicolon and an open-brace
(or in C++, a 'try', ':' or '='), then the error is probably a function
definition with a spurious ';', rather than a mysterious '{'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145372 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29 05:27:40 +00:00
Douglas Gregor efaa93aaa2 Tighten up the conditions under which we consider ourselves to be
entering the context of a nested-name-specifier. Fixes
<rdar://problem/10397846>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143967 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-07 17:33:42 +00:00
Peter Collingbourne fe9b2a8410 Simplify parsing ellipsis in Parser::ParseAlignArgument, spotted by Doug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142814 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-24 17:56:00 +00:00
Peter Collingbourne 0b64ba9267 Fix grammar for C++11 alignment specifiers, and add a few FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142760 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-23 20:07:52 +00:00
Richard Smith 0706df4006 Improve the diagnostic when a comma ends up at the end of a declarator group
instead of a semicolon (as sometimes happens during refactorings). When such a
comma is seen at the end of a line, and is followed by something which can't
possibly be a declarator (or even something which might be a plausible typo for
a declarator), suggest that a semicolon was intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142544 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19 21:33:05 +00:00
Douglas Gregor 43f5103f80 Improve the warning for cv-qualifiers on free functions, from Ahmed Charles!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142478 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19 06:04:55 +00:00
Fariborz Jahanian b224343723 objc: allow class name qualified with protocols in
iboutletcollection attribute. But ignore protocol
list. // rdar://10296078


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142459 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18 23:13:50 +00:00
Fariborz Jahanian 7a81e41a5e objc: diagnose invalid argument to an
iboutletcollection attribute intead of crashing.
// rdar://10296078


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142364 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18 17:11:10 +00:00
Richard Smith fe0a0fb65f Refactor __attribute__ parsing, and add a diagnostic if the r_paren at the end
of an attrib is missing. gcc does not allow the closing parenthesis to be omitted.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142255 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 21:20:17 +00:00
Richard Smith 7fe6208c3f Implement -Wc++98-compat warnings for the parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142056 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-15 05:09:34 +00:00
Anton Korobeynikov aa4a99b4a6 Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142016 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 23:23:15 +00:00
Douglas Gregor 4a8dfb511e Introduce BalancedDelimiterTracker, to better track open/close
delimiter pairs and detect when we exceed the implementation limit for
nesting depth, from Aaron Ballman!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141782 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-12 16:37:45 +00:00
Kaelyn Uhrain fac9467d16 Add typo correction for type names.
The main motivation was to do typo correction in C++ "new" statements,
though picking it up in other places where type names are expected was
pretty much a freebie.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141621 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 01:02:41 +00:00
Eli Friedman b001de7458 Support for C1x _Atomic specifier (see testcase). This is primarily being committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic.
Thanks to Jeffrey Yasskin for the thorough review!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 23:00:33 +00:00
Peter Collingbourne b8b0e75aee OpenCL: add a non-standard extension, cl_clang_storage_class_specifiers,
which enables support for C99 storage-class specifiers.

This extension is intended to be used by implementations to implement
OpenCL C built-in functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141271 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 03:01:00 +00:00
John McCall cdda47faab Parse attributes written in an ObjC method parameter type as
attributes on the parameter declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140944 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-01 09:56:14 +00:00
Peter Collingbourne 82d0b0aab9 Add support for alignment-specifiers in C1X and C++11, remove
support for the C++0x draft [[align]] attribute and add the C1X
standard header file stdalign.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140796 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 18:04:28 +00:00
Peter Collingbourne f190768485 Add support for parsing the optional attribute-specifier-seq at the
end of a decl-specifier-seq

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140793 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 18:03:57 +00:00
David Blaikie 77b6de07be ArrayRef-ifying the fields passed to Sema::ActOnFields
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140293 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 02:58:26 +00:00
Francois Pichet 62ec1f2fd7 Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag.
Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139987 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-17 17:15:52 +00:00
Argyrios Kyrtzidis ffcc3105d2 Record the full source range of an attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139599 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 16:05:53 +00:00
Douglas Gregor e761230ae3 __module_private__ is inherited by redeclarations of an entity, and
must also be present of the first declaration of that entity.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139384 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 19:05:14 +00:00
Douglas Gregor 8d267c57af Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is
declared in.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139348 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 02:06:17 +00:00
Caitlin Sadowski ed9d84a211 Thread safety: added support for function scopes in attribute arguments.
This patch was written by DeLesley Hutchins.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139302 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 17:42:31 +00:00
Caitlin Sadowski eff98fc356 Thread Safety: Patch to implement delayed parsing of attributes within a
class scope.

This patch was also written by DeLesley Hutchins.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139301 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 17:42:22 +00:00
Douglas Gregor 5471bc85b6 Allow C++0x enumerations with a fixed underlying type in
Objective-C. The @encode'ing of such an enumeration type is the same
as its underlying type. <rdar://problem/5276348>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139297 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 17:18:35 +00:00
Richard Smith 87e96eb04b PR10458: Last part of providing 'auto' type specifier as an extension in C++98: permit it within type-ids.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 20:24:20 +00:00
Richard Smith 8f4fb19085 PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139102 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 19:54:14 +00:00
Argyrios Kyrtzidis 7d10087234 Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.

Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.

Fixes rdar://10056932&8319466

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 03:32:15 +00:00
Fariborz Jahanian e8cff36db2 objc - fixes a regression in declaring c decls nested in
objective-c containers due to recent changes to objc decl 
contexts. // rdar://10041908


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138803 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 17:10:52 +00:00
Francois Pichet 58fd97a6f4 Add support for Microsoft __ptr32 keyword.
Patch by Chris Cudmore!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138533 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 00:36:46 +00:00
Fariborz Jahanian a28948f348 Restore patch I reversed in r138040. Known buildbot
failures are resolved.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138234 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 15:54:49 +00:00
Fariborz Jahanian e6f07f538f Revers r138040. Need to look at a few buildbot failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 18:02:47 +00:00
Fariborz Jahanian 3dbf2f5f00 objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138040 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 16:06:57 +00:00
Francois Pichet 3bd9aa4593 Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64-bit mode (ie: when _M_IA64 or _M_AMD64 is defined)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137935 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 09:59:55 +00:00
Caitlin Sadowski b51e0315d4 Thread Safety: Added basic argument parsing for all new attributes.
This patch special cases the parser for thread safety attributes so that all
attribute arguments are put in the argument list (instead of a special
parameter) since arguments may not otherwise resolve correctly without two-token
lookahead.

This patch also adds checks to make sure that attribute arguments are
lockable objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137130 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 17:59:31 +00:00
Douglas Gregor ae7902c429 Parsing of C++0x lambda expressions, from John Freeman with help from
David Blaikie!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136876 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 15:30:47 +00:00
Chris Lattner 5f9e272e63 remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-23 10:55:15 +00:00
Douglas Gregor 90ebed0734 Add 'mutable' to the function declarator chunk, to be used when
parsing lambda expressions, from John Freeman!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135090 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 21:47:47 +00:00
John McCall 57c13008c6 Properly protect colons when parsing a nested-name-specifier as part
of an enum specifier in dialects which permit fixed underlying types.
Fixes the rejects-valid part of PR10264.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134468 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 05:58:41 +00:00
Douglas Gregor 3fd1ba0fa1 Clean up and refactor ParseFunctionDeclarator to reduce code
repetition and better reflect the actual grammar, from John Freeman!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134417 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 16:44:18 +00:00
Richard Smith c89edf5aaa Fix AST representations of alias-declarations which define tag types. Inside classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 19:46:12 +00:00
Argyrios Kyrtzidis 25a767651d Introduce DelayedCleanupPool useful for simplifying clean-up of certain resources that, while their
lifetime is well-known and restricted, cleaning them up manually is easy to miss and cause a leak.

Use it to plug the leaking of TemplateIdAnnotation objects. rdar://9634138.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133610 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 06:09:49 +00:00
Francois Pichet e3d49b44ad Handle decltype keyword in Parser::isDeclarationSpecifier.
Fixes PR10154. Found by parsing MFC 2010 code with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133380 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 08:02:06 +00:00
John McCall f85e193739 Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:02:42 +00:00
Sebastian Redl dbef1bb8a8 Parse C++0x generalized initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132662 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-05 12:23:16 +00:00
Sean Hunt db5d44b775 Implement __underlying_type for libc++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131633 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-19 05:37:45 +00:00
Sean Hunt e4246a633b Properly parse the 'default' and 'delete' keywords.
They are actually grammatically considered definitions and parsed
accordingly.

This fixes the outstanding bugs regarding defaulting functions after
their declarations.

We now really nicely diagnose the following construct (try it!)

int foo() = delete, bar;

Still todo: Defaulted functions other than default constructors
            Test cases (including for the above construct)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131228 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-12 06:15:49 +00:00
Francois Pichet 373197b9ca Don't fail at parsing __declspec(property(get=get_func_name)). Just skip everything inside property() for now while we wait for the BoostPro people to provide a complete patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131053 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-07 19:04:49 +00:00
Sean Hunt bb85f8edca Per Richard's suggestion, rename DefLoc to DefaultLoc where it appears.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131018 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 21:24:28 +00:00
Sean Hunt fe2695eec1 Do defaulted constructors properly.
Explictly defaultedness is correctly reflected on the AST, but there are
no changes to how that affects the definition of functions or much else
really.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130974 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 01:42:00 +00:00
Sean Hunt 5f802e5140 Revert r130912 in order to approach defaulted functions from the other
direction and not introduce things in the wrong place three different
times.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130968 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 00:11:07 +00:00
Sean Hunt ad7ec12ef2 Implement some framework for defaulted constructors.
There's some unused stuff for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130912 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-05 03:36:28 +00:00
Douglas Gregor bfad9150bf libstdc++ 4.4 uses __is_signed as an identifier, while Clang treats it
as a keyword for the __is_signed type trait. Cope with this conflict
via some hackish recovery: if we see a declaration of the form

 static const bool __is_signed

then we stop treating __is_signed as a keyword and instead treat it as
an identifier. It's ugly, but it's better than making the __is_signed
type trait conditional on some language flag. Fixes PR9804.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130399 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-28 15:48:45 +00:00
Francois Pichet 338d7f7362 Upgrade Microsoft's __int8, __int16, __int32 and __int64 types from builtin defines to real types.
Otherwise statements like:
  __int64 var = __int64(0);

would be expanded to:
  long long var = long long(0);

and fail to compile.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130369 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-28 01:59:37 +00:00
Douglas Gregor d0719b183a Clean out some cruft I introduced when adding Sema::ClassifyName()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130295 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 05:44:51 +00:00
Douglas Gregor d9d75e57df Simplify the parser's handling of Sema::ClassifyName() for types, by
creating a type-annotation token rather than jumping into the
declaration parsing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130293 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 05:41:15 +00:00
Douglas Gregor 312eadb832 Implement a new identifier-classification scheme where Sema
performs name lookup for an identifier and resolves it to a
type/expression/template/etc. in the same step. This scheme is
intended to improve both performance (by reducing the number of
redundant name lookups for a given identifier token) and error
recovery (by giving Sema a chance to correct type names before the
parser has decided that the identifier isn't a type name). For
example, this allows us to properly typo-correct type names at the
beginning of a statement:

t.c:6:3: error: use of undeclared identifier 'integer'; did you mean
'Integer'?
  integer *i = 0;
  ^~~~~~~
  Integer
t.c:1:13: note: 'Integer' declared here
typedef int Integer;
            ^


Previously, we wouldn't give a Fix-It because the typo correction
occurred after the parser had checked whether "integer" was a type
name (via Sema::getTypeName(), which isn't allowed to typo-correct)
and therefore decided to parse "integer * i = 0" as an expression. By
typo-correcting earlier, we typo-correct to the type name Integer and
parse this as a declaration. 

Moreover, in this context, we can also typo-correct identifiers to
keywords, e.g.,

t.c:7:3: error: use of undeclared identifier 'vid'; did you mean
'void'?
  vid *p = i;
  ^~~
  void

and recover appropriately.

Note that this is very much a work-in-progress. The new
Sema::ClassifyName is only used for expression-or-declaration
disambiguation in C at the statement level. The next steps will be to
make this work for the same disambiguation in C++ (where
functional-style casts make some trouble), then push it
further into the parser to eliminate more redundant name lookups.

Fixes <rdar://problem/7963833> for C and starts us down the path of
<rdar://problem/8172000>.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-24 05:37:28 +00:00
Argyrios Kyrtzidis b8a9d3b801 Fixit suggestion for adding missing tag name should have a space after the tag name. Fixes rdar://9295072
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129917 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-21 17:29:47 +00:00
Fariborz Jahanian e106a0bfac Avoid superfluous warning after an error is detcted and reported.
// rdar://9132143


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129822 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-19 21:42:37 +00:00
Peter Collingbourne c6eb44b321 C1X: implement static asserts
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129555 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15 00:35:57 +00:00
Richard Smith ad762fcdc1 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129541 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-14 22:09:26 +00:00
John McCall a5fc472b35 Fix a bunch of major problems with __unknown_anytype and properly test
for them.  The only major missing feature is references.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129234 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-09 22:50:59 +00:00
Douglas Gregor b53e417ba4 Extend the new 'availability' attribute with support for an
'unavailable' argument, which specifies that the declaration to which
the attribute appertains is unavailable on that platform.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128329 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-26 03:35:55 +00:00
John McCall 0b7e678a11 Insomniac refactoring: change how the parser allocates attributes so that
AttributeLists do not accumulate over the lifetime of parsing, but are
instead reused.  Also make the arguments array not require a separate
allocation, and make availability attributes store their stuff in
augmented memory, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-24 11:26:52 +00:00
Douglas Gregor 0a0d2b1790 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128127 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-23 00:50:03 +00:00
Peter Collingbourne 207f4d8543 Add support for language-specific address spaces. On top of that,
add support for the OpenCL __private, __local, __constant and
__global address spaces, as well as the __read_only, _read_write and
__write_only image access specifiers.  Patch originally by ARM;
language-specific address space support by myself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127915 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 22:38:29 +00:00
Abramo Bagnara 0daaf32723 Use ElaboratedType also for C.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127755 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-16 20:16:18 +00:00
Douglas Gregor 18d8b7996b Disable 'auto' type deduction in Objective-C. It likes 'id' a bit too
much to be useful.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127625 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-14 21:43:30 +00:00
Abramo Bagnara 796aa443ab Forgotten part of previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127536 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-12 11:17:06 +00:00
Peter Collingbourne f4e3cfbe8a Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof.  Original
patch by Guy Benyei.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127475 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11 19:24:49 +00:00
Sebastian Redl 6e5d319b67 Propagate new-style exception spec information to Declarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127111 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-05 22:42:13 +00:00
Sebastian Redl 7acafd032e Parser support for noexcept specifications.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-05 14:45:16 +00:00
Douglas Gregor 059101f922 Push nested-name-specifier source-location information into dependent
template specialization types. This also required some parser tweaks,
since we were losing track of the nested-name-specifier's source
location information in several places in the parser. Other notable
changes this required:

  - Sema::ActOnTagTemplateIdType now type-checks and forms the
    appropriate type nodes (+ source-location information) for an
    elaborated-type-specifier ending in a template-id. Previously, we
    used a combination of ActOnTemplateIdType and
    ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped
    around a DependentTemplateSpecializationType, which duplicated the
    keyword ("class", "struct", etc.) and nested-name-specifier
    storage.

  - Sema::ActOnTemplateIdType now gets a nested-name-specifier, which
    it places into the returned type-source location information.

  - Sema::ActOnDependentTag now creates types with source-location
    information.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126808 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 00:47:37 +00:00
Douglas Gregor 9e876876af Reinstate the introduction of source-location information for
nested-name-speciciers within elaborated type names, e.g.,
 
  enum clang::NestedNameSpecifier::SpecifierKind

Fixes in this iteration include:

  (1) Compute the type-source range properly for a dependent template
  specialization type that starts with "template template-id ::", as
  in a member access expression

    dep->template f<T>::f()

  This is a latent bug I triggered with this change (because now we're
  checking the computed source ranges for dependent template
  specialization types). But the real problem was...

  (2) Make sure to set the qualifier range on a dependent template
  specialization type appropriately. This will go away once we push
  nested-name-specifier locations into dependent template
  specialization types, but it was the source of the
  valgrind errors on the buildbots.
  



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126765 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 18:12:44 +00:00
Douglas Gregor 2786864406 Revert r126748, my second attempt at nested-name-specifier source
location information for elaborated types. *sigh*


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126753 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 17:25:47 +00:00
Douglas Gregor be38c5f5d8 Reinstate r126737, extending the generation of type-source location
information for qualifier type names throughout the parser to address
several problems.

The commit message from r126737:

Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of
nested-name-specifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126748 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 16:31:39 +00:00
Douglas Gregor c34348a7ef Retain complete source-location information for C++
nested-name-specifiers throughout the parser, and provide a new class
(NestedNameSpecifierLoc) that contains a nested-name-specifier along
with its type-source information.

Right now, this information is completely useless, because we don't
actually store the source-location information anywhere in the
AST. Call this Step 1/N.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126391 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 17:54:50 +00:00
Douglas Gregor 9ddba32f25 Tweak the CXXScopeSpec API a bit, so that we require the
nested-name-specifier and source range to be set at the same time.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126347 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 00:49:34 +00:00
Chandler Carruth d067c07c6c Fix the behavior of -Wignored-qualifiers on return type qualifiers in
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.

Patch by Hans Wennborg, a couple of minor style tweaks from me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126321 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 18:51:59 +00:00
Fariborz Jahanian 12e3ecec90 Provide Fixit warning when 'auto' is intended as storage
specifier in legacy code. Patch is reviewed offline by Doug.
// rdar://9036633.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126261 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 23:17:49 +00:00
Douglas Gregor 86f208c1a1 Enable enumeration types with a fixed underlying type, e.g.,
enum X : long { Value = 0x100000000 };

when in Microsoft-extension mode (-fms-extensions). This (now C++0x)
feature has been supported since Microsoft Visual Studio .NET 2003.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 20:32:04 +00:00
Douglas Gregor b907560184 Fix a little bug in the handling of enumeration types with a fixed
underlying type: we weren't parsing unnamed enumeration types with a
fixed underlying type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126184 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 02:55:24 +00:00
Richard Smith 483b9f3bc0 Tweaks to C++0x deduced auto type support:
* Flag indicating 'we're parsing this auto typed variable's initializer' moved from VarDecl to Sema
 * Temporary template parameter list for auto deduction is now allocated on the stack.
 * Deduced 'auto' types are now uniqued.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126139 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-21 20:05:19 +00:00
Fariborz Jahanian 6c6b0ebc33 Turn on 'auto' in plain objc mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126134 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-21 18:37:13 +00:00
Richard Smith 34b41d939a Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126069 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-20 03:19:35 +00:00
Douglas Gregor 68e3c2eef5 When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125594 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 20:33:25 +00:00
Peter Collingbourne f315fa81ee OpenCL: add support for __kernel, kernel keywords and EXTENSION,
FP_CONTRACT pragmas.  Patch originally by ARM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125475 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 01:42:53 +00:00
Peter Collingbourne e2f82f7138 Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125399 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 19:59:54 +00:00
Douglas Gregor 683a81f437 Implement the suggested resolution to core issue 547, extended to also
allow ref-qualifiers on function types used as template type
arguments. GNU actually allows cv-qualifiers on function types in many
places where it shouldn't, so we currently categorize this as a GNU
extension.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124584 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-31 16:09:46 +00:00
Francois Pichet dfaa5fb15d Allow Microsoft attributes in a constructor's parameter list.
This fixes a few compile errors when parsing <regex> from MSVC 2008 with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124573 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-31 04:54:32 +00:00
Douglas Gregor 1f3810623f Improve the extension warning for the use of ref-qualifiers, to
distinguish them from rvalue references. Using the rvalue-references
warning was weird when the ref-qualifier was '&'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124316 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 20:35:32 +00:00
Douglas Gregor 83f51722ed Rvalue references for *this: parse ref-qualifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124276 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 03:43:54 +00:00
Douglas Gregor 16cf8f5b6f Downgrade the error about rvalue references to an extension warning
and turn on __has_feature(cxx_rvalue_references). The core rvalue
references proposal seems to be fully implemented now, pending lots
more testing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124169 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 02:17:32 +00:00
Jeffrey Yasskin dec0984fce Fix warnings found by gcc-4.6, from -Wunused-but-set-variable and
-Wint-to-pointer-cast.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123719 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 02:00:16 +00:00
Douglas Gregor 8678d44d97 Fix an embarrassing think in the disambiguation logic for the ellipsis in a parameter-type-list
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122924 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 23:06:07 +00:00
John McCall 7f040a9d81 Refactor how we collect attributes during parsing, and add slots for attributes
on array and function declarators.  This is pretty far from complete, and I'll
revisit it later if someone doesn't beat me to it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122535 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 02:08:15 +00:00
Douglas Gregor a8bc8c9e9b Implement parsing of function parameter packs and non-type template
parameter packs (C++0x [dcl.fct]p13), including disambiguation between
unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for
cases like 

  void f(T...)

where T may or may not contain unexpanded parameter packs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122520 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 22:44:42 +00:00
Abramo Bagnara 075f8f1b6b Added ParenType type node.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121488 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 16:29:40 +00:00
Abramo Bagnara a88cefd266 Added struct/class syntactic info for c++0x scoped enum.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120828 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:54:17 +00:00
Douglas Gregor a61b3e7443 After parsing a ':' in an enum-specifier within class context,
disambiguate between an expression (for a bit-field width) and a type
(for a fixed underlying type). Since the disambiguation can be
expensive (due to tentative parsing), we perform a simplistic
disambiguation based on one-token lookahead before going into the
full-blown tentative parsing. Based on a patch by Daniel Wallin.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120582 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-01 17:42:47 +00:00
Nico Weber f27f03e215 Remove the other FIXME I added. This is covered by the Index test and not testable via -ast-dump.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119971 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-22 13:48:02 +00:00
Nico Weber c43271e317 Try to get the bots green after r119966.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119968 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-22 12:50:03 +00:00
Nico Weber 253e80b019 Fix the source range of CXXNewExprs. Fixes http://llvm.org/pr8661.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-22 10:30:56 +00:00
Douglas Gregor 46f936e055 When parsing something that looks like an ill-formed
protocol-qualifier list without a leading type (e.g., <#blah#>), don't
complain about it being an archaic protocol-qualifier list unless it
actually parses as one.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-19 17:10:50 +00:00
Argyrios Kyrtzidis 4383e18fc3 Emit a specific diagnostic when typedefing C++ bool, mirroring gcc.
Fixes rdar://8365458

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119359 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 18:18:13 +00:00
Ted Kremenek 8113ecfa4e Region-allocate all AttributeList objects from a factory object instead of manually managing them
using new/delete and OwningPtrs.  After memory profiling Clang, I witnessed periodic leaks of these
objects; digging deeper into the code, it was clear that our management of these objects was a mess.  The ownership rules were murky at best, and not always followed.  Worse, there are plenty of error paths where we could screw up.

This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList
objects and then blows them away all at once.  While conceptually simple, most of the changes in
this patch just have to do with migrating over to the new interface.  Most of the changes have resulted in some nice simplifications.

This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser
object.  This is easily tunable.  If we desire to have more bound the lifetime of AttributeList
objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its
underlying allocator as we enter/leave key methods in the Parser.  This means that we get
simple memory management while still having the ability to finely control memory use if necessary.

Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic
in many large files with attributes.

This fixes the leak reported in: <rdar://problem/8650003>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118675 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-10 05:59:39 +00:00
John McCall 78b810559d Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former.  Fixes PR8022.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118669 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-10 02:40:36 +00:00
Chris Lattner 729ad83035 fix PR8380, a crash on invalid due to an illogical DeclSpec SourceRange being constructed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118625 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-09 20:14:26 +00:00
John McCall 5b629aa86c Parse attributes on enumerators and instantiate attributes on enum decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117182 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 23:36:17 +00:00
Douglas Gregor 9bd1d8d174 Teach the C++ simple-type-specifier parser and tentative parses about
protocol-qualified types such as id<Protocol>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117081 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-21 23:17:00 +00:00
Francois Pichet 334d47e92e Add parsing support for Microsoft attributes. MS attributes will just be skipped and not inserted into the AST for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-11 12:59:39 +00:00
Douglas Gregor 1274ccd90a Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked a
bit by me). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116122 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-08 23:50:27 +00:00
Argyrios Kyrtzidis a6eb5f81d1 When we encounter a '==' in a context expecting a '=', assume the user made a typo:
t.c:1:7: error: invalid '==' at end of declaration; did you mean '='?
int x == 0;
      ^~
      =

Implements rdar://8488464.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116035 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-08 02:39:23 +00:00
Douglas Gregor dab60ad68a Implement the C++0x "trailing return type" feature, e.g.,
auto f(int) -> int

from Daniel Wallin!

(With a few minor bug fixes from me).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-01 18:44:50 +00:00
Fariborz Jahanian c5be7b0fc8 vla expressions used in __typeof__ must be evaluated.
Fixes rdar://8476159.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114982 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28 20:42:35 +00:00
Anders Carlsson 37bf9d2bb7 Allow the use of C++0x deleted functions as an extension in C++98.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114762 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-24 21:25:25 +00:00
Douglas Gregor c7b6d88336 Implement code completion for Objective-C class message sends that are
missing the opening bracket '[', e.g.,

  NSArray <CC>

at function scope. Previously, we would only give trivial completions
(const, volatile, etc.), because we're in a "declaration name"
scope. Now, we also provide completions for class methods of NSArray,
e.g.,

  alloc

Note that we already had support for this after the first argument,
e.g.,

  NSArray method:x <CC>

would get code completion for class methods of NSArray whose selector
starts with "method:". This was already present because we recover
as if NSArray method:x were a class message send missing the opening
bracket (which was committed in r114057).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-16 15:14:18 +00:00
Douglas Gregor 9497a73ad0 Implement automatic bracket insertion for Objective-C class message
sends. These are far trickier than instance messages, because we
typically have something like

  NSArray alloc]

where it appears to be a declaration of a variable named "alloc" up
until we see the ']' (or a ':'), and at that point we can't backtrace.
So, we use a combination of syntactic and semantic disambiguation to
treat this as a message send only when the type is an Objective-C type
and it has the syntax of a class message send (which would otherwise
be ill-formed).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114057 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-16 01:51:54 +00:00
Douglas Gregor be0f7bd61c When parsing default function arguments, do not mark any declarations
used in the default function argument as "used". Instead, when we
actually use the default argument, make another pass over the
expression to mark any used declarations as "used" at that point. This
addresses two kinds of related problems:

  1) We were marking some declarations "used" that shouldn't be,
  because we were marking them too eagerly.
  2) We were failing to mark some declarations as "used" when we
  should, if the first time it was instantiated happened to be an
  unevaluated context, we wouldn't mark them again at a later point.

I've also added a potentially-handy visitor class template
EvaluatedExprVisitor, which only visits the potentially-evaluated
subexpressions of an expression. I bet this would have been useful for
noexcept...

Fixes PR5810 and PR8127.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113700 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-11 20:24:53 +00:00
Douglas Gregor a1a04786ce Eliminate the comma locations from all of the Sema routines that deal
with comma-separated lists. We never actually used the comma
locations, nor did we store them in the AST, but we did manage to
waste time during template instantiation to produce fake locations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113495 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 16:33:13 +00:00
Douglas Gregor 751f692237 Improve recovery when a comma is missing between enumerators in an
enumeration definition. Fixes <rdar://problem/7159693>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113201 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 14:51:08 +00:00
Dawn Perchik 52fc314e1b Add symantic support for the Pascal calling convention via
"__attribute((pascal))" or "__pascal" (and "_pascal" under
-fborland-extensions).  Support still needs to be added to llvm.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112939 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 01:29:35 +00:00
Sebastian Redl 88e64ca96d Enable inline namespaces in C++03 as an extension.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112566 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 00:36:45 +00:00
Sebastian Redl d078e64145 Parser support for inline namespaces
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112320 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 23:12:46 +00:00
Douglas Gregor 1a480c403a Suggest "const" and "volatile" code completions after a function
declarator, the very definition of "low-hanging fruit".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 17:35:51 +00:00
John McCall f312b1ea17 One who seeks knowledge learns something new every day.
One who seeks the Tao unlearns something new every day.
Less and less remains until you arrive at non-action.
When you arrive at non-action,
nothing will be left undone.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112244 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 23:41:50 +00:00
John McCall 911093e535 Reformatting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112018 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 02:45:51 +00:00
John McCall 60d7b3a319 OwningExprResult -> ExprResult. This patch brought to you by
M-x query-replace-regexp
\(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111903 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 06:29:42 +00:00
John McCall b3d8748e79 Abstract out passing around types and kill off ActionBase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111901 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 05:47:05 +00:00
John McCall 9ae2f076ca Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111863 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 23:25:46 +00:00
Douglas Gregor 2ccccb3ff4 Introduce a new code-completion point when we're parsing a
declarator. Here, we can only see a few things (e.g., cvr-qualifiers,
nested name specifiers) and we do not want to provide other non-macro
completions. Previously, we would end up in recovery mode and would
provide a large number of non-relevant completions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 18:23:48 +00:00
Douglas Gregor ae2fb144fe When complaining about a duplicate declspec, provide a Fix-It that
removes the copy. Patch from Eelis van der Weegen, tweaked/updated by
me.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111807 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 14:34:43 +00:00
John McCall ca0408fb49 Sundry incremental steps towards killing off Action.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 06:44:23 +00:00
John McCall d226f65006 DeclPtrTy -> Decl *
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111733 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-21 09:40:31 +00:00
John McCall 1951085672 Another step in the process of making the parser depend on Sema:
- move DeclSpec &c into the Sema library
  - move ParseAST into the Parse library
Reflect this change in a thousand different includes.
Reflect this change in the link orders.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111667 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20 18:27:03 +00:00
Fariborz Jahanian 46877cd012 Get rid of extra nesting when checking for invalid type,
per Doug's comment.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111328 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 23:50:37 +00:00
Fariborz Jahanian 1b72fa7222 Diagnose if type of iboutletcollection attribute is a builtin type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111324 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 23:19:16 +00:00
Fariborz Jahanian d657742862 Fix a crash when parsing malformed out-of-line member function
definition. radar 8307865.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111163 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 17:58:53 +00:00
Douglas Gregor e6b1bb6e7f Once code completion has completed, pass a "completion context" on to
the code-completion consumer. The consumer can use this information to
augument, filter, or display the code-completion results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110858 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 21:23:17 +00:00
Argyrios Kyrtzidis 2b602adf97 Introduce a new token kind 'cxx_defaultarg_end' to mark the end of C++ default arguments that were part of
lexed method declarations.

This avoid interference with tokens coming after the point where the default arg tokens were 'injected', e.g. for

typedef struct Inst {
  void m(int x=0);
} *InstPtr;

when parsing '0' the next token would be '*' and things would be messed up.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-06 09:47:24 +00:00
Douglas Gregor 0333296d14 Reword the empty struct/union warning in C to note that such structs and unions have size 0 in C, size 1 in C++. Put this warning under -Wc++-compat.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109748 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-29 14:29:34 +00:00
Chris Lattner 004659a569 Fix PR7617 by not entering ParseFunctionDefinition when
a function prototype is followed by a declarator if we
aren't parsing a K&R style identifier list.

Also, avoid skipping randomly after a declaration if a
semicolon is missing.  Before we'd get:

t.c:3:1: error: expected function body after function declarator
void bar();
^

Now we get:

t.c:1:11: error: invalid token after top level declarator
void foo()
          ^
          ;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108105 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-11 22:42:07 +00:00
Chris Lattner c82daefa30 add a const qualifier, refactor some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-11 22:24:20 +00:00
Douglas Gregor 23c94dbb66 Move the "current scope" state from the Parser into Action. This
allows Sema some limited access to the current scope, which we only
use in one way: when Sema is performing some kind of declaration that
is not directly driven by the parser (e.g., due to template
instantiatio or lazy declaration of a member), we can find the Scope
associated with a DeclContext, if that DeclContext is still in the
process of being parsed. 

Use this to make the implicit declaration of special member functions
in a C++ class more "scope-less", rather than using the NULL Scope hack.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107491 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02 17:43:08 +00:00
Argyrios Kyrtzidis 36d36806f1 Make sure parens/braces/brackets are correctly balanced.
In a line like:

(;

the semicolon leaves Parser:ParenCount unbalanced (it's 1 even though we stopped looking for a right paren).
This may affect later parsing and result in bad recovery for parsing errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106213 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 10:52:18 +00:00
Douglas Gregor f13ca06e57 Make the "extra ';' inside a struct or union" diagnostic more
precise. Fixes PR7336.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106170 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 23:08:59 +00:00
Douglas Gregor a8f031fa67 Add some missing parentheses, from Anton Yartsev
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106101 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 15:28:57 +00:00
Douglas Gregor 5ac3bdb2cb Teach code completion to adjust its completion priorities based on the
type that we expect to see at a given point in the grammar, e.g., when
initializing a variable, returning a result, or calling a function. We
don't prune the candidate set at all, just adjust priorities to favor
things that should type-check, using an ultra-simplified type system.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30 01:49:25 +00:00
Fariborz Jahanian 0511552e20 Empty enum in c is now error to match gcc's behavior.
(radar 8040068).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105011 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 22:23:22 +00:00
Douglas Gregor dc8453422b Improve code completion in failure cases in two ways:
1) Suppress diagnostics as soon as we form the code-completion
  token, so we don't get any error/warning spew from the early
  end-of-file.
  2) If we consume a code-completion token when we weren't expecting
  one, go into a code-completion recovery path that produces the best
  results it can based on the context that the parser is in.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104585 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-25 05:58:43 +00:00
John McCall aec0371e62 Propagate access specifiers to anonymous union members nested within classes.
Fixes <rdar://problem/7987650>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104376 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21 20:45:30 +00:00