Commit Graph

5123 Commits

Author SHA1 Message Date
Douglas Gregor 68762e7852 Introduce a code-completion hook for the Objective-C collection
argument in a for-each statement (e.g., "for (id x in <blah>)"), which
restricts the expression completions provided to Objective-C types (or
class types in C++).

llvm-svn: 111843
2010-08-23 21:17:50 +00:00
Douglas Gregor 2529b55b4d Don't include macro results when we're completing a declarator.
llvm-svn: 111830
2010-08-23 19:33:40 +00:00
Fariborz Jahanian bf9294fb65 Support for IRGen of synthesize bitfield ivars in
objc-nonfragile-abi2 (radar 7824380).

llvm-svn: 111823
2010-08-23 18:51:39 +00:00
Douglas Gregor c49f5b2f11 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.

llvm-svn: 111818
2010-08-23 18:23:48 +00:00
Chandler Carruth c926240172 Relax the construction of a definition for implicit, trivial default
constructors. We perform semantic checking when creating the definition, and
this isn't needed in certain contexts (value initialization) but is in others
(default initialization). This fixes PR7948.

We add explicit code to the default initialization path to ensure the
definition is both present and valid.

Doug, please review. I think this follows your latest suggestion, and it ended
up remarkably cleaner than I anticipated. Also let me know if similar logic
should be followed for destructors and copy-constructors.

llvm-svn: 111802
2010-08-23 07:55:51 +00:00
John McCall 3e56fd4d22 Push DeclGroupRefs and TemplateNames in an opaque but type-safe way
through the parser.

llvm-svn: 111800
2010-08-23 07:28:44 +00:00
Argyrios Kyrtzidis 421ad5e1e6 In Sema::AddBuiltinOperatorCandidates, candidate pointer types set can also contain a ObjCObjectPointerType since r111699.
Don't assume that they are only PointerTypes or we will crash.

llvm-svn: 111798
2010-08-23 07:12:16 +00:00
John McCall 37ad551a25 Sundry incremental steps towards killing off Action.
llvm-svn: 111795
2010-08-23 06:44:23 +00:00
Douglas Gregor ec3a3f5257 Do not elide copy construction when we're performing base-class initialization
llvm-svn: 111783
2010-08-22 18:27:02 +00:00
Douglas Gregor b0a04fff51 Preserve the zero-initialization and construction-kind settings when
instantiating CXXConstructExpr expressions.

llvm-svn: 111780
2010-08-22 17:20:18 +00:00
Eli Friedman 04831926ec Detabify.
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
Fariborz Jahanian f2afc804c3 twik to my previous patch for pr7936.
Build qualified version of ObjC pointers (not pointers) when
doing overload resolution.

llvm-svn: 111740
2010-08-21 17:11:09 +00:00
John McCall 4887165193 DeclPtrTy -> Decl *
llvm-svn: 111733
2010-08-21 09:40:31 +00:00
Fariborz Jahanian e4151b590e patch to support comparison involving
objctive-c pointer conversions. Fixes pr7936.

llvm-svn: 111699
2010-08-21 00:10:36 +00:00
Fariborz Jahanian 45b31616bd Remove dead code.
llvm-svn: 111693
2010-08-20 23:02:01 +00:00
Fariborz Jahanian 662f05a035 Rmove dead code.
llvm-svn: 111680
2010-08-20 21:45:03 +00:00
Fariborz Jahanian a50b3a20f1 objective-c ivar refactoring patch. Iterations
over ivars for a varienty of puposes is now
consolidated into two small routines; DeepCollectObjCIvars
and ShallowCollectObjCIvars. 

llvm-svn: 111679
2010-08-20 21:21:08 +00:00
Nick Lewycky fe71238b8d Add a workaround for PR7947, a crash trying to recover from invalid C++ code.
llvm-svn: 111675
2010-08-20 20:54:15 +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
Douglas Gregor 5be1eb8daf Revert r111609, which is failing its new test.
llvm-svn: 111611
2010-08-20 03:26:10 +00:00
John McCall a189f2eb0a Detect efforts to declare a template member friend and explicitly ignore them.
Avoids a crash.

llvm-svn: 111609
2010-08-20 01:40:01 +00:00
John McCall b3774b5c1e Regularize the API for accessing explicit template arguments.
llvm-svn: 111584
2010-08-19 23:49:38 +00:00
John McCall 13d031593e Correctly instantiate templates with non-type template arguments that
are local externs.  Fixes <rdar://problem/8302138>.

llvm-svn: 111570
2010-08-19 23:06:02 +00:00
Douglas Gregor 086cae6c1f Fix the source range of an anonymous namespace, from Jan Bierbaum
llvm-svn: 111561
2010-08-19 20:55:47 +00:00
Douglas Gregor c0afc67608 We don't actually need to check the implicit object argument's
conversion a second time for a conversion candidate (with the real
acting context), because the only problems we would find are access or
ambiguity issues that won't be diagnosed until we pick this
candidate. Add a test case to prove it to myself.

llvm-svn: 111526
2010-08-19 17:02:01 +00:00
Douglas Gregor c9ed4681a8 Properly implement the part of C++ [over.match.funcs]p4 that treats
conversion functions as if their acting context were the class that
we're converting from (the implicit object argument's
type). Retroactively tweaking the implicit conversion sequence, as we
were trying to do before, breaks the invariants of that implicit
conversion sequence (e.g., the types and conversions don't match
up). Fixes <rdar://problem/8018274>.

llvm-svn: 111520
2010-08-19 15:57:50 +00:00
Douglas Gregor 6affc78f1b Include a proper citation for the wacky hijinks involving conversion functions and the implicit object parameter type. No functionality change.
llvm-svn: 111519
2010-08-19 15:37:02 +00:00
Charles Davis 6bcb07ad71 Add some enum goodness as requested by Chris. Now instead of storing the
active C++ ABI as a raw string, we store it as an enum. This should improve
performance somewhat.

And yes, this time, I started from a clean build directory, and
all the tests passed. :)

