Commit Graph

1156 Commits

Author SHA1 Message Date
Nico Weber ece562ed27 Remove the other FIXME I added. This is covered by the Index test and not testable via -ast-dump.
llvm-svn: 119971
2010-11-22 13:48:02 +00:00
Nico Weber 13c13d4da8 Remove one I just added, add a more focused test for why the current code is correct.
llvm-svn: 119969
2010-11-22 13:12:28 +00:00
Nico Weber 7f8bb368ea Try to get the bots green after r119966.
llvm-svn: 119968
2010-11-22 12:50:03 +00:00
Nico Weber 774303425b Fix the source range of CXXNewExprs. Fixes http://llvm.org/pr8661.
llvm-svn: 119966
2010-11-22 10:30:56 +00:00
Argyrios Kyrtzidis de2bdf637e Revert r119838 "Don't warn for empty 'if' body if there is a macro that expands to nothing"
and use a better and more general approach, where NullStmt has a flag to indicate whether it was preceded by an empty macro.

Thanks to Abramo Bagnara for the hint!

llvm-svn: 119887
2010-11-20 02:04:01 +00:00
Argyrios Kyrtzidis 90ee2a4ecf Don't warn for empty 'if' body if there is a macro that expands to nothing, e.g:
if (condition)
    CALL(0); // empty macro but don't warn for empty body.

Fixes rdar://8436021.

llvm-svn: 119838
2010-11-19 20:54:25 +00:00
Douglas Gregor 3a001f48e4 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.

llvm-svn: 119805
2010-11-19 17:10:50 +00:00
Argyrios Kyrtzidis 1865342442 Refactoring.
Move ErrorTrap from clang/Sema to clang/Basic as DiagnosticErrorTrap and use it in Scope.

llvm-svn: 119763
2010-11-19 00:19:12 +00:00
Argyrios Kyrtzidis d004064864 Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
   SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

llvm-svn: 119730
2010-11-18 20:06:41 +00:00
Craig Silverstein 9bc166ac86 In some situations, TemplateArgumentLoc wasn't setting TypeSourceLoc (see
http://llvm.org/bugs/show_bug.cgi?id=8558).  This patch fixes it.  Thanks to
rjmccall for all the coaching!

Approved by rjmccall

llvm-svn: 119697
2010-11-18 08:32:02 +00:00
Douglas Gregor b1b71e50a0 For an Objective-C @synthesize statement, e.g.,
@synthesize foo = _foo;

keep track of the location of the ivar ("_foo"). Teach libclang to
visit the ivar as a member reference.

llvm-svn: 119447
2010-11-17 01:03:52 +00:00
Argyrios Kyrtzidis 20ee5ae871 Emit a specific diagnostic when typedefing C++ bool, mirroring gcc.
Fixes rdar://8365458

llvm-svn: 119359
2010-11-16 18:18:13 +00:00
Ted Kremenek 5eec2b0bd3 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>

llvm-svn: 118675
2010-11-10 05:59:39 +00:00
John McCall 9b72f89f0f Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former.  Fixes PR8022.

llvm-svn: 118669
2010-11-10 02:40:36 +00:00
Fariborz Jahanian dbee986290 Issues good diagnostic when @end is missing.
// rdar://8283484

llvm-svn: 118629
2010-11-09 20:38:00 +00:00
Chris Lattner 8ea6442f92 tidy up
llvm-svn: 118626
2010-11-09 20:15:55 +00:00
Chris Lattner 0786544ac5 fix PR8380, a crash on invalid due to an illogical DeclSpec SourceRange being constructed.
llvm-svn: 118625
2010-11-09 20:14:26 +00:00
Nick Lewycky 07e97c594d Make this error less specific but also less likely to cause confusion. Fixes
PR7702.

llvm-svn: 118181
2010-11-03 17:52:57 +00:00
Argyrios Kyrtzidis 3050d9bdb8 Properly handle temporaries that are created in a AsmStmt.
Previously the temporaries would get destroyed before the asm call.

llvm-svn: 118001
2010-11-02 02:33:08 +00:00
Fariborz Jahanian d4c5348a55 Diagnose a coherant message when @interface
does not terminate with @end.
// rdar: //7824372

llvm-svn: 117991
2010-11-02 00:44:43 +00:00
Argyrios Kyrtzidis 375584c7eb Clean up temporaries created by an asm statement. Fixes rdar://8540491
llvm-svn: 117961
2010-11-01 21:51:42 +00:00
John McCall 811a0f5578 Parse attributes on enumerators and instantiate attributes on enum decls.
llvm-svn: 117182
2010-10-22 23:36:17 +00:00
Douglas Gregor 06e41ae5c7 Teach the C++ simple-type-specifier parser and tentative parses about
protocol-qualified types such as id<Protocol>.

llvm-svn: 117081
2010-10-21 23:17:00 +00:00
Douglas Gregor a02bb37a8c Diagnose the declaration of template template parameters that
themselves have no template parameters. This is actually a restriction
due to the grammar of template template parameters, but we choose to
diagnose it in Sema to provide better recovery.

llvm-svn: 117032
2010-10-21 17:26:49 +00:00
John McCall 32723e9198 Tag references shouldn't ever get template parameter lists.
Fixes rdar://problem/8568507

llvm-svn: 116843
2010-10-19 18:40:57 +00:00
John McCall ace48cd872 Redirect templated friend class decls to a new Sema callback and
construct an unsupported friend when there's a friend with a templated
scope specifier.  Fixes a consistency crash, rdar://problem/8540527

llvm-svn: 116786
2010-10-19 01:40:49 +00:00
Douglas Gregor 643c330b91 Provide code completion for types after the '^' that starts a block
literal. 

