Commit Graph

116 Commits

Author SHA1 Message Date
John McCall 37ad551a25 Sundry incremental steps towards killing off Action.
llvm-svn: 111795
2010-08-23 06:44:23 +00:00
John McCall 4887165193 DeclPtrTy -> Decl *
llvm-svn: 111733
2010-08-21 09:40:31 +00:00
John McCall 8b0666cf79 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.

llvm-svn: 111667
2010-08-20 18:27:03 +00:00
Chris Lattner d28e6cc554 Add a slightly better hack for microsoft style inline asm,
patch by Per Linden!

llvm-svn: 111235
2010-08-17 16:00:12 +00:00
Douglas Gregor 00c37ef021 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.

llvm-svn: 110858
2010-08-11 21:23:17 +00:00
Nick Lewycky 2667f1d409 Remove ElseScope which is also dead code now.
llvm-svn: 110433
2010-08-06 06:50:17 +00:00
Chandler Carruth 3c31aa3a44 Fix PR7673 by allowing an empty clobbers section in an ASM statement.
llvm-svn: 109087
2010-07-22 07:11:21 +00:00
Douglas Gregor 0be31a2eb7 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.

llvm-svn: 107491
2010-07-02 17:43:08 +00:00
Argyrios Kyrtzidis 355094ef06 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.

llvm-svn: 106213
2010-06-17 10:52:18 +00:00
Douglas Gregor 7aa6b229fe 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.

llvm-svn: 105128
2010-05-30 01:49:25 +00:00
Douglas Gregor f4c33349b5 Make -code-completion-patterns only cover multi-line code
completions. Plus, tweak a few completion patterns to better reflect
the language grammar.

llvm-svn: 104905
2010-05-28 00:22:41 +00:00
Douglas Gregor 6da3db4af3 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.

llvm-svn: 104585
2010-05-25 05:58:43 +00:00
Douglas Gregor 4abc32d033 Improve parser recovery when a switch condition is invalid; fixes
<rdar://problem/7971948>.

llvm-svn: 104291
2010-05-20 23:20:59 +00:00
Douglas Gregor 12cc7eeb82 Fixed DISABLE_SMART_POINTERS breakage
llvm-svn: 103198
2010-05-06 21:39:56 +00:00
Douglas Gregor e60e41add9 Rework our handling of temporary objects within the conditions of
if/switch/while/do/for statements. Previously, we would end up either:

  (1) Forgetting to destroy temporaries created in the condition (!),
  (2) Destroying the temporaries created in the condition *before*
  converting the condition to a boolean value (or, in the case of a
  switch statement, to an integral or enumeral value), or
  (3) In a for statement, destroying the condition's temporaries at
  the end of the increment expression (!).

We now destroy temporaries in conditions at the right times. This
required some tweaking of the Parse/Sema interaction, since the parser
was building full expressions too early in many places.

Fixes PR7067.

llvm-svn: 103187
2010-05-06 17:25:47 +00:00
Chris Lattner df74264787 change Scope::WithinElse to be a normal scope flag, widen the
fields to two 16-bit values instead of using bitfields.

llvm-svn: 101020
2010-04-12 06:12:50 +00:00
Chris Lattner 005fc1bbcf fix PR6782, an accept invalid. We weren't emitting the diagnostic
returned by SetTypeSpecType.

llvm-svn: 100443
2010-04-05 18:18:31 +00:00
Argyrios Kyrtzidis 90ab3b7779 Don't skip past the '}' if an expression has error and is not followed by ';'.
llvm-svn: 99972
2010-03-31 00:37:59 +00:00
Ted Kremenek c162e8e193 Clean up ownership of 'AttributeList' objects in Parser. Apparently
we would just leak them all over the place, with no clear ownership of
these objects at all.  AttributeList objects would get leaked on both
error and non-error paths.

Note: I introduced the usage of llvm::OwningPtr<AttributeList> to
manage these objects, which is particularly useful for methods with
multiple return sites.  In at least one method I used them even when
they weren't strictly necessary because it clarified the ownership
semantics and made the code easier to read.  Should the excessive
'take()' and 'reset()' calls become a performance issue we can always
re-evaluate.

Note+1: I believe I have not introduced any double-frees, but it would
be nice for someone to review this.

This fixes <rdar://problem/7635046>.

llvm-svn: 95847
2010-02-11 02:19:13 +00:00
Anders Carlsson 9a020f9a3a Use IdentifierInfo * instead of std::string for the AsmStmt names.
llvm-svn: 94925
2010-01-30 22:25:16 +00:00
Chris Lattner 8fd2d01118 fix PR6034, a crash on invalid where the switch stack would get
unbalanced.

llvm-svn: 94347
2010-01-24 01:50:29 +00:00
Douglas Gregor 504a6ae83e Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for

  static_cast<type>(expr)

when we can have an expression, or

  using namespace identifier;

when we can have a using directive.

Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.

llvm-svn: 93134
2010-01-10 23:08:15 +00:00
Mike Stump 90be58afce Remember if the AsmStmt came from Microsoft-style inline assembly code.
llvm-svn: 92526
2010-01-04 22:37:17 +00:00
Chris Lattner 1576850a76 fix PR5500: clang fails to parse inline asm with :: in C++ mode
llvm-svn: 91802
2009-12-20 23:08:04 +00:00
Chris Lattner bf5fff5fbb refactor asm stmt parsing to avoid nesting as much, and
pull ':' eating out of ParseAsmOperandsOpt.

