Commit Graph

8553 Commits

Author SHA1 Message Date
Douglas Gregor 822514fe39 Allow a declaration of an array to complete a prior, incomplete
declaration of that array in C++.

llvm-svn: 81309
2009-09-09 01:45:28 +00:00
Douglas Gregor 308047d3a5 Initial stab at implement dependent member references to member
templates, e.g.,
  
  x.template get<T>

We can now parse these, represent them within an UnresolvedMemberExpr
expression, then instantiate that expression node in simple cases.

This allows us to stumble through parsing LLVM's Casting.h.

llvm-svn: 81300
2009-09-09 00:23:06 +00:00
Fariborz Jahanian 063c7720f4 More objc GC's API work for array of pointers declared
as __strong.

llvm-svn: 81283
2009-09-08 23:38:54 +00:00
Daniel Dunbar faabdc3b81 Change Darwin toolchain lookup to use llvm::Triple.
- -2+1 FIXMEs.

llvm-svn: 81282
2009-09-08 23:37:36 +00:00
Daniel Dunbar 9c3f7c4a4b Validate arguments to -arch.
llvm-svn: 81281
2009-09-08 23:37:30 +00:00
Daniel Dunbar 1ef3f2aa3a Rename HostInfo::getToolChain to HostInfo::CreateToolChain, and don't recreate
the default tool chain when binding the default architecture.

llvm-svn: 81279
2009-09-08 23:37:19 +00:00
Daniel Dunbar b5c741a427 Delete trailing whitespace.
llvm-svn: 81278
2009-09-08 23:37:08 +00:00
Daniel Dunbar 7b57404dea Simplify.
llvm-svn: 81277
2009-09-08 23:37:02 +00:00
Daniel Dunbar 953b8d1f15 Fix ShouldUseClangCompiler to use llvm::Triple.
- -1 FIXME, and fixes 'clang -arch armv4t ...', for example.

llvm-svn: 81276
2009-09-08 23:36:55 +00:00
Daniel Dunbar f26a7ab377 Tweak & reflow comments, and delete trailing whitespace.
llvm-svn: 81275
2009-09-08 23:36:43 +00:00
Douglas Gregor 5b5559b272 Make sure to access APValue's data via a char array (rather than
through an array of void*), so that we don't run afoul of the
strict-aliasing rules in C++ 3.10p15. Unfortunately, GCC 4.4 still
complains about this code.

llvm-svn: 81251
2009-09-08 19:57:33 +00:00
Anders Carlsson 2fb0824197 Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam Weinig!
llvm-svn: 81237
2009-09-08 18:24:21 +00:00
Chris Lattner 0c79736553 Fix PR4922, where Sema would complete tentative definitions in nondeterminstic
order because it was doing so while iterating over a densemap.

There are still similar problems in other places, for example 
WeakUndeclaredIdentifiers is still written to the PCH file in a nondeterminstic
order, and we emit warnings about #pragma weak in nondeterminstic order.

llvm-svn: 81236
2009-09-08 18:19:27 +00:00
Chris Lattner e6eab983f4 reduce indentation.
llvm-svn: 81234
2009-09-08 18:10:11 +00:00
John McCall d8fe9af3a2 Support templateids in friend declarations. Fixes bug 4859.
llvm-svn: 81233
2009-09-08 17:47:29 +00:00
Daniel Dunbar c09988dda5 Remove FIXMEs for pedantically-gcc-bug-compatible behavior.
- We aren't going to fix these since they haven't caused problems in practice.

 - Similarly, don't forward -object to Darwin ld.

llvm-svn: 81224
2009-09-08 16:39:16 +00:00
Anders Carlsson 6816affaa4 Handle variadic constructors better. Share code between BuildCXXConstructExpr and BuildCXXTemporaryObjectExpr.
llvm-svn: 81181
2009-09-08 01:48:42 +00:00
Anders Carlsson 6d5de59d09 Clean up the CXXConstructExpr constructor, add Arg getters.
llvm-svn: 81178
2009-09-08 01:23:37 +00:00
Chris Lattner 870158eebf reject returning a block expr even when it has parens and casts in the way.
llvm-svn: 81176
2009-09-08 00:36:37 +00:00
Daniel Dunbar 49f0e80fdd Remove trailing whitespace.
llvm-svn: 81169
2009-09-07 23:07:56 +00:00
Anders Carlsson 5995a3e8fa BuildCXXConstructExpr now takes a MultiExprArg.
llvm-svn: 81160
2009-09-07 22:23:31 +00:00
Anders Carlsson 85ec4ffaf5 Check that the destination type of a static_cast expression is a complete type.
llvm-svn: 81151
2009-09-07 18:25:47 +00:00
Benjamin Kramer 635444bcea More <sstream> removal.
llvm-svn: 81150
2009-09-07 12:33:46 +00:00
Benjamin Kramer b178ab2155 Remove unnecessary #include <sstream>.
llvm-svn: 81147
2009-09-07 11:12:05 +00:00
Mike Stump e73d5ca9a8 Refine vcall offsets. Cleanups. WIP.
llvm-svn: 81143
2009-09-07 04:27:52 +00:00
Daniel Dunbar d027a92431 Use a SetVector for tracking some Obj-C metadata, to ensure deterministic
output.
 - Also, cleanup code to output inline asm references.

llvm-svn: 81139
2009-09-07 00:20:42 +00:00
Anders Carlsson faf1ced5ee Reapply 81096, now with a fix. Spot the bug:
for (unsigned i = numargs; i < NumArgs; ++i)
        Args[0] = 0;

;)

llvm-svn: 81123
2009-09-06 16:54:02 +00:00
Daniel Dunbar 94bcae46d5 Revert "Initialize default CXXConstructExpr arguments to 0. Fixes a crash when
destroying the CXXConstructExpr.", this is causing test failures across the
board.

llvm-svn: 81100
2009-09-06 01:31:23 +00:00
Anders Carlsson 8284d7caa3 Initialize default CXXConstructExpr arguments to 0. Fixes a crash when destroying the CXXConstructExpr.
llvm-svn: 81096
2009-09-05 22:51:06 +00:00
Ted Kremenek b5850f9c80 Fix buffer overflow reported in PR 4903.
llvm-svn: 81092
2009-09-05 17:59:01 +00:00
Mike Stump b82db12b35 Refine overrides and thunks for virtual bases. Cleanups. WIP.
llvm-svn: 81080
2009-09-05 11:28:33 +00:00
Benjamin Kramer 26db6481c5 Replace some instances of std::string with StringRefs.
llvm-svn: 81079
2009-09-05 09:49:39 +00:00
Mike Stump c9eb1727db Cleanup.
llvm-svn: 81078
2009-09-05 09:24:43 +00:00
Mike Stump 69bbd6ce84 Cleanups.
llvm-svn: 81077
2009-09-05 09:10:58 +00:00
Mike Stump 6363021ab9 Cleanups.
llvm-svn: 81075
2009-09-05 08:47:24 +00:00
Mike Stump 3cdb051425 Cleanups.
llvm-svn: 81074
2009-09-05 08:45:02 +00:00
Mike Stump 5e3ac0249c Cleanups.
llvm-svn: 81073
2009-09-05 08:40:18 +00:00
Mike Stump ea8eea2c45 Cleanups.
llvm-svn: 81072
2009-09-05 08:37:03 +00:00
Mike Stump db14a73606 Cleanups.
llvm-svn: 81071
2009-09-05 08:07:32 +00:00
John McCall cc5e23ca8d Overhaul the mangler to use a visitor pattern, at least for types. We can safely
ignore non-canonical type classes, but apparently we need to know how to mangle
dependent names.

The missing cases are much more obvious now.

llvm-svn: 81070
2009-09-05 07:56:18 +00:00
Mike Stump 001ad31c9a Cleanups. WIP.
llvm-svn: 81069
2009-09-05 07:49:12 +00:00
Anders Carlsson 1b4ebfab2b Pass the ConstructLoc to BuildCXXConstructExpr.
llvm-svn: 81068
2009-09-05 07:40:38 +00:00
Mike Stump 453fe4285d Install thunks later to fixup overrides. Track space taken by vbase
offsets better for thunk refinements.  Cleanups.  WIP.