llvm-svn: 111507
2010-08-19 02:18:14 +00:00
John McCall 5cf48cd17c On second thought, don't warn about reinterpret_casts under -Wcast-align.
llvm-svn: 111497
2010-08-19 01:19:08 +00:00
Ted Kremenek 50e0105f1c Add warning for functions/blocks that have attribute 'noreturn' but return a non-void result. (<rdar://problem/7562925>)
llvm-svn: 111492
2010-08-19 00:52:13 +00:00
Ted Kremenek 5295ce8120 HandleCommonNoReturnAttr() now only has a single caller. Move that logic to HandleAnalyzerNoReturnAttr.
llvm-svn: 111491
2010-08-19 00:51:58 +00:00
John McCall f733268e7a When deducing the element type of an array, ignore qualifiers if
the context allows us to ignore qualifiers on the array type itself.

llvm-svn: 111486
2010-08-19 00:20:19 +00:00
Sebastian Redl d44cd6adba More PCH -> AST renaming.
llvm-svn: 111472
2010-08-18 23:57:06 +00:00
Sebastian Redl 2c499f6561 Rename PCHReader to ASTReader.
llvm-svn: 111467
2010-08-18 23:56:43 +00:00
Alexis Hunt dcfba7b35b Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

llvm-svn: 111455
2010-08-18 23:23:40 +00:00
Douglas Gregor fb640869ed There is no pointer conversion between to similar types (i.e., same
type ignoring cv-qualifiers). These are qualification
conversions. Fixes PR7934.

llvm-svn: 111428
2010-08-18 21:25:30 +00:00
Chris Lattner 396639db95 zap dead code.
llvm-svn: 111365
2010-08-18 16:09:06 +00:00
Douglas Gregor c1a42fdd53 Make sure to add MallocAttr to explicitly-declared operator new/new[]
when -fassume-sane-operator-new. Patch by Tom Jablin!

llvm-svn: 111363
2010-08-18 15:06:25 +00:00
John McCall 02db245d5e Rip out the existing retroactive abstract-class usage checker,
which in a fit of zeal wanted to walk the entire translation unit,
and replace it with a new checker that walks the types of declarations
nested within the class.  Also, look into templates when doing this.

llvm-svn: 111357
2010-08-18 09:41:07 +00:00
Chris Lattner e876fcd77a zap a big dead method.
llvm-svn: 111346
2010-08-18 02:44:19 +00:00
Douglas Gregor caa1bf434d Emit an error if an array is too large. We're slightly more strict
than GCC 4.2 here when building 32-bit (where GCC will allow
allocation of an array for which we can't get a valid past-the-end
pointer), and emulate its odd behavior in 64-bit where it only allows
63 bits worth of storage in the array. The former is a correctness
issue; the latter is harmless in practice (you wouldn't be able to use
such an array anyway) and helps us pass a GCC DejaGNU test.

Fixes <rdar://problem/8212293>.

llvm-svn: 111338
2010-08-18 00:39:00 +00:00
Daniel Dunbar 56df97761d StringRef'ication of lots stuff, patch by Peter Davies!
llvm-svn: 111314
2010-08-17 22:39:59 +00:00
Argyrios Kyrtzidis beb71b315a Rename -Wunused-method -> -Wunused-member-function.
llvm-svn: 111305
2010-08-17 22:06:44 +00:00
Argyrios Kyrtzidis cad715fb9b Introduce -Wunused-method option for warning on unused class methods in anonymous namespace.
This option is not part of the Unused diagnostic group until the warnings on llvm codebase are fixed
and we are ready to turn it on. Suggestion by Daniel.

llvm-svn: 111298
2010-08-17 21:43:11 +00:00
Fariborz Jahanian 798f83239c Diagnose use of iboutletcollection on ivar/property
of non-object types. Radar 8308053.

llvm-svn: 111296
2010-08-17 21:39:27 +00:00
John McCall 815039af77 Implicit decl ref expressions might not have name locations; don't silently
fail to instantiate them.

llvm-svn: 111293
2010-08-17 21:27:17 +00:00
Fariborz Jahanian b5d59b66c2 Patch to add type parameter support for attribute iboutletcollection.
Radar 8308053.

llvm-svn: 111275
2010-08-17 20:23:12 +00:00
Douglas Gregor 7116a8c19a When generating code completion patterns for method declarations, give
the resulting pattern the appropriate cursor kind of an instance or
class method declaration.

llvm-svn: 111237
2010-08-17 16:06:07 +00:00
Douglas Gregor b0ce9b79ba 1 != I. Fix the formulation of code-completion patterns for
Objective-C method declarations with > 2 parameters.

llvm-svn: 111233
2010-08-17 15:53:35 +00:00
Benjamin Kramer 35b077e674 Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()
and remove getStrData().  Patch by Peter Davies (with some tweaks).

llvm-svn: 111229
2010-08-17 12:54:38 +00:00
John McCall 3696dcb171 Don't try to initialize a reference with a constructed temporary if either
of the classes is invalid.  A class is invalid if a base is invalid.

llvm-svn: 111227
2010-08-17 07:23:57 +00:00
John McCall 2677e10732 A field of incomplete type is sufficiently disruptive that we should mark
the record invalid.

llvm-svn: 111211
2010-08-16 23:42:35 +00:00
Douglas Gregor 59cab5564f Implement support for cached code completions for
nested-name-specifiers. Also includes fixes to the generation of
nested-name-specifier result in the non-cached case; we were producing
lame results for namespaces and namespace aliases, which (1) didn't
always have nested-name-specifiers when we want them, and (2) did not
have the necessary "::" as part of the completion.

llvm-svn: 111203
2010-08-16 23:05:20 +00:00
Fariborz Jahanian 99311ba1a8 Diagnose assiging to an interface object in
non-fragile abi mode as sizes are not statically known.
Fixes radar 8315734.

llvm-svn: 111191
2010-08-16 21:51:12 +00:00
Argyrios Kyrtzidis a3ae3eb690 Fix initialization for members of anonymous struct in a union.
llvm-svn: 111159
2010-08-16 17:27:13 +00:00
Argyrios Kyrtzidis 33aee3934a Emit diagnostic error when the field of an anonymous struct is non trivial.
llvm-svn: 111158
2010-08-16 17:27:08 +00:00
Douglas Gregor 6e24033bd2 When caching global completion results, keep track of the simplified
type class, so that we can adjust priorities appropriately when the
preferred type for the context and the actual type of the completion
are similar.

This gets us one step closer to parity of the cached completion
results with the non-cached completion results.

llvm-svn: 111139
2010-08-16 16:18:59 +00:00
Charles Davis ebab1ed5d3 Error out if reinterpret_casting between member pointers of two different
sizes.

llvm-svn: 111119
2010-08-16 05:30:44 +00:00
Charles Davis 2d3694297d Err on incomplete class types in member pointers when compiling for the
Microsoft C++ ABI, for now.

llvm-svn: 111118
2010-08-16 04:01:50 +00:00
Argyrios Kyrtzidis 04c7fa09e4 Don't warn for the common pattern of disallowing copying:
class S {
  S(const S&); // DO NOT IMPLEMENT
  void operator=(const S&); // DO NOT IMPLEMENT
};

llvm-svn: 111100
2010-08-15 10:17:33 +00:00
Douglas Gregor 3998219789 Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to
a certain set of completion contexts, and the ASTUnit completion logic
introduces the completion strings for those declarations if the actual
code-completion occurs in one of the contexts where it matters. 

There are a few new code-completion-context kinds. Without these,
certain completions (e.g., after "using namespace") would need to
suppress all global completions, which would be unfortunate.

Note that we don't get the priorities right for global completions,
because we don't have enough type information. We'll need a way to
compare types in an ASTContext-agnostic way before this can be
implemented.

llvm-svn: 111093
2010-08-15 06:18:01 +00:00
Eli Friedman f8d9817f4b Use Enumerators.data() instead of &Enumerators[0] to fix a potential
assertion failure.

llvm-svn: 111092
2010-08-15 02:27:09 +00:00
Argyrios Kyrtzidis 1cec2cc798 Remove dead code, caught by unused function warnings.
llvm-svn: 111091
2010-08-15 01:15:58 +00:00
Argyrios Kyrtzidis 1b30d9c0f0 Commit improved version of 111026 & 111027.
Unused warnings for functions:
-static functions
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

Unused warnings for variables:
-static variables
-variables in anonymous namespace
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

Reveals lots of opportunities for dead code removal in llvm codebase that will
interest my esteemed colleagues.

llvm-svn: 111086
2010-08-15 01:15:20 +00:00
Eli Friedman df2392572e PR3344: Downgrade "too many braces around scalar initializer" to a warning.
llvm-svn: 111067
2010-08-14 03:14:53 +00:00
Douglas Gregor b14904c4a8 Implement caching of code-completion results for macro definitions
when the CXTranslationUnit_CacheCompletionResults option is given to
clang_parseTranslationUnit(). Essentially, we compute code-completion
results for macro definitions after we have parsed the file, then
store an ASTContext-agnostic version of those results (completion
string, cursor kind, priority, and active contexts) in the
ASTUnit. When performing code completion in that ASTUnit, we splice 
the macro definition results into the results provided by the actual
code-completion (which has had macros turned off) before libclang gets
those results. We use completion context information to only splice in
those results that make sense for that context.

With a completion involving all of the macros from Cocoa.h and a few other
system libraries (totally ~8500 macro definitions) living in a
precompiled header, we get about a 9% performance improvement from
code completion, since we no longer have to deserialize all of the
macro definitions from the precompiled header. 

Note that macro definitions are merely the canary; the cache is
designed to also support other top-level declarations, which should be
a bigger performance win. That optimization will be next.

Note also that there is no mechanism for determining when to throw
away the cache and recompute its contents.

llvm-svn: 111051
2010-08-13 22:48:40 +00:00
Argyrios Kyrtzidis 98703d3883 Revert 111026 & 111027, build breakage.
llvm-svn: 111036
2010-08-13 20:13:06 +00:00
Argyrios Kyrtzidis 1063a71e43 The unused warnings extravaganza continues. Warn for:
-static variables
-variables in anonymous namespace (fixes rdar://7794535)
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

llvm-svn: 111027
2010-08-13 18:42:40 +00:00
Argyrios Kyrtzidis 540bc01f50 Expand the unused warnings for functions. Warn for:
-static function declarations
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

llvm-svn: 111026
2010-08-13 18:42:29 +00:00
Argyrios Kyrtzidis 35672e7852 Change Sema's UnusedStaticFuncs to UnusedFileScopedDecls to allow also keeping track of unused file scoped variables.
This is only preparation, currently only static function definitions are tracked, as before.

llvm-svn: 111025
2010-08-13 18:42:17 +00:00
Fariborz Jahanian 18d90a97df When issuing warning for future conflict resolution,
(nonfragile-abi2), do not consider 'ivar' access
in class methods. Also, improve on diagnostics.
Radar 8304561.

llvm-svn: 111023
2010-08-13 18:09:39 +00:00
Abramo Bagnara c852cef1f2 Fixed NNS insertion in MemberPointerType.
llvm-svn: 111013
2010-08-13 12:56:25 +00:00
John McCall bd8062dff1 Work around a crash when checking access to injected class names
qua templates.  The current fix suppresses the access check entirely
in this case;  to do better, we'd need to be able to say that a
particular lookup result came from a particular injected class name,
which is not easy to do with the current representation of LookupResult.
This is on my known-problems list.

llvm-svn: 111009
2010-08-13 07:02:08 +00:00
Douglas Gregor 6fd55e06d3 Teach ASTUnit to hold on to the Sema object and ASTConsumer that are
used when parsing (or re-parsing) a file. Also, when loading a
precompiled header into ASTUnit, create a Sema object that holds onto
semantic-analysis information.

llvm-svn: 111003
2010-08-13 03:15:25 +00:00
John McCall dcc7140f86 Perform access control when template lookup finds a class template.
This is *really* hacky.

llvm-svn: 110997
2010-08-13 02:23:42 +00:00
Eli Friedman a2622dd266 Zap unused UnaryOperator::OffsetOf.
llvm-svn: 110996
2010-08-13 01:36:11 +00:00
Sebastian Redl e7c1fe6ab7 Instead of modifying the ObjC AST to not modify existing declarations, teach chained PCH to overwrite declarations from earlier PCH files in dependent ones. Tell Sema to note when it changes AST nodes so that they have to be reserialized. Finally, the ObjCProtocolDecls created in forward decls, like the ObjCInterfaceDecls in @class forward decls, are not lexically part of the decl context; only the definition is.
llvm-svn: 110989
2010-08-13 00:28:03 +00:00
Douglas Gregor 5c6f10b54c Add a ParseAST overload that takes a Sema object, so that the caller
can create (and hold on to) the Sema object. Also, move Sema-related
initialization/finalization with its various consumers and external
sources into the Sema constructor and destructor, rather than placing
it in ParseAST.

llvm-svn: 110973
2010-08-12 22:51:45 +00:00
Fariborz Jahanian b5a6246b91 Typo.
llvm-svn: 110965
2010-08-12 22:33:42 +00:00
Fariborz Jahanian 68e69ca9f9 Patch to issue warning when colllection expresion's type
does not implement 'countByEnumeratingWithState' API.
Implements radar 7634669.

llvm-svn: 110964
2010-08-12 22:25:42 +00:00
John McCall 2b5c1b2516 Implement -Wcast-align. The initial design of this diagnostic diverges
from GCC's in that we warn on *any* increase in alignment requirements, not
just those that are enforced by hardware.  Please let us know if this causes
major problems for you (which it shouldn't, since it's an optional warning).

llvm-svn: 110959
2010-08-12 21:44:57 +00:00
John McCall 112fd083fa Fixing the build isn't good enough; back out r110956 and r110953.
llvm-svn: 110958
2010-08-12 21:39:05 +00:00
John McCall 0af2b7c93e dgregor should write code that compiles.
llvm-svn: 110956
2010-08-12 21:23:27 +00:00
Douglas Gregor ad814e224f Add a ParseAST overload that takes a Sema object, so that the caller
can create (and hold on to) the Sema object. Also, move Sema-related
initialization/finalization with its various consumers and external
sources into the Sema constructor and destructor, rather than placing
it in ParseAST.

llvm-svn: 110952
2010-08-12 20:50:39 +00:00
Douglas Gregor c3a6ade0bb Move Sema's headers into include/clang/Sema, renaming a few along the way.
llvm-svn: 110945
2010-08-12 20:07:10 +00:00
Douglas Gregor 62157e5342 Downgrade error about nonnull attribute bbeing applied to a function without point arguments to a warning
llvm-svn: 110939
2010-08-12 18:48:43 +00:00
Abramo Bagnara 8de74e9c81 Added locations and type source info for DeclarationName inside UsingDecl.
llvm-svn: 110912
2010-08-12 11:46:03 +00:00
Jordy Rose 5af0e3cbba Remove OwnershipAttr::Kind, since it's essentially redundant with attr::Kind the way it's being used. Also fix isa<OwnershipAttr> support, break more-than-80-char lines, and other miscellaneous ownership attr cleanup.
llvm-svn: 110908
2010-08-12 08:54:03 +00:00
John McCall 8246e350be Handle the obvious case for diagnosing redeclarations of extern "C" functions.
Fixes PR7859.

llvm-svn: 110906
2010-08-12 07:09:11 +00:00
John McCall bdb989eca4 Bail out of MaybeBindToTemporary if the record type is invalid. Test case
is 8.5MB, sorry.

llvm-svn: 110901
2010-08-12 02:40:37 +00:00
John McCall 12d53da8cb Fix a crash on invalid when declaring an implicit member of a class with an
invalid destructor.

llvm-svn: 110891
2010-08-12 00:57:17 +00:00
John McCall 2ded5d25a9 Don't try to implicitly declare special members of an invalid class.
Fixes a crash in a rather large and difficult-to-reduce test case.

llvm-svn: 110882
2010-08-11 23:52:36 +00:00
Abramo Bagnara d6d2f18905 Added locations and type source info for DeclarationName.
llvm-svn: 110860
2010-08-11 22:01:17 +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
Fariborz Jahanian d539d098a4 IRGen support for functions returning objc object
types. Fixes PR7865.

llvm-svn: 110832
2010-08-11 17:37:35 +00:00
Benjamin Kramer e8394df11b Random temporary string cleanup.
llvm-svn: 110807
2010-08-11 14:47:12 +00:00
Douglas Gregor 13e6587313 If name lookup finds different type declarations in different scopes
that actually refer to the same underlying type, it is not an
ambiguity; add uniquing support based on the canonical type of type
declarations. Fixes <rdar://problem/8296180>.

llvm-svn: 110806
2010-08-11 14:45:53 +00:00
Douglas Gregor 1c28331b57 Speculatively revert r110610 " Make ObjCInterfaceDecl redeclarable,
and create separate decl nodes for forward declarations and the
definition," which appears to be causing significant Objective-C
breakage.

llvm-svn: 110803
2010-08-11 12:19:30 +00:00
Douglas Gregor 836a7e8468 Improve our handling of user-defined conversions when computing
implicit conversion sequences. In particular, model the "standard
conversion" from a class to its own type (or a base type) directly as
a standard conversion in the normal path *without* trying to determine
if there is a valid copy constructor. This appears to match the intent
of C++ [over.best.ics]p6 and more closely matches GCC and EDG.

As part of this, model non-lvalue reference initialization via
user-defined conversion in overloading the same way we handle it in
InitializationSequence, separating the "general user-defined
conversion" and "conversion to compatible class type" cases.

The churn in the overload-call-copycon.cpp test case is because the
test case was originally wrong; it assumed that we should do more
checking for copy constructors that we actually should, which affected
overload resolution.

Fixes PR7055. Bootstrapped okay.

llvm-svn: 110773
2010-08-11 02:15:33 +00:00
Fariborz Jahanian 32e59ba01d Fix a spurious warning when message sent to qualified-id
type receiver (pr7861).

llvm-svn: 110696
2010-08-10 18:10:50 +00:00
Douglas Gregor 7058c265f5 Eliminate unnecessary uses of TemporaryBase in TreeTransform;
transforming TypeSourceInfos already gives us proper (and better)
source-location information.

llvm-svn: 110678
2010-08-10 14:27:00 +00:00
Abramo Bagnara f9985b4560 Fixed redundant NNS loading.
llvm-svn: 110677
2010-08-10 13:46:45 +00:00
Abramo Bagnara 27db23948c Added TypeLocs to VAArgExpr node.
llvm-svn: 110666
2010-08-10 10:06:15 +00:00
Abramo Bagnara 092990ac68 Added TypeLocs to TypesCompatibleExpr node.
llvm-svn: 110663
2010-08-10 08:50:03 +00:00
Eli Friedman 88f4ed9011 Fix redefinition of typedefs of fixable variably-modified array types; should
fix an issue compiling <windows.h>.

llvm-svn: 110651
2010-08-10 03:13:15 +00:00
Fariborz Jahanian 3337b2e8dd Implements gcc's -Wstrict-selector-match.
(radar 8127244).

llvm-svn: 110622
2010-08-09 23:27:58 +00:00
Douglas Gregor 86b8d9ff87 When attempting to recover from a failed unqualified name lookup, make
sure to clear out the LookupResult structure after looking into each class.

llvm-svn: 110615
2010-08-09 22:38:14 +00:00
Sebastian Redl ab6a088314 - Make ObjCInterfaceDecl redeclarable, and create separate decl nodes for forward declarations and the definition.
- Eagerly create ObjCInterfaceTypes for declarations.
- The two above changes lead to a 0.5% increase in memory use and no speed regression when parsing Cocoa.h. On the other hand, now chained PCH works when there's a forward declaration in one PCH and the interface definition in another.
- Add HandleInterestingDecl to ASTConsumer. PCHReader passes the "interesting" decls it finds to this function instead of HandleTopLevelDecl. The default implementation forwards to HandleTopLevelDecl, but ASTUnit's handler for example ignores them. This fixes a potential crash when lazy loading of PCH data would cause ASTUnit's "top level" declaration collection to change while being iterated.

llvm-svn: 110610
2010-08-09 21:55:28 +00:00
John Thompson cdb847ba16 Added vecreturn attribute parsing.
llvm-svn: 110609
2010-08-09 21:53:52 +00:00
Chandler Carruth 9b41823177 Fix a crash on template delete operators.
llvm-svn: 110542
2010-08-08 07:04:00 +00:00
Chandler Carruth 9c524c1d53 Silence GCC warning about && and || without explicit grouping.
llvm-svn: 110537
2010-08-08 05:02:51 +00:00
Eli Friedman aab1fda91f PR7800: both virtual and non-virtual bases must be marked as used for VTTs.
llvm-svn: 110526
2010-08-07 23:11:44 +00:00
Douglas Gregor f58ff32c16 Integral-to-pointer conversions are not always null -> member pointer
conversions. Fixes PR7443.

llvm-svn: 110519
2010-08-07 13:36:37 +00:00
Douglas Gregor 114e55df5b Fix an Objective-C crasher, PR7839.
llvm-svn: 110515
2010-08-07 12:29:18 +00:00
Douglas Gregor 8b2d2fe234 Allow reference binding of a reference of Objective-C object type to
an lvalue of another, compatible Objective-C object type (e.g., a
subclass). Introduce a new initialization sequence step kind to
describe this binding, along with a new cast kind. Fixes PR7741.

llvm-svn: 110513
2010-08-07 11:51:51 +00:00
John McCall cf14216509 Store inheritance paths after CastExprs instead of inside them.
This takes some trickery since CastExpr has subclasses (and indeed,
is abstract).

Also, smoosh the CastKind into the bitfield from Expr.

Drops two words of storage from Expr in the common case of expressions
which don't need inheritance paths.  Avoids a separate allocation and
another word of overhead in cases needing inheritance paths.  Also has
the advantage of not leaking memory, since destructors for AST nodes are
never run.

llvm-svn: 110507
2010-08-07 06:22:56 +00:00
Eli Friedman 964dbda0e9 PR7837: For qualified id's, make sure the decl context is complete if not
dependent in ActOnIdExpression.  (This issue only shows up with member
operators because an operator is never a type.)

llvm-svn: 110486
2010-08-06 23:41:47 +00:00
Douglas Gregor 229c281d37 Remove some incorrect assertions when deduction template arguments in
a template-argument-list. When template template parameters are
involved, we won't already have checked the template-argument-list (it
may not be known yet!). Fixes PR7807.

llvm-svn: 110444
2010-08-06 14:15:26 +00:00
Douglas Gregor 7260905918 Make sure that we diagnose attribute((overloadable)) functions without
prototypes. Fixes PR7738.

llvm-svn: 110443
2010-08-06 13:50:58 +00:00
Abramo Bagnara 7c5dee4280 Template keyword should not be ignored building a QualifiedTemplateName.
llvm-svn: 110441
2010-08-06 12:11:11 +00:00
Douglas Gregor 2588691a69 Diagnose the use of "inline" on block-scope function declarations in
C++, from Andrea Nall!

llvm-svn: 110439
2010-08-06 11:44:10 +00:00
Douglas Gregor 59e8b3bd7b Introduce implicit conversions between AltiVec vectors and GCC
vectors, from Anton Yartsev!

llvm-svn: 110437
2010-08-06 10:14:59 +00:00
Nick Lewycky 60ecc522e0 Remove the DeclaredInCondition bit now that it's no longer used.
llvm-svn: 110432
2010-08-06 05:43:55 +00:00
John McCall dc9796e23a Properly pop out of Objective-C method declarations when they are (ill-formedly)
found within contexts other than the translation unit.

llvm-svn: 110417
2010-08-06 00:46:05 +00:00
Eli Friedman 06dcfd94c8 Flip the switch to use OffsetOfExpr unconditionally; feel free to revert if
this breaks something.

I'll wait a few days before cleaning out UnaryOperator::OffsetOf.

llvm-svn: 110328
2010-08-05 10:15:45 +00:00
Eli Friedman 74ef7cf144 PR7769: Fix references to anonymous structs/unions in base classes in
offsetof expressions.

llvm-svn: 110327
2010-08-05 10:11:36 +00:00
Argyrios Kyrtzidis 7f76d11dcc Store the pending implicit instantiations in the PCH and perform them at the end of the translation unit that
included the PCH, as God intended.

llvm-svn: 110324
2010-08-05 09:48:16 +00:00
Argyrios Kyrtzidis ee1afa3082 Support #pragma weak for PCH.
llvm-svn: 110323
2010-08-05 09:48:08 +00:00
John McCall 42d7d19710 TDK_InconsistentQuals is really totally different from TDK_Inconsistent.
Rename it to TDK_Underqualified to avoid this sort of confusion and give it
its own diagnostic.

llvm-svn: 110318
2010-08-05 09:05:08 +00:00
Eli Friedman 570024a8d9 Implement #pragma GCC visibility.
llvm-svn: 110315
2010-08-05 06:57:20 +00:00
Nick Lewycky ef7c0ffe40 Remove the warning for variables declared in the if-expression being used in
the else clause. The problem is that it's overly zealous and will respond to
uses in assignments, or after assignments. We should bring this back once we
can do it right. Fixes PR7100.

llvm-svn: 110314
2010-08-05 06:27:49 +00:00
John McCall da518417fa Permit template argument deduction to add qualifiers within ObjC object
pointers like it can with normal and member pointers.

llvm-svn: 110313
2010-08-05 05:30:45 +00:00
Eli Friedman d8725a9602 Preserve calling convention etc. across template instantiations.
llvm-svn: 110304
2010-08-05 02:54:05 +00:00
Eli Friedman a170cd6257 Get rid of isObjectType; when C++ says "object type", it generally
just means "not a function type", not "not a function type or void". This
changes behavior slightly, but generally in a way which accepts more code.

llvm-svn: 110303
2010-08-05 02:49:48 +00:00
Sebastian Redl e0351b970d Remove a redundant and broken check. Fixes PR7810.
llvm-svn: 110294
2010-08-05 00:45:34 +00:00
Ted Kremenek b786156b01 Teach SemaChecking::CheckReturnStackAddr about ImplicitCastExprs that convert values to an lvalue. This allows us to warn (again) about returning references to stack variables. (fixes PR 7812).
llvm-svn: 110242
2010-08-04 20:01:07 +00:00
Douglas Gregor 8e984da800 Add code-completion support directly to ASTUnit, which performs code
completion within the translation unit using the same command-line
arguments for parsing the translation unit. Eventually, we'll reuse
the precompiled preamble to improve code-completion performance, and
this also gives us a place to cache results.

Expose this function via the new libclang function
clang_codeCompleteAt(), which performs the code completion within a
CXTranslationUnit. The completion occurs in-process
(clang_codeCompletion() runs code completion out-of-process).

llvm-svn: 110210
2010-08-04 16:47:14 +00:00
John McCall deb646ebb5 Only look up an 'operator delete' on the definition of a destructor, not on
a declaration.

llvm-svn: 110175
2010-08-04 01:04:25 +00:00
John McCall 66a8759400 Look through using declarations when deciding whether to use an operator
delete for a virtual destructor.  Diagnose ambiguities.

Fixes PR7803.

llvm-svn: 110173
2010-08-04 00:31:26 +00:00
Nate Begeman f568b074db Add support for VFP status & control operations for ARM.
llvm-svn: 110153
2010-08-03 21:32:34 +00:00
John McCall 4a33fa95c0 Labels (and case statement) don't create independent scope parents for the
purposes of the jump checker.  Also extend Ted's iteration fix to labels.

Fixes PR7789.

llvm-svn: 110082
2010-08-02 23:33:14 +00:00
Sebastian Redl 75d8a32817 Simplify global method pool implementation in Sema. No functionality change.
llvm-svn: 110078
2010-08-02 23:18:59 +00:00
Ted Kremenek 04d50f5d13 Fix another case (this time in JumpScopeChecker) where walking deeply nested CaseStmts can blow out the stack. Fixes <rdar://problem/8125165>.
llvm-svn: 110071
2010-08-02 22:46:57 +00:00
John McCall 8b0f4ff317 Further adjustments to -Wglobal-constructors; works for references and direct
initializations now.

llvm-svn: 110063
2010-08-02 21:13:48 +00:00
Argyrios Kyrtzidis 2d68810caf Read/write in PCH Sema's StdNamespace and StdBadAlloc and use a LazyDeclPtr for them that will deserialize them when needed.
llvm-svn: 110031
2010-08-02 07:14:54 +00:00
Argyrios Kyrtzidis 4f8e17379d Rename getStdNamespace -> getOrCreateStdNamespace, to better reflect its functionality.
No functionality change.

llvm-svn: 110030
2010-08-02 07:14:39 +00:00
John McCall 81c9cea24b Kill off RequiresGlobalConstructor in favor of isConstantInitializer.
Note some obvious false positives in the test case.

llvm-svn: 109986
2010-08-01 21:51:45 +00:00
John McCall 47e40931c9 Make a first pass at implementing -Wglobal-constructors. I'm worried that this
will end up bizarrely mirroring CGExprConstant, but that might be the hazard of
this feature.

llvm-svn: 109984
2010-08-01 20:20:59 +00:00
John McCall 6602bb1115 Instantiate attributes from the pattern record when instantiating
a class template.  Fixes rdar://problem/8243419.

llvm-svn: 109967
2010-08-01 02:01:53 +00:00
John McCall a755f0f74a Fix indentation.
llvm-svn: 109965
2010-08-01 01:25:24 +00:00
John McCall d4e1b767f3 Don't consider all local variables in C++ to mandate scope-checking, just
those with initializers.

llvm-svn: 109964
2010-08-01 01:24:59 +00:00
John McCall a95172baa0 Only run the jump-checker if there's a branch-protected scope *and* there's
a switch or goto somewhere in the function.  Indirect gotos trigger the
jump-checker regardless, because the conditions there are slightly more
elaborate and it's too marginal a case to be worth optimizing.

Turns off the jump-checker in a lot of cases in C++.  rdar://problem/7702918

llvm-svn: 109962
2010-08-01 00:26:45 +00:00
Ted Kremenek d21139a34f After a lengthy design discussion, add support for "ownership attributes" for malloc/free checking. Patch by Andrew McGregor!
llvm-svn: 109939
2010-07-31 01:52:11 +00:00
Sebastian Redl 671eee9e68 Correctly deal with using names for both functions and structs in chained PCH.
llvm-svn: 109871
2010-07-30 17:25:10 +00:00
Fariborz Jahanian 7b70eb4bb1 Tighten the rules when deciding if an ivar must be
auto-synthesized (nonfragile-abi2 specific).
Fixes radar 8251648.

llvm-svn: 109866
2010-07-30 16:59:05 +00:00
Abramo Bagnara ed5b6899ab Fixed typedef inside extern "C".
llvm-svn: 109865
2010-07-30 16:47:02 +00:00
John McCall 0925714eca If a TST_typename has a null type, mark the declarator invalid. Prevents
some downstream crashes, among them rdar://problem/8229840.

llvm-svn: 109850
2010-07-30 05:17:22 +00:00
Nate Begeman 1194bd2bd8 Wire up sema checking for __builtin_arm_usat and __builtin_arm_ssat immediates.
llvm-svn: 109814
2010-07-29 22:48:34 +00:00
Fariborz Jahanian c15dfd8a87 Tigthen the condition for issung ivar shadowing
variables to those in file scope (nonfragile-abi2).
Fixes radar 8248681.

llvm-svn: 109758
2010-07-29 16:53:53 +00:00
Douglas Gregor e9bf2d159c When dynamic_cast'ing from a type to itself, fill in the cast kind
with CK_NoOp. Fixes PR7727.

llvm-svn: 109757
2010-07-29 16:12:45 +00:00
Douglas Gregor 0bdcb8a239 When taking the address of a value of Objective-C object type (e.g.,
one because we're referencing a variable of type NSString &), the
resulting type is an ObjCObjectPointerType.

llvm-svn: 109753
2010-07-29 16:05:45 +00:00
Douglas Gregor 17ea3f5dbd Allow a looser form of compatibility checking (which ignores
qualifiers) when checking a K&R function definition against a previous
prototype. Fixes <rdar://problem/8193107>.

llvm-svn: 109751
2010-07-29 15:18:02 +00:00
Douglas Gregor f65f490ae9 When deleting a value of class type, make sure that type is complete
before looking for conversions to pointer type. Fixes <rdar://problem/8248780>.

llvm-svn: 109749
2010-07-29 14:44:35 +00:00
Douglas Gregor 43397fc4dc Don't set out-of-line template specialization/definition information
for AST nodes that aren't actually out-of-line (i.e., require a
nested-name-specifier). Fixes <rdar://problem/8204126>.

llvm-svn: 109704
2010-07-28 23:59:57 +00:00
Douglas Gregor a9c3e82755 Don't die when a member access refers to a non-class member via a
qualified name. Fixes <rdar://problem/8231724>.

llvm-svn: 109682
2010-07-28 22:27:52 +00:00
Douglas Gregor 85b5063f2c When performing code completion for a case statement in a switch whose
condition is not of enumeration type, provide code-completion results
containing all values of integral or enumeral type.

llvm-svn: 109677
2010-07-28 21:50:18 +00:00
Douglas Gregor bbfd2c0a86 Enable expression transformations in the current-instantiation
rebuilder, i.e., remove a silly short-sighted hack from long
ago. Thanks to Abramo Bagnara for the test case/bug report!

llvm-svn: 109583
2010-07-28 15:14:14 +00:00
Douglas Gregor df65c8ed2a When a nested-name-specifier refers into a current instantiation that has
dependent bases, construct a dependent nested-name-specifier rather
than complaining that the name could not be found within the current
instantiation itself. Fixes PR7725.

llvm-svn: 109582
2010-07-28 14:49:07 +00:00
Eli Friedman 7530049b16 Fix a minor crash bug with constructs like Obj.Class::ENUM_VALUE.
llvm-svn: 109537
2010-07-27 20:51:02 +00:00
Eli Friedman 6b197e0651 PR7724: Don't try to evaluate value-dependent expressions.
llvm-svn: 109532
2010-07-27 19:14:53 +00:00
Michael J. Spencer 2c35bc1232 Revert r109428 "Hoist argument type checking into CheckFormatHandler. This is prep for scanf format"
Got errors about ASTContext being undefined with Visual Studio 2010.

llvm-svn: 109491
2010-07-27 04:46:02 +00:00
Dan Gohman 4888f1a210 Minor code simplification.
llvm-svn: 109443
2010-07-26 21:33:22 +00:00
Dan Gohman 28ade550f4 Fix namespace polution.
llvm-svn: 109440
2010-07-26 21:25:24 +00:00
Ted Kremenek df4472bca0 Hoist argument type checking into CheckFormatHandler. This is prep for scanf format
string argument type checking.

llvm-svn: 109428
2010-07-26 19:45:54 +00:00
Ted Kremenek 6adb7e35ab Consolidate #args checking for scanf/printf format strings.
llvm-svn: 109427
2010-07-26 19:45:42 +00:00
Sebastian Redl ae8cbb7220 Make sure that implicit qualification and derived-to-base conversions of xvalues preserve xvalue-ness. Unfortunately I have no idea how to test this property; there doesn't seem to be a syntactical construct that triggers such a conversion and still allows the distinction between prvalues and xvalues to be made.
llvm-svn: 109406
2010-07-26 17:52:21 +00:00
Nick Lewycky 19b9f958e1 Add source location information to C++ base specifiers.
llvm-svn: 109396
2010-07-26 16:56:01 +00:00
Douglas Gregor a9b2dbc1a4 Kill off the last Destroy method in the AST library
llvm-svn: 109378
2010-07-25 18:23:53 +00:00
Douglas Gregor b412e174db Remove the vast majority of the Destroy methods from the AST library,
since we aren't going to be calling them ever.

llvm-svn: 109377
2010-07-25 18:17:45 +00:00
Eli Friedman e4686d7acf Remove dead code.
llvm-svn: 109358
2010-07-24 21:35:09 +00:00
Eli Friedman 9255adfb7a PR7698: Make sure we correctly handle the initialization of an array with
dependent size.

llvm-svn: 109356
2010-07-24 21:19:15 +00:00
Chris Lattner 938533db60 turn down the logical bitwise confusion warning to not warn
when the RHS of the ||/&& is ever 0 or 1.  This handles a variety of
creative idioms for "true" used in C programs and fixes many false 
positives at the expense of a few false negatives.  This fixes
rdar://8230351.

llvm-svn: 109314
2010-07-24 01:10:11 +00:00
John McCall 2ca705eb13 Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.
Diagnose attempts to do this under the GNU or fragile NeXT runtimes.

llvm-svn: 109298
2010-07-24 00:37:23 +00:00
Douglas Gregor 536f091f95 Be careful; even though we had a proper name at the beginning of
Sema::ActOnDeclarator doesn't mean that the Decl we ended up creating
has a useful name. <rdar://problem/8229910>

llvm-svn: 109296
2010-07-24 00:10:38 +00:00
John McCall dd762d1e5b We never want to pop the translation unit DC, so assert if this happens.
llvm-svn: 109280
2010-07-23 22:45:07 +00:00
Fariborz Jahanian 946274471d Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks.
Radar 8218839.

llvm-svn: 109272
2010-07-23 21:53:24 +00:00
Eli Friedman d4c75cddde Fix for PR7694: make sure to pass in a RecordType to CheckBaseClassAccess;
fixes crashes on both valid and invalid code.  The diagnostic here could
potentially be improved, but it's good enough as-is.

llvm-svn: 109257
2010-07-23 19:25:41 +00:00
Douglas Gregor 5cc2c8b9c3 Vectors are not integer types, so the type system should not classify
them as such. Type::is(Signed|Unsigned|)IntegerType() now return false
for vector types, and new functions
has(Signed|Unsigned|)IntegerRepresentation() cover integer types and
vector-of-integer types. This fixes a bunch of latent bugs.

Patch from Anton Yartsev!

llvm-svn: 109229
2010-07-23 15:58:24 +00:00
Bill Wendling 8abd1ca8d2 Remove unneeded iostream include.
llvm-svn: 109219
2010-07-23 07:19:31 +00:00
Fariborz Jahanian 86151343b4 Warn when property ivar lookup finds a global variable
of same name. In nonfragile-abi2, lookup accesses a synthesized
ivar. This is a transition warning.  Radar 8225011.

llvm-svn: 109197
2010-07-22 23:33:21 +00:00
Fariborz Jahanian 6e7e8cc19d atch for implementation of objective-c's -Wselector
warning flag in clang. Little more to do
for a PCH issue. Radar 6507158.

llvm-svn: 109129
2010-07-22 18:24:20 +00:00
Ted Kremenek 1ddd6d2b6b Upgrade "'X' is unavailable" from a warning to an error. This matches GCC's behavior. Note that
GCC emits a warning instead of an error when using an unavailable Objective-C protocol, so now
Clang's behavior is more strict in this case, but more consistent.  We will need to see how much
this fires on real code and determine whether this case should be downgraded to a warning.

Fixes <rdar://problem/8213093>.

llvm-svn: 109033
2010-07-21 20:43:11 +00:00
Fariborz Jahanian da2da9c93e Added extra check when looking for location of '=' in
a copy initialization.

llvm-svn: 109025
2010-07-21 18:40:47 +00:00
Fariborz Jahanian 3fd2a555d3 Fix source location of the initializer in
a copy initialization. Back out hack in objc rewriter.
fixes radar 8213998.

llvm-svn: 109024
2010-07-21 18:31:47 +00:00
Ted Kremenek 4407ea4948 Hookup checking for invalid length modifiers in scanf format strings.
llvm-svn: 108907
2010-07-20 20:04:47 +00:00
Ted Kremenek f03e6d85a1 Add 'ConversionSpecifier' root class in 'analyze_format_string' namespace and
derived 'PrintfConversionSpecifier' from this class.  We will do the same for
'ScanfConversionSpecifier'.

llvm-svn: 108903
2010-07-20 20:04:27 +00:00
Ted Kremenek 516ef222ba Rename 'ConsumedSoFarArg' -> 'nArg' and 'OutIntPtrArg' to 'nArg' (scanf and printf checking).
llvm-svn: 108900
2010-07-20 20:04:10 +00:00
Ted Kremenek b65a9d5a1a Rename diagnostic so that it can be reused with scanf checking. No functionality change.
llvm-svn: 108896
2010-07-20 20:03:43 +00:00
Argyrios Kyrtzidis dde5790562 Hide FunctionTemplateDecl's specializations folding set as implementation detail and introduce
FunctionTemplateDecl::findSpecialization.

Redeclarations of specializations will not cause the previous decl to be removed from the set,
the set will keep the canonical decl. findSpecialization will return the most recent redeclaration.

llvm-svn: 108834
2010-07-20 13:59:58 +00:00
Argyrios Kyrtzidis 47470f2f3f Hide the specializations folding sets of ClassTemplateDecl as an implementation detail (InsertPos
leaks though) and add methods to its interface for adding/finding specializations.

Simplifies its users a bit and we no longer need to replace specializations in the folding set with
their redeclarations. We just return the most recent redeclarations.

As a bonus, it fixes http://llvm.org/PR7670.

llvm-svn: 108832
2010-07-20 13:59:28 +00:00