Commit Graph

5750 Commits

Author SHA1 Message Date
Fariborz Jahanian 751c1e7b24 patch to add a property from a protocol to a class that adopts the protocol.
(fixes radar 7466494).

llvm-svn: 91227
2009-12-12 21:26:21 +00:00
Douglas Gregor 6131b44183 Rework the way we handle template instantiation for
implicitly-generated AST nodes. We previously built instantiated nodes
for each of these AST nodes, then passed them on to Sema, which was
not prepared to see already-type-checked nodes (see PR5755). In some
places, we had ugly workarounds to try to avoid re-type-checking
(e.g., in VarDecl initializer instantiation).

Now, we skip implicitly-generated nodes when performing instantiation,
preferring instead to build just the AST nodes that directly reflect
what was written in the source code. This has several advantages:

  - We don't need to instantiate anything that doesn't have a direct
    correlation to the source code, so we can have better location
    information.
  - Semantic analysis sees the same thing at template instantiation
    time that it would see for a non-template.
  - At least one ugly hack (VarDecl initializers) goes away.

Fixes PR5755.

llvm-svn: 91218
2009-12-12 18:16:41 +00:00
Zhongxing Xu c0484fa611 Add initial support for realloc() in MallocChecker.
llvm-svn: 91216
2009-12-12 12:29:38 +00:00
Douglas Gregor fab31f47b2 When certain diagnostics involving run-time behavior would be emitted
in a potentially potentially evaluated context, queue those
diagnostics and only emit them if the context ends up being
potentially evaluated. This completes the fix for PR5761.

llvm-svn: 91213
2009-12-12 07:57:52 +00:00
Douglas Gregor 7ca84af48e Suppress warnings and errors about certain uses of non-POD types (in
__builtin_offsetof, passing through an ellipsis) when we're in an
unevaluated context. This is the first part of the fix to PR5761,
which deals with the simple case of an unevaluated context.

llvm-svn: 91210
2009-12-12 07:25:49 +00:00
Daniel Dunbar 3c6d1b52a0 Remove clang-cc tool, it has joined in unholy union with clang.
- tools/driver will be renamed to tools/clang at some point.

llvm-svn: 91195
2009-12-12 00:56:47 +00:00
Ted Kremenek e1996c27eb Convert the remainder of this test case over to using FileCheck.
llvm-svn: 91194
2009-12-12 00:42:52 +00:00
Daniel Dunbar f075e62620 XFAIL this test on Win32 until I can take a look.
llvm-svn: 91193
2009-12-12 00:40:42 +00:00
Ted Kremenek eadc7c3537 Make using '-fshort-enums' an error until it is actually implemented (changes the ABI, so it is dangerous to not error out if we don't support it). Fixes <rdar://problem/7461006>.
llvm-svn: 91191
2009-12-12 00:38:18 +00:00
Anders Carlsson e363c8e1df Correctly diagnose [basic.stc.dynamic.allocation]p1
llvm-svn: 91190
2009-12-12 00:32:00 +00:00
Daniel Dunbar 01bf3397a0 Tests: Stop looking for clang-cc, we don't need it.
llvm-svn: 91183
2009-12-11 23:35:10 +00:00
Anders Carlsson 12308f41e7 Improve diagnostics for malformed delete operator function declarations.
llvm-svn: 91180
2009-12-11 23:23:22 +00:00
Daniel Dunbar 6c536aa0fb Driver: Switch to using "clang" "-cc1" instead of "clang-cc".
llvm-svn: 91174
2009-12-11 23:00:49 +00:00
Daniel Dunbar 8c5024a63f Tests: Change substitution to automagically use 'clang -cc1' instead of 'clang-cc'. I still plan to eventually rewrite the tests to clarify the magic (I will probably actually rewrite them to %clang so it is more obvious this is a variable that gets substituted).
llvm-svn: 91173
2009-12-11 22:52:03 +00:00
Fariborz Jahanian ffe912c647 Patch to allow C-style cast from 'void *' to block pointer type.
(fixes radar 7465023).

llvm-svn: 91171
2009-12-11 22:40:48 +00:00
Fariborz Jahanian 8811885366 Consider conversion of objective-c pointer to 'bool' a
valid standard conversion to match g++'s behaviour.

llvm-svn: 91157
2009-12-11 21:23:13 +00:00
Eli Friedman b095e15af4 Fix for PR5714: make sure globals that will be modified aren't marked const.
llvm-svn: 91156
2009-12-11 21:23:03 +00:00
John McCall d53cee1aa0 Reorganize testcase.
llvm-svn: 91153
2009-12-11 20:51:23 +00:00
Eli Friedman 3ace52b3a7 Fix linkage of type info and vtable for classes without linkage.
llvm-svn: 91152
2009-12-11 20:48:18 +00:00
Eli Friedman 75c9b97123 Make sure mangling doesn't crash in another case. Add some more tests.
llvm-svn: 91149
2009-12-11 20:21:38 +00:00
John McCall 2b058ef245 Don't enter a new scope for a namespace-qualified declarator unless we're
in a file context.  In well-formed code, only happens with friend functions.
Fixes PR 5760.

llvm-svn: 91146
2009-12-11 20:04:54 +00:00
Douglas Gregor 0f622367d3 Add a function's cv-qualifiers to the code-completion results as an
informative chunk.

llvm-svn: 91139
2009-12-11 18:44:16 +00:00
Douglas Gregor 800f2f0ff0 Teach code completion to instantiate templates when it needs to
llvm-svn: 91138
2009-12-11 18:28:39 +00:00
Douglas Gregor 7078839b0e Member function templates can occur after . or ->
llvm-svn: 91137
2009-12-11 18:14:22 +00:00
Eli Friedman 30e94d047e Fix for PR5706: let mangleName deal with mangling names without identifiers
correctly.

llvm-svn: 91136
2009-12-11 18:00:57 +00:00
Douglas Gregor 99fe2ad8c8 Tweak code-completion results by suppressing class template
specializations and class template partial specializations (they're
never named directly). Also, member access expressions only refer to
value declarations (fields, functions, enumerators, etc.) and
Objective-C property declarations; filter out everything else.

llvm-svn: 91133
2009-12-11 17:31:05 +00:00
Anders Carlsson b41a5c9308 XFAIL this for now, fixing linkage bugs causes the order of globals to change. Will fix later today.
llvm-svn: 91130
2009-12-11 17:01:29 +00:00
Anders Carlsson a0b98f083a Use GetAddrOfRTTI when getting the RTTI pointer for a base class.
llvm-svn: 91127
2009-12-11 16:37:06 +00:00
Douglas Gregor 83c49b56fe Class template (partial) specializations should not show up in code completion results
llvm-svn: 91125
2009-12-11 16:18:54 +00:00
Eli Friedman 68396b16f6 Move the code for converting a member pointer to a bool so that it is usable
for logical not.

llvm-svn: 91112
2009-12-11 09:26:29 +00:00
Eli Friedman 1762cf2ad0 Fix for PR5718: implement equality comparisons for member function pointers.
llvm-svn: 91108
2009-12-11 07:36:43 +00:00
Ted Kremenek f6d9cebafd Enhance understanding of VarRegions referenced by a block whose declarations are outside the current stack frame. Fixes <rdar://problem/7462324>.
llvm-svn: 91107
2009-12-11 06:43:27 +00:00
John McCall 0048c5115d Test member template using hiding.
llvm-svn: 91099
2009-12-11 02:55:56 +00:00
Anders Carlsson fd7dfeb779 Improve linkage of RTTI data structures. Introduce CodeGenModule::GetAddrOfRTTI which figures out the right linkage of the RTTI information for the given type and whether it should be defined or not. I will migrate clients over to GetAddrOfRTTI in subsequent commits (with tests).
llvm-svn: 91098
2009-12-11 02:46:30 +00:00
Eli Friedman ad6c2e5b3a Fix a recent regression from the initialization changes.
llvm-svn: 91097
2009-12-11 02:42:07 +00:00
John McCall a17e83e437 Check if the target of a using decl is already declared in this scope before
doing any of the other redeclaration checks.  We were missing a few cases.
Fixes PR 5752.

llvm-svn: 91096
2009-12-11 02:33:26 +00:00
John McCall a009726ce3 Implement access declarations. Most of the work here is parsing them, which
is difficult because they're so terribly, terribly ambiguous.


We implement access declarations in terms of using declarations, which is
quite reasonable.  However, we should really persist the access/using
distinction in the AST and use the appropriate name in diagnostics.  This
isn't a priority, so I'll just file a PR and hope someone else does it. :)

