Commit Graph

13576 Commits

Author SHA1 Message Date
Douglas Gregor a57478e8f6 Added an RAII object that helps set up/tear down the Sema context
information required to implicitly define a C++ special member
function. Use it rather than explicitly setting CurContext on entry
and exit, which is fragile. 

Use this RAII object for the implicitly-defined default constructor,
copy constructor, copy assignment operator, and destructor.

llvm-svn: 102840
2010-05-01 15:04:51 +00:00
David Chisnall c0cf422d56 Attach message send metadata to the lookup as well as to the call (GNU runtime).
llvm-svn: 102839
2010-05-01 12:56:56 +00:00
David Chisnall ea529a43d4 Make super message lookups cacheable (GNUstep Runtime)
llvm-svn: 102837
2010-05-01 12:37:16 +00:00
David Chisnall 9eecafa480 Tweaked EmitCall() to permit the caller to provide some metadata to attach to the call site.
Used this in CGObjCGNU to attach metadata about message sends to permit speculative inlining.

llvm-svn: 102833
2010-05-01 11:15:56 +00:00
John McCall 0b66eb38c7 It turns out that basically every caller to RequireCompleteDeclContext
already knows what context it's looking in.  Just pass that context in
instead of (questionably) recalculating it.

llvm-svn: 102818
2010-05-01 00:40:08 +00:00
Ted Kremenek bc1416dcad Add null check in CFGBuilder::VisitStmt() to make CFG construction
more resilient to bad code.

llvm-svn: 102793
2010-04-30 22:25:53 +00:00
Ted Kremenek b802192a7e Don't perform AnalysisBasedWarnings in Sema or run the static analyzer when a
fatal error has occurred.

llvm-svn: 102778
2010-04-30 21:49:25 +00:00
Douglas Gregor fabf95d066 After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a
qualification conversion, since the pointee type of the parameter
might be more qualified than the pointee type of the argument we form
from the declaration. Fixes PR6986.

llvm-svn: 102777
2010-04-30 21:46:38 +00:00
John McCall 4d4dcc8ed7 When synthesizing Objective C records, give the synthetic fields public
access.  Fixes an assertion.

Fixes rdar://problem/7927811.  Too lazy to reduce a test case.

llvm-svn: 102776
2010-04-30 21:35:41 +00:00
Douglas Gregor 0be628ff64 Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. 

llvm-svn: 102762
2010-04-30 20:35:01 +00:00
Anders Carlsson d6c5391cd9 Remove an unnecessary parameter from EmitClassCopyAssignment.
llvm-svn: 102747
2010-04-30 19:45:28 +00:00
Douglas Gregor 14cf752486 Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.

Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them. 

Fixes PR6990.

llvm-svn: 102732
2010-04-30 18:55:50 +00:00
David Chisnall d6a6af6a53 Fixed incorrect type of alloca (GNU runtime).
llvm-svn: 102711
2010-04-30 13:36:12 +00:00
Abramo Bagnara 5009937f47 Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok.
llvm-svn: 102710
2010-04-30 13:10:51 +00:00
Abramo Bagnara b639ab9ffc Attribute noreturn is now put in declaration attributes. Fixed a double warning generation.
llvm-svn: 102705
2010-04-30 09:13:03 +00:00
John McCall 5af1aa6393 An edge from a call expression to the exit block is only an abnormal edge
if *none* of the successors of the call expression is the exit block.
This matters when a call of bool type is the condition of (say) a while
loop in a function with no statements after the loop.  This *can* happen
in C, but it's much more common in C++ because of overloaded operators.

Suppresses some substantial number of spurious -Wmissing-noreturn warnings.

llvm-svn: 102696
2010-04-30 07:10:06 +00:00
Douglas Gregor 8b895228d9 Fix ADL for types declared in transparent decls, from Alp Toker!
llvm-svn: 102695
2010-04-30 07:08:38 +00:00
Douglas Gregor 407e961645 Introduce a sequence number into class template partial
specializations, which keeps track of the order in which they were
originally declared. We use this number so that we can always walk the
list of partial specializations in a predictable order during matching
or template instantiation. This also fixes a failure in Boost.Proto,
where SourceManager::isBeforeInTranslationUnit was behaving
poorly in inconsistent ways.

llvm-svn: 102693
2010-04-30 05:56:50 +00:00
John McCall b3cec96a7c Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases.  Just a patch until Sema starts (correctly) doing
most of this analysis.

Fixes PR 6622.

llvm-svn: 102692
2010-04-30 05:56:45 +00:00
Douglas Gregor 1e13c5a8fb When we start the definition of a class template, set the
InjectedClassNameType's Decl to point at the definition. It's a little
messy, but we do the same thing with classes and their record types,
since much of Clang expects that the TagDecl* one gets out of a type
is the definition. Fixes several Boost.Proto failures.

llvm-svn: 102691
2010-04-30 04:39:27 +00:00
Zhongxing Xu 526f504f06 Remove unused trait.
llvm-svn: 102690
2010-04-30 04:17:33 +00:00
Zhongxing Xu 685a1d818d Refactor the AnalysisConsumer to analyze functions after the whole
translation unit is parsed. This enables us to inline some calls when still
analyzing one function at a time.

Actions are classified into Function, CXXMethod, ObjCMethod, 
ObjCImplementation.

This does not hurt performance much. The analysis time for sqlite3.c:

before:
real    17m52.440s
user    17m49.460s
sys    0m2.010s

after:
real    18m0.500s
user    17m56.900s
sys    0m2.330s

DisplayProgress option is broken now. -inine-call action is removed. It
will be reenabled in another form, perhaps as an indenpendant option.

llvm-svn: 102689
2010-04-30 04:14:20 +00:00
John McCall e7db86ddb0 Fix a tentative-parse error with unqualified template ids in cast expressions.
Also resolve a long-working FIXME in the test case I modified.