llvm-svn: 116754
2010-10-18 21:34:55 +00:00
Douglas Gregor b048402073 When we are missing the ',' or '>' to terminate a template parameter
list, complain about it! Fixes PR7053.

llvm-svn: 116551
2010-10-15 01:15:58 +00:00
Douglas Gregor efc469587a Parse default arguments within member functions in source order, from
Manuel Klimek! Fixes PR7715.

llvm-svn: 116311
2010-10-12 16:25:54 +00:00
Cameron Esfahani f6c73c463f Fix spelling error.
llvm-svn: 116283
2010-10-12 00:21:25 +00:00
Francois Pichet c2bc5ac149 Add parsing support for Microsoft attributes. MS attributes will just be skipped and not inserted into the AST for now.
llvm-svn: 116203
2010-10-11 12:59:39 +00:00
Douglas Gregor 0bf3140424 Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked a
bit by me). 

llvm-svn: 116122
2010-10-08 23:50:27 +00:00
Argyrios Kyrtzidis b5c7c51392 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.

llvm-svn: 116035
2010-10-08 02:39:23 +00:00
Anders Carlsson fe15a78ff2 Use ParseObjCSelectorPiece for parsing getter and setter names in @property declarations. Fixes PR8169.
llvm-svn: 115411
2010-10-02 17:45:21 +00:00
Douglas Gregor 7fb25418ed 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).

llvm-svn: 115322
2010-10-01 18:44:50 +00:00
Chris Lattner d7821e4ec4 enhance tentative parsing to handle ms extensions, patch by Martin Vejnar!
llvm-svn: 115004
2010-09-28 23:35:09 +00:00
Fariborz Jahanian 1db5c941ad vla expressions used in __typeof__ must be evaluated.
Fixes rdar://8476159.

llvm-svn: 114982
2010-09-28 20:42:35 +00:00
Douglas Gregor 1ba435f0f9 When we have two identifiers in a row in Objective-C, make sure to
verify that we aren't in a message-send expression before digging into
the identifier or looking ahead more tokens. Fixes a regression
(<rdar://problem/8483253>) I introduced with bracket insertion.

llvm-svn: 114968
2010-09-28 17:48:56 +00:00
Argyrios Kyrtzidis 9f48354b71 Don't warn for an unused label if it has 'unused' attribute. Fixes rdar://8483139.
llvm-svn: 114954
2010-09-28 14:54:07 +00:00
Anders Carlsson 991285e425 Allow the use of C++0x deleted functions as an extension in C++98.
llvm-svn: 114762
2010-09-24 21:25:25 +00:00
Douglas Gregor f86e4da7ae Refactor code completion for expressions that occur as arguments in
Objective-C message sends. There is no functionality change here; this
is prep work for using the parameter types to help guide the
expression results when code-completing the argument.

llvm-svn: 114375
2010-09-20 23:34:21 +00:00
Douglas Gregor eda7e545e6 Continue parsing more postfix expressions, even after semantic
errors. Improves code completion in yet another case.

llvm-svn: 114255
2010-09-18 01:28:11 +00:00
Douglas Gregor ec06c124f1 Improve recovery when the middle expression of a ternary operator is ill-formed
llvm-svn: 114231
2010-09-17 22:41:34 +00:00
Douglas Gregor 29d907de03 When we run into an error parsing or type-checking the left-hand side
of a binary expression, continue on and parse the right-hand side of
the binary expression anyway, but don't call the semantic actions to
type-check. Previously, we would see the error and then, effectively,
skip tokens until the end of the statement. 

The result should be more useful recovery, both in the normal case
(we'll actually see errors beyond the first one in a statement), but
it also helps code completion do a much better job, because we do
"real" code completion on the right-hand side of an invalid binary
expression rather than completing with the recovery completion. For
example, given

  x = p->y

if there is no variable named "x", we can still complete after the p->
as a member expression. Along the recovery path, we would have
completed after the "->" as if we were in an expression context, which
is mostly useless.

llvm-svn: 114225
2010-09-17 22:25:06 +00:00
Gabor Greif 433c9e146a rename variable, 'Type' seems to be present in
the enclosing scope, which confuses gcc v3.4 to no end

llvm-svn: 114174
2010-09-17 10:21:45 +00:00
Douglas Gregor bfcea8b5b1 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).

llvm-svn: 114078
2010-09-16 15:14:18 +00:00
Douglas Gregor abf4a3e4c6 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).

llvm-svn: 114057
2010-09-16 01:51:54 +00:00
Douglas Gregor 3e972009fb Handle bracket insertion for Objective-C class messages in a very
narrow, almost useless case where we're inside a parenthesized
expression, e.g.,

  (NSArray alloc])

The solution to the general case still eludes me.

llvm-svn: 114039
2010-09-15 23:19:31 +00:00
Nick Lewycky 970aed92c0 Initialize TypeOrExpr to NULL to silence a false-positive uninitialized warning
from certain GCC's. Patch by Neil Vachharajani!

llvm-svn: 113995
2010-09-15 18:35:19 +00:00
Douglas Gregor ed0b69dc81 Improve code completion for Objective-C message sends when the opening
'[' is missing. Prior commits improving recovery also improved code
completion beyond the first selector, e.g., at or after the "to" in

  calculator add:x to:y

but not after "calculator". We now provide the same completions for

  calculator <CC>

that we would for

  [calculator <CC>

if "calculator" is an expression whose type is something that can
receive Objective-C messages.

This code completion works for instance and super message sends, but not
class message sends.

llvm-svn: 113976
2010-09-15 16:23:04 +00:00