llvm-svn: 91095
2009-12-11 02:10:03 +00:00
Chris Lattner 56caf31afb Give the "cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime" warning a -W flag (non-pod-varargs) and default it being an error by default. There is no good reason to allow users to get bitten by this sort of thing by default.
llvm-svn: 91094
2009-12-11 01:52:50 +00:00
Eli Friedman d0e6097bb0 Fix the handling of dependent enums per C++ DR 502.
llvm-svn: 91089
2009-12-11 01:34:50 +00:00
Anders Carlsson afd1edb52e When an exception needs to be freed by calling __cxa_exception_free, make sure to stash away the exception pointer somewhere.
This fixes an "Instruction does not dominate all uses!" verification error when compiling TableGen.

llvm-svn: 91084
2009-12-11 00:32:37 +00:00
Daniel Dunbar ff141799fb Remove this test for now, it is flaky.
llvm-svn: 91083
2009-12-11 00:27:30 +00:00
Fariborz Jahanian 73fab4f3f4 Patch to fix a crash trying to access a category name in
objective-c++ mode and also removed dead-code in this area.
(fixes radar 7456710).

llvm-svn: 91081
2009-12-11 00:26:36 +00:00
Mike Stump 18f4196792 Testcase for recent checkin.
llvm-svn: 91080
2009-12-11 00:10:15 +00:00
Mike Stump e1f6280093 Don't complain about falling off the end of a function with an asm
block, if the function is supposed to return a value as we don't know
exactly what the asm code does.

llvm-svn: 91073
2009-12-10 22:57:48 +00:00
Eli Friedman d70bbfd7d8 Support unary type traits in a scalar context. Not that I've actually seen
this construct, but might as well for completeness.

llvm-svn: 91071
2009-12-10 22:40:32 +00:00
Eli Friedman ee275c82ff Clean up enum constants so that they're finally sane. Fixes PR3173 and a
recently introduced crash.

llvm-svn: 91070
2009-12-10 22:29:29 +00:00
Anders Carlsson 781161dc55 Make sure that explicitly instantiated functions get the right linkage.
llvm-svn: 91069
2009-12-10 22:25:34 +00:00
John McCall 7a2865a217 Actually try to trigger the last diagnostic in the declaration-collision test case.
Surprisingly, we *do* diagnose one of them.  Since we don't really track scopes into
instantiation, this has to signal some kind of bug.

llvm-svn: 91063
2009-12-10 21:17:25 +00:00
Fariborz Jahanian f63a028756 No need to add -x objecitve-c++
llvm-svn: 91060
2009-12-10 20:57:43 +00:00
Fariborz Jahanian 798d2bd546 Add support for finding composite type of twp objective-c pointers
in objective-c++ mode.

llvm-svn: 91059
2009-12-10 20:46:08 +00:00
John McCall e29c5cd239 Improve the diagnostic when a new declaration conflicts with a using shadow
declaration.  Rename note_using_decl to note_using, which is possibly less confusing.
Add a test for non-class-scope using decl collisions and be sure to note the case
we can't diagnose yet.

llvm-svn: 91057
2009-12-10 19:51:03 +00:00
Douglas Gregor 5b747a169e Implement C++ DR437, which involves exception-specifications that name
a type currently being defined, from Nicola Gigante!