llvm-svn: 91801
2009-12-20 23:00:41 +00:00
Anders Carlsson afb2dade0c Check in a rudimentary FullExpr class that isn't used anywhere yet. Rename Action::FullExpr to Action::MakeFullExpr to avoid name clashes.
llvm-svn: 91494
2009-12-16 02:09:40 +00:00
Mike Stump 6da5d75449 Implement just a bit more of inline assembly.
llvm-svn: 91079
2009-12-11 00:04:56 +00:00
Chris Lattner 125c0ee5c7 fix PR5740: a colon is sacred when parsing case statement expressions!
llvm-svn: 91016
2009-12-10 00:38:54 +00:00
Chris Lattner 8a9a97a660 rename ExtensionRAIIObject.h -> RAIIObjectsForParser.h
llvm-svn: 91008
2009-12-10 00:21:05 +00:00
Douglas Gregor 3ff3af4ff9 When the condition of a switch() statement is semantically invalid,
still parse the body of the switch to try to avoid spurious
diagnostics. Fixes PR5606.

llvm-svn: 89847
2009-11-25 06:20:02 +00:00
Douglas Gregor 7bab5ff8e7 Eliminate CXXConditionDeclExpr with extreme prejudice.
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).

Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting

Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.

llvm-svn: 89817
2009-11-25 00:27:52 +00:00
Douglas Gregor 7f800f9d50 "Do" loops cannot have condition variables, so don't parse them.
llvm-svn: 89801
2009-11-24 21:34:32 +00:00
Alexis Hunt 96d5c76498 Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
 - align() - semantics believed to be conformant to n3000, except for
   redeclarations and what entities it may apply to
 - final - semantics believed to be conformant to CWG issue 817's proposed
   wording, except for redeclarations
 - noreturn - semantics believed to be conformant to n3000, except for
   redeclarations
 - carries_dependency - currently ignored (this is an optimization hint)

llvm-svn: 89543
2009-11-21 08:43:09 +00:00
Fariborz Jahanian e774fa6412 Don't issue spurious diagnostic with Obj-C fast enumeration.
(radar 7409165).

llvm-svn: 89400
2009-11-19 22:12:37 +00:00
John McCall d5a36321b9 Reorganize the parsing of decl groups / function definitions so that
declarators are parsed primarily within a single function (at least for
these cases).  Remove some excess diagnostics arising during parse failures.

llvm-svn: 85924
2009-11-03 19:26:08 +00:00
Daniel Dunbar 07d0785dbb PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

llvm-svn: 84447
2009-10-18 21:17:35 +00:00
Daniel Dunbar 70e7eadd15 Move misc clients to IdentifierInfo StringRef API.
- strcmp -> ==
 - OS.write(II->getName() ...) -> OS << II->getNameStr()
 - Avoid std::string concatenation
 - Use getNameStr().str() when an std::string is really needed.

llvm-svn: 84437
2009-10-18 20:26:27 +00:00
Douglas Gregor 9d64c5e3a5 Code completion for ordinary names when we're starting a declaration, expression, or statement
llvm-svn: 82481
2009-09-21 20:51:25 +00:00
Douglas Gregor d328d57c39 Code completion for "case" statements within a switch on an expression
of enumeration type, providing the various unused enumerators as options.

llvm-svn: 82467
2009-09-21 18:10:23 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Anders Carlsson a192947509 Change ActOnReturnStmt to not take a FullExprArg. Instead, Sema will wrap the return expr inside a CXXExprWithTemporaries if needed.
llvm-svn: 79342
2009-08-18 16:11:00 +00:00
Chris Lattner 8e3eed0890 change ParseStatementOrDeclaration to emit the 'missing ;' with
ExpectAndConsume instead of custom diag logic.  This gets us an
insertion hint and positions the ; at the end of the line 
instead of on the next token.  Before:

t.c:5:1: error: expected ';' after return statement
}
^

after:

t.c:4:11: error: expected ';' after return statement
  return 4
          ^
          ;

llvm-svn: 73315
2009-06-14 00:23:56 +00:00
Chris Lattner 34a9566c8c improve localizability by not passing english phrases into
diagnostics in some cases.

llvm-svn: 73314
2009-06-14 00:07:48 +00:00
Chris Lattner 815b70efcd add the location of the ')' in a do/while statement to DoStmt.
This fixes a source range problem reported by Olaf Krzikalla.

llvm-svn: 73266
2009-06-12 23:04:47 +00:00
Anders Carlsson 8936009a91 Make sure to call FullExpr before parsing anything else.
llvm-svn: 72834
2009-06-04 02:18:15 +00:00
Anders Carlsson 5de832ecfa ActOnReturnStmt should also take a FullExprArg.
llvm-svn: 72641
2009-05-30 21:42:34 +00:00
Douglas Gregor 269f0b1b69 Merge the ASTVector and ASTOwningVector templates, since they offered
redundant functionality. The result (ASTOwningVector) lives in
clang/Parse/Ownership.h and is used by both the parser and semantic
analysis. No intended functionality change.

llvm-svn: 72214
2009-05-21 16:25:11 +00:00
Jay Foad 7d0479f2c2 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Anders Carlsson ee13926fbe Make ActOnWhileStmt take a FullExprArg for the condition expr.
llvm-svn: 71990
2009-05-17 21:22:26 +00:00
Anders Carlsson 24824e5009 Make ActOnExprStmt take a FullExprArg.
llvm-svn: 71989
2009-05-17 21:11:30 +00:00