llvm-svn: 102688
2010-04-30 03:11:01 +00:00
Douglas Gregor 6602c25c0c Add Clang version inspection macros. Fixes PR6681.
llvm-svn: 102686
2010-04-30 02:51:06 +00:00
John McCall 48bf349471 Fix -fno-rtti -fexceptions by forcing the emission of (non-"builtin") RTTI
when used by the exceptions routines.  Fixes PR 6974.

llvm-svn: 102684
2010-04-30 01:15:21 +00:00
Nate Begeman 4a623eed26 logical ops, unary ops, pairwise ops
llvm-svn: 102681
2010-04-30 00:46:57 +00:00
John McCall dac3ea6e8d Teach EHCleanupBlock to deal appropriately with the possibility that there
might not have been an insertion block set at start.  Fixes PR6975.

llvm-svn: 102677
2010-04-30 00:06:43 +00:00
Anders Carlsson 786a3d910e Get the base class addresses before calling EmitClassCopyAssignment.
llvm-svn: 102676
2010-04-30 00:04:01 +00:00
Anders Carlsson 2b4ec8d003 Remove an unnecessary argument to EmitClassCopyAssignment.
llvm-svn: 102674
2010-04-29 23:51:42 +00:00
John McCall 99b2fe5f54 Rebuild the nested name specifiers in member-pointer declarator chunks when
entering the current instantiation.  Set up a little to preserve type location
information for typename types while we're in there.

Fixes a Boost failure.

llvm-svn: 102673
2010-04-29 23:50:39 +00:00
Nate Begeman 723169d8ec Comparisons.
llvm-svn: 102669
2010-04-29 23:36:09 +00:00
Ted Kremenek d8a23f988d Do not enable '-analyze-check-security-syntactic' by default when using '--analyze'. There
are several known issues to address for it should be turned on by default.

llvm-svn: 102664
2010-04-29 22:50:22 +00:00
Douglas Gregor 980fb16f9a When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.

Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a 
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.

Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.

llvm-svn: 102650
2010-04-29 18:24:40 +00:00
Fariborz Jahanian 9e1a3af030 Properties cannot be synthesized by-dafult in
categories. Issue usual warnings instead of
confusing error message. Radar 7920807

llvm-svn: 102645
2010-04-29 17:52:18 +00:00
Devang Patel dfcd0661a1 Use clang::VarDecl name instead of llvm::GlobalVariable name.
llvm::GLobalVariable name may not match user visibile name for function static variables.

llvm-svn: 102644
2010-04-29 17:48:37 +00:00
Nate Begeman 23a2f2ff79 Start stamping out the __builtin_neon stuff.
llvm-svn: 102638
2010-04-29 17:37:19 +00:00
Ted Kremenek 186a074346 Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ObjCMethodDecl::isVariadic().
Do some minor refactoring along the way.

llvm-svn: 102635
2010-04-29 16:49:01 +00:00
Ted Kremenek 8af4f40f4a Rename BlockDecl::IsVariadic() to BlockDecl::isVariadic() to match the casing
for similar methods.  No functionality change.

llvm-svn: 102634
2010-04-29 16:48:58 +00:00
Daniel Dunbar 0c00537583 IRgen/NeXT: Put the synthesized _objc_super, _message_ref_t decls in a valid DeclContext, to satisfy the invariants that should hold on a RecordDecl.
llvm-svn: 102624
2010-04-29 16:29:11 +00:00
Daniel Dunbar 50aa0a528d Remove a FIXME that is unlikely to be fixed (streaming code generation).
llvm-svn: 102623
2010-04-29 16:29:09 +00:00
Daniel Dunbar 117c19fa4d Frontend: Tie backend verification passes to CodeGenOptions::VerifyModule,
instead of NDEBUG.

llvm-svn: 102622
2010-04-29 16:29:06 +00:00
Douglas Gregor 9225b02096 When performing partial ordering of class template partial
specializations, substitute the deduced template arguments and check
the resulting substitution before concluding that template argument
deduction succeeds. This marvelous little fix makes a bunch of
Boost.Spirit tests start working.

llvm-svn: 102601
2010-04-29 06:31:36 +00:00
Douglas Gregor 684268daab For template argument deduction from class template partial
specializations, separate out the deduction part from the checking and
substitution of the deduced arguments.

llvm-svn: 102600
2010-04-29 06:21:43 +00:00
Mon P Wang 75c645c6d7 A not equal for an unordered relation should return true as specified in IEEE-754, e.g.,
NAN != NAN ? 1 : 0 should return 1.  Also fix the case for complex.

llvm-svn: 102598
2010-04-29 05:53:29 +00:00
Douglas Gregor 33dcc2e34d It turns out that we *can* end up having to display template argument
bindings when the template argument is still an expression; it happens
while checking the template arguments of a class template partial
specializations. Fixes PR6964.

llvm-svn: 102595
2010-04-29 04:55:13 +00:00
Ted Kremenek e506ddc71e Add '__has_feature' support for weak ObjC classes.
llvm-svn: 102588
2010-04-29 02:06:46 +00:00
Ted Kremenek 6459939112 Sort '__has_feature' cases. No functionality change.
llvm-svn: 102587
2010-04-29 02:06:42 +00:00
John McCall e23b871c4b Access-check during template argument deduction from the context of the
template decl itself, not its context.  Testcase to follow;  fixes selfhost.

llvm-svn: 102578
2010-04-29 01:18:58 +00:00
Ted Kremenek 989da5eeff Fix CFG crasher involving statement expressions reported in PR 6938.
llvm-svn: 102576
2010-04-29 01:10:26 +00:00
John McCall 80e58cd3e9 Properly switch into the declaring scope of a template when performing
template argument deduction or (more importantly) the final substitution
required by such deduction.  Makes access control magically work in these
cases.

Fixes PR6967.

llvm-svn: 102572
2010-04-29 00:35:03 +00:00
Douglas Gregor d170206761 Teach __builtin_offsetof to compute the offsets of members of base
classes, since we only warn (not error) on offsetof() for non-POD
types. We store the base path within the OffsetOfExpr itself, then
evaluate the offsets within the constant evaluator.

