Commit Graph

6941 Commits

Author SHA1 Message Date
Chris Lattner a503f7c9d2 convert to -verify mode.
llvm-svn: 100674
2010-04-07 18:43:41 +00:00
Douglas Gregor 3b4abb6792 Improve handling of friend types in several ways:
- When instantiating a friend type template, perform semantic
  analysis on the resulting type.
  - Downgrade the errors concerning friend type declarations that do
  not refer to classes to ExtWarns in C++98/03. C++0x allows
  practically any type to be befriended, and ignores the friend
  declaration if the type is not a class.

llvm-svn: 100635
2010-04-07 17:57:12 +00:00
John McCall 8586bfd85d @llvm.sqrt isn't really close enough to C's sqrt to justify emitting calls
to the intrinsic, even when math-errno is off.

Fixes rdar://problem/7828230 by falling back on the library function.

llvm-svn: 100613
2010-04-07 08:20:20 +00:00
John McCall 1bff99322a Teach -Wsign-compare to treat 1 << blah as "idiomatically non-negative".
Fixes a spurious warning in LLVM.

llvm-svn: 100595
2010-04-07 01:14:35 +00:00
Ted Kremenek 6e95bfc6a5 Fix crash in StoreManager::CastRegion() when the base region is a type with 0 size.
llvm-svn: 100594
2010-04-07 00:46:49 +00:00
John McCall 8e36d53e34 Check access for the implicit calls to destructors that occur when we
have a temporary object in C++.

Also fix a tag mismatch that Doug noticed.

llvm-svn: 100593
2010-04-07 00:41:46 +00:00
Ted Kremenek 6ca136a77f Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.
llvm-svn: 100589
2010-04-07 00:27:13 +00:00
Fariborz Jahanian ea7a133775 Improve on diagnostics when an objc class is used as
a stand-alone type declaration.

llvm-svn: 100588
2010-04-07 00:22:00 +00:00
Douglas Gregor 636a61e0d2 Implement code completion for Objective-C method declarations and
definitions, e.g., after 

  -

or

  - (id)

we'll find all of the "likely" instance methods that one would want to
declare or define at this point. In the latter case, we only produce
results whose return types match "id".

llvm-svn: 100587
2010-04-07 00:21:17 +00:00
Fariborz Jahanian b2c1aac544 default access for synthesize ivar is @protect.
Fixes radar 7823675.

llvm-svn: 100582
2010-04-06 23:36:17 +00:00
Fariborz Jahanian 6a0a2e0ccc Patch to not build ivar ASTs when they are ilegally
declared in categories.

llvm-svn: 100577
2010-04-06 22:43:48 +00:00
John McCall 2351cb9139 Devote a special diagnostic to the typo
(void*) someFunction(5, 10, 15, 20);
where the cast is presumably meant to be to 'void'.

llvm-svn: 100574
2010-04-06 22:24:14 +00:00
Ted Kremenek f969841a1a Teach MemRegion::getBaseRegion() about ObjCIvarRegions. We want to treat
them the same way as fields.  This fixes a regression in RegionStore::RemoveDeadbindings()
that emerged from going to the cluster-based analysis.

llvm-svn: 100570
2010-04-06 22:06:03 +00:00
John McCall a8ae222d0e Implement the protected access restriction ([class.protected]), which requires
that protected members be used on objects of types which derive from the
naming class of the lookup.  My first N attempts at this were poorly-founded,
largely because the standard is very badly worded here.