llvm-svn: 81067
2009-09-05 07:20:32 +00:00
Zhongxing Xu 1309a852d3 pass the correct predecessor node.
llvm-svn: 81066
2009-09-05 06:46:12 +00:00
John McCall b2e195a585 Start emitting ElaboratedTypes in C++ mode. Support the effort in various
ways:  remove elab types during desugaring, enhance pretty-printing to allow
tags to be suppressed without suppressing scopes, look through elab types
when associating a typedef name with an anonymous record type.

llvm-svn: 81065
2009-09-05 06:31:47 +00:00
Zhongxing Xu d7674a47f9 Do not call FlushReports() in GRBugReporter's dtor. We already call it in
ActionGRExprEngine().

llvm-svn: 81064
2009-09-05 06:06:49 +00:00
Anders Carlsson dc6d2c3cda Report errors for member functions correctly.
llvm-svn: 81063
2009-09-05 05:38:54 +00:00
Anders Carlsson 657bad441e Use a separate diagnostic for default function argument expressions.
llvm-svn: 81062
2009-09-05 05:14:19 +00:00
Zhongxing Xu 88f07cd49c Refactor builtin function evaluation code into its own function.
llvm-svn: 81061
2009-09-05 05:00:57 +00:00
John McCall fcc33b074b Basic support for representing elaborated type specifiers
directly in the AST.  The current thinking is to create these
only in C++ mode for efficiency.  But for now, they're not being
created at all; patch to follow.

This will let us do things like verify that tags match during
template instantation, as well as signal that an elaborated type
specifier was used for clients that actually care.

Optimally, the TypeLoc hierarchy should be adjusted to carry tag
location information as well.

llvm-svn: 81057
2009-09-05 00:15:47 +00:00
Douglas Gregor 34ec2ef159 Improve the AST representation and semantic analysis for extern
templates. We now distinguish between an explicit instantiation
declaration and an explicit instantiation definition, and know not to
instantiate explicit instantiation declarations. Unfortunately, there
is some remaining confusion w.r.t. instantiation of out-of-line member
function definitions that causes trouble here.
 

llvm-svn: 81053
2009-09-04 22:48:11 +00:00
Douglas Gregor d94105a1c2 Don't generate any code for an explicit call to a trivial destructor.
Now that parsing, semantic analysis, and (I think) code generation of
pseudo-destructor expressions and explicit destructor calls works,
update the example-dynarray.cpp test to destroy the objects it
allocates and update the test to actually compile + link.
The code seems correct, but the Clang-compiled version dies with a
malloc error. Time to debug!

llvm-svn: 81025
2009-09-04 19:04:08 +00:00
Daniel Dunbar 037f389f4d Merge libgcc spec changes for darwin::Link::ConstructJob.
llvm-svn: 81022
2009-09-04 18:35:47 +00:00
Daniel Dunbar 2b5f6817e0 Tweak darwin::Link::AddLinkArgs.
llvm-svn: 81021
2009-09-04 18:35:41 +00:00
Daniel Dunbar 91dbfd6666 Implement darwin::Link::AddDarwinArch for ARM.
llvm-svn: 81020
2009-09-04 18:35:31 +00:00
Daniel Dunbar 84e727fb72 Darwin: Pass -iphoneos-version-min to ld when building for ARM.
llvm-svn: 81019
2009-09-04 18:35:21 +00:00
Daniel Dunbar 5ed07fe794 Add -ccc-install-dir option for faking installation path.
llvm-svn: 81017
2009-09-04 18:35:03 +00:00
Daniel Dunbar f0a5b9b126 Rename Darwin_X86 toolchain to just Darwin, this can support all platforms.
llvm-svn: 81016
2009-09-04 18:34:51 +00:00
Douglas Gregor bddb73fa1d If a destructor is referenced or a pseudo-destructor expression is
formed without a trailing '(', diagnose the error (these expressions
must be immediately called), emit a fix-it hint, and fix the code.

llvm-svn: 81015
2009-09-04 18:29:40 +00:00
Mike Stump 5a522353c3 Add overidding for methods for vtable building for the secondary
vtables.  Add thunk generation.  WIP.

llvm-svn: 81014
2009-09-04 18:27:16 +00:00
Daniel Dunbar 5095b293b7 Remove unused argument.
llvm-svn: 81010
2009-09-04 17:39:02 +00:00
Douglas Gregor ad8a336b40 Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

  p->~T()

when p is a pointer to a scalar type. 

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.

llvm-svn: 81009
2009-09-04 17:36:40 +00:00
Steve Naroff ef9618b75f Implement accessors clang_getCursorKind(), clang_getCursorDecl().
Implement clang_getCursor() - wired up to Argiris's work.
Implement callbacks for CXCursor_ObjCProtocolRef.

llvm-svn: 81004
2009-09-04 15:44:05 +00:00
Douglas Gregor 2d2282e8f9 When searching for a default constructor or copy constructor, skip constructor templates
llvm-svn: 81002
2009-09-04 14:46:39 +00:00
Douglas Gregor 43e75176ec Parse extern templates, pass that information all the way to Sema,
then drop it on the floor.

llvm-svn: 80989
2009-09-04 06:33:52 +00:00
Douglas Gregor 119b0c7185 Introduce an egregious hack to fix PR4828.
The problem this change addresses is that we treat __is_pod and
__is_empty as keywords in C++, because they are built-in type traits
in GCC >= 4.3. However, GNU libstdc++ 4.2 (and possibly earlier
versions) define implementation-detail struct templates named __is_pod
and __is_empty. 

This commit solves the problem by recognizing

  struct __is_pod

and

  struct __is_empty

as special token sequences. When one of these token sequences is
encountered, the keyword (__is_pod or __is_empty) is implicitly
downgraded to an identifier so that parsing can continue. This is an
egregious hack, but it has the virtue of "just working" whether
someone is using libstdc++ 4.2 or not, without the need for special
flags.

llvm-svn: 80988
2009-09-04 05:53:02 +00:00
Zhongxing Xu bfb000f337 move the check into MarkNoReturnFunction.
llvm-svn: 80980
2009-09-04 02:17:35 +00:00
Zhongxing Xu 1748d8a43d Extract mark-no-return-function code into a function.
llvm-svn: 80979
2009-09-04 02:13:36 +00:00
John McCall 06f6fe8df7 Correctly handle elaborated template ids. Still not handled properly for friends.
llvm-svn: 80977
2009-09-04 01:14:41 +00:00
Fariborz Jahanian 37d065680b Patch to instantiate destructors used to destruct
base and data members when they are needed.

llvm-svn: 80967
2009-09-03 23:18:17 +00:00
Anders Carlsson 0e91275ab4 If the alignment of the chosen field in a union is greater than the alignment of the union, we need to use a packed LLVM struct. Fixes <rdar://problem/7184250>.
llvm-svn: 80964
2009-09-03 22:56:02 +00:00
Douglas Gregor f816bd70ce Implement tree transformations for DeclarationNames. Among other
things, this means that we can properly cope with member access
expressions such as 

  t->operator T()

where T is a template parameter (or other dependent type).

llvm-svn: 80957
2009-09-03 22:13:48 +00:00
Douglas Gregor 2b6ca46c6b Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.

llvm-svn: 80953
2009-09-03 21:38:09 +00:00
Fariborz Jahanian 59a1cd4a06 Mark constructors used in initialization of base(s) and fields
as referecned with location where they are used. Still
need to look at destructor aspects of them.

llvm-svn: 80950
2009-09-03 21:32:41 +00:00
Fariborz Jahanian 3501bcec7d Issue diagnostics in variety of situations involving
reference/const data members when user has declared
the constructor. This necessitated some non-minor
refactoring.