llvm-svn: 102571
2010-04-29 00:18:15 +00:00
Daniel Dunbar 92d5c1a4bf build: Add CLANG_NO_RUNTIME build variable, which disables building clang
runtime library stuff, even if compiler-rt is available.

llvm-svn: 102560
2010-04-28 23:36:26 +00:00
Daniel Dunbar 12c82080a2 Driver: Add support for -fobjc-abi-version=.
- <rdar://problem/7919678>

llvm-svn: 102559
2010-04-28 23:25:24 +00:00
Alexis Hunt c46382e4b3 Ensure that cv-qualifiers are correctly removed for post-inc/decrements
as well as pre- and post-inc/decrements in C (not that I think it
matters for any C code).

llvm-svn: 102552
2010-04-28 23:02:27 +00:00
Douglas Gregor ea679ec125 Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions
llvm-svn: 102551
2010-04-28 22:43:14 +00:00
Nate Begeman a8a9d6a1f0 A bit more neon work, adds work (but the ABI is wrong), types mostly stamped out.
llvm-svn: 102549
2010-04-28 22:37:01 +00:00
Douglas Gregor 10982ea3f9 Diagnose __builtin_offsetof expressions that refer to bit-fields
llvm-svn: 102548
2010-04-28 22:36:06 +00:00
Fariborz Jahanian 499b902510 Support for construct/destruct of ivar array
of c++ objects (NeXt runtime).
radar 7900343.

llvm-svn: 102546
2010-04-28 22:30:33 +00:00
Douglas Gregor 882211c1da Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.

This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.

OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.

There are two major caveats to this patch:

  1) CodeGen cannot handle the case where __builtin_offsetof is not a
  constant expression, so it produces an error. So, to avoid
  regressing in C, we retain the old UnaryOperator-based
  __builtin_offsetof implementation in C while using the shiny new
  OffsetOfExpr implementation in C++. The old implementation can go
  away once we have proper CodeGen support for this case, which we
  expect won't cause much trouble in C++.

  2) __builtin_offsetof doesn't work well with non-POD class types,
  particularly when the designated field is found within a base
  class. I will address this in a subsequent patch.

Fixes PR5880 and a bunch of assertions when building Boost.Python
tests. 

llvm-svn: 102542
2010-04-28 22:16:22 +00:00
Fariborz Jahanian 0dec1e0d56 IRGen for initialization/destruction of
ivar class objects (NeXt runtime).
(radar 7900343).

llvm-svn: 102533
2010-04-28 21:28:56 +00:00
Chris Lattner e82411b47f add regex support for -verify mode. You can now do things like
expected-error-re {{someregex}}

Patch by mike-m!

llvm-svn: 102516
2010-04-28 20:02:30 +00:00
David Chisnall 01aa46795e Changed signature of GenerateMessageSend() function to pass the ObjCInterfaceDecl for class messages and removed the boolean IsClassMessage argument, which wasn't used anywhere.
Emitted some metadata on message sends to allow a later pass to do some speculative inlining of class methods (GNU runtime).  Speculative inlining of instance methods requires type feedback to be useful (work in progress), but for class methods it works quite nicely.  

llvm-svn: 102514
2010-04-28 19:33:36 +00:00
Nate Begeman cb2563f0c3 Stub out NEON support, more to come.
llvm-svn: 102512
2010-04-28 18:37:32 +00:00
Daniel Dunbar edd5bae86c Revert "Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of", it is breaking the builds of quite a few projects (emacs, dovecot, gnutar, bison).
llvm-svn: 102501
2010-04-28 16:20:58 +00:00
Fariborz Jahanian c83726e64e More of Sema to implement initialization of
ivar of c++ object types.

llvm-svn: 102500
2010-04-28 16:11:27 +00:00
Benjamin Kramer 9c05bf46d1 Remove unused function.
llvm-svn: 102499
2010-04-28 15:54:45 +00:00
Benjamin Kramer d76b698ca6 Reduce string trashing in getQualifiedNameAsString.
llvm-svn: 102498
2010-04-28 14:33:51 +00:00
David Chisnall d472c85285 Emit the correct symbol name for the class (GNU runtime).
llvm-svn: 102497
2010-04-28 14:29:56 +00:00
Abramo Bagnara 41160fed4c Written storage class for declarations inside linkage specifications without braces is none.
llvm-svn: 102496
2010-04-28 13:11:54 +00:00
Douglas Gregor a02bb34155 When the qualifier of a id-expression is non-dependent but not
complete, return an error rather than falling back to building a
dependent declaration reference, since we might not be in a dependent
context. Fixes a fiendish crash-on-invalid in Boost.FunctionTypes that
I wasn't able to reduce to anything useful.

llvm-svn: 102491
2010-04-28 07:04:26 +00:00
Douglas Gregor 7988def89f Improve name mangling for dependent template names (e.g., typename
T::template apply<U>), handling a few cases where we previously failed
and performing substitutions on such dependent names. Fixes a crash in
Boost.PropertyTree.

llvm-svn: 102490
2010-04-28 05:58:56 +00:00
Douglas Gregor 1614237822 When instantiating a function template specialization following
template argument deduction, use the lexical declaration context as
the owner for friend function templates. Fixes 2 failures in
Boost.Graph.

llvm-svn: 102489
2010-04-28 04:52:24 +00:00
John McCall d06fb865eb Properly pass the address of a lazily-generated function declaration with
incomplete type.  Fixes PR6911.

llvm-svn: 102473
2010-04-28 00:00:30 +00:00
Douglas Gregor 1524333004 It's okay to refer to non-type template parameters anywhere they are
visible. Fixes the remaining two failures in Boost.ScopeExit.

llvm-svn: 102466
2010-04-27 21:10:04 +00:00
Abramo Bagnara 3bca8e0f2f Removed spaces at end of line. (Test commit.)
llvm-svn: 102465
2010-04-27 21:08:25 +00:00
Eli Friedman 7955e52f5c Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of
function types.