llvm-svn: 91052
2009-12-10 18:13:52 +00:00
Douglas Gregor 51e77d5ab0 Move initialization via initializer list over to InitializationSequences.
llvm-svn: 91050
2009-12-10 17:56:55 +00:00
John McCall 84d8767c15 Implement redeclaration checking and hiding semantics for using declarations. There
are a couple of O(n^2) operations in this, some analogous to the usual O(n^2)
redeclaration problem and some not.  In particular, retroactively removing
shadow declarations when they're hidden by later decls is pretty unfortunate.
I'm not yet convinced it's worse than the alternative, though.

llvm-svn: 91045
2009-12-10 09:41:52 +00:00
Eli Friedman e919e382a4 Fix for PR5515: allow "merging" array bounds both forwards and backwards.
llvm-svn: 91044
2009-12-10 08:54:47 +00:00
Eli Friedman d011893e86 Test for r90950.
llvm-svn: 91043
2009-12-10 08:51:23 +00:00
Anders Carlsson bf56946073 Mangle static variables inside Objective-C methods in Objective-C++. We currently mangle them the same way as gcc does.
llvm-svn: 91042
2009-12-10 03:14:39 +00:00
Chris Lattner 3c674cf804 If we enter parens, colons can become un-sacred, allowing us to emit
a better diagnostic in the second example.

llvm-svn: 91040
2009-12-10 02:08:07 +00:00
Chris Lattner 244b96ba0a fix a more evil case of : / :: confusion arising in ?:.
llvm-svn: 91039
2009-12-10 02:02:58 +00:00
Chris Lattner 17c3b1f278 fix incorrect parsing of bitfields pointed out by Doug. I chose
to use ColonProtectionRAIIObject in the C codepath even though it
won't matter for consistency.

llvm-svn: 91037
2009-12-10 01:59:24 +00:00
Anders Carlsson a72ddd4609 Handle emitting static variables that have reference type.
llvm-svn: 91027
2009-12-10 01:05:11 +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 793c75a28f rename testcase
llvm-svn: 91015
2009-12-10 00:37:13 +00:00
Fariborz Jahanian 531c16f9fb Code gen for ObjCIsaExpr AST used as lvalue.
(fixes radar 7457534).

llvm-svn: 90995
2009-12-09 23:35:29 +00:00
Mike Stump 25b20fc2ae Add terminate handler for copy constructors for thrown objects. WIP.
llvm-svn: 90994
2009-12-09 23:31:35 +00:00
Ted Kremenek 8573913760 Fix null dereference in OSAtomicChecker and special case SymbolicRegions. We still aren't handling them correctly; I've added to failing test cases to test/Analysis/NSString-failed-cases.m that should pass and then be merged in to test/Analysis/NSString.m.
llvm-svn: 90993
2009-12-09 23:29:55 +00:00
Douglas Gregor 3e1e527826 Reimplement reference initialization (C++ [dcl.init.ref]) using the
new notion of an "initialization sequence", which encapsulates the
computation of the initialization sequence along with diagnostic
information and the capability to turn the computed sequence into an
expression. At present, I've only switched one CheckReferenceInit
callers over to this new mechanism; more will follow.

Aside from (hopefully) being much more true to the standard, the
diagnostics provided by this reference-initialization code are a bit
better than before. Some examples:

p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct
Derived'
      cannot bind to a value of unrelated type 'struct Base'
  Derived &dr2 = b; // expected-error{{non-const lvalue reference to
  ...
           ^     ~
p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to
a value of
      type 'struct Base const' drops qualifiers
  Base &br3 = bc; // expected-error{{drops qualifiers}}
        ^     ~~

p5-var.cpp:57:15: error: ambiguous conversion from derived class
      'struct Diamond' to base class 'struct Base':
    struct Diamond -> struct Derived -> struct Base
    struct Diamond -> struct Derived2 -> struct Base
  Base &br5 = diamond; // expected-error{{ambiguous conversion from
      ...
              ^~~~~~~
p5-var.cpp:59:9: error: non-const lvalue reference to type 'long'
      cannot bind to
      a value of unrelated type 'int'
  long &lr = i; // expected-error{{non-const lvalue reference to type
      ...
        ^    ~

p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct
Base' cannot
      bind to a temporary of type 'struct Base'
  Base &br1 = Base(); // expected-error{{non-const lvalue reference to
  ...
        ^     ~~~~~~

p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field
'i'
  int & ir1 = (ib.i); // expected-error{{non-const reference cannot
  ...
        ^     ~~~~~~
p5-var.cpp:98:7: note: bit-field is declared here
  int i : 17; // expected-note{{bit-field is declared here}}
      ^

llvm-svn: 90992
2009-12-09 23:02:17 +00:00
Fariborz Jahanian 26de2e594b Fixes a bogus error when declaring an extern "C" array.
(fixes radar 7457109).

llvm-svn: 90986
2009-12-09 21:39:38 +00:00
Fariborz Jahanian a5fee26d28 Codegen. support for ObjCIsaExpr AST which until now
was not needed (fixes radar 7453430).

llvm-svn: 90981
2009-12-09 19:05:56 +00:00
John McCall 5677499fbf First pass at implementing C++ enum semantics: calculate (and store) an
"integer promotion" type associated with an enum decl, and use this type to
determine which type to promote to.  This type obeys C++ [conv.prom]p2 and
is therefore generally signed unless the range of the enumerators forces
it to be unsigned.

Kills off a lot of false positives from -Wsign-compare in C++, addressing
rdar://7455616

llvm-svn: 90965
2009-12-09 09:09:27 +00:00
Zhongxing Xu 1d153328be OSAtomic simulation: use the original region as the location to load from,
instead of the ElementRegion obtained from casts.

Test cast: the leak cannot occur bacause the true branch cannot be taken.