llvm-svn: 80934
2009-09-03 19:36:46 +00:00
Daniel Dunbar fe07aecd37 Don't use '%ll', this doesn't workin on Win32.
llvm-svn: 80933
2009-09-03 19:23:49 +00:00
Steve Naroff c0683b909a Add ASTUnit::getOriginalSourceFileName() and use in clang_getTranslationUnitSpelling().
llvm-svn: 80932
2009-09-03 18:19:54 +00:00
Douglas Gregor c26e0f626b Improved handling for dependent, qualified member access expressions, e.g.,
t->Base::f

where t has a dependent type. We save the nested-name-specifier in the
CXXUnresolvedMemberExpr then, during instantiation, substitute into
the nested-name-specifier with the (transformed) object type of t, so
that we get name lookup into the type of the object expression.

Note that we do not yet retain information about name lookup into the
lexical scope of the member access expression, so several regression
tests are still disabled.

llvm-svn: 80925
2009-09-03 16:14:30 +00:00
Douglas Gregor b3286fe685 Save/load POSIXThreads flag for PCH
llvm-svn: 80916
2009-09-03 14:36:33 +00:00
Daniel Dunbar 3a0637b06b Revert "Visit function/method bodies and issue callback for parameters and local
variables.", this is breaking x86_64-apple-darwin10 and Linux tests.

llvm-svn: 80896
2009-09-03 05:59:50 +00:00
Daniel Dunbar 2d9c740cc5 Revert "Remove redundant local variable (use newly created instance data).", the
previous commit this depends on is breaking x86_64-apple-darwin10 and Linux tests.

llvm-svn: 80895
2009-09-03 05:59:35 +00:00
Daniel Dunbar a77eaeb1e6 Add basic support for -pthread.
- Patch by David Chisnall, with PCH and Darwin support mixed in.

llvm-svn: 80883
2009-09-03 04:54:28 +00:00
Ted Kremenek 17a0296a09 Fix 80 column violations.
llvm-svn: 80873
2009-09-03 03:02:58 +00:00
David Chisnall 2c5bef2a74 Fixed bug introduced in r79900 where FreeBSD was turned into NetBSD, transposing the ABIs and breaking both platforms.
llvm-svn: 80870
2009-09-03 01:48:05 +00:00
Ted Kremenek b117fd9168 Fix regression introduced in r80786 and reported in PR 4867. We should use
'dyn_cast' instead of 'cast' as the denominator value could be UnknownVal (and
is not guaranteed to be a DefinedVal).

llvm-svn: 80869
2009-09-03 01:48:03 +00:00
Zhongxing Xu 677e6a2faf remove a debug output I introduced in the last commit.
llvm-svn: 80865
2009-09-03 01:31:59 +00:00
Mike Stump 850cc1c5a4 Update.
llvm-svn: 80864
2009-09-03 01:30:36 +00:00
Anders Carlsson 496335ea1a Add CastExpr::getCastKindName and use it in the StmtDumper.
llvm-svn: 80862
2009-09-03 00:59:21 +00:00
Steve Naroff 517ea46e2e Remove redundant local variable (use newly created instance data).
llvm-svn: 80861
2009-09-03 00:43:52 +00:00
Fariborz Jahanian f15d4b6050 This patch does the following.
1) Issue digsnostics in non-fragile ABI, when an expression
   evaluates to an interface type (except when it is used to
   access a non-fragile ivar).
2) Issue unsupported error in fragile ABI when an expression
   evaluates to an interface type (except when it is used to
   access a fragile ivar).

llvm-svn: 80860
2009-09-03 00:43:07 +00:00
Steve Naroff ef3cf2a576 Visit function/method bodies and issue callback for parameters and local variables.
Add clang_getTranslationUnitSpelling().

llvm-svn: 80859
2009-09-03 00:32:06 +00:00
Douglas Gregor 64792e021d Add a wicked little test-case that illustrates what we have to deal
with to properly support member access expressions in templates. This
test is XFAIL'd, because we get it completely wrong, but I've made the
minimal changes to the representation to at least avoid a crash.

llvm-svn: 80856
2009-09-02 23:58:38 +00:00
Douglas Gregor e5feb51624 Don't try to CodeGen using directives, from Anders Johnsen
llvm-svn: 80853
2009-09-02 23:49:23 +00:00
Fariborz Jahanian cc043a7154 Minor refactoring of my last patch.
llvm-svn: 80847
2009-09-02 23:11:48 +00:00
Fariborz Jahanian 3117e2b9d4 Referenced instatiated default constructors
must be defined. Fixed pr4853.

llvm-svn: 80846
2009-09-02 23:02:57 +00:00
Douglas Gregor b7bfe79412 Rewrite of our handling of name lookup in C++ member access expressions, e.g.,
x->Base::f

We no longer try to "enter" the context of the type that "x" points
to. Instead, we drag that object type through the parser and pass it
into the Sema routines that need to know how to perform lookup within
member access expressions.

We now implement most of the crazy name lookup rules in C++
[basic.lookup.classref] for non-templated code, including performing
lookup both in the context of the type referred to by the member
access and in the scope of the member access itself and then detecting
ambiguities when the two lookups collide (p1 and p4; p3 and p7 are
still TODO). This change also corrects our handling of name lookup
within template arguments of template-ids inside the
nested-name-specifier (p6; we used to look into the scope of the
object expression for them) and fixes PR4703.

I have disabled some tests that involve member access expressions
where the object expression has dependent type, because we don't yet
have the ability to describe dependent nested-name-specifiers starting
with an identifier.