This could potentially have unexpected side-effects, so look here if there are
new regressions.

llvm-svn: 102464
2010-04-27 21:07:06 +00:00
Douglas Gregor 199db36b79 When explicitly building a temporary object (CXXTemporaryObjectExpr),
keep track of whether we need to zero-initialize storage prior to
calling its constructor. Previously, we were only tracking this when
implicitly constructing the object (a CXXConstructExpr).

Fixes Boost's value-initialization tests, which means that the
Boost.Config library now passes all of its tests.

llvm-svn: 102461
2010-04-27 20:36:09 +00:00
David Chisnall e6d0073fa9 Fixed message send to void (broken by my last commit - GNU runtime).
llvm-svn: 102459
2010-04-27 20:33:30 +00:00
Douglas Gregor 7d8072e038 Diagnose the use of abstract types as array element types. Previously,
we were relying on checking for abstract class types when an array
type was actually used to declare a variable, parameter, etc. However,
we need to check when the construct the array for, e.g., SFINAE
purposes (see DR337). Fixes problems with Boost's is_abstract type
trait. 

llvm-svn: 102452
2010-04-27 19:38:14 +00:00
Douglas Gregor 9262f4775d During template instantiation, set the naming class of
UnresolvedLookupExpr and UnresolvedMemberExpr by substituting the
naming class we computed when building the expression in the
template...

... which we didn't always do correctly. Teach
UnresolvedMemberExpr::getNamingClass() all about the new 
representation of injected-class-names in templates, so	that it	can
return a naming	class that is the current instantiation.

Also, when decomposing a template-id into its template name and its
arguments, be sure to set the naming class on the LookupResult
structure. 

Fixes PR6947 the right way.