llvm-svn: 100562
2010-04-06 21:38:20 +00:00
Douglas Gregor c01890e1cc When code completion produces an overload set as its results (e.g.,
while we're completing in the middle of a function call), also produce
"ordinary" name results that show what can be typed at that point.

llvm-svn: 100558
2010-04-06 20:19:47 +00:00
Douglas Gregor 2cb6c30673 Do not produce semicolons at the end of code-completion results
llvm-svn: 100557
2010-04-06 20:11:37 +00:00
Douglas Gregor 285560929f Only prove macros as code-completion results when we're in a case
statement or for ordinary names. This means that we won't show macros
when completing, e.g., member expressions such as "p->".

llvm-svn: 100555
2010-04-06 20:02:15 +00:00
Douglas Gregor 9d2ddb2e5d When sending a message to "id", apply some heuristics to try to narrow
down the set of code-completion results based on Objective-C
conventions. 

llvm-svn: 100548
2010-04-06 19:22:33 +00:00
Chris Lattner e6485c5873 add a testcase that the integrated assembler rejects, this verifies
that the integrated assembler is working.

llvm-svn: 100545
2010-04-06 18:46:25 +00:00
Douglas Gregor d720daf8bc Make code-completion for Objective-C message sends to "id" work in the
presence of precompiled headers by forcibly loading all of the
methods we know about from the PCH file before constructing our
code-completion list.

llvm-svn: 100535
2010-04-06 17:30:22 +00:00
Fariborz Jahanian 440a6832c5 Put type restriction on convesion to nonconforming 'id' back in
block pointer type comparison.

llvm-svn: 100533
2010-04-06 17:23:39 +00:00
Douglas Gregor 6285f754fa Implement support for code completion of an Objective-C message send to
"id" or an expression of type "id". In these cases, we produce a list
of all of the (class or instance) methods, respectively, that we know about.

Note that this implementation does not yet work well with precompiled
headers; that's coming soon.

llvm-svn: 100528
2010-04-06 16:40:00 +00:00
Douglas Gregor e7938a04c8 Add test for code completion of Objective-C message sends to classes.
llvm-svn: 100527
2010-04-06 15:27:03 +00:00
Douglas Gregor be9ea80abf Perform code-completion within ParseCastExpression, which handles,
e.g., the right-hand side of binary expressions.

llvm-svn: 100526
2010-04-06 15:09:27 +00:00
Douglas Gregor cf04b02d1d Extend the type printing policy to allow one to turn off the printing
of file locations for anonymous tag types (e.g., "enum <anonymous at
t.h:15:6>"), which can get rather long.

llvm-svn: 100470
2010-04-05 21:25:31 +00:00
Jeffrey Yasskin 6e085c1efe Print the errors when a clang test fails instead of just listing the
failing test files.

llvm-svn: 100469
2010-04-05 21:20:38 +00:00
Devang Patel a2c048eaf8 Emit debug info for objc getters and setters.
llvm-svn: 100462
2010-04-05 21:09:15 +00:00
Chris Lattner da081a8e1f fix PR6780, properly handling the IR {|} escapes in inline asm strings.
llvm-svn: 100449
2010-04-05 18:44:00 +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
Douglas Gregor f3df985ba7 Code completion results that refer to macros now get the cursor kind
of macro definitions when passed to CIndex. Add test for code
completion of macros via CIndex.

llvm-svn: 100431
2010-04-05 16:10:30 +00:00
Zhongxing Xu faa4905e0c Always assume block-level expressions in the caller are alive when analyzing
the callee.

llvm-svn: 100429
2010-04-05 13:16:29 +00:00
Mon P Wang cc2ab0cdc9 Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
llvm-svn: 100305
2010-04-04 03:10:52 +00:00
Rafael Espindola 8e7ca8e0b1 Don't produce a vtable for a class if we have an explicit template instantiation declaration and no key function. We will produce the vtable at the explicit template instantiation.
Fixes PR6748

llvm-svn: 100266
2010-04-03 04:26:42 +00:00
Fariborz Jahanian d077f719be Improve diagnosing when a method type does not start with '-'|'+'
when parsing. Fixes radar 7822196.

llvm-svn: 100248
2010-04-02 23:15:40 +00:00
Daniel Dunbar 8f0be43669 Avoid unneeded calls to opt/llvm-dis.
llvm-svn: 100236
2010-04-02 22:29:38 +00:00
Daniel Dunbar 87c1991bb4 Merge several tests into switch.c.
llvm-svn: 100235
2010-04-02 22:29:35 +00:00
Fariborz Jahanian e16cdb407a diagnose declaring class extension after its implementation
(radar 7822210).

llvm-svn: 100226
2010-04-02 20:53:05 +00:00
Fariborz Jahanian a9f8675e02 Diagnose invalid code with -fobjc-nonfragile-abi2 when
property is being accessed without the dot-syntax notation.
(radar 7822344).

llvm-svn: 100212
2010-04-02 20:09:24 +00:00
Douglas Gregor ce6c2748f7 We seem to get an inconsistent alignment value in the generated
assembly for the global "d7". We were previously testing for alignment
3, which seems to happen for some builders and not for others. I've
eliminated the alignment check and added a FIXME to unbreak the
buildbots.

llvm-svn: 100205
2010-04-02 19:02:06 +00:00
Mon P Wang f7f3bff646 Revert r100193 since it causes failures in objc in clang
llvm-svn: 100200
2010-04-02 18:43:42 +00:00
Douglas Gregor 45cf7e3d2a Rework our handling of copy construction of temporaries, which was a
poor (and wrong) approximation of the actual rules governing when to
build a copy and when it can be elided.

The correct implementation is actually simpler than the
approximation. When we only enumerate constructors as part of
initialization (e.g., for direct initialization or when we're copying
from a class type or one of its derived classes), we don't create a
copy. When we enumerate all conversion functions, we do create a
copy. Before, we created some extra copies and missed some
others. The new test copy-initialization.cpp shows a case where we
missed creating a (required, non-elidable) copy as part of a
user-defined conversion, which resulted in a miscompile. This commit
also fixes PR6757, where the missing copy made us reject well-formed
code in the ternary operator.

This commit also cleans up our handling of copy elision in the case
where we create an extra copy of a temporary object, which became
necessary now that we produce the right copies. The code that seeks to
find the temporary object being copied has moved into
Expr::getTemporaryObject(); it used to have two different
not-quite-the-same implementations, one in Sema and one in CodeGen.

Note that we still do not attempt to perform the named return value
optimization, so we miss copy elisions for return values and throw
expressions.

llvm-svn: 100196
2010-04-02 18:24:57 +00:00
Mon P Wang 4b82a88764 Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
llvm-svn: 100193
2010-04-02 18:04:30 +00:00
Anders Carlsson db0a965eca If a constructor is a dependent context, just set the base and member initializers as they are written. Fixes a bug where we wouldn't show initialization order warnings when instantiating.
llvm-svn: 100180
2010-04-02 06:26:44 +00:00
Anders Carlsson 7b3f2788a1 Diagnose multiple base and member initializers in class templates.
llvm-svn: 100179
2010-04-02 05:42:15 +00:00
John McCall cdf40bed1b Check in a motivating test for the revised access semantics.
llvm-svn: 100159
2010-04-02 00:11:49 +00:00
John McCall d79b4d8173 Correct the calculation of access to more closely model the wording in
the standard.

llvm-svn: 100155
2010-04-02 00:03:43 +00:00
Fariborz Jahanian d603b54c55 Relax the typesafty rules of block pointers types which
take'id' or return 'id' in their type. Fixes radar 7814131.

llvm-svn: 100129
2010-04-01 19:50:22 +00:00
Douglas Gregor b242683d99 Overhaul checking of non-type template arguments that should refer to
an object or function. Our previous checking was too lax, and ended up
allowing missing or extraneous address-of operators, among other
evils. The new checking provides better diagnostics and adheres more
closely to the standard.

Fixes PR6563 and PR6749.

llvm-svn: 100125
2010-04-01 18:32:35 +00:00
Zhongxing Xu 640aad7667 Use the element type to compute the array size when the base region is a VarRegion.
Patch by Jordy Rose.

llvm-svn: 100099
2010-04-01 08:20:27 +00:00
Ted Kremenek c3e1f2f9ba Fix a bug (PR 6699) in RegionStore::RemoveDeadBindings() where
array values with a non-zero offset would get prematurely pruned from the store.

llvm-svn: 100067
2010-04-01 00:15:55 +00:00
Douglas Gregor f5af3584ca Improve diagnostics when an elaborated-type-specifer containing a
nested-name-specifier (e.g., "class T::foo") fails to find a tag
member in the scope nominated by the
nested-name-specifier. Previously, we gave a bland

  error: 'Nested' does not name a tag member in the specified scope

which didn't actually say where we were looking, which was rather
horrible when the nested-name-specifier was instantiated. Now, we give
something a bit better:

  error: no class named 'Nested' in 'NoDepBase<T>'

llvm-svn: 100060
2010-03-31 23:17:41 +00:00
Douglas Gregor e677dafce1 Change the representation of dependent elaborated-type-specifiers
(such as "class T::foo") from an ElaboratedType of a TypenameType to a
DependentNameType, which more accurately models the underlying
concept.

Improve template instantiation for DependentNameType nodes that
represent nested-name-specifiers, by performing tag name lookup and
checking the resulting tag appropriately. Fixes PR5681.

There is still much testing and cleanup to do in this area.

llvm-svn: 100054
2010-03-31 22:19:08 +00:00
Fariborz Jahanian 083712fbb7 Issue better syntax error when objc's messaging
ares are not separated by ':' (radar 7030268).

llvm-svn: 100040
2010-03-31 20:22:35 +00:00
Chandler Carruth b32b344c8f Re-bind non-dependent CXXTemporaryObjectExpr nodes as temporaries when
instantiating a template, which ensures the destructor is called. This fixes
PR6671.

llvm-svn: 100029
2010-03-31 18:34:58 +00:00
Fariborz Jahanian c1fb862fda Patch implements gcc's -Wno-protocol option to suppress warning
on unimplemented methods in protocols adopted by a class.
(radar 7056600).

llvm-svn: 100028
2010-03-31 18:23:33 +00:00
John McCall cef1582923 Support __attribute__((unused)) on types. This suddenly started firing
a lot for me on selfhosts, I dunno why.

llvm-svn: 99981
2010-03-31 02:47:45 +00:00
John McCall eae5acbbd0 Fix PR6327: restore invariants when there's a parse error in an initializer.
llvm-svn: 99980
2010-03-31 02:13:20 +00:00
John McCall da4458e98f Regularize support for naming conversion functions in using decls.
llvm-svn: 99979
2010-03-31 01:36:47 +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
Douglas Gregor d7f18dd750 Drastically simplify the computation of linkage for typeinfo by using
the existing (and already well-tested) linkage computation for types,
with minor tweaks for dynamic classes and (pointers to) incomplete
types. Fixes PR6597.

llvm-svn: 99968
2010-03-31 00:15:35 +00:00
John McCall d9c7c6568e Introduce a new kind of derived-to-base cast which bypasses the need for
null checks, and make sure we elide null checks when accessing base class
members.

llvm-svn: 99963
2010-03-30 23:58:03 +00:00
Jakob Stoklund Olesen 4d2972d793 Slightly relax test case. An upcoming LLVM commit will change the xor instruction.
llvm-svn: 99962
2010-03-30 23:57:49 +00:00
Daniel Dunbar c4d551b6ff Fix test in -Asserts build.
llvm-svn: 99960
2010-03-30 23:50:00 +00:00
Fariborz Jahanian df58603c26 Recognize __attribute__((NSObject)) directly applied
on retain properties. (radar 7809468).

llvm-svn: 99951
2010-03-30 22:40:11 +00:00
Bob Wilson adb58e32cc Revert Mon Ping's 99930 due to broken llvm-gcc buildbots.
llvm-svn: 99949
2010-03-30 22:28:46 +00:00
Rafael Espindola 49b85ab6e6 Remember the regparm attribute in FunctionType::ExtInfo.
Fixes PR3782.

llvm-svn: 99940
2010-03-30 22:15:11 +00:00
Argyrios Kyrtzidis 998d51b98f When "delayed parsing" C++ default arguments, if there is an error, there may be tokens left in the token stream
that will interfere (they will be parsed as if they are after the class' '}') and a crash will occur because
the CachedTokens that holds them will be deleted while the lexer is still using them.

Make sure that the tokens of default args are removed from the token stream.
Fixes PR6647.

llvm-svn: 99939
2010-03-30 22:14:32 +00:00
Douglas Gregor 504662f28f Add a test for C++ [stmt.select]p3, which specifies that redeclaring a
name in the outermost block of a if/else that declares the same name
is ill-formed. Turns out that Clang and MSVC were right about PR6739;
GCC is too lax.

llvm-svn: 99937
2010-03-30 22:07:46 +00:00
John McCall 16df1e59f2 Propagate the "found declaration" (i.e. the using declaration instead of
the underlying/instantiated decl) through a lot of API, including "intermediate"
MemberExprs required for (e.g.) template instantiation.  This is necessary
because of the access semantics of member accesses to using declarations:
only the base class *containing the using decl* need be accessible from the
naming class.

This allows us to complete an access-controlled selfhost, if there are no
recent regressions.

llvm-svn: 99936
2010-03-30 21:47:33 +00:00
Rafael Espindola 5c61cbeb58 Fix this test on windows. When running on windows we print
double 0.000000e+000
instead of
double 0.000000e+00

llvm-svn: 99932
2010-03-30 21:19:02 +00:00
Mon P Wang 231e99743a Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset
llvm-svn: 99930
2010-03-30 21:02:45 +00:00
Douglas Gregor 607f14168a Improve diagnostics when printing a template instantiation backtrace
involving substitution of deduced template arguments into a class
template partial specialization or function template, or when
substituting explicitly-specific template arguments into a function
template. We now print the actual deduced argument bindings so the
user can see what got deduced.

llvm-svn: 99923
2010-03-30 20:35:20 +00:00
Ted Kremenek 2d107f9d1d RegionStore: specially handle loads from integer global variables declared 'const'.
Fixes a false positive reported in PR 6288.

llvm-svn: 99922
2010-03-30 20:31:04 +00:00
Rafael Espindola c50c27cca8 the big refactoring bits of PR3782.
This introduces FunctionType::ExtInfo to hold the calling convention and the
noreturn attribute. The next patch will extend it to include the regparm
attribute and fix the bug.

llvm-svn: 99920
2010-03-30 20:24:48 +00:00
Ted Kremenek 4be6a75884 Change the analyzer to recognize (but ignore) assignments to isa. Fixes PR 6302.
llvm-svn: 99904
2010-03-30 18:24:54 +00:00
Fariborz Jahanian 5cab26d058 Add Support for 'warn_unused_result" attribute on
objective-c methods. (radar 7418262).

llvm-svn: 99903
2010-03-30 18:22:15 +00:00
Rafael Espindola ff6a1fc1f3 Don't produce a vtable if we are just instantiating a method and the
class has no key function.

Fix PR6738.

llvm-svn: 99900
2010-03-30 18:07:27 +00:00
Anders Carlsson 83ac312965 Fix a bug where we would incorrectly report an error about initializing two fields in an anonymous struct.
llvm-svn: 99891
2010-03-30 16:19:37 +00:00
Anders Carlsson 9d08fc1cd2 Use the new function in EmitClassAggrMemberwiseCopy, fixing the same assert as seen in PR6628 but for arrays this time.
llvm-svn: 99867
2010-03-30 03:30:08 +00:00
Anders Carlsson 10834b8d56 Handle default arguments when calling copy constructors for bases or members when synthesizing a copy constructor. Fixes PR6628.
llvm-svn: 99864
2010-03-30 02:57:48 +00:00
Anders Carlsson c3a4b12c82 Change a test to FileCheck bitcode instead of assembler.
llvm-svn: 99863
2010-03-30 02:53:30 +00:00
Anders Carlsson 85e64359df Flip the switch and use the new vtable layout code for everything. I've verified that this passes a self-host but I'll let the bots self host as well before removing the now dead code.
llvm-svn: 99861
2010-03-30 02:21:54 +00:00
Anders Carlsson e47380fb19 When collecting virtual bases it's very important to use the canonical type of the base class. Otherwise, we might add the same virtual base class twice if the virtual base is an instantiated template. Fixes PR6251.
llvm-svn: 99829
2010-03-29 19:49:09 +00:00
Chris Lattner bf2803fb20 add support for -MQ flag to quote targets in dependency file,
PR6661, patch by Ori Avtalion!

llvm-svn: 99821
2010-03-29 17:55:58 +00:00
Anders Carlsson eba1a60ef0 Another vtable layout fix, making us match gcc better.
llvm-svn: 99812
2010-03-29 15:08:41 +00:00
Douglas Gregor c48a10d652 Support __attribute__((packed)) (along with other attributes) at the
end of a struct/class/union in C++, from Justin Bogner!

llvm-svn: 99811
2010-03-29 14:42:08 +00:00
Anders Carlsson abb20e6249 Fix a nasty bug in the virtual base computation which would lead to us initializing virtual bases in the wrong order.
llvm-svn: 99806
2010-03-29 05:13:12 +00:00
Douglas Gregor d5cb1ddb2c After performing template argument deduction for a function template,
check deduced non-type template arguments and template template
arguments against the template parameters for which they were deduced,
performing conversions as appropriate so that deduced template
arguments get the same treatment as explicitly-specified template
arguments. This is the bulk of PR6723.

Also keep track of whether deduction of a non-type template argument
came from an array bound (vs. anywhere else). With this information,
we enforce C++ [temp.deduct.type]p17, which requires exact type
matches when deduction deduces a non-type template argument from
something that is not an array bound.

Finally, when in a SFINAE context, translate the "zero sized
arrays are an extension" extension diagnostic into a hard error (for
better standard conformance), which was a minor part of PR6723.

llvm-svn: 99734
2010-03-28 02:42:43 +00:00
Fariborz Jahanian 2e8074bfc3 Further improvement to point to category
whose protocolls methods needs implementation.

llvm-svn: 99730
2010-03-27 21:10:05 +00:00
Anders Carlsson 174376629a Give thunks the same linkage as their original methods.
llvm-svn: 99729
2010-03-27 20:50:27 +00:00
Fariborz Jahanian 97752f7c95 Improve diagnostics on incomplete implementation
of objc classes; including which methods
need be implemented and where they come from.
WIP.

llvm-svn: 99724
2010-03-27 19:02:17 +00:00
John McCall 3dc81f77f6 Accumulate all functions and classes that the effective context is
nested within, and suddenly local classes start working.  Wouldn't be
necessary if I hadn't used local classes in Clang in the first place.
Or, well, wouldn't be necessary yet. :)

llvm-svn: 99709
2010-03-27 06:55:49 +00:00
John McCall 2f88d7d72c Implement method friends in class templates and fix a few related problems.
llvm-svn: 99708
2010-03-27 05:57:59 +00:00
Rafael Espindola 6e281ffdc0 Test for the previous commit.
llvm-svn: 99702
2010-03-27 02:52:40 +00:00
John McCall 39ec71f2e9 When mapping restrict to noalias, look for 'restrict' on the parameter variable
instead of the canonical parameter type (which has correctly dropped all such
direct qualifiers).  Fixes PR6695.

llvm-svn: 99688
2010-03-27 00:47:27 +00:00
John McCall 30837102a2 Put function templates instantiated from friend declarations in the correct
lexical context.  This is required for ADL to work properly;  fixes PR6716.

llvm-svn: 99665
2010-03-26 23:10:15 +00:00
Douglas Gregor 4667effa8b Compare namespaces properly when looking for redeclarations of
namespace aliases. Fixes PR6341.

llvm-svn: 99664
2010-03-26 22:59:39 +00:00
Ted Kremenek 0f250e4c5b Fix NoReturnFunctionChecker to properly look at a function's type
when determining if it returns.  Fixes <rdar://problem/7796563>.

llvm-svn: 99663
2010-03-26 22:57:13 +00:00
Douglas Gregor c14922f14a When adding initializers to a constructor, be sure that we are looking
through the bases and fields of the definition of the class in which
the constructor is declared, rather than some other declaration of
that class.

llvm-svn: 99661
2010-03-26 22:43:07 +00:00
John McCall 93cc732ffc Properly account for redeclarations when explicitly instantiating class templates.
What happens here is that we actually turn the first declaration into a
definition, regardless of whether it was actually originally a definition,
and furthermore we do this all after we've instantiated all the declarations.
This exposes a bug in my DefinitionData patch where it was only setting the
DefinitionData for previous declarations, not future declarations.
Fortunately, there's an iterator for that.

llvm-svn: 99657
2010-03-26 21:56:38 +00:00