llvm-svn: 80843
2009-09-02 22:59:36 +00:00
Anders Carlsson 35dca26835 Fix an assertion when initializing a union using a member initializer. (We weren't casting from the union type to the initializer type correctly).
llvm-svn: 80837
2009-09-02 21:14:47 +00:00
John McCall f8bd861ce9 Borrow a friend class's previous declaration's access specifier regardless of
whether the current context is dependent.

Thanks to Anders for pointing this out.

llvm-svn: 80828
2009-09-02 19:32:14 +00:00
Anders Carlsson 2e56cc6e6c Fix a codegen crash when a class template has a constructor that does member initialization of an anonymous union.
llvm-svn: 80826
2009-09-02 19:17:55 +00:00
Anders Carlsson 09a3774cd3 Packed unions should be packed. Fixes an assert Daniel reported.
llvm-svn: 80808
2009-09-02 17:51:33 +00:00
Fariborz Jahanian fc60ca8801 Allow null initialization of scalara data members
in constructors's initializer list. pr4854

llvm-svn: 80802
2009-09-02 17:10:17 +00:00
Zhongxing Xu 6e4232c79c Refactor the check for bad divide into a checker.
Also fix a checker context bug: the Dst set is not always empty initially. 
Because in GRExprEngine::CheckerVisit(), *CurrSet is used repeatedly. 
So we removed the Dst.empty() condition in ~CheckerContext() when deciding
whether to do autotransision.

llvm-svn: 80786
2009-09-02 13:26:26 +00:00
Douglas Gregor c707da6866 Document how we intepret C++ DR 382
llvm-svn: 80785
2009-09-02 13:12:51 +00:00
Douglas Gregor 12bbfe1d31 When parsing typename specifiers (with either the identifier or
simple-template-id form), check whether the scope specifier is
computable as a declaration context rather than checking whether it is
dependent, so that we properly cope with members of the current
instantiation. 

Improve testing for typename specifiers that terminate in a
simpe-template-id.

llvm-svn: 80783
2009-09-02 13:05:45 +00:00
Zhongxing Xu 79affb7b94 Refactor bad callee check into a Checker.
Now bad callee is checked as a PreVisit to the CallExpr.

llvm-svn: 80771
2009-09-02 08:10:35 +00:00
Zhongxing Xu 656b10a1fa Still use BadArg bugtype in the checker. This saves us implement registerInitialVisitors
in the BugReport. 

When all internal bug checking logic are moved to checkers, BuiltinBug will
not reference GRExprEngine, and FlushReports() will be not necessary, since
all bugs are emitted into the equivalent classes immediately.

For now just add a ctor with no arguments.

llvm-svn: 80770
2009-09-02 07:09:39 +00:00
Ted Kremenek cf768cd202 Replace uses of ImmutableSet in SymbolReaper with DenseSet. This was
motivated from Shark profiles that shows that 'markLive' was very
heavy when using --analyzer-store=region.  On my benchmark file, this
reduces the analysis time for --analyzer-store=region from 19.5s to
13.5s and for --analyzer-store=basic from 5.3s to 3.5s.  For the
benchmark file, this is a reduction of about 30% analysis time for
both analysis modes (a huge win).

llvm-svn: 80765
2009-09-02 06:03:18 +00:00
Ted Kremenek ad5a600a24 Implement: <rdar://problem/6337100> CWE-338: Use of cryptographically weak prng
Patch by Geoff Keating!

llvm-svn: 80752
2009-09-02 02:47:41 +00:00
John McCall e94dd7ccf5 When adding a friend class declaration to the lookup tables, use the access specifier
of any previous declaration in case we replace it in a class's declaration table.
Fixes bug 4858.  This sort of thing makes me reconsider putting friend declarations in
declaration lists.

llvm-svn: 80750
2009-09-02 02:15:17 +00:00
John McCall e8dbaef730 Fix a little crasher in friend decls. Thanks again to Eli for finding this.
llvm-svn: 80748
2009-09-02 01:07:03 +00:00
Mike Stump 3f707e9f14 Add mangling for covariant thunks.
llvm-svn: 80747
2009-09-02 00:56:18 +00:00
John McCall 2dc078f24e Ensure that the tag decls of friend decls aren't added to the friending class's
decl list, and remove some workarounds that were due to this.  Thanks to Eli for
pointing this out and providing the test case.

llvm-svn: 80745
2009-09-02 00:55:30 +00:00
Mike Stump a119813218 Shorten name.
llvm-svn: 80744
2009-09-02 00:28:47 +00:00
Mike Stump 9cc7d30435 Add mangling for thunks.
llvm-svn: 80743
2009-09-02 00:25:38 +00:00
Fariborz Jahanian 086ac11606 It is illegal to derefrercne to an interface in
objc's non-fragile ABI.

llvm-svn: 80739
2009-09-02 00:00:05 +00:00
Mike Stump 2348e62498 More overriding base work and some cleanups. WIP.
llvm-svn: 80737
2009-09-01 23:22:44 +00:00
Fariborz Jahanian 5083e2623b After a conversation with Doug. I added a fix me to
where we build the constructor's initializer list.

llvm-svn: 80735
2009-09-01 23:08:16 +00:00
Mike Stump 40dc64bcfc Split out overriding. WIP.
llvm-svn: 80732
2009-09-01 22:20:28 +00:00
Anders Carlsson c82555fb85 Handle member expressions that return references correctly.
llvm-svn: 80723
2009-09-01 21:18:52 +00:00
Anders Carlsson 783ab50b33 Assert that we don't have any virtual bases. We can emit dtors for polymorphics classes just fune.
llvm-svn: 80722
2009-09-01 21:12:16 +00:00
Douglas Gregor a3a3f6fecd In CXXBaseOrMemberInitializer, don't confuse CtorTocall with
AnonUnionMember. Fixes PR4826.

llvm-svn: 80721
2009-09-01 21:04:42 +00:00
Anders Carlsson f1ae6d45dd Use the correct cast kinds for bit casts and function to pointer decay. Fixes PR4827.
llvm-svn: 80720
2009-09-01 20:52:42 +00:00
Anders Carlsson 6904f644e7 Add a CK_FunctionToPointerDecay cast kind.
llvm-svn: 80719
2009-09-01 20:37:18 +00:00
Anders Carlsson 6b8b4b459d We can generate constructors/destructors with base classes and non-trivial fields just fine now.
llvm-svn: 80701
2009-09-01 18:33:46 +00:00
Douglas Gregor 2ffd96549d Implement proper substitution for OverloadedFunctionDecls, but substituting each of the functions in the overload set
llvm-svn: 80692
2009-09-01 17:53:10 +00:00
Douglas Gregor d51896311d Add DeclContext::Equals to compare declaration contexts based on their primary context. Use this instead of pointer comparisons
llvm-svn: 80690
2009-09-01 17:22:34 +00:00
Fariborz Jahanian 1a50477385 Fixed a property getter ir-gen crash.
llvm-svn: 80681
2009-09-01 17:02:21 +00:00
Douglas Gregor 32e2c8472e Fix a crasher involving template instantiation of non-dependent
expressions making use of an overloaded operator. Thanks for the test
case, Anders!

llvm-svn: 80679
2009-09-01 16:58:52 +00:00
Daniel Dunbar 6cdf83c192 Add driver support for -emit-ast and AST compilation steps.
- <rdar://problem/7185031> Add 'clang' option '-emit-ast'

llvm-svn: 80678
2009-09-01 16:57:46 +00:00
Anders Carlsson bcec05c9fd Don't assume that a base is always a RecordType, it can also be a TemplateSpecializationType. Also, make sure to get the instantiated union member.
llvm-svn: 80662
2009-09-01 06:22:14 +00:00
Anders Carlsson 62215c4fb5 Add pretty stack traces when instantiating functions and static data members.
llvm-svn: 80661
2009-09-01 05:12:24 +00:00
Anders Carlsson 17dc7e2007 Handle member initializers that point to fields in anonymous structs.
llvm-svn: 80659
2009-09-01 04:31:02 +00:00
Anders Carlsson 5da848427a Don't assert when instantiating member references to fields in anonymous structs.
llvm-svn: 80657
2009-09-01 04:26:58 +00:00
Eli Friedman 1c277d0fe8 PR4836, part 2: CodeGen for __builtin_isnan.
llvm-svn: 80655
2009-09-01 04:19:44 +00:00
Douglas Gregor 84f14dd674 Preliminary AST representation and semantic analysis for
explicitly-specified template argument lists in member reference
expressions, e.g.,

  x->f<int>()

llvm-svn: 80646
2009-09-01 00:37:14 +00:00
Ted Kremenek 3aff920676 Sentence-case bug category.
llvm-svn: 80644
2009-09-01 00:17:12 +00:00
Douglas Gregor f4b34ba326 Remember to write the qualifier of a MemberExpr to the PCH file when we get to C++ PCH
llvm-svn: 80643
2009-08-31 23:44:04 +00:00
Douglas Gregor f405d7e6f1 Eliminate CXXAdornedMemberExpr entirely. Instead, optionally allocate
space within the MemberExpr for the nested-name-specifier and its
source range. We'll do the same thing with explicitly-specified
template arguments, assuming I don't flip-flop again.

llvm-svn: 80642
2009-08-31 23:41:50 +00:00
John McCall 759e32bdc6 Fix bug 4784 and allow friend declarations to properly extend
existing declaration chains.

llvm-svn: 80636
2009-08-31 22:39:49 +00:00
Devang Patel 124095bb18 Rename DIBlock as DILexicalBlock.
llvm-svn: 80634
2009-08-31 22:00:32 +00:00
Douglas Gregor 96ee789d33 Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional
"adornment". No functionality change.

llvm-svn: 80628
2009-08-31 21:41:48 +00:00
Douglas Gregor fbc1823451 Add parsing for references to member function templates with explicit
template argument lists, e.g., x.f<int>().

Semantic analysis will be a separate commit.

llvm-svn: 80624
2009-08-31 21:16:32 +00:00
Eli Friedman 7e4faaccda PR4836, part 1: add Sema support for __builtin_isnan and friends; they
are apparently used by Solaris libc despite the fact that clang claims 
to be compatible with gcc 4.2, which doesn't support them.

llvm-svn: 80610
2009-08-31 20:06:00 +00:00
Douglas Gregor f14b46f9a8 Implement template instantiation for member operator access.
llvm-svn: 80609
2009-08-31 20:00:26 +00:00
Douglas Gregor 522fbc4969 Support explicit C++ member operator syntax, from James Porter!
llvm-svn: 80608
2009-08-31 19:52:13 +00:00
Fariborz Jahanian 879d726608 Re-implemented generation of objc_memmove_collectable
API for copying GC'able aggregates (Next runtime only).

llvm-svn: 80607
2009-08-31 19:33:16 +00:00
Daniel Dunbar 6733a7ec15 Fix a -Asserts warning.
llvm-svn: 80606
2009-08-31 19:16:38 +00:00
David Chisnall 5778fce141 Updated GNU runtime non-fragile ABI.
Added -fconstant-string-class= option.
Added __has_feature() test for non-fragile ABI.

llvm-svn: 80591
2009-08-31 16:41:57 +00:00
Anders Carlsson b533df02b5 More missing member goodness.
llvm-svn: 80491
2009-08-30 07:09:50 +00:00
Anders Carlsson 0d2a51b61f Improve missing error messages as suggested by Doug.
llvm-svn: 80489
2009-08-30 06:49:43 +00:00
Anders Carlsson 5167a4644d Use DiagnoseMissingMember for UsingDecls.
llvm-svn: 80470
2009-08-30 00:58:45 +00:00
Anders Carlsson 896c230a19 Improve diagnostics for missing members. This renames the err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead.
llvm-svn: 80469
2009-08-30 00:54:35 +00:00
Eli Friedman 744a249493 Unbreak tests. I'll look into why this is necessary later.
llvm-svn: 80468
2009-08-30 00:53:54 +00:00
Argyrios Kyrtzidis 321995b5e5 Fix the start source location for type-specs like long, short, etc.
llvm-svn: 80448
2009-08-29 22:39:34 +00:00
Eli Friedman 15e05261d4 Make instantiating initializers for classes with a dependent base type
work correctly.

The change in lib/AST/DeclCXX.cpp is mostly a large reindentation; I 
couldn't figure out a good way to avoid it.

llvm-svn: 80446
2009-08-29 22:22:07 +00:00
Eli Friedman 033e8d4ae6 Make IRGen for initializing a member reference work correctly.
llvm-svn: 80439
2009-08-29 20:58:20 +00:00
Anders Carlsson adf36b2379 Add a workaround for decls that come from friend decls pointing to undeclared classes.
llvm-svn: 80438
2009-08-29 20:47:47 +00:00
Anders Carlsson 6df9e076ea In DeclPrinter, assert when asked to print AS_None.
llvm-svn: 80437
2009-08-29 20:36:12 +00:00
Fariborz Jahanian 0a484d007b Patch to ir-gen user-defined conversions used in expressions
[12.3.2-p3]

llvm-svn: 80436
2009-08-29 20:33:32 +00:00
Anders Carlsson 7b194b780d Set the access specifier for using decls.
llvm-svn: 80435
2009-08-29 19:54:19 +00:00
Anders Carlsson 4bb87ce33e Improve instantiation of UnresolvedUsingDecls.
llvm-svn: 80434
2009-08-29 19:37:28 +00:00
Fariborz Jahanian 3df8767869 Patch for code gen. for c-style cast which ends in
using class's conversion functions [12.3.2-p2]

llvm-svn: 80433
2009-08-29 19:15:16 +00:00
Eli Friedman 9ab0319b2b Get rid of mostly-unused, buggy method.
llvm-svn: 80432
2009-08-29 19:09:59 +00:00
John McCall 5966088621 Fix the breakage by handling indirect instantiations. This would be much
improved if there were a consistent name for getInstantiatedFromMemberX()
across all classes.  Cheap refactor if someone wants to do it, but let's get the
buildbots happy first.

llvm-svn: 80425
2009-08-29 08:11:13 +00:00
Anders Carlsson 705539441b Instantiate member and base initializers. Patch by Anders Johnsen! (tweaked slightly by me)
llvm-svn: 80422
2009-08-29 05:16:22 +00:00
Eli Friedman 2624be4fd4 Fix a couple issues with parsing invalid nested-name-specifiers.
llvm-svn: 80421
2009-08-29 04:08:08 +00:00
John McCall 75c03bbb0c For consistency, just make friend declarations AS_public.
llvm-svn: 80420
2009-08-29 03:50:18 +00:00
John McCall 970d530a84 Ensure code generation for friend declarations in class templates.
llvm-svn: 80418
2009-08-29 03:16:09 +00:00
Zhongxing Xu 6fd66d4588 Refactor undefined argument checking into a Checker.
llvm-svn: 80417
2009-08-29 02:11:01 +00:00
Anders Carlsson 1e172e068f Store the SourceLocation of right parentheses in member initializers. Patch by Anders Johnsen!
llvm-svn: 80416
2009-08-29 01:31:33 +00:00
Anders Carlsson 6e1ca8315c Don't assert that friend declarations must have access specifiers for now.
llvm-svn: 80415
2009-08-29 01:13:02 +00:00
Anders Carlsson 938b10079a CreateDeclRefExprs that point to UnresolvedUsingDecls.
llvm-svn: 80413
2009-08-29 01:06:32 +00:00
Anders Carlsson a884e67485 Add another check for UnresolvedUsingDecl.
llvm-svn: 80412
2009-08-29 00:56:38 +00:00
Mike Stump beefdc8948 iGenerate vcalls as we build up the methods. WIP.
llvm-svn: 80405
2009-08-28 23:22:54 +00:00
Douglas Gregor 90820ee62a Make sure we actually found a redeclaration before complaining about attributes added to a redeclaration in C++
llvm-svn: 80403
2009-08-28 22:54:55 +00:00
Anders Carlsson 601d6e4c7b Add printing of access specifiers to DeclPrinter. The formatting is pretty bad but it works :)
llvm-svn: 80402
2009-08-28 22:39:52 +00:00
Douglas Gregor c37709b3c5 Remove #if 0'd code that is clearly not needed
llvm-svn: 80399
2009-08-28 22:06:43 +00:00
Fariborz Jahanian 2fee79a9a1 path to ir-gen 12.3.1 Conversion by constructor
llvm-svn: 80398
2009-08-28 22:04:50 +00:00
Douglas Gregor f3db003358 Don't crash when instantiating templates containing anonymous structs/unions
llvm-svn: 80397
2009-08-28 22:03:51 +00:00
Douglas Gregor 11395b66c6 Test instantiation of static data members that live within nested
member templates.