llvm-svn: 102448
2010-04-27 18:19:34 +00:00
Benjamin Kramer 0a3fe0456f More simplifications.
llvm-svn: 102447
2010-04-27 17:47:25 +00:00
Fariborz Jahanian 38b77a9d8e Move CollectIvarsToConstructOrDestruct to Sema
from AST, consider ivar array of objects
(per Doug's comment).

llvm-svn: 102446
2010-04-27 17:18:58 +00:00
Benjamin Kramer 2e3197e60b Simplify some code. No change in functionality.
llvm-svn: 102445
2010-04-27 17:12:11 +00:00
Douglas Gregor 4423926e66 When checking the redeclaration context of a typedef that refers to a
tag of the same name, compare the lookup contexts rather than the
actual contexts. Fixes PR6923.

llvm-svn: 102437
2010-04-27 16:26:47 +00:00
Douglas Gregor 19defcd6f5 Don't look into incomplete types when trying to warn about unused
variables. Fixes PR6948.

llvm-svn: 102436
2010-04-27 16:20:13 +00:00
Douglas Gregor da7be08a0c When instantiating UnresolvedLookupExpr and UnresolvedMemberExpr
expressions, be sure to set the naming class of the LookupResult
structure. Fixes PR6947.

llvm-svn: 102434
2010-04-27 16:10:10 +00:00
Daniel Dunbar 2cb4e7a872 Simplify.
llvm-svn: 102432
2010-04-27 15:35:03 +00:00
Daniel Dunbar 34d7a99062 Add Driver support for -fno-constant-cfstrings.
llvm-svn: 102431
2010-04-27 15:34:57 +00:00
David Chisnall 75afda6c33 Ensure return from a message to nil is always 0 (GNU runtime).
This works around stack corruption / crashes resulting from PR6944, and also
works around people who expect 'what works on my machine' to work everywhere
(GCC crashes in a number of cases on SPARC that should now work correctly with
clang).

llvm-svn: 102430
2010-04-27 15:08:48 +00:00
Daniel Dunbar 19d6355b77 Fix comments.
llvm-svn: 102429
2010-04-27 14:51:07 +00:00
Enea Zaffanella f205977e6f Wrap a couple of long lines. (Test commit.)
llvm-svn: 102420
2010-04-27 07:38:32 +00:00
John McCall 1e67dd6b2f Improve the diagnostic you get when making a qualified member access
with a qualifier referencing a different type.

llvm-svn: 102409
2010-04-27 01:43:38 +00:00
John McCall 2408e32096 Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization.  That is to
say, in
  template <class T> class A { ... };
or
  template <class T> class B<const T*> { ... };
make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType
when written inside the appropriate context.  This allows us to track the
current instantiation appropriately even inside AST routines.  It also allows
us to compute a DeclContext for a type much more efficiently, at some extra
cost every time we write a template specialization (which can be optimized,
but I've left it simple in this patch).

llvm-svn: 102407
2010-04-27 00:57:59 +00:00
Fariborz Jahanian b310259060 New method to construct/destruct ivars that have non-trivial default
constructors or destructors, not used yet.

llvm-svn: 102403
2010-04-26 23:51:25 +00:00
Devang Patel 42fb6f8b9a Enable debug info for local variables at -O1+.
llvm-svn: 102398
2010-04-26 23:28:46 +00:00
Douglas Gregor 9da641912d Improve source-location information in a C++ typeid (type) expression
by using TypeSourceInfo, cleaning up the representation
somewhat. Teach getTypeOperand() to strip references and
cv-qualifiers, providing the semantic view of the type without
requiring any extra storage (the unmodified type remains within the
TypeSourceInfo). This fixes a bug found by Boost's call_traits test.

Finally, clean up semantic analysis, by splitting the ActOnCXXTypeid
routine into ActOnCXXTypeId (the parser action) and two BuildCXXTypeId
functions, which perform the semantic analysis for typeid(type) and
typeid(expression), respectively. We now perform less work at template
instantiation time (we don't look for std::type_info again) and can
give better diagnostics.

llvm-svn: 102393
2010-04-26 22:37:10 +00:00
Chris Lattner 678eaa90ab fix PR6936: don't generate line marker directives when preprocessing
.S files.  "# 123" is passed through as-is, not treated as a line
marker in this mode.  No testcase, because it would be nasty and isn't
worth it.

llvm-svn: 102391
2010-04-26 22:08:10 +00:00
Fariborz Jahanian 0103d67f98 Diagnose declaration of reference typed ivars.
llvm-svn: 102390
2010-04-26 22:07:03 +00:00
Douglas Gregor 8385a06929 Introduce Type::isStructureOrClassType(), which does the obvious
thing. Audit all uses of Type::isStructure(), changing those calls to
isStructureOrClassType() as needed (which is alsmost
everywhere). Fixes the remaining failure in Boost.Utility/Swap.

llvm-svn: 102386
2010-04-26 21:31:17 +00:00
Fariborz Jahanian 65654df92c Cleanup error recovery for a missing '-'|'+'
on a method declaration (radar 7822196).

llvm-svn: 102383
2010-04-26 21:18:08 +00:00
Douglas Gregor b7e20eb883 Implement template instantiation for implicit property references in
Objective-C++. This is the last bit of (non-blocks-related) template
instantiation logic for Objective-C++. Yay! 

llvm-svn: 102382
2010-04-26 21:04:54 +00:00
Douglas Gregor 9faee21f67 Implement template instantiation for ObjCPropertyRefExpr.
llvm-svn: 102379
2010-04-26 20:47:02 +00:00
Chris Lattner 5e8416a77f emit dtors with the right calling convention in -fno-use-cxa-atexit
mode.

llvm-svn: 102377
2010-04-26 20:35:54 +00:00
Douglas Gregor d51d90dd04 Implement template instantiation for value-dependent Objective-C ivar
references and isa expressions. Also, test template instantiation of
unresolved member references to Objective-C ivar references and isa
expressions.

llvm-svn: 102374
2010-04-26 20:11:03 +00:00
Douglas Gregor f4e837f66c Implement template instantiation for Objective-C @catch
statements. This is the last of the Objective-C statements.

llvm-svn: 102356
2010-04-26 17:57:08 +00:00
Douglas Gregor f356419bf5 Refactor Objective-C @catch parameter checking by detangling it from
function-parameter checking and splitting it into the normal
ActOn*/Build* pair in Sema. We now use VarDecl to represent the @catch
parameter rather than the ill-fitting ParmVarDecl.

llvm-svn: 102347
2010-04-26 17:32:49 +00:00
Douglas Gregor 46a572b871 Make the static type of the exception variable in an Objective-C
@catch a VarDecl. The dynamic type is still a ParmVarDecl, but that
will change soon. No effective functionality change.

llvm-svn: 102341
2010-04-26 16:46:50 +00:00
Douglas Gregor d984815ed9 Ensure that we have completed a type before attempting initialization
on that type. Fixes several problems in Boost.Interprocess.

llvm-svn: 102339
2010-04-26 14:36:57 +00:00
Douglas Gregor 516d672310 When name lookup finds a single declaration that was imported via a
using declaration, look at its underlying declaration to determine the
lookup result kind (e.g., overloaded, unresolved). Fixes at least one
issue in Boost.Bimap.

llvm-svn: 102317
2010-04-25 21:15:30 +00:00
Douglas Gregor 861eb80a3b Improve the diagnostic when we find something we did not expect in a
member expression (p-> or x.), by showing the type we looked into and
what we did actually find.

llvm-svn: 102315
2010-04-25 20:55:08 +00:00
Daniel Dunbar 710cb20cd6 IRgen/NeXT: Fix several alignment issues with Objective-C metadata symbols:
- Fix some places that had the alignment hard coded.
 - Use ABI type alignment, not preferred type alignment -- neither of this is exactly right, as we really want the C type alignment as required by the runtime, but the ABI alignment is a more correct choice.

This should be equivalent for x86_64, but fixes the alignment for ARM.

llvm-svn: 102314
2010-04-25 20:39:32 +00:00
Daniel Dunbar 5e63927d41 IRgen/NeXT: Reuse EmitImageInfo for both fragile and non-fragile ABI. This fixes Clang to correctly emit the "CorrectedSynthesize" bit when using the non-fragile ABI.
llvm-svn: 102312
2010-04-25 20:39:01 +00:00
Douglas Gregor 645d76f271 When performing name lookup for an operator name, be sure to look
through using declarations. Fixes ~18 tests in Boost.Fusion.

llvm-svn: 102311
2010-04-25 20:25:43 +00:00
Anders Carlsson 06eed9bee2 Land another cleanup patch.
llvm-svn: 102293
2010-04-25 01:03:12 +00:00
Douglas Gregor d0ace02496 When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't
end up calling the destructor for the copy. Fixes Boost.Optional.

llvm-svn: 102290
2010-04-25 00:55:24 +00:00
Anders Carlsson 53e1ba948d Revert enough of my patches to fix self-host again :(
llvm-svn: 102289
2010-04-25 00:52:09 +00:00
Douglas Gregor 9556257252 When we create a temporary of class type that we don't immediately
bind, check accessibility of the destructor and mark the declaration
as referenced. Fixes a bunch of Boost.Regex failures.

llvm-svn: 102287
2010-04-24 23:45:46 +00:00
Anders Carlsson dde8b46e62 Cleanup SynthesizeCXXCopyConstructor.
llvm-svn: 102286
2010-04-24 23:11:18 +00:00
Anders Carlsson 84e3b62ac0 Clean up SynthesizeCXXCopyAssignment a little.
llvm-svn: 102285
2010-04-24 23:09:21 +00:00
Anders Carlsson c4ba0cd2ea RenameGetAddressOfBaseOfCompleteClass to GetAddressOfDirectBaseInCompleteClass to reflect that it only handles direct bases.
llvm-svn: 102284
2010-04-24 23:01:49 +00:00
Anders Carlsson 36db0d9c47 Add an explicit UsuallyTinyPtrVector that takes a single element.
llvm-svn: 102283
2010-04-24 22:54:32 +00:00
Anders Carlsson 26b6e23d57 More cleanup.
llvm-svn: 102282
2010-04-24 22:43:39 +00:00
Anders Carlsson 9523ad4fd3 Simplify EmitClassMemberwiseCopy now that it's only used for fields.
llvm-svn: 102281
2010-04-24 22:36:50 +00:00
Nick Lewycky 0a7de38a22 Switch this to new API.
llvm-svn: 102280
2010-04-24 22:31:36 +00:00
Anders Carlsson 90235beb55 DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now).
llvm-svn: 102279
2010-04-24 22:25:18 +00:00
Anders Carlsson af13c7bea9 When building implicit base initializers, add a derived-to-base cast that points to the exact base specifier.
llvm-svn: 102277
2010-04-24 22:02:54 +00:00
Anders Carlsson bea9e74e82 Rename GetAddressOfBaseClass to OldGetAddressOfBaseClass.
llvm-svn: 102275
2010-04-24 21:51:08 +00:00
Anders Carlsson 795213efde Get rid of the old GetNonVirtualBaseClassOffset and change all call sites to use the new version.
llvm-svn: 102274
2010-04-24 21:27:51 +00:00
Anders Carlsson 8a64c1c94c Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.
llvm-svn: 102273
2010-04-24 21:23:59 +00:00
Anders Carlsson c6eaea70af Convert more call sites over to the new GetAddressOfBaseClass.
llvm-svn: 102272
2010-04-24 21:12:55 +00:00
Douglas Gregor d5c231e745 When we attempt to create a temporary object of class type, be sure
that the type we're copying is complete. 

Boost.Regex now builds, although it's failing its regression tests
with our favorite "Sema doesn't consider destructor as used."
assertion.

llvm-svn: 102271
2010-04-24 21:09:25 +00:00
Anders Carlsson d829a02514 Add a new GetAddressOfBaseClass overload that takes a base path and. Use it for derived-to-base casts.
llvm-svn: 102270
2010-04-24 21:06:20 +00:00
Douglas Gregor c779e99540 When we are performing copy initialization of a class type via its
copy constructor, suppress user-defined conversions on the
argument. Otherwise, we can end up in a recursion loop where the
bind the argument of the copy constructor to another copy constructor call,
whose argument is then a copy constructor call...

Found by Boost.Regex which, alas, still isn't building.

llvm-svn: 102269
2010-04-24 20:54:38 +00:00
Daniel Dunbar cfc12ddb0a Headers: Hide intptr_t and uintptr_t definitions behind _INTPTR_T and _UINTPTR_T
defines, for increased compatibility with Darwin gcc.
 - This is a bit of a hack, since platform compatibility issues don't belong
   here, but I don't think this hurts anyone either.

llvm-svn: 102264
2010-04-24 20:32:12 +00:00
Benjamin Kramer 20f2d4382f Fix pasto, add a comment.
llvm-svn: 102263
2010-04-24 20:26:20 +00:00
Benjamin Kramer bbb5deace6 Factor code. No functionality change.
llvm-svn: 102262
2010-04-24 20:19:58 +00:00
Anders Carlsson 7d3360f123 Add base paths for CK_BaseToDerived and CK_BaseToDerivedMemberPointer.
llvm-svn: 102261
2010-04-24 19:36:51 +00:00
Anders Carlsson b78fecaf6f Add base paths to CK_UncheckedDerivedToBase and CK_DerivedToBaseMemberPointer.
llvm-svn: 102260
2010-04-24 19:22:20 +00:00
Anders Carlsson a70cff624e Actually produce base paths for CastExprs of kind CK_DerivedToBase.
llvm-svn: 102259
2010-04-24 19:06:50 +00:00
Anders Carlsson 5d270e8fa6 Add BasePath arguments to all cast expr constructors.
llvm-svn: 102258
2010-04-24 18:38:56 +00:00
Daniel Dunbar df3d1c2d1f Driver/Darwin: Fix Objective-C non-fragile ABI and dispatch method defaults, which were wrong in numerous places.
- <rdar://problem/7903449>

llvm-svn: 102257
2010-04-24 18:37:41 +00:00
Douglas Gregor 53ce178cef When we take the address of a declaration to bind it to a non-type
template parameter, by sure to mark that declaration as
"referenced". The Boost.Iterator library now passes all tests.

llvm-svn: 102256
2010-04-24 18:20:53 +00:00
Daniel Dunbar fca18c1b41 NeXT: Clean up dispatch method policy selection.
- Replace -cc1 level -fobjc-legacy-dispatch with -fobjc-dispatch-method={legacy,non-legacy,mixed}.

 - Lift "mixed" vs "non-mixed" policy choice up to driver level, instead of being buried in CGObjCMac.cpp.

 - No intended functionality change.

llvm-svn: 102255
2010-04-24 17:56:46 +00:00
Daniel Dunbar db059592fe Simplify.
llvm-svn: 102254
2010-04-24 17:56:39 +00:00
Anders Carlsson 7afe4245e2 Pass the base specifiers through to CheckDerivedToBaseConversion. No functionality change yet.
llvm-svn: 102250
2010-04-24 17:11:09 +00:00
Anders Carlsson 0c509eeac7 CastExpr should not hold a pointer to the base path. More cleanup.
llvm-svn: 102249
2010-04-24 16:57:13 +00:00
Douglas Gregor ba41d01b59 Be more careful around dependent nested-name-specifiers, complaining
when they are not complete (since we could not match them up to
anything) and ensuring that enum parsing can cope with dependent
elaborated-type-specifiers. Fixes PR6915 and PR6649.

llvm-svn: 102247
2010-04-24 16:38:41 +00:00
Anders Carlsson b34f88205f isValue is set to false by default.
llvm-svn: 102246
2010-04-24 16:36:20 +00:00
Anders Carlsson 7d96cd7799 Rename InheritancePath to BasePath, rename CastExpr::CXXBaseVector to CXXBaseSpecifierArray. More to come.
llvm-svn: 102245
2010-04-24 16:34:21 +00:00
Douglas Gregor bbdf20acd0 Keep track of when DependentNameTypes have no associated keyword
(e.g., no typename, enum, class, etc.), e.g., because the context is
one that is known to refer to a type. Patch from Enea Zaffanella!

llvm-svn: 102243
2010-04-24 15:35:55 +00:00
Benjamin Kramer fb278831aa Update prototypes.
llvm-svn: 102241
2010-04-24 08:26:17 +00:00
Dan Gohman 7905d187e6 Fix a place in inline asm lowering which was creating a TruncInst with a
pointer operand. This fixes an abort on
MultiSource/Applications/ClamAV/libclamav_mbox.c.

llvm-svn: 102238
2010-04-24 04:55:02 +00:00
John McCall b9467b6c9a Recommit r102215, this time being more careful to only set the "principal
declaration" (i.e. the only which will actually be looked up) to have the
non-member-operator bit.

llvm-svn: 102231
2010-04-24 01:30:58 +00:00
Nick Lewycky 784fad7a41 Teach clang -fixit to modify files in-place, or -fixit=suffix to create new
files with the additional suffix in the middle.

llvm-svn: 102230
2010-04-24 01:30:46 +00:00
Devang Patel 8471593892 Revert accidental check-in.
llvm-svn: 102226
2010-04-24 00:49:16 +00:00
Devang Patel f8b55d478c Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.
llvm-svn: 102224
2010-04-24 00:40:35 +00:00
Fariborz Jahanian 0731763efc With -fno-constant-cfstrrings, class NSConstantString
must be there or it is error (Next runtime).

llvm-svn: 102223
2010-04-23 23:19:04 +00:00
Douglas Gregor e11ee11068 Rework Parser-Sema interface for Objective-C @catch exception object
arguments. Rather than having the parser call ActOnParamDeclarator
(which is a bit of a hack), call a new ActOnObjCExceptionDecl
action. We'll be moving more functionality into this handler to
perform earlier checking of @catch.

llvm-svn: 102222
2010-04-23 23:01:43 +00:00
Douglas Gregor 96c79498fb Improve the AST representation of Objective-C @try/@catch/@finally
statements. Instead of the @try having a single @catch, where all of
the @catch's were chained (using an O(n^2) algorithm nonetheless),
@try just holds an array of its @catch blocks. The resulting AST is
slightly more compact (not important) and better represents the actual
language semantics (good).

llvm-svn: 102221
2010-04-23 22:50:49 +00:00
Fariborz Jahanian d3fa70181d More -fno-constant-cfstrings API work.
llvm-svn: 102219
2010-04-23 22:33:39 +00:00
Anders Carlsson 9759793855 Add an InheritancePath parameter to the ImplicitCastExpr constructor.
llvm-svn: 102218
2010-04-23 22:18:37 +00:00
John McCall 67b29a26df Transition the last acceptable-result filter kind in LookupResult over to use
a simple IDNS mask by introducing a namespace for non-member operators.

llvm-svn: 102215
2010-04-23 21:37:18 +00:00
Argyrios Kyrtzidis 8d7bdba08c Make Parser::ConsumeAndStoreUntil() more consistent with Parser::SkipUntil().
ConsumeAndStoreUntil would stop at tok::unknown when caching an inline method
definition while SkipUntil would go past it while parsing the method.

Fixes PR 6903.

llvm-svn: 102214
2010-04-23 21:20:12 +00:00
Anders Carlsson c20f78c761 Destroy the inheritance path.
llvm-svn: 102211
2010-04-23 21:02:34 +00:00
Anders Carlsson 720130c0cf Turn CXXMethodVector into a generic class template.
llvm-svn: 102208
2010-04-23 19:53:03 +00:00
Daniel Dunbar e3883874c5 NeXT/EH: When generating the rethrow code for a finally block, make sure to
chain outwards when inside a nested exception scope.
 - A real test for this is going into LLVM test-suite.

llvm-svn: 102204
2010-04-23 19:12:32 +00:00
Daniel Dunbar 5a6b3e0865 NeXT/EH: Tidy up EH code a bit, don't emit the catch block EH handler if it is unreachable.
llvm-svn: 102203
2010-04-23 19:12:24 +00:00
John McCall e87beb2591 Recommit my change to how C++ does elaborated type lookups, now with
two bugfixes which fix selfhost and (hopefully) the nightly tests.

llvm-svn: 102198
2010-04-23 18:46:30 +00:00
Fariborz Jahanian e804c28745 More work toward implementing
NeXt's -fno-constant-cfstrings - wip.

llvm-svn: 102189
2010-04-23 17:41:07 +00:00
Chris Lattner db6d5cb892 Implement PR6845. We allow matching constraints to have different
input and output types when the smaller value isn't mentioned in the
asm string.  Extend this support from integers to also allowing 
fp values to be mismatched (if not mentioned in the asm string).

llvm-svn: 102188
2010-04-23 17:27:29 +00:00
Sebastian Redl 26a0f1cff9 Require a complete type for the lhs of member pointer dereference operations if the type isn't exactly the same as the container class. Fixes PR6783.
llvm-svn: 102186
2010-04-23 17:18:26 +00:00
Chris Lattner 1a8f394a1f david conrad points out that {|} in inline assembly on arm are not asm
variants.  This fixes neon inline asm which my patch for PR6780 broke.

llvm-svn: 102181
2010-04-23 16:29:58 +00:00
Douglas Gregor 83eb5032c0 When instantiating a typedef of an anonymous tag type, note in the tag
declaration that this typedef gives the tag a name. Fixes a problem
uncovered by Boost.GIL (Generic Image Library).

llvm-svn: 102180
2010-04-23 16:25:07 +00:00
Anders Carlsson 7a0ffdbe53 Cleanup.
llvm-svn: 102179
2010-04-23 16:24:12 +00:00
Anders Carlsson 423f5d85fd Handle copy initialization in BuildImplicitMemberInitializer. Not used yet.
llvm-svn: 102178
2010-04-23 16:04:08 +00:00
Chris Lattner 092d1c9f64 add GNU C++ include paths for Fedora 11,12 x86_64,
patch by mikem!

llvm-svn: 102177
2010-04-23 15:55:20 +00:00
Daniel Dunbar 45b2d8ab42 Revert "C++ doesn't really use "namespaces" for different kinds of names the same", which seems to break most C++ nightly test apps.
llvm-svn: 102174
2010-04-23 13:07:39 +00:00
Douglas Gregor 914af2182b Handle compound assignment expressions (i += j) as lvalues, which is
permitted in C++ but not in C. Fixes PR6900. Clang can now handle all
of Boost.Lambda's regression tests.

llvm-svn: 102170
2010-04-23 04:16:32 +00:00
Anders Carlsson 11373b5277 Add another 'catch all' access diagnostic.
llvm-svn: 102169
2010-04-23 03:41:35 +00:00
Douglas Gregor ffe0884bc4 Emit a lame diagnostic when we can't mangle operator names
llvm-svn: 102168
2010-04-23 03:19:53 +00:00
Douglas Gregor 173627188d Mangle dependent template names such as the nested-name-specifier in
T::apply <U>::type

Fixes PR6899, although I want to dig a little deeper into the FIXME
for dependent template names that refer to operators.

llvm-svn: 102167
2010-04-23 03:10:43 +00:00
Anders Carlsson 1b00e24d13 Add an ImplicitInitializerKind enum and pass it to BuildImplicitBaseInitializer and BuildImplicitMemberInitializer.
llvm-svn: 102166
2010-04-23 03:10:23 +00:00
Anders Carlsson dca6be04db Fix a think-o that broke self-host.
llvm-svn: 102165
2010-04-23 03:07:47 +00:00
John McCall a245671ae0 C++ doesn't really use "namespaces" for different kinds of names the same
way that C does.  Among other differences, elaborated type specifiers
are defined to skip "non-types", which, as you might imagine, does not
include typedefs.  Rework our use of IDNS masks to capture the semantics
of different kinds of declarations better, and remove most current lookup
filters.  Removing the last remaining filter is more complicated and will
happen in a separate patch.

Fixes PR 6885 as well some spectrum of unfiled bugs.

llvm-svn: 102164
2010-04-23 02:41:41 +00:00
Anders Carlsson 3c1db570b2 Factor code to initialize an implicit member out into a separate function.
llvm-svn: 102162
2010-04-23 02:15:47 +00:00
Douglas Gregor 2c4a7501ee When parsing a cast-expression that starts with a scope annotation,
try to annotate as a type first to determine whether we have a
functional-style cast. Patch by Eli Friedman, fixes PR6830.

llvm-svn: 102161
2010-04-23 02:08:13 +00:00
Douglas Gregor 19043f0a6a I hate default statements. Fixes PR6874.
llvm-svn: 102160
2010-04-23 02:02:43 +00:00
Anders Carlsson 6bd91c387b Remove calls to isDependentContext, since we handle that case earlier in the code. Make BuildImplicitBaseInitializer return a boolean instead.
llvm-svn: 102159
2010-04-23 02:00:02 +00:00
Douglas Gregor 306de2f6a1 Template instantiation for @try and @finally (but not @catch, yet).
llvm-svn: 102147
2010-04-22 23:59:56 +00:00
Douglas Gregor ff1915208d Make TemplateDecl and ObjCContainerDecl abstract
llvm-svn: 102145
2010-04-22 23:35:25 +00:00
Douglas Gregor e93525ed95 Kill off IDNS_ObjCImplementation and IDNS_ObjCCategoryName; they
aren't and never were used. There's a gap in the bit pattern for IDNS
now, but I'm sure *someone* will fill it.

llvm-svn: 102143
2010-04-22 23:19:50 +00:00
Douglas Gregor f68a508586 Template instantiation for the Objective-C "fast enumeration"
statement, i.e., 

  for (element in collection) {
    // do something
  }

llvm-svn: 102138
2010-04-22 23:10:45 +00:00
Douglas Gregor 6148de71dd Template instantiation for Objective-C++ @synchronized statements.
llvm-svn: 102134
2010-04-22 22:01:21 +00:00
Douglas Gregor 2900c16b92 Implement template instantiation for Objective-C++ @throw statements.
llvm-svn: 102133
2010-04-22 21:44:01 +00:00
Fariborz Jahanian 62c560246e Check for -fno-constant-cfstrings consistency
in pch.

llvm-svn: 102130
2010-04-22 21:01:59 +00:00
Fariborz Jahanian 63408e848b Support for -fno-constant-cfstrings option - wip.
llvm-svn: 102112
2010-04-22 20:26:39 +00:00
John McCall 8c12dc4351 Use the naming class from the overloaded lookup when access-checking an
address of overloaded function, instead of assuming that a nested name
specifier was used.  A nested name specifier is not required for static
functions.

Fixes PR6886.

llvm-svn: 102107
2010-04-22 18:44:12 +00:00
Chris Lattner 8b29021712 another tweak for haiku support, patch by Paul Davey!
llvm-svn: 102098
2010-04-22 17:48:00 +00:00
Douglas Gregor 21515a992f Some Objective-C++ types and expressions will never change during
template instantiation, since they cannot be dependent or have
dependent parts. Handle them the simple way.

llvm-svn: 102094
2010-04-22 17:28:13 +00:00
Douglas Gregor b5186b1d44 When a dependent Objective-C++ message send was able to resolve the
method being called at template definition time, retain that method
and pass it through to type-checking. We will not perform any lookup
for the method during template instantiation.

llvm-svn: 102081
2010-04-22 17:01:48 +00:00