llvm-svn: 90964
2009-12-09 08:32:57 +00:00
Anders Carlsson c50b340108 Look through using declarations when searching for allocation overloads.
llvm-svn: 90961
2009-12-09 07:39:44 +00:00
Anders Carlsson f9812782b7 In CXXRecordDecl::forallBases, add the base to the "queue", so we walk more than one heirarchy of classes. John, please review.
llvm-svn: 90948
2009-12-09 04:26:02 +00:00
Zhongxing Xu 39644a62f9 Add notes to a test case.
llvm-svn: 90947
2009-12-09 04:22:30 +00:00
Anders Carlsson a038825b1c Don't warn about function templates or function template specializations.
llvm-svn: 90943
2009-12-09 03:44:46 +00:00
Anders Carlsson 31c7e88667 Move the missing prototypes checking out into a new function. Don't warn about inline functions. Add a test.
llvm-svn: 90938
2009-12-09 03:30:09 +00:00
Eli Friedman 4f678f3de1 Fix for PR5709: use the computed type of the declaration instead of the
type of the builtin when generating the function declaration for a builtin
library call.

llvm-svn: 90936
2009-12-09 03:05:59 +00:00
Anders Carlsson efa4732747 Pass the current SourceLocation to getAssignOperatorMethod, fixing a crash when the assign operator method needs to be instantiated. Doug, please review the updated default-assignment-operator.cpp change.
llvm-svn: 90935
2009-12-09 03:01:51 +00:00
Ted Kremenek 32c32892f7 Fix a horrid bug in GRExprEngine::CheckerVisit() that was identified
by the test case in PR 5627.  Essentially we shouldn't clear the
ExplodedNodeSet where we deposit newly constructed nodes if that set
is the 'Dst' set passed in.  It is not okay to clear that set because
it may already contain nodes.

llvm-svn: 90931
2009-12-09 02:45:41 +00:00
Douglas Gregor 40cb9ad391 Implemented an implicit conversion from "noreturn" function types (and
pointers thereof) to their corresponding non-noreturn function
types. This conversion is considered an exact match for
overload-resolution purposes. Note that we are a little more strict
that GCC is, because we encode noreturn in the type system, but that's
a Good Thing (TM) because it does not allow us to pretend that
potentially-returning function pointers are non-returning function
pointers.

Fxies PR5620.

llvm-svn: 90913
2009-12-09 00:47:37 +00:00
Daniel Dunbar a8ad0a90fb Improve test portability; I can't figure out how to get the regexp library to
match $ correctly with \r\n, unfortunately.

llvm-svn: 90907
2009-12-09 00:04:46 +00:00
Fariborz Jahanian 859c415567 More detailed analysis of typecast to an objective-c pointer
in objective-c++ mode without being too lenient.

llvm-svn: 90895
2009-12-08 23:09:15 +00:00
John McCall 3a60c87a59 Handle unresolved using decls in bare lookups. These are not being adequately
tested.  Fixes PR5727.

llvm-svn: 90893
2009-12-08 22:45:53 +00:00
Daniel Dunbar 8775727b39 Improve test portability.
llvm-svn: 90890
2009-12-08 22:22:20 +00:00
Daniel Dunbar f51087656d Remove include of system header.
llvm-svn: 90883
2009-12-08 21:52:24 +00:00
Daniel Dunbar e74042a8e3 Don't use MS extensions in this test, we expect header include markers.
llvm-svn: 90880
2009-12-08 21:40:02 +00:00
Daniel Dunbar 6059021edc Switch this test to use clang-cc.
llvm-svn: 90875
2009-12-08 21:12:25 +00:00
Fariborz Jahanian 33e148f64b Patch to allow matching 0 with an objective-c pointer type
in objective-c++ mode. Fixes radar 7443165

llvm-svn: 90874
2009-12-08 20:04:24 +00:00
Daniel Dunbar 6cc525b44e Unbreak clang-cc handling of -msoft-float / -mfloat-abi=, which I borked.
llvm-svn: 90873
2009-12-08 19:49:51 +00:00
Daniel Dunbar 888a89ccf2 Use clang-cc in this test.
llvm-svn: 90872
2009-12-08 19:49:40 +00:00
Fariborz Jahanian 1c548021ec Patch to allow cstyle cast of objective-c pointers in objective-c++
mode as they are pervasive.

llvm-svn: 90867
2009-12-08 19:22:33 +00:00
Douglas Gregor 049bdcac49 Implement template instantiation for exception specifications. Also,
print exception specifications on function types and
declarations. Fixes <rdar://problem/7450999>.

There is some poor source-location information here, because we don't
track locations of the types in exception specifications. Filed PR5719.

Failures during template instantiation of the signature of a function
or function template have wrong point-of-instantiation location
information. I'll tackle that with a separate commit.

llvm-svn: 90863
2009-12-08 17:45:32 +00:00
Steve Naroff 04bc01833e Integrate the following from the 'objective-rewrite' branch:
http://llvm.org/viewvc/llvm-project?view=rev&revision=80043

llvm-svn: 90860
2009-12-08 16:38:12 +00:00
Douglas Gregor a64c1e5452 When performing unqualified name lookup in C++, don't look directly
into transparent contexts; instead, we'll look into their nearest
enclosing non-transparent contexts further up the stack. Fixes PR5479.

llvm-svn: 90859
2009-12-08 15:38:36 +00:00
John McCall 3969e30d38 Correctly implement the C++03 and 0x restrictions on class-member using
declarations.

llvm-svn: 90843
2009-12-08 07:46:18 +00:00
Eli Friedman bb5008a32a Fix for PR5707: make sure implicit copy constructors initialize the vtable
pointer.

llvm-svn: 90840
2009-12-08 06:46:18 +00:00
Eli Friedman 7316819fcf Fix for PR5710: make sure to put function template specializations into the
DeclContext, so they don't completely disappear from the AST.

I don't particularly like this fix, but I don't see any obviously better way
to deal with it, and I think it's pretty clearly an improvement; comments
welcome.