llvm-svn: 80396
2009-08-28 21:41:19 +00:00
Douglas Gregor d99bb43068 Fix and test template instantiation for nested member templates.
llvm-svn: 80394
2009-08-28 21:09:48 +00:00
Douglas Gregor 39cacdb04b Tighten up the conversion from a single-level template argument list
to a multi-level template argument list by making it explicit. The
forced auditing of callers found a bug in the instantiation of member
classes inside member templates.

I *love* static type systems.

llvm-svn: 80391
2009-08-28 20:50:45 +00:00
Douglas Gregor 6533292684 Remove the conversion from a multi-level template argument list back to a single template argument list. We no longer need this crutch
llvm-svn: 80390
2009-08-28 20:33:09 +00:00
Douglas Gregor 01afeeff1d Implement template instantiation for member class templates.
When performing template instantiation of the definitions of member
templates (or members thereof),  we build a data structure containing
the template arguments from each "level" of template
instantiation. During template instantiation, we substitute all levels
of template arguments simultaneously. 

llvm-svn: 80389
2009-08-28 20:31:08 +00:00
Ted Kremenek 52ac2b5735 retain/release checker: [CIContext createCGImage...] and friends returned CF
objects that are not automatically garbage collected. This fixes
<rdar://problem/7174400>.

llvm-svn: 80387
2009-08-28 19:52:12 +00:00
Anders Carlsson df5a1c8b5d Improve support for using decls in the decl printer.
llvm-svn: 80386
2009-08-28 19:16:39 +00:00
Anders Carlsson 01ff6d7094 Check for UnresolvedUsingDecl when determining if a declaration is a redeclaration or not.
llvm-svn: 80383
2009-08-28 17:57:07 +00:00
Fariborz Jahanian b1771e4e74 patch to prevent crash in hopelessly incorrect
method definition with labels.