llvm-svn: 90835
2009-12-08 05:40:03 +00:00
Eli Friedman 48c6b0d14f Slight tweak to vtable linkage.
llvm-svn: 90832
2009-12-08 04:09:14 +00:00
Eli Friedman f2c79b6b9c Misc key function fixes.
llvm-svn: 90831
2009-12-08 03:56:49 +00:00
Fariborz Jahanian 4569f69558 Patch to warn when discarding objective-c pointer type qualifiers
Still some refactoring to do.

llvm-svn: 90830
2009-12-08 03:35:08 +00:00
Eli Friedman 8aaff69e86 Fix some direct checks of expressions which might be surrounded by parentheses.
llvm-svn: 90825
2009-12-08 02:09:46 +00:00
Eli Friedman cd6a50f3e5 Make copy assignment operator synthesis not explode for classes with complex
or non-record aggregate members.

It might be worth spending some time to optimize this code (and the parallel
code for copy constructors) to memcpy in larger chunks, rather than copying
one member at a time.  Not sure exactly how beneficial that would be, but
it seems like could help for large classes with, for example, a vtable pointer
forcing the generation of a copy constructor.

llvm-svn: 90823
2009-12-08 01:57:53 +00:00
Anders Carlsson 220bf4fc5a No need to add tail padding if the resulting LLVM struct type will have the same size as the final record size.
llvm-svn: 90820
2009-12-08 01:24:23 +00:00
Eli Friedman f6c175b745 Correctly handle conditional operators involving throw.
llvm-svn: 90800
2009-12-07 20:25:53 +00:00
Fariborz Jahanian c2949f9f26 Allow accessing 'isa' via '->' operator.
(fixes radar 7447251).

llvm-svn: 90795
2009-12-07 20:09:25 +00:00
Anders Carlsson 1aaecfa02d Mangle basic_ostream and basic_iostream specializations.
llvm-svn: 90794
2009-12-07 19:56:42 +00:00
Mike Stump b2a568d9e5 Switch over to checking .ll files instead of .s files.
llvm-svn: 90786
2009-12-07 19:22:29 +00:00
Fariborz Jahanian 1b31c37922 Patch to allow restrict applied to id/Class types.
(fixes radar 7442244).

llvm-svn: 90773
2009-12-07 18:08:58 +00:00
Douglas Gregor 9225369891 When in an Objective-C instance method, super is a valid code-completion result
llvm-svn: 90758
2009-12-07 09:54:55 +00:00
Douglas Gregor bc7c5e471a Code completion for Objective-C @ keywords that are statements or expressions
llvm-svn: 90757
2009-12-07 09:51:25 +00:00
Douglas Gregor f48706c787 Code completion for Objective-C @ directives
llvm-svn: 90756
2009-12-07 09:27:33 +00:00
Anders Carlsson 8e0317bf05 Instantiated or specialized class templates never have a key function. This (and the previous check-in) fixes PR5557.
llvm-svn: 90753
2009-12-07 08:29:39 +00:00
Anders Carlsson 82fccd014a Rework how virtual member functions are marked. If a class has no key function, we now wait until the end of the translation unit to mark its virtual member functions as references. This lays the groundwork for fixing PR5557.
llvm-svn: 90752
2009-12-07 08:24:59 +00:00
Anders Carlsson e1b3e6292a It's OK to try to emit a vtable definition more than once. Fixes PR5697.
llvm-svn: 90751
2009-12-07 07:59:52 +00:00
Douglas Gregor 70dd094105 Remove empty test cases
llvm-svn: 90749
2009-12-07 06:11:34 +00:00
Chris Lattner 0f3a228e73 add 'F' to a bunch of libm builtins so that codegen doesn't die on them,
pointed out by Charles Davis.

llvm-svn: 90736
2009-12-07 02:09:14 +00:00
Chris Lattner 9dfed9fdb6 fix -dM with variadic macros, PR5699
llvm-svn: 90735
2009-12-07 01:58:34 +00:00
Chris Lattner 5a6fb511c7 rename names for consistency
llvm-svn: 90734
2009-12-07 01:57:13 +00:00
Chris Lattner 01c73e1b16 filecheckize
llvm-svn: 90733
2009-12-07 01:49:36 +00:00
Chris Lattner 1c4280328d reapply my patch for PR4451, which improves diagnostics for :: vs : confusion.
This time with a fix to bail out when in a dependent context.

llvm-svn: 90730
2009-12-07 01:36:53 +00:00
Chris Lattner 045cbffb65 fix a crash on invalid I found when working on something unrelated.
llvm-svn: 90729
2009-12-07 00:48:47 +00:00
Eli Friedman d0e8de2cd8 Move RequireCompleteType requirement for fields early into ActOnField so that
subsequent code which depends on a complete type does the right thing.

llvm-svn: 90727
2009-12-07 00:22:08 +00:00
Sam Weinig d060ed4d70 Don't print a void return type for C++ constructors and destructors when generating a predefined expr for them.
llvm-svn: 90725
2009-12-06 23:55:13 +00:00
Eli Friedman 8174f2c23c Work-in-progess rewrite of thunks: move thunk generation outside of vtable
generation, and make sure we generate thunks when the function is defined
rather than when the vtable is defined.

llvm-svn: 90722
2009-12-06 22:01:30 +00:00
Douglas Gregor 94bb5e8d75 PointerUnion == PointerUnion does not do what I thought it did. Also, fix a thinko in a PointerUnion::get call.
llvm-svn: 90719
2009-12-06 21:27:58 +00:00
Chris Lattner ed085234dc revert my previous patch, it is breaking something and I don't have time
to fix it ATM.

llvm-svn: 90717
2009-12-06 20:58:07 +00:00
Chris Lattner 2b6651e908 this is really about both PR's, 4452 is "don't crash", 4451 is "recover nicely".
llvm-svn: 90714
2009-12-06 19:11:41 +00:00
Chris Lattner 71d5bf1c5d implement PR4451, improving error recovery for a mistaken : where a :: was
intended.  On the first testcase in the bug, we now produce:

cxx-decl.cpp:12:2: error: unexpected ':' in nested name specifier
y:a a2;
 ^
 ::