llvm-svn: 80381
2009-08-28 17:52:37 +00:00
Douglas Gregor a654dd8ae8 Collect multiple levels of template arguments into a new type,
MultiLevelTemplateArgumentList. This is a baby step toward
instantiating member templates; no intended functionality change yet.

llvm-svn: 80380
2009-08-28 17:37:35 +00:00
Anders Carlsson d20e795a5b Fix this for real.
llvm-svn: 80377
2009-08-28 16:57:08 +00:00
Anders Carlsson f2bc7c386e Allow explicit ctors for casts.
llvm-svn: 80374
2009-08-28 16:22:20 +00:00
Anders Carlsson 759b78951e When doing overload resolution, expressions that are value dependent but not type dependent and of integral type should not be treated as null pointer constants.
llvm-svn: 80369
2009-08-28 15:55:56 +00:00
Anders Carlsson 228eea36a3 Pass InOverloadResolution all the way down to IsPointerConversion.
llvm-svn: 80368
2009-08-28 15:33:32 +00:00
Anders Carlsson 4bd7875b9c Instantiate unresolved using declarations.
llvm-svn: 80366
2009-08-28 15:18:15 +00:00
Fariborz Jahanian 8b899e4247 ir-gen related patch for type conversion
with class type conversion methods. WIP.

llvm-svn: 80365
2009-08-28 15:11:24 +00:00
John McCall aa74a0c3b5 Omnibus friend decl refactoring. Instead of cloning AST classes for friend
declarations of same, introduce a single AST class and add appropriate bits
(encoded in the namespace) for whether a decl is "real" or not.  Much hackery
about previously-declared / not-previously-declared, but it's essentially
mandated by the standard that friends alter lookup, and this is at least
fairly non-intrusive.

Refactor the Sema methods specific to friends for cleaner flow and less nesting.

Incidentally solve a few bugs, but I remain confident that we can put them back.

llvm-svn: 80353
2009-08-28 07:59:38 +00:00
Anders Carlsson f038fc2c12 Create UnresolvedUsingDecls.
llvm-svn: 80346
2009-08-28 05:49:21 +00:00
Anders Carlsson 696a3f199b Factor declaration building out to Sema::BuildUsingDeclaration.
llvm-svn: 80337
2009-08-28 05:40:36 +00:00
Anders Carlsson 8305c1fa97 Check in UnresolvedUsingDecl.
llvm-svn: 80336
2009-08-28 05:30:28 +00:00
Ted Kremenek 198a8c5f95 Use SymbolicRegion instead of CodeTextRegion for symbolic function
pointers.  Most logic cares first about whether or not a region is
symbolic, and second if represents code.  This should fix a series of
silent corner case bugs (as well as simplify a bunch of code).

llvm-svn: 80335
2009-08-28 04:49:15 +00:00
Anders Carlsson 5a9c5acf0f More work on using declarations.
llvm-svn: 80333
2009-08-28 03:35:18 +00:00
Anders Carlsson 59140b3b86 Many improvements to using declarations.
llvm-svn: 80332
2009-08-28 03:16:11 +00:00
Ted Kremenek aeca0954c2 Use C++ style comments.
llvm-svn: 80320
2009-08-28 00:24:55 +00:00
Ted Kremenek d032fcce5c Implement: <rdar://problem/6337132> CWE-273: Failure to Check Whether Privileges
Were Dropped Successfully

Patch by Geoff Keating!

llvm-svn: 80313
2009-08-28 00:08:09 +00:00
Douglas Gregor 6a1f965853 When looking for overloaded member operators, make sure to instantiate
class template specializations (when possible) and look into base
classes. Thanks to Eli for the test case!

FIXME -=1.

llvm-svn: 80302
2009-08-27 23:35:55 +00:00
Ted Kremenek ce499c2078 CFG construction: Abort CFG construction when processing a CompoundStmt if any
of its subexpressions resulted in a "bad CFG".

llvm-svn: 80298
2009-08-27 23:16:26 +00:00
Ted Kremenek 1d5f2f3546 Rename 'bindExpr' to 'BindExpr'.
llvm-svn: 80294
2009-08-27 22:17:37 +00:00
Ted Kremenek 0ac724be55 Move the AnalysisContext* from GRState to Environment.
llvm-svn: 80293
2009-08-27 22:15:20 +00:00
Eli Friedman 80110179f4 Define _GNU_SOURCE in C++ mode so that clang works with GNU libstdc++.
llvm-svn: 80289
2009-08-27 22:01:41 +00:00
Eli Friedman ff083ef429 Clean up CodeGenFunction::EmitCastLValue to use the cast kind. Error
out for user-defined conversions instead of crashing.

llvm-svn: 80282
2009-08-27 21:19:33 +00:00
Eli Friedman bda4ef15ce Fix for PR4794 (instantiating friend class decl); this version shouldn't
cause any regressions.

llvm-svn: 80277
2009-08-27 19:11:42 +00:00
Eli Friedman 1e97108bdd Back out bad piece of r80272. Will look at fixing this a different way.
llvm-svn: 80273
2009-08-27 18:44:04 +00:00
Eli Friedman 7a61407d0b PR4794: Make instantiating friend class decls not crash.
llvm-svn: 80272
2009-08-27 18:38:56 +00:00
Anders Carlsson 20d1332d76 Add an InOverloadResolution flag to TryCopyInitialization.
llvm-svn: 80261
2009-08-27 17:37:39 +00:00
Anders Carlsson 271e3a4d47 Remove more default arguments.
llvm-svn: 80260
2009-08-27 17:30:43 +00:00
Anders Carlsson ef4c72135f Remove default arguments from TryImplicitConversion and fix a bug found in the process.
llvm-svn: 80258
2009-08-27 17:24:15 +00:00
Anders Carlsson 03068aa077 Remove default argument from TryCopyInitialization.
llvm-svn: 80256
2009-08-27 17:18:13 +00:00
Anders Carlsson 5ec4abf268 Revert the flags change for now, I have a better idea for this.
llvm-svn: 80255
2009-08-27 17:14:02 +00:00
Douglas Gregor e704c9df31 Implement instantiation of the declarations of member function
templates within class templates, producing a member function template
of a class template specialization. If you can parse that, I'm
sorry. Example:

  template<typename T>
  struct X {
    template<typename U> void f(T, U);
  };

When we instantiate X<int>, we now instantiate the declaration
X<int>::f, which looks like this:

  template<typename U> void X<int>::f(int, U);

The path this takes through
TemplateDeclInstantiator::VisitCXXMethodDecl is convoluted and
ugly, but I don't know how to improve it yet. I'm resting my hopes on
the multi-level substitution required to instantiate definitions of
nested templates, which may simplify this code as well.

More testing to come...

llvm-svn: 80252
2009-08-27 16:57:43 +00:00
Anders Carlsson 2f7e956f16 Add a OverloadResolutionFlags and start converting some of the overload methods over to using it instead of bools arguments.
llvm-svn: 80248
2009-08-27 16:01:18 +00:00
Zhongxing Xu 3ca89b9f20 Remove a unused member variable. Instead query the option from AnalysisManager.
llvm-svn: 80226
2009-08-27 06:55:26 +00:00
Douglas Gregor e985a3b724 When checking whether one declaration context encloses another, make sure to look at the primary contexts. Thanks to Eli for the test case
llvm-svn: 80212
2009-08-27 06:03:53 +00:00
Anders Carlsson 35d6e3e710 Don't check member and base initializers if the constructor is dependent.
llvm-svn: 80211
2009-08-27 05:57:30 +00:00
Anders Carlsson e0eebb3ee4 Use early returns to avoid indentation.
llvm-svn: 80209
2009-08-27 05:45:01 +00:00
Eli Friedman 561154dd6b Stub out an error so we don't crash.
llvm-svn: 80207
2009-08-27 05:09:36 +00:00
Anders Carlsson 574315a0fa Add a BuildCXXTemporaryObjectExpr and use it so default arguments will be instantiated correctly for temporary object expressions.
llvm-svn: 80206
2009-08-27 05:08:22 +00:00
Anders Carlsson 55243168df In ActOnCXXTypeConstructExpr, check that the type is complete and non-abstract before creating any expressions. This assures that any templates are instantiated if necessary.
llvm-svn: 80200
2009-08-27 03:53:50 +00:00
Ted Kremenek 907a711f60 Simplify 'Environment' to contain only one map from 'const Stmt*' to SVals, greatly simplifying the logic of the analyzer in many places. We now only distinguish between block-level expressions and subexpressions in Environment::RemoveDeadBindings and GRState pretty-printing.
llvm-svn: 80194
2009-08-27 01:39:13 +00:00
Anders Carlsson eabf770457 New RequireNonAbstractType function.
llvm-svn: 80183
2009-08-27 00:13:57 +00:00
Anders Carlsson d624e16833 Bye-bye old RequireCompleteType.
llvm-svn: 80182
2009-08-26 23:45:07 +00:00
Mike Stump a0d0e6fcb1 Fixup codegen for static dispatch to a virtual function that was
almost correct.  :-)

llvm-svn: 80181
2009-08-26 23:38:08 +00:00
Fariborz Jahanian c71f094c08 ir-gen for type convesion of class objects. WIP.
llvm-svn: 80178
2009-08-26 23:31:30 +00:00
Douglas Gregor ce2a5e18f2 Make sure to bump the reference count of the last element in the ParenListExpr representing the direct initializer of a declaration
llvm-svn: 80177
2009-08-26 23:26:04 +00:00
Anders Carlsson 3c912f66c8 Remove another unused argument.
llvm-svn: 80175
2009-08-26 23:00:36 +00:00
Anders Carlsson 029fc690d3 Remove the PrintType argument from RequireCompleteType.
llvm-svn: 80174
2009-08-26 22:59:12 +00:00
Douglas Gregor c190523d7a When a member reference expression includes a qualifier on the member
name, e.g.,
  
  x->Base::f()

retain the qualifier (and its source range information) in a new
subclass of MemberExpr called CXXQualifiedMemberExpr. Provide
construction, transformation, profiling, printing, etc., for this new
expression type.

When a virtual function is called via a qualified name, don't emit a
virtual call. Instead, call that function directly. Mike, could you
add a CodeGen test for this, too?

llvm-svn: 80167
2009-08-26 22:36:53 +00:00
Anders Carlsson f68079e77b Add a RequireCompleteType variant that takes a PartialDiagnostic. The old RequireCompleteType now creates a PartialDiagnostic and calls the new function.
llvm-svn: 80165
2009-08-26 22:33:56 +00:00
Mike Stump 3722f5896c Regularize the case and sort.
llvm-svn: 80163
2009-08-26 22:31:08 +00:00
Douglas Gregor 402250f2f9 Implement support for C++ direct initializers that involve dependent
types or type-dependent expressions.

llvm-svn: 80143
2009-08-26 21:14:46 +00:00
Mike Stump 849416a388 More work for conversion functions.
llvm-svn: 80142
2009-08-26 21:11:25 +00:00
Mike Stump a5588bf3ac Implement virtual dispatch. :-) This is self-consistent with clang,
but not yet necessarily perfectly consistent with gcc.  Also addressed
Doug and John's comments.

llvm-svn: 80137
2009-08-26 20:46:33 +00:00
Fariborz Jahanian d79d5053bd AST for conversion by conversion functions. WIP.
llvm-svn: 80135
2009-08-26 20:34:58 +00:00
Eli Friedman 95f896380f Make address-space qualification work correctly for compound literals.
Issue reported on cfe-dev.

Also fixed the code to use isConstant to determine whether to generate a 
constant global, to be consistent with CodeGenModule.  This probably 
needs to be refactored to deal with C++, though.

llvm-svn: 80131
2009-08-26 20:01:39 +00:00
Anders Carlsson c24fc2949e More support for pseudo dtors.
llvm-svn: 80129
2009-08-26 19:22:42 +00:00
Fariborz Jahanian 1cec0c4c94 update to CXXFunctionalCastExpr to support ir-gen for
type convesions of class objects [class.conv]. WIP.

llvm-svn: 80127
2009-08-26 18:55:36 +00:00
Douglas Gregor 13789b3af2 Make sure to compare primary declaration contexts when determining whether a declaration is in scope
llvm-svn: 80126
2009-08-26 18:54:58 +00:00
Douglas Gregor 5e0962f944 When we know that we are parsing a class-name, implicitly construct a
TypenameType if getTypeName is looking at a member of an unknown
specialization. This allows us to properly parse class templates that
derived from type that could only otherwise be described by a typename type, 
e.g.,

  template<class T> struct X {};
  template<typename T> struct Y : public X<T>::X { }; 

Fixes PR4381.

llvm-svn: 80123
2009-08-26 18:27:52 +00:00
Anders Carlsson f571c11d54 Add Sema::BuildMemberReferenceExpr and have Sema::ActOnMemberReferenceExpr call it.
llvm-svn: 80122
2009-08-26 18:25:21 +00:00
Anders Carlsson e7b9d71aab Address some of Doug's comments.
llvm-svn: 80114
2009-08-26 17:36:19 +00:00
Douglas Gregor e9899d9769 Fix for overloaded binary operators whose operands need implicit
conversions, from Sylvere Teissier!

llvm-svn: 80112
2009-08-26 17:08:25 +00:00
Douglas Gregor 7e112b0d79 Source location information for ? and : in a ConditionalOperator, from Enea Zaffanella
llvm-svn: 80097
2009-08-26 14:37:04 +00:00
Douglas Gregor 66a985d16e Fix bug in __extension__ handling for declarations, from Abramo
Bagnara with a fix from Enea Zaffanella!

llvm-svn: 80094
2009-08-26 14:27:30 +00:00
Anders Carlsson 458055a890 Revert r80064 since it broke the build.
llvm-svn: 80066
2009-08-26 03:30:14 +00:00
Mike Stump fbddfdacdc Implement virtual dispatch. :-) This is self-consistent with clang, but not yet
necessarily perfectly consistent with gcc.

llvm-svn: 80064
2009-08-26 01:54:35 +00:00
Fariborz Jahanian 2c73b1d2a2 Simplified default construction of array data members
in the constructor prologue.

llvm-svn: 80060
2009-08-26 00:23:27 +00:00
Douglas Gregor 053f691d5e Improve diagnostics and recovery when the nested-name-specifier of a
qualified name does not actually refer into a class/class
template/class template partial specialization. 

Improve printing of nested-name-specifiers to eliminate redudant
qualifiers. Also, make it possible to output a nested-name-specifier
through a DiagnosticBuilder, although there are relatively few places
that will use this leeway.

llvm-svn: 80056
2009-08-26 00:04:55 +00:00
Anders Carlsson 7e3f0e4e0d Parsing of pseudo-destructors.
llvm-svn: 80055
2009-08-25 23:46:41 +00:00
Ted Kremenek c4c48be88e Fix regression in BasicStoreManager caused by implicitly casting loaded values and trying to load/store from arrays. RegionStoreManager already properly handles these cases well; we just need to gracefully not handle this case in BasicStoreManager. This fixes PR 4781.
llvm-svn: 80051
2009-08-25 23:29:04 +00:00
Ted Kremenek d1d6066be8 Handle pointer arithmetic in RegionStoreManager involving Objective-C pointers
when using the non-fragile Objective-C ABI.  This fixes <rdar://problem/7168531>.

llvm-svn: 80047
2009-08-25 22:55:09 +00:00
Douglas Gregor e861bac059 Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.

To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,

  template<typename X> template<typename Y>
  X Outer<X>::Inner1<Y>::foo(Y) {
    return X();
  }

we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.

Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.

llvm-svn: 80044
2009-08-25 22:51:20 +00:00
John McCall 76d824f3f9 Clarify the difference between substitution and instantiation by renaming
functions that don't instantiate definitions.