instead of:

t.cc:8:1: error: C++ requires a type specifier for all declarations
x:a a2;
^
t.cc:8:2: error: invalid token after top level declarator
x:a a2;
 ^
 ;
t.cc:9:11: error: use of undeclared identifier 'a2'
x::a a3 = a2;
          ^

llvm-svn: 90713
2009-12-06 19:08:11 +00:00
Anders Carlsson 3efc6e6f46 Add rudimentary support for member pointers to CGDebugInfo.
llvm-svn: 90711
2009-12-06 18:00:51 +00:00
Zhongxing Xu efd9ae8a85 Add test case for mktemp. Patch by Lei Zhang.
llvm-svn: 90706
2009-12-06 12:45:46 +00:00
Daniel Dunbar 6c8884ce08 Drop Preprocessor/open-failure test, it breaks running the test suite as root,
and I can't figure out how to write it more portably.

llvm-svn: 90705
2009-12-06 10:07:46 +00:00
Eli Friedman eddf1213e2 Fix a slight oversight in computing whether a copy constructor is elidable.
Fixes PR5695.

llvm-svn: 90702
2009-12-06 09:26:33 +00:00
Daniel Dunbar 58ecb2ab51 Unbreak and add test case for r90276, a situation in which getBuffer is expected to fail.
Also, update SourceManager.h doxyments for getBuffer() to reflect reality.

llvm-svn: 90701
2009-12-06 09:19:25 +00:00
Daniel Dunbar 7cea5f1747 Add a pretty horrible hack to prevent clang from crashing with inconsistent PCH
files.
 - The issue is that PCH uses a stat cache, which may reference files which have
   been deleted or moved. In such cases ContentCache::getBuffer was returning 0
   but most clients are incapable of dealing with this (i.e., they don't).

   For the time being, resolve this issue by just making up some invalid file
   contents and. Eventually we should detect that we are in an inconsistent
   situation and error out with a nice message that the PCH is out of date.

llvm-svn: 90699
2009-12-06 05:43:36 +00:00
Anders Carlsson 232324c5c0 More linkage improvements.
llvm-svn: 90687
2009-12-06 00:53:22 +00:00
Eli Friedman 89c038e518 Fix for PR5693: shift some code into SetClassDeclAttributesFromBase so that
it gets called during template instantiation.

llvm-svn: 90682
2009-12-05 23:03:49 +00:00
Anders Carlsson 0ab79e22ab If a class does not have a key function, its linkage should be weak_odr.
llvm-svn: 90680
2009-12-05 22:24:38 +00:00
Anders Carlsson 58b271d450 Use createGlobalVariable for creating vtable variables too.
llvm-svn: 90679
2009-12-05 22:19:10 +00:00
Steve Naroff ec60b43ee2 Integrate the following from the 'objective-rewrite' branch:
http://llvm.org/viewvc/llvm-project?view=rev&revision=71225
http://llvm.org/viewvc/llvm-project?view=rev&revision=73207
http://llvm.org/viewvc/llvm-project?view=rev&revision=73414

llvm-svn: 90677
2009-12-05 21:43:12 +00:00
Anders Carlsson 21bbc1e705 Factor vtable related GlobalVariable creation out into a separate function. Add vtable linkage test.
llvm-svn: 90667
2009-12-05 17:04:47 +00:00
Chris Lattner 2da786f794 fix comment.
llvm-svn: 90660
2009-12-05 08:33:21 +00:00
Chris Lattner ded98d4172 consolidate some tests.
llvm-svn: 90659
2009-12-05 08:30:04 +00:00
Chris Lattner e99c110d06 implement rdar://7346691 by codegen'ing struct/array initializers
to a memset or a memcpy from a global when possible.

llvm-svn: 90658
2009-12-05 08:22:11 +00:00
Chris Lattner ffcd06ea7c simplify a condition and add a testcase.
llvm-svn: 90652
2009-12-05 06:49:57 +00:00
Chris Lattner 9a152e2570 fix rdar://7446395, a crash on invalid, by fixing a broken assertion.
llvm-svn: 90647
2009-12-05 05:40:13 +00:00
Eli Friedman 0846d52f70 Tweak "key function" rules so that they work for templates with virtual
inline functions.

llvm-svn: 90645
2009-12-05 04:55:55 +00:00
Daniel Dunbar 72fe5b1bcc CIndex: For the time being, don't return translation units if we encounter an error during parsing.
- We need to be more careful in the rest of CIndex if we are to handle
   possibly-invalid ASTs, and don't have much experience with this yet.

llvm-svn: 90643
2009-12-05 02:17:18 +00:00
Anders Carlsson a30e1750cd Don't emit explicit specializations of static member variable declarations.
llvm-svn: 90624
2009-12-04 23:50:01 +00:00
John McCall b96ec56871 Fix "using typename" and the instantiation of non-dependent using declarations.
llvm-svn: 90614
2009-12-04 22:46:56 +00:00
Anders Carlsson cfb65d7432 Be a little more clever about inline member functions that are marked inline in the inline class declaration but not in the actual definition:
class A {
  inline void f();
}

void A::f() { }

This is not the most ideal solution, since it doesn't work 100% with regular functions (as my FIXME comment states).

llvm-svn: 90607
2009-12-04 22:35:50 +00:00
Anders Carlsson 1f78b2bf62 Diagnose declarations of implicit member functions.
llvm-svn: 90605
2009-12-04 22:33:25 +00:00
Daniel Dunbar acd6957b59 Driver: Switch -ccc-* options to using the standard options functionality.
- I still want to get rid of them, but manually handling them isn't adding value.

llvm-svn: 90602
2009-12-04 21:55:23 +00:00
John Thompson 47981226d5 Fix for PR5650 - Revised vector_size attribute handling to be done earlier before declaration is finalized.
llvm-svn: 90600
2009-12-04 21:51:28 +00:00
Anders Carlsson ce460529c0 When generating a virtual destructor, don't try to make a virtual call to the base class destructor because then we'll just re-enter the same destructor!
This was done to fix PR5619, so I went ahead and passed a dummy VTT pointer for now.

llvm-svn: 90578
2009-12-04 19:33:17 +00:00
Daniel Dunbar 644dca07b9 ASTUnit/CIndex: Explicitly track the top-level decls when using an ASTUnit made
from a source file.
 - This allows CIndex to avoid iterating over all the top-level decls when using
   a PCH, which means we deserialize far fewer decls.

llvm-svn: 90559
2009-12-04 08:17:33 +00:00
Eli Friedman 78cde14444 Make sure to call PerformObjectMemberConversion where necessary.
llvm-svn: 90555
2009-12-04 07:18:51 +00:00
Anders Carlsson 5c9e7b16a5 Correctly mangle the 'std' namespace inside extern "C++" blocks.
llvm-svn: 90544
2009-12-04 06:23:23 +00:00
Eli Friedman d67751766b Test for non-canonical decl and vtables.
llvm-svn: 90541
2009-12-04 04:30:55 +00:00
Eli Friedman f3da334da6 Fix for PR5447: teach Evaluate to deal with floating-point conditionals.
llvm-svn: 90521
2009-12-04 02:12:53 +00:00
Eli Friedman 5efba264cb Fix for PR5679: make __builtin_prefetch a bit more flexible in what it accepts
as a constant integer.  Also, some minor cleanup and improvements to the
diagnostics.

llvm-svn: 90504
2009-12-04 00:30:06 +00:00
John McCall 9f545181f7 When recovering from an invalid forward reference to an enum type in C++,
create the enum type in the same scope as you would a record type.

llvm-svn: 90500
2009-12-04 00:07:04 +00:00
Eli Friedman 1d6fb1669c Add recursion guards to ice-checking and evaluation for declrefs, so we
don't infinitely recurse for cases we can't evaluate.

llvm-svn: 90480
2009-12-03 20:31:57 +00:00
Daniel Dunbar e357d5689e Fix Clang tool translation to forward -fvisibility as separate arguments, the
old syntax isn't supported.

llvm-svn: 90469
2009-12-03 18:42:11 +00:00
Douglas Gregor c99f155365 Unify the end-of-class code paths used by the parser and template
instantiation, to ensure that we mark class template specilizations as
abstract when we need to and perform checking of abstract classes.

Also, move the checking that determines whether we are creating a
variable of abstract class type *after* we check whether the type is
complete. Otherwise, we won't see when we have an abstract class
template specialization that is implicitly instantiated by this
declaration. This is the "something else" that Sebastian had noted
earlier.

llvm-svn: 90467
2009-12-03 18:33:45 +00:00
Ted Kremenek 2a3dbb5749 Add another blocks test case illustrating how parameters passed-by-reference in block invocations are invalidated (just like function calls).
llvm-svn: 90466
2009-12-03 18:29:20 +00:00
Anders Carlsson ae3c5cf76a When instantiating a class, if a base specifier is not dependent we still need to copy its attributes down to the instantiated class.
llvm-svn: 90463
2009-12-03 17:49:57 +00:00
Anders Carlsson ce2cd01647 Handle static_assert inside functions.
llvm-svn: 90461
2009-12-03 17:26:31 +00:00
Douglas Gregor 580cd4a23e When we're building a CXXExprWithTemporaries, only include those
temporaries that are within our current evaluation context. That way,
nested evaluation contexts (e.g., within a sizeof() expression) won't
see temporaries from outer contexts. Also, make sure to push a new
evaluation context when instantiating the initializer of a variable;
this may be an unevaluated context or a potentially-evaluated context,
depending on whether it's an in-class initializer or not. Fixes PR5672.

llvm-svn: 90460
2009-12-03 17:10:37 +00:00
Benjamin Kramer 70e39fe99c Make test 64 bit safe.
llvm-svn: 90452
2009-12-03 13:09:24 +00:00
Eli Friedman c339081c24 Fix for PR5659: correct a rather nasty oversight in the type conversion for
member pointer types.

llvm-svn: 90450
2009-12-03 12:44:31 +00:00
Daniel Dunbar c449ed3ebf XFAIL this on Win32 for the time being.
llvm-svn: 90448
2009-12-03 11:12:50 +00:00
Ted Kremenek 5bee5c4ff0 Add value invalidation logic for block-captured variables. Conceptually invoking a block (without specific reasoning of what the block does) can invalidate any value to it by reference when the block was created.
llvm-svn: 90431
2009-12-03 08:25:47 +00:00
Daniel Dunbar 3eff927255 Update test and CIndex to use -FOO BAR form for -{remap-file,code-completion-at}.
llvm-svn: 90416
2009-12-03 05:32:40 +00:00
Eli Friedman 4039f35344 Fix thunk generation for thunks with a parameter with reference type.
llvm-svn: 90412
2009-12-03 04:49:52 +00:00
John McCall 6e9f8f6374 Honor using declarations in overload resolution. Most of the code for
overloaded-operator resolution is wildly untested, but the parallel code for
methods seems to satisfy some trivial tests.

Also change some overload-resolution APIs to take a type instead of an expression,
which lets us avoid creating a spurious CXXThisExpr when resolving implicit
member accesses.

llvm-svn: 90410
2009-12-03 04:06:58 +00:00
Ted Kremenek 5ef26fb4fd Add 'has_feature(cxx_exceptions)' to allow code to determine via preprocessor logic if C++ exceptions are enabled.
llvm-svn: 90378
2009-12-03 01:34:15 +00:00
Ted Kremenek c3fe01943f Rename has_feature(rtti) to has_feature(cxx_rtti) for clarity.
llvm-svn: 90376
2009-12-03 01:31:28 +00:00
Ted Kremenek 7dac00b2e8 Add FileCheck test for '__has_feature(rtti)'.
llvm-svn: 90373
2009-12-03 01:17:43 +00:00
John McCall 800538253d Stop stripping UnresolvedUsingDecls out of LookupResults that have other
results in them (which we were doing intentionally as a stopgap).  Fix
an DeclContext lookup-table ordering problem which was causing UsingDecls to
show up incorrectly when looking for ordinary results.  And oh hey
Clang-Code-Syntax passes now.

llvm-svn: 90367
2009-12-03 00:58:24 +00:00
Ted Kremenek f66b72094a Add a heuristic to the dead stores checker to prune dead stores for variables annotated with '__block'. This is overly conservative, but now the analyzer doesn't report dead stores for variables that can be updated by a block call.
llvm-svn: 90364
2009-12-03 00:46:16 +00:00
Sebastian Redl 79eba1ca3b Introduce the notion of literal types, as specified in C++0x.
llvm-svn: 90361
2009-12-03 00:13:20 +00:00
Eli Friedman d4df7753d2 Fix for PR5522 and PR5666: fix a bunch of mangling issues with extern variables
and funcctions declared locally within a function.

llvm-svn: 90344
2009-12-02 20:32:49 +00:00
John McCall 5af0450a67 Use a more rigorous definition of 'class member'. I don't have any evidence
that this was causing a problem, but it could have.

llvm-svn: 90343
2009-12-02 20:26:00 +00:00
John McCall 1a49e9dc87 Recognize that EnumConstantDecls can be found by lookup and are not instance
members.  Fixes PR5667.

llvm-svn: 90341
2009-12-02 19:59:55 +00:00
Douglas Gregor 407e2124bf Extend -remap-file=from;to to permit mapping from a non-existent
file. This is accomplished by introducing the notion of a "virtual"
file into the file manager, which provides a FileEntry* for a named
file whose size and modification time are known but which may not
exist on disk.

Added a cute little test that remaps both a .c file and a .h file it
includes to alternative files.

llvm-svn: 90329
2009-12-02 18:12:28 +00:00
Anders Carlsson f98849eb8a In Sema, whenever we think that a function is going to cause a vtable to be generated, we mark any virtual implicit member functions as referenced.
llvm-svn: 90327
2009-12-02 17:15:43 +00:00
Douglas Gregor 9485bf9538 Extend the CIndex code-completion API to perform code completion
involving unsaved files, using the -remap-file= functionality recently
added to clang-cc.

llvm-svn: 90314
2009-12-02 09:21:34 +00:00
Douglas Gregor d062bff7ee Introduce a new clang-cc option
-remap-file=from;to

which takes the file "from" and transparently replaces its contents
with the contents of the file "to" from the source manager's
perspective. This is the moral equivalent of

  cp from saved
  cp to from
  <call clang>
  cp saved from
  rm saved

without all of the pesky file copying.

llvm-svn: 90307
2009-12-02 08:08:39 +00:00
Eli Friedman 6393aac45e Fix another "operator delete missing" crash: make sure we don't check
isVirtual() before we've actually calculated whether the destructor is
virtual.

llvm-svn: 90303
2009-12-02 07:16:50 +00:00
Eli Friedman df76fe45e6 Tweak test to check for a bit more.
llvm-svn: 90302
2009-12-02 07:04:32 +00:00
Eli Friedman 81bce6b05e Make sure to call AddOverriddenMethods for implicit copy assignment operators;
it's rare, but possible, for the difference to be significant.

llvm-svn: 90301
2009-12-02 06:59:20 +00:00
John McCall cd4b47747b Stop trying to analyze class-hierarchies for dependently-scoped id-expressions;
there's nothing interesting we can say now that we're correctly not requiring
the qualifier to name a known base class in dependent contexts.

Require scope specifiers on member access expressions to name complete types
if they're not dependent;  delay lookup when they are dependent.

Use more appropriate diagnostics when qualified implicit member access
expressions find declarations from unrelated classes.

llvm-svn: 90289
2009-12-02 03:53:29 +00:00
Fariborz Jahanian 4d9ab43f23 Fix a code gen. crash synthesizing a destructor.
Fixes pr5660.

llvm-svn: 90283
2009-12-01 23:18:25 +00:00
Ted Kremenek 733a3e6104 Added dead-stores test cases that involve the use of blocks.
llvm-svn: 90277
2009-12-01 23:04:14 +00:00
Ted Kremenek b2dc72d2d0 Add new test case file that focuses on testing analyzer support for blocks.
llvm-svn: 90274
2009-12-01 22:47:46 +00:00
John McCall a6d407c296 Fix IsProvablyNotDerivedFrom to always use record definitions when available.
Gets clang-on-clang passing again.

llvm-svn: 90270
2009-12-01 22:28:41 +00:00
John McCall 2d74de9632 Rework how we support C++ implicit member accesses. If we can resolve an
implicit member access to a specific declaration, go ahead and create
it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as
appropriate.  Otherwise, create an UnresolvedMemberExpr or
DependentScopeMemberExpr with a null base expression.

By representing implicit accesses directly in the AST, we get the ability
to correctly delay the decision about whether it's actually an instance
member access or not until resolution is complete.  This permits us
to correctly avoid diagnosing the 'problem' of 'MyType::foo()'
where the relationship to the type isn't really known until instantiation.

llvm-svn: 90266
2009-12-01 22:10:20 +00:00
Daniel Dunbar d0c9a29cb8 Add test case for PR5662.
llvm-svn: 90264
2009-12-01 21:57:39 +00:00
Fariborz Jahanian a6227fd896 (objc2 nonfragile-abi specific). If the translation unit includes an implementation
of a subclass (direct or indirect) of a weak_import root class, emit a weak reference 
for the root class's metaclass (should complete radar 6815425).

llvm-svn: 90249
2009-12-01 18:25:24 +00:00
Douglas Gregor 6be3de3fa7 Funtion templates and function template specializations do not
override virtual functions. Also, eliminate a (now redundant) call to
AddOverriddenMethods.

llvm-svn: 90242
2009-12-01 17:35:23 +00:00