llvm-svn: 80037
2009-08-25 22:02:44 +00:00
Ted Kremenek 3ed9543ace Fix crash reported in <rdar://problem/7124210> by "back-porting" some of the
implicit cast logic in RegionStoreManager to BasicStoreManager. This involved
moving CastRetriedVal from RegionStoreManager to StoreManager.

llvm-svn: 80026
2009-08-25 20:51:30 +00:00
Ted Kremenek 3a459dc8c9 Move logic of GRExprEngine::EvalBinOp to SValuator::EvalBinOp.
llvm-svn: 80018
2009-08-25 18:44:25 +00:00
John McCall 1dfa9a9872 Modify an assert to capture the restriction on friend declarations more
accurately.  Prevents the assert from triggering incorrectly when friending 
functions first declared in extern "C" contexts.  Fixes bug 4757.

llvm-svn: 80016
2009-08-25 17:53:59 +00:00
Douglas Gregor 1d5e9f9368 Implement out-of-line definitions of nested class templates. Most of
the logic is there for out-of-line definitions with multiple levels of
nested templates, but this is still a work-in-progress: we're having
trouble determining when we should look into a dependent
nested-name-specifier. 

llvm-svn: 80003
2009-08-25 17:23:04 +00:00
Fariborz Jahanian 797cf62703 Skip over bases/fields with dependent types.
Fixes pr4771.

llvm-svn: 79999
2009-08-25 16:37:49 +00:00
Dan Gohman a98e0e73de Update clang for raw_fd_ostream no longer requiring F_Force.
llvm-svn: 79991
2009-08-25 15:36:09 +00:00
Anders Carlsson be96bc94e8 Handle the implicit 'this' parameter for format attributes.
llvm-svn: 79987
2009-08-25 14:12:34 +00:00
Anders Carlsson 114056f22c If a parameter has a default argument expression, make sure to instantiate the parameter type before checking that the expression is a valid initializer.
llvm-svn: 79986
2009-08-25 13:46:13 +00:00
Anders Carlsson 6c0a6e490c Emit conversion functions correctly.
llvm-svn: 79985
2009-08-25 13:14:46 +00:00
Anders Carlsson 10ebe78730 Improved support for default arguments in constructors for class templates.
llvm-svn: 79984
2009-08-25 13:07:08 +00:00
Zhongxing Xu 342950efc5 Remove CodeDecl and CFG from GRExprEngine and GRStateManager.
Now AnalysisManager is the only place we can get CodeDecl.
This leads to an API change: GRState::bindExpr() now takes the CFG argument.

llvm-svn: 79980
2009-08-25 06:51:30 +00:00
Anders Carlsson c1eb79b7c9 InitializeVarWithConstructor now returns true on failure.
llvm-svn: 79976
2009-08-25 05:18:00 +00:00
Anders Carlsson 6eb55575da BuildCXXConstructExpr now returns an OwningExprResult.
llvm-svn: 79975
2009-08-25 05:12:04 +00:00
Anders Carlsson 355933d096 Factor building of CXXDefaultArgExpr expressions out into a separate function.
llvm-svn: 79974
2009-08-25 03:49:14 +00:00
Zhongxing Xu 94ec649b33 Remove Decl and CFG from ExplodedGraph. This leads to a series small changes.
llvm-svn: 79973
2009-08-25 03:33:41 +00:00
Anders Carlsson 4562f1f066 Basic support for default argument expressions for function templates.
llvm-svn: 79972
2009-08-25 03:18:48 +00:00
Anders Carlsson c80a127c4d Factor setting default arguments out into SetParamDefaultArgument.
llvm-svn: 79970
2009-08-25 02:29:20 +00:00
Anders Carlsson 12e022ddbf Fix ivar layout map generation (hopefully).
llvm-svn: 79968
2009-08-25 02:07:02 +00:00
Anders Carlsson 5a532380a1 Use hasDefaultArg instead of getDefaultArg.
llvm-svn: 79967
2009-08-25 01:23:32 +00:00
Anders Carlsson f1c2695d48 Check that the default argument is well-formed before checking the initializer types.
llvm-svn: 79964
2009-08-25 01:02:06 +00:00
Douglas Gregor 9d01b5b40c Eliminate a GCC warning
llvm-svn: 79962
2009-08-25 00:17:23 +00:00
Fariborz Jahanian a6a3494c1d Remove #ifdef'out code.
llvm-svn: 79956
2009-08-24 23:16:37 +00:00
Douglas Gregor a3dff8e37a Keep track of the template parameter depth properly when we have
member templates declared inside other templates. This allows us to
match out-of-line definitions of member function templates within
class templates to the declarations within the class template. We
still can't handle out-of-line definitions for member class templates,
however.

llvm-svn: 79955
2009-08-24 23:03:25 +00:00
Ted Kremenek d6cfbafd3b ConstraintManager::AssumeDual now accepts a 'DefinedSVal' instead of 'SVal' for
the condition. This eliminates a source of bugs where the client doesn't
correctly reason about undefined or unknown values. This fixes PR 4759.

llvm-svn: 79952
2009-08-24 22:47:34 +00:00
Daniel Dunbar a6b4a3d646 PR4766: Don't pass -static to 'as' on x86_64 on Darwin.
Also, do pass -static even with -dynamic on i386.

llvm-svn: 79948
2009-08-24 22:26:16 +00:00
Fariborz Jahanian 7c07d5fed8 Remove ivarlayout bitmap optimization, instead if all zeros,
put out the bitmap when all objects are scanned.

llvm-svn: 79947
2009-08-24 21:55:06 +00:00
Douglas Gregor 4c95288f64 Don't try to evaluate an expression that is type- or value-dependent while building the CFG
llvm-svn: 79941
2009-08-24 21:39:56 +00:00
Douglas Gregor f2270430a1 Skip transparent contexts when performing C++ name lookup
llvm-svn: 79931
2009-08-24 18:55:03 +00:00
Anders Carlsson c327709db8 Handle array to pointer decay in EmitCastExpr and get rid of VisitImplicitCastExpr.
llvm-svn: 79930
2009-08-24 18:37:17 +00:00
Anders Carlsson 3df53bcf10 Handle CK_NullToMemberPointer in ScalarExprEmitter::EmitCast
llvm-svn: 79929
2009-08-24 18:26:39 +00:00
Anders Carlsson 15583e4493 Pass the cast kind to ScalarExprEmitter::EmitCastExpr.
llvm-svn: 79928
2009-08-24 18:12:39 +00:00
Anders Carlsson 83133d9a74 Use the right cast kind when comparing null to member pointers.
llvm-svn: 79927
2009-08-24 18:03:14 +00:00
Douglas Gregor b00b10eb2e Implement support for equality comparisons (!=, ==) of member
pointers, by extending the "composite pointer type" logic to include
member pointer types.

Introduce test cases for member pointer comparisons, including those
that involve the builtin operator candidates implemented earlier. 

llvm-svn: 79925
2009-08-24 17:42:35 +00:00
Chris Lattner e6434cb421 normalize the CharacterLiteral::getLocation method name, patch
by Enea Zaffanella!

llvm-svn: 79924
2009-08-24 17:39:36 +00:00
Fariborz Jahanian 20464fba70 Fixes pr4763.
llvm-svn: 79923
2009-08-24 17:19:23 +00:00
Anders Carlsson 867b48f713 More member pointer work.
llvm-svn: 79922
2009-08-24 17:16:23 +00:00
Anders Carlsson 4557b2c0c2 Remove dead code
llvm-svn: 79921
2009-08-24 16:52:33 +00:00
Douglas Gregor 8a2e601917 Try to complete a type before looking for conversion functions within
that type. Note that we do not produce a diagnostic if the type is
incomplete; rather, we just don't look for conversion functions. Fixes PR4660.

llvm-svn: 79919
2009-08-24 15:23:48 +00:00
Douglas Gregor 84605aeac9 Refactor the template-instantiation logic for expressions into a
generic tree transformation (also used for recanonicalization) and a
small amount of template-instantiation-specific logic.

llvm-svn: 79917
2009-08-24 13:43:27 +00:00