Commit Graph

9284 Commits

Author SHA1 Message Date
Chris Lattner 72cdcacb02 add helpful methods to TargetInfo for querying builtin integer type properties,
patch by Ken Dyck!

llvm-svn: 84746
2009-10-21 06:24:21 +00:00
Douglas Gregor 74ba25ca5a Improve diagnostics and template instantiation behavior when calling
an overloaded function call operator.

llvm-svn: 84745
2009-10-21 06:18:39 +00:00
Chris Lattner 6720492c39 hookize wint_t's definition, patch by Edward O'Callaghan (from PR5233).
llvm-svn: 84740
2009-10-21 04:59:34 +00:00
Mike Stump 7fe9cc1dd5 Prep work to always preallocate BlockDeclRefExprs so that we can
generate the debug information for the first parameter to the block
invoke functions.  WIP.

llvm-svn: 84737
2009-10-21 03:49:08 +00:00
John McCall b879435493 Revert those last two commits. Beware the treacherous semicolon.
llvm-svn: 84736
2009-10-21 03:40:01 +00:00
John McCall fb81159c30 Preserve type source information when substituting into ParmVarDecls.
Apparently I'm grinding my commit count.

llvm-svn: 84735
2009-10-21 02:50:40 +00:00
John McCall c30047ae8d Preserve type source information when substituting into FieldDecls.
llvm-svn: 84734
2009-10-21 02:42:37 +00:00
John McCall f1abcdcddd Preserve source information when substituting into VarDecls.
llvm-svn: 84733
2009-10-21 02:39:02 +00:00
John McCall 609459e070 Clone Sema::SubstType for DeclaratorInfos.
llvm-svn: 84724
2009-10-21 00:58:09 +00:00
John McCall de88989e5d Initialize using the base location provided by the derived implementation,
not the default one (which is always empty).

llvm-svn: 84721
2009-10-21 00:44:26 +00:00
Mike Stump 70197d5441 Fix 80-col violation.
llvm-svn: 84719
2009-10-21 00:42:55 +00:00
John McCall 550e0c2f0f Rewrite TreeTransform to transform types as DeclaratorInfos rather than as bare
QualTypes.  Don't actually exploit this yet.

llvm-svn: 84716
2009-10-21 00:40:46 +00:00
John McCall 26fe7e0b8a Add TypeLocBuilder, an API for incrementally creating TypeLocs. Change
the API for creating DeclaratorInfos to allow callers to provide an exact
size.

llvm-svn: 84715
2009-10-21 00:23:54 +00:00
Ted Kremenek ab929bb352 Remove stale comment and tighten code.
llvm-svn: 84697
2009-10-20 23:59:28 +00:00
Ted Kremenek 89e53fddb8 Add FIXME.
llvm-svn: 84696
2009-10-20 23:48:29 +00:00
Ted Kremenek 8aed49000d Use llvm::OwningPtr in CFGBuilder, fixing a leak on an error path.
llvm-svn: 84695
2009-10-20 23:46:25 +00:00
Fariborz Jahanian e4d94cee05 Code-gen for CXXZeroInitValueExpr AST passed
as argument to a function call. Removes a FIXME.

llvm-svn: 84694
2009-10-20 23:29:04 +00:00
Anders Carlsson b68b028a02 Change ResolveAddressOfOverloadedFunction to support TemplateIdRefExpr. No testcase yet because FixOverloadedFunctionReference needs to be updated too. Doug, plz review.
llvm-svn: 84693
2009-10-20 22:53:47 +00:00
Anders Carlsson 5789c497a0 Fix the 32-bit ABI to return structures with non-trivial copy ctors or dtors indirectly.
llvm-svn: 84686
2009-10-20 22:07:59 +00:00
Ted Kremenek d45ff6cced Add destructor and cleanup code to LocationContext (fixing some leaks). Along the way, have
AnalysisManager periodically cleanup its AnalysisContextManager and LocationContextManager objects,
as they don't need to forever retain all the CFGs ever created when analyzing a file.

llvm-svn: 84684
2009-10-20 21:39:41 +00:00
Mike Stump 38382028c7 For now, we need to have the llvm type of the block pointer remain as
it was.  Fixes codegen bug introduced yesterday.

llvm-svn: 84668
2009-10-20 20:30:01 +00:00
Fariborz Jahanian ac741ffd44 Moved comment to its proper place in my last patch.
llvm-svn: 84662
2009-10-20 20:07:35 +00:00
Fariborz Jahanian 9a587b0111 Patch implements ranking conversions between member pointers [over.ics.rank]
llvm-svn: 84660
2009-10-20 20:04:46 +00:00
Devang Patel e21912d1ae Do not eagerly cache DITypes because it allows real struct type to be shadowed by forward declared struct type.
llvm-svn: 84659
2009-10-20 19:55:01 +00:00
Daniel Dunbar f4534ee0a3 Driver: If unable to find the gcc tool chain, try the next OS rev.
llvm-svn: 84656
2009-10-20 19:25:43 +00:00
Devang Patel e4f2b2a8ac Encode global variable name in debug info.
llvm-svn: 84653
2009-10-20 18:26:30 +00:00
Daniel Dunbar 710a80d3ba Add missing semi-colon.
llvm-svn: 84650
2009-10-20 18:07:06 +00:00
Edward O'Callaghan 462e4ab4ac Bring Darwin into the switch-case statement instead of its own if for readability.
llvm-svn: 84646
2009-10-20 17:22:50 +00:00
Fariborz Jahanian 040d75d9b6 Issue warning if method body starts with a semicolon.
Fixes 
<rdar://problem/7308503> clang should disallow the trailing semicolon in method definitions

llvm-svn: 84645
2009-10-20 16:39:13 +00:00
Eli Friedman 06ed2a5c94 Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers.  Switch a few other users of CK_Unknown to proper cast 
kinds.

Note that there are still some situations where we end up with 
CK_Unknown; they're pretty easy to find with grep. There 
are still a few missing conversion kinds, specifically 
pointer/int/float->bool and the various combinations of real/complex 
float/int->real/complex float/int.

llvm-svn: 84623
2009-10-20 08:27:19 +00:00
Ted Kremenek 2e385f9319 Call 'clear()' in ~RopePieceBTreeLeaf(), decrementing the reference
counts of the bufffers referened by the RopePieces in
RopePieceBTreeLeaf.  This (I believe) corrently fixes the leak I meant
to fix in r84601 (which ended up causing an overrelease).

llvm-svn: 84615
2009-10-20 06:31:34 +00:00
Douglas Gregor a5cb6da0cd Handle substitutions into the "first qualifier in scope" of a
qualified member access expression (e.g., t->U::member) when that
first qualifier refers to a template parameters.

llvm-svn: 84612
2009-10-20 05:58:46 +00:00
Ted Kremenek 988c5811ee Revert 84601. Looks like it was causing failures on some systems.
llvm-svn: 84610
2009-10-20 05:53:05 +00:00
Chris Lattner bd19b18100 Implement PR5242: don't desugar a type more than once in a diagnostic. This
implements a framework that allows us to use information about previously
substituted values to simplify subsequent ones.  Maybe this would be useful
for C++'y stuff, who knows.  We now get:

t.c:4:21: error: invalid operands to binary expression ('size_t' (aka 'unsigned long *') and 'size_t')
  return (size_t) 0 + (size_t) 0;
         ~~~~~~~~~~ ^ ~~~~~~~~~~

on the testcase.  Note that size_t is only aka'd once.

llvm-svn: 84604
2009-10-20 05:36:05 +00:00
Chris Lattner c243f299ce teach FormatDiagnostic to aggregate previously formatted arguments and
pass them down into the ArgToStringFn implementation.  This allows 
redundancy across operands to a diagnostic to be eliminated.

This isn't used yet, so no functionality change.

llvm-svn: 84602
2009-10-20 05:25:22 +00:00
Ted Kremenek 2f9876cf7c Fix a reference count imbalance in RewriteRope::MakeRopeString().
This was causing a ton of memory to be leaked when using HTML
diagnostics with the static analyzer (on large files with many errors).

llvm-svn: 84601
2009-10-20 05:25:11 +00:00
Chris Lattner dac91470d7 code cleanup, convert if tree to switch etc.
llvm-svn: 84599
2009-10-20 05:12:36 +00:00
Mike Stump d015328f15 Refine the type of the first parameter to block invoke functions.
WIP.  I have yet to find the magic incantation to get the structure
type to be defined.  If someone has a pointer, love to hear it.

llvm-svn: 84590
2009-10-20 02:12:22 +00:00
Ted Kremenek 481c121ab5 RegionStore: Use the *default* binding (instead of the *direct* binding) of an Objective-C object
region when doing lazy value retrieval of an ivar.

This fixes: <rdar://problem/7312221>

llvm-svn: 84584
2009-10-20 01:20:57 +00:00
Ted Kremenek 90c953e98f retain/release checker: allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when determining Cocoa fundamental rule.
Fixes: <rdar://problem/7265711>
llvm-svn: 84569
2009-10-20 00:13:00 +00:00
Fariborz Jahanian a4a9334a50 Builtin candidate minimization for
<<=, >>= and the rest.

llvm-svn: 84568
2009-10-20 00:04:40 +00:00
Douglas Gregor c59e56190e Parse a simple-template-id following a '~' when calling a destructor, e.g.,
t->~T<A0, A1>()

Fixes PR5213.

llvm-svn: 84545
2009-10-19 22:04:39 +00:00
Ted Kremenek 428c637ada The constructor for ASTUnit now takes a DiagnosticClient*, allowing uses of ASTUnit to specify
alternate DiagnosticClients. To match this API, ASTUnit::LoadFromPCHFile() now takes a corresponding
DiagnosticClient* argument as well. The DiagnosticClient object is destroyed when the ASTUnit object
is destroyed.

The CIndex library now uses this API to create a 'IgnoreDiagnosticsClient' that simply silences
diagnostics when using the clang_createTranslationUnitFromSourceFile() function. This fixes
<rdar://problem/7312058>. This API can change in the future as we add more flexibility for clients.

llvm-svn: 84539
2009-10-19 21:44:57 +00:00
Fariborz Jahanian b9e8c42ee6 Add the built-in candidate set reduction hueristic
to '+=', '-=', '*=' and '/=' builtin operators and
fixes a logic bug exposed by doing this.

llvm-svn: 84538
2009-10-19 21:30:45 +00:00
Fariborz Jahanian 996a6aa3f1 Copy conversion of an expression to its base class
is a standard convesion and not a user-defined
conversion.

llvm-svn: 84525
2009-10-19 19:18:20 +00:00
Anders Carlsson 0999aafda5 Handle emitting the assignment operator when the lhs is a reference. Fixes PR5227.
llvm-svn: 84518
2009-10-19 18:28:22 +00:00
Anders Carlsson 027732b5b9 Set the cast kind to CK_NoOp for C-style casts that are really const casts. Fixes PR5248.
llvm-svn: 84514
2009-10-19 18:14:28 +00:00
Steve Naroff 505fb84ed9 Move Diagnostic/DiagClient/FileManager from Indexer => ASTUnit.
Removing this shared data should enable clang_createTranslationUnit/clang_createTranslationUnitFromSourceFile to be run from multiple threads (related to <rdar://problem/7303432>).

llvm-svn: 84499
2009-10-19 14:34:22 +00:00
Daniel Dunbar 28a24fdbbc Workaround a bug exposed by the FileCheckify of message-length.c, the caret end
column computation isn't correct and could exceed the line length, which
resulted in a buffer overflow later.
 - Chris, is there a better way for this code to compute the final column used
   by the caret?

llvm-svn: 84475
2009-10-19 09:11:21 +00:00
Edward O'Callaghan f208b55825 AuroraUX toolchain should call GNU assembler not the Solaris assembler.
llvm-svn: 84469
2009-10-19 07:02:08 +00:00
Daniel Dunbar d238681113 Avoid std::string concatenation.
llvm-svn: 84458
2009-10-19 01:21:19 +00:00
Daniel Dunbar b5aacc282c Twinify CodeGenFunction::CreateTempAlloca
llvm-svn: 84456
2009-10-19 01:21:05 +00:00
Daniel Dunbar 3d6f651652 Suppress build warning.
llvm-svn: 84453
2009-10-19 01:20:42 +00:00
Anders Carlsson 69c2c4becc When binding a reference to a temporary, it's important that other temporaries created as on the RHS are destroyed before emitting the dtor for the temporary.
llvm-svn: 84451
2009-10-18 23:09:21 +00:00
Anders Carlsson 8f741bfad7 When building a cast argument, make sure to bind the result to a temporary.
llvm-svn: 84448
2009-10-18 21:20:14 +00:00
Daniel Dunbar 07d0785dbb PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

llvm-svn: 84447
2009-10-18 21:17:35 +00:00
Daniel Dunbar 349e6fbfce Twinify CGObjCMac, this simplifies the code and should reduce std::string
trashing.

llvm-svn: 84439
2009-10-18 20:48:59 +00:00
Anders Carlsson 9500ad13b0 Use CK_BitCast for member function pointer casts. Fixes PR5138.
llvm-svn: 84438
2009-10-18 20:31:03 +00:00
Daniel Dunbar 70e7eadd15 Move misc clients to IdentifierInfo StringRef API.
- strcmp -> ==
 - OS.write(II->getName() ...) -> OS << II->getNameStr()
 - Avoid std::string concatenation
 - Use getNameStr().str() when an std::string is really needed.

llvm-svn: 84437
2009-10-18 20:26:27 +00:00
Daniel Dunbar 2c422dc9ca Move clients to use IdentifierInfo::getNameStart() instead of getName()
llvm-svn: 84436
2009-10-18 20:26:12 +00:00
Nate Begeman 19351639fb Support IRgen of OpenCL vector initializers, ensuring the resulting IR is in a
form that LLVM code generators can turn into efficient code.  For example,
int4 a, b, c;
a = (int4)(b.yzw, a.x)

llvm-svn: 84434
2009-10-18 20:10:40 +00:00
Anders Carlsson 7001794302 It's OK for a pure virtual function to override another pure virtual function. Fixes PR5222.
llvm-svn: 84428
2009-10-18 19:34:08 +00:00
Benjamin Kramer beb873d84a Add FloatingCast to getCastKindName's list.
llvm-svn: 84427
2009-10-18 19:02:15 +00:00
Anders Carlsson 094c459525 Add some more cast kinds.
llvm-svn: 84423
2009-10-18 18:12:03 +00:00
Nuno Lopes ff3507b951 add support for codegening CXXZeroInitValueExprs
llvm-svn: 84418
2009-10-18 15:18:11 +00:00
Edward O'Callaghan 9dda8e98d4 The AuroraUX toolchain has conflicting wchar_t between the system stdlib.h header and the clang stddef.h header where clang was defining as int where we use long.
llvm-svn: 84416
2009-10-18 13:33:59 +00:00
Benjamin Kramer 6c839f827c Use sys::Path::eraseFromDisk instead of unlink as suggested by Chris.
llvm-svn: 84415
2009-10-18 11:34:14 +00:00
John McCall cebee16bc0 When performing template-substitution into a type, don't just replace the
TemplateTypeParmType with the substituted type directly;  instead, replace it
with a SubstTemplateTypeParmType which will note that the type was originally
written as a template type parameter.  This makes it reasonable to preserve
source information even through template substitution.

Also define the new SubstTemplateTypeParmType class, obviously.

For consistency with current behavior, we stringize these types as if they
were the underlying type.  I'm not sure this is the right thing to do.
At any rate, I paled at adding yet another clause to the don't-desugar 'if'
statement, so I extracted a function to do it.  The new function also does
The Right Thing more often, I think:  e.g. if we have a chain of typedefs
leading to a vector type, we will now desugar all but the last one.

llvm-svn: 84412
2009-10-18 09:09:24 +00:00
Zhongxing Xu 775a2c08c8 use DenseSet instead of SmallSet.
llvm-svn: 84398
2009-10-18 04:15:47 +00:00
Daniel Dunbar c04294035f Add another two ExtVectorComponent FIXMEs.
llvm-svn: 84393
2009-10-18 02:09:38 +00:00
Daniel Dunbar ce5a0b3deb Switch ExtVectorElementExpr::getEncodedElementAccess to use StringRef.
- Really this should be simplified by the FIXME above, but I'm too deep in DFS.

llvm-svn: 84392
2009-10-18 02:09:31 +00:00
Daniel Dunbar afff4340d5 Simplify HandleModeAttr.
llvm-svn: 84391
2009-10-18 02:09:24 +00:00
Daniel Dunbar ccbd9a46e7 Simplify HandleFormatAttr.
- I have this crazy dream that one day someone will invent a miraculous tool so
   that developers, instead of hand optimizing their source code to obscure its
   intent and decrease its maleability, will instead write what they mean, and
   this strange and wonderful tool -- which I imagine would be called something
   fancy sounding like "an optimizing compiler" -- will make their code fast
   *for* them. With all the saved time, developers could maybe even focus on
   making the magic "optimizing compiler" better!!

 - No intended functionality change, all though I expect the universe to mock me
   for snarkiness.

llvm-svn: 84390
2009-10-18 02:09:17 +00:00
Daniel Dunbar cb2a056980 Add FIXME... maybe Nate will get bored? :)
llvm-svn: 84389
2009-10-18 02:09:09 +00:00
John McCall 1700197e65 Clone the full Type hierarchy into the TypeLoc hierarchy. Normalize
TypeLoc class names to be $(Type classname)Loc.  Rewrite the visitor.
Provide skeleton implementations for all the new TypeLocs.

Handle all cases in PCH.  Handle a few more cases when inserting
location information in SemaType.

It should be extremely straightforward to add new location information
to existing TypeLoc objects now.

llvm-svn: 84386
2009-10-18 01:05:36 +00:00
Daniel Dunbar 125c9c98f7 Simplify ExtVectorElementExpr::containsDuplicateElements().
llvm-svn: 84380
2009-10-17 23:53:04 +00:00
Daniel Dunbar ebd5b4a3aa Avoid std::string concatenation.
llvm-svn: 84378
2009-10-17 23:52:50 +00:00
Daniel Dunbar f8502d50f7 Switch to llvm::HashString.
llvm-svn: 84375
2009-10-17 23:52:28 +00:00
Nuno Lopes 24241d249e add gentoo x86 2009.1 (gcc 4.3.4) include paths
llvm-svn: 84371
2009-10-17 23:11:14 +00:00
Douglas Gregor 0b3d95ae64 Fix a crash with qualified member access into a non-type, from Sean Hunt!
llvm-svn: 84370
2009-10-17 22:37:54 +00:00
Douglas Gregor 4bbd1acf8b When type-checking a C++ "new" expression, don't type-check the actual
initialization if any of the constructor/initialization arguments are
type-dependent. Fixes PR5224.

llvm-svn: 84365
2009-10-17 21:40:42 +00:00
Sebastian Redl df4b80e7c0 When resolving the address of an overloaded function or function template, mark the result as referenced.
The most important effect of this is that function templates only referenced by address expressions now get instantiated. This, in turn, means that Hello World compiles with the Apache stdcxx library even when using endl.

llvm-svn: 84363
2009-10-17 21:12:09 +00:00
Sebastian Redl fef1c0d54f Don't add implicit casts of explicit address-taking of overloaded functions.
Taking the address of an overloaded function with an explicit address-of operator wrapped the operator in an implicit cast that added yet another pointer level, leaving us with a corrupted AST, which crashed CodeGen in the test case I've added. Fix this by making FixOverloadedFunctionReference return whether there was an address-of operator and not adding the implicit cast in that case.

llvm-svn: 84362
2009-10-17 20:50:27 +00:00
Daniel Dunbar 283ccf4342 Use StringExtra's HashString instead of BernsteinHash.
llvm-svn: 84360
2009-10-17 20:43:58 +00:00
Chris Lattner ec3a1565f6 teach getCorrespondingUnsignedType how to handle vectors of integers,
fixing PR4838.

llvm-svn: 84353
2009-10-17 20:33:28 +00:00
Sebastian Redl 548e629e02 In some dependent contexts, incomplete array types persist into FinalizeDeclaratorGroup. Don't require them to have a complete type. This allows us to compile Hello World with the Apache stdcxx library. If you don't use endl, it even links and runs.
llvm-svn: 84347
2009-10-17 19:37:06 +00:00
Edward O'Callaghan 93135aad29 Fix for PR5190, Credit to Zhanyong Wan.
llvm-svn: 84346
2009-10-17 19:32:54 +00:00
Daniel Dunbar 1c0761d6e9 Avoid std::string thrashing in MultiKeywordSelector::getName(), and simplify.
llvm-svn: 84343
2009-10-17 18:13:02 +00:00
Daniel Dunbar acb5a4b57c Simplify more.
llvm-svn: 84342
2009-10-17 18:12:53 +00:00
Daniel Dunbar 9d9aa167e6 Simplify.
llvm-svn: 84341
2009-10-17 18:12:45 +00:00
Daniel Dunbar e81a553162 Use raw_ostream instead of C stdio.
llvm-svn: 84340
2009-10-17 18:12:37 +00:00
Daniel Dunbar 5bf78579bd Rewrite AttributeList::getKind to use StringRef API.
llvm-svn: 84339
2009-10-17 18:12:29 +00:00
Daniel Dunbar 403073e471 Simplify.
llvm-svn: 84338
2009-10-17 18:12:21 +00:00
Daniel Dunbar e36337910f Use raw_ostream for formatting integers, and use IdentifierInfo::getNameStr
instead of getName.
 - -2 FIXMEs.

llvm-svn: 84337
2009-10-17 18:12:14 +00:00
Ted Kremenek 9f3a643bad Minor cleanup: move typedef out of anonymous namespace (which now contains nothing) and into RemoveDeadBindings. No functionality change.
llvm-svn: 84335
2009-10-17 17:45:11 +00:00
Douglas Gregor 4505315726 Write the preprocessor block after we write out types + declarations,
so that we catch any macros used within the declarations and types. 

Also, properly store a NULL selector.

llvm-svn: 84334
2009-10-17 17:25:45 +00:00
Daniel Dunbar 1d4172c52b Suppress -Asserts warning.
llvm-svn: 84329
2009-10-17 09:39:30 +00:00
Zhongxing Xu c0c6508981 Per discussion with Ted, the 'FromSuper'/'FromSub' logic is invalid. Simplify
the code to standard worklist algorithm. Always add both sub and super 
regions of live regions.

llvm-svn: 84323
2009-10-17 08:39:24 +00:00
Ted Kremenek 1baf407fbc Fix another static analyzer crash due to a corner case in "folding" symbolic values that are constrained to be a constant.
llvm-svn: 84320
2009-10-17 07:39:35 +00:00
Zhongxing Xu 8b2f5d3929 Actually all regions whose super region is not MemSpaceRegion are of these 3
kinds. This means we are visiting all regions 'from super region'.

llvm-svn: 84319
2009-10-17 07:32:08 +00:00
Daniel Dunbar 68d9d7b319 Don't crash when dumping pretty stack traces, if the current tok is an
annotation token.
 - I'm not sure what the best thing to print is, for now we just print the token
   location and 'at annotation token'.

llvm-svn: 84312
2009-10-17 06:13:04 +00:00
Chris Lattner 671fec8727 Fix PR5211: codegen shouldn't assume that the result of ||/&& is int
anymore.  In C++ it is bool.

llvm-svn: 84308
2009-10-17 04:24:20 +00:00
Daniel Dunbar 6e924a3090 Simplify.
llvm-svn: 84307
2009-10-17 03:28:56 +00:00
Daniel Dunbar a80c07e8e6 Add Ubuntu 9.04 C++ search path.
llvm-svn: 84301
2009-10-17 03:19:56 +00:00
Ted Kremenek 8bcb1c6883 Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created ASTContext to use
its own BumpPtrAllocator to allocate ASTs.

Change clang_createTranslationUnit (CIndex) to pass 'UseBumpPtrAllocator = true' to
ASTUnit::LoadFromPCHFile().

llvm-svn: 84296
2009-10-17 00:34:24 +00:00
Douglas Gregor 12bfa3859d Merge the "types" and "declarations" blocks in the precompiled header
format, so that we don't end up with multiple declaration and types
blocks. Also, fix a few obscure bugs with PCH loading and generation:

  - If the DeclIDs DenseMap reallocates while we are writing a
    declaration (due to recursively writing other declarations), we
    could end up writing a bad ID to ExternalDefinitions.
  - When loading an ArrayLoc (part of DeclaratorInfo), we need to set
    the size expression to NULL if no size expression was provided.

PCH -> AST rewriting is still partly broken, unfortunately.

llvm-svn: 84293
2009-10-17 00:13:19 +00:00
Fariborz Jahanian 956127de22 Patch to clean up and improve visual display of
builtin function ambiguity.

llvm-svn: 84289
2009-10-16 23:25:02 +00:00
Douglas Gregor 8655e88603 While writing source-location entries to a PCH file, go through an
interface that can load those source-location entries on demand (from
another PCH file).

llvm-svn: 84287
2009-10-16 22:46:09 +00:00
John McCall 1f1a097f66 Allow TypeLocs to be fully initialized with a single SourceLocation. This
will be the keystone of converting existing rewrites to be rewrites on TypeLocs.

llvm-svn: 84286
2009-10-16 22:31:57 +00:00
Fariborz Jahanian b06ec054fc Use VisibleQuals to control setting of Volatile/Restrict qualifiers on
candidate types in BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants
further trimming the overload candidate set.

llvm-svn: 84281
2009-10-16 22:08:05 +00:00
John McCall 8f115c6b45 Factor out routines to encode/decode DeclaratorInfos and move them into the
core PCH reader/writer implementation files.

llvm-svn: 84278
2009-10-16 21:56:05 +00:00
Ted Kremenek 70bf6d6102 Fix static analyzer crash due to recently add symbolic-value constant folding. The issue was falsely
converting the constant value of the LHS of a '<<'/'>>' operation to the same APSInt value of the
RHS.

llvm-svn: 84269
2009-10-16 20:46:24 +00:00
Douglas Gregor 16bef857d9 Keep track of whether declararions were loaded from a precompiled
header or not via a new "PCHLevel" field in Decl. We currently use
this information to help CIndex filter out declarations that came from
a precompiled header (rather than from an AST file). Further down the
road, it can be used to help implement multi-level precompiled
headers.

llvm-svn: 84267
2009-10-16 20:01:17 +00:00
Edward O'Callaghan 7d3c275526 dynamic linker arg is incorrectly invoking gnu ld arg syntax instead of svr4 ld syntax in AuroraUX toolchain.
llvm-svn: 84266
2009-10-16 19:44:18 +00:00
Fariborz Jahanian da21efb566 Implement derived-to-base AST/code gen. There is a
FIXME in CGCXX.cpp that I would like Anders to
take a look at.

llvm-svn: 84265
2009-10-16 19:20:59 +00:00
Douglas Gregor d2eb58abac Add support for a chain of stat caches in the FileManager, rather than
only supporting a single stat cache. The immediate benefit of this
change is that we can now generate a PCH/AST file when including
another PCH file; in the future, the chain of stat caches will likely
be useful with multiple levels of PCH files.

llvm-svn: 84263
2009-10-16 18:18:30 +00:00
Chris Lattner a96d427966 Implement PR4407 - missing warnings on case value overflow,
patch by Zhanyong Wan!

llvm-svn: 84259
2009-10-16 16:45:22 +00:00
Nuno Lopes 8550cb250c ignore 'using' directive in CodeGenFunction::EmitDecl(). this fixes PR5085
llvm-svn: 84255
2009-10-16 14:40:52 +00:00
Nuno Lopes 275225dd05 fix -ansi in c++: it means -std=c++98
llvm-svn: 84254
2009-10-16 14:28:06 +00:00
Anders Carlsson 43d70f874d Add CK_VectorSplat and use it for casting non-pointer scalars to ExtVectors.
llvm-svn: 84245
2009-10-16 05:23:41 +00:00
Anders Carlsson 525b76b59c Make CheckVectorCast return a CastKind. Reduce nesting of if statements in CheckCastTypes.
llvm-svn: 84242
2009-10-16 02:48:28 +00:00
Anders Carlsson ef918ac840 Add a ToVoid cast kind and start using it.
llvm-svn: 84241
2009-10-16 02:35:04 +00:00
Chris Lattner cb4e68c340 increase helpfulness of assert message.
llvm-svn: 84240
2009-10-16 02:34:51 +00:00
Anders Carlsson f847117ac8 Builtin types are subsitutable if they are qualified. Fixes PR5196.
llvm-svn: 84237
2009-10-16 02:06:06 +00:00
Anders Carlsson 35a99d95b3 The result type of logical || and && is bool in C++. Fixes PR5206.
llvm-svn: 84231
2009-10-16 01:44:21 +00:00
John Thompson 1faca9e0fb Work-around wchar_t and __pragma problem in VC headers
llvm-svn: 84227
2009-10-16 01:12:00 +00:00
Ted Kremenek 1eb68096a2 retain/release checker: Stop tracking reference counts for any symbols touched by StoreManager::InvalidateRegion().
This fixes <rdar://problem/7257223> and <rdar://problem/7283470>.

llvm-svn: 84223
2009-10-16 00:30:49 +00:00
John McCall c5b8225285 Remove the ConstantArrayType subtypes. This information is preserved in the
TypeLoc records for declarations;  it should not be necessary to represent it
directly in the type system.

Please complain if you were using these classes and feel you can't replicate
previous functionality using the TypeLoc API.

llvm-svn: 84222
2009-10-16 00:14:28 +00:00
Anton Korobeynikov 051913bb86 Disallow arbitrary custom inline asm constraints for msp430.
llvm-svn: 84219
2009-10-15 23:17:13 +00:00
Douglas Gregor 78236a0788 Improve point-of-instantiation location information for members of class templates
llvm-svn: 84217
2009-10-15 23:05:15 +00:00
Douglas Gregor 12e49d3250 Make the remaining explicit-instantiation semantic action use
CheckSpecializationInstantiationRedecl to check for
redeclarations/instantiations. Also fixes a longstanding issue where
our explicit-instantiation location information wasn't as good as it
could have been.

llvm-svn: 84216
2009-10-15 22:53:21 +00:00
Ted Kremenek 4e45d80bfe Educate the retain/release checker about [NSCursor dragCopyCursor].
This fixes <rdar://problem/7306898>

llvm-svn: 84213
2009-10-15 22:26:21 +00:00
Ted Kremenek 55adb821e8 retain/release checker: Use simpler utility method for creating class method summaries. No functionality change.
llvm-svn: 84210
2009-10-15 22:25:12 +00:00
Steve Naroff 44cd60eebe Make sure temporary files get unlinked.
llvm-svn: 84208
2009-10-15 22:23:48 +00:00
Daniel Dunbar cbc34b769e Driver: Default to using PTH for C++ precompiled header support, PCH for C++
isn't implemented yet.
 - <rdar://problem/7297571> Clang should use pretokenized headers for C++ PCH
   files

llvm-svn: 84197
2009-10-15 20:02:44 +00:00
Douglas Gregor 8f003d0fa3 Make sure that we're diagnosing duplicate explicit instantiation definitions.
llvm-svn: 84189
2009-10-15 18:07:02 +00:00
Douglas Gregor 3d7e69f2c9 Simplify checking of explicit template specialization/explicit
instantiation redeclaration semantics for function template
specializations and member functions of class template
specializations. Also, record the point of instantiation for
explicit-instantiated functions and static data members.

llvm-svn: 84188
2009-10-15 17:21:20 +00:00
Fariborz Jahanian 3b937fa298 Apply heuristics to cut back on number of candidate
sets of builtin operators. Currently, it is applied 
to '++' and '->*' operators. I need to apply it to others
as well. Also, heuristics need be applied to 
BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants.
This is WIP.

llvm-svn: 84187
2009-10-15 17:14:05 +00:00
Douglas Gregor d6ba93dc6e Check the interactions between explicit instantiations and template
specializations. Work in progress; there's more cleanup required to
actually use the new CheckSpecializationInstantiationRedecl checker
uniformly.

llvm-svn: 84185
2009-10-15 15:54:05 +00:00
Douglas Gregor a8b89d2622 Diagnose explicit instantiations of function templates and member
functions/static data members of class template specializations that
do not have definitions. This is the latter part of [temp.explicit]p4;
the former part still needs more testing.

llvm-svn: 84182
2009-10-15 14:05:49 +00:00
Douglas Gregor 68edf13213 More explicit template instantiation. Now we're checking for more
cases where an explicit instantiation requires a definition; the
remainder of these checks will come with the implementation of
paragraph 4 of [temp.explicit].

llvm-svn: 84181
2009-10-15 12:53:22 +00:00
Mike Stump 8bccbfdafe Refine non-virtual part of the this adjustment for thunks. Refine
non-virtual part of the return result adjustments for covariant
thunks.  WIP.

llvm-svn: 84178
2009-10-15 09:30:16 +00:00
Edward O'Callaghan d8712d9143 AuroraUX toolchain fixes.
llvm-svn: 84176
2009-10-15 07:44:07 +00:00
John McCall 33815690af Better living through metaprogramming. Create a base class which abstracts
most of the unsafe boilerplate out of TypeLoc.  Create a QualifiedLoc class
to represent the idea that we *might* start representing source locations
of qualifiers.  Dealing with qualifiers explicitly like this also lets us
efficiently ignore them in all the concrete cases.

This should make it obvious and easy to add new TypeLoc subclasses.

llvm-svn: 84168
2009-10-15 03:50:32 +00:00
Mike Stump 37dbe96a06 Track the offset to the current virtual base in CurrentVBaseOffset.
Track path information completely to ensure we get all the overrides.  WIP.

llvm-svn: 84166
2009-10-15 02:04:03 +00:00
Ted Kremenek 3abc41f45d Per an astute observation from Zhongxing Xu, remove a "special case" logic in
RegionStoreManager::Retrieve() that was intended to handle conflated uses of pointers as integers.
It turns out this isn't needed, and resulted in inconsistent behavior when creating symbolic values on the following test case in 'tests/Analysis/misc-ps.m':

  typedef struct _BStruct { void *grue; } BStruct;
  void testB_aux(void *ptr);
  void testB(BStruct *b) {
    {
      int *__gruep__ = ((int *)&((b)->grue));
      int __gruev__ = *__gruep__;
      testB_aux(__gruep__);
    }
    {
      int *__gruep__ = ((int *)&((b)->grue));
      int __gruev__ = *__gruep__;
      if (~0 != __gruev__) {}
    }
  }

When the code was analyzed with '-arch x86_64', the value assigned to '__gruev__' be would be a
symbolic integer, but for '-arch i386' the value assigned to '__gruev__' would be a symbolic region
(a blob of memory). With this change the value created is always a symbolic integer.

Since the code being removed was added to support analysis of code calling
OSAtomicCompareAndSwapXXX(), I also modified 'test/Analysis/NSString.m' to analyze the code in both
'-arch i386' and '-arch x86_64', and also added some complementary test cases to test the presence
of leaks when using OSAtomicCompareAndSwap32Barrier()/OSAtomicCompareAndSwap64Barrier() instead of
just their absence. This code change reveals that previously both RegionStore and BasicStore were
handling these cases wrong, and would never cause the analyzer to emit a leak in these cases (false
negatives). Now RegionStore gets it right, but BasicStore still gets it wrong (and hence it has been
disabled temporarily for this test case).

llvm-svn: 84163
2009-10-15 01:40:34 +00:00
Anders Carlsson 66413c29d3 Handle
struct A { };
struct B : A { };

void f() {
  const A& a = B();
}

correctly. (This now does the offset conversion if necessary and calls the destructor when a goes out of scope).

llvm-svn: 84162
2009-10-15 00:51:46 +00:00
Anders Carlsson 63dce02544 Check the return type when calling pointer to member functions.
llvm-svn: 84161
2009-10-15 00:41:48 +00:00
Ted Kremenek 8070b82d91 Remove stale comment.
llvm-svn: 84157
2009-10-14 23:58:34 +00:00
Douglas Gregor ba8e1ac3a1 CheckTemplateSpecializationScope isn't going to be used for explicit
instantiations, since the requirements are too different from those
for template specializations. Simplify it slightly.

llvm-svn: 84156
2009-10-14 23:50:59 +00:00
Douglas Gregor e47f5a76cc Additional semantic checking for explicit template instantiations,
focusing on the scope- and qualifier-related semantic requirements in
C++ [temp.explicit]p2.

llvm-svn: 84154
2009-10-14 23:41:34 +00:00
Douglas Gregor 5d85197edf Reuse some code for checking the scope of an explicit instantiation
llvm-svn: 84148
2009-10-14 21:46:58 +00:00
Douglas Gregor 819c3ddda8 Fix a thinko that John pointed out
llvm-svn: 84142
2009-10-14 21:36:34 +00:00
Douglas Gregor 3cc3cdeea9 Give explicit and implicit instantiations of static data members of
class templates the proper linkage. 

Daniel, please look over the CodeGenModule bits.

llvm-svn: 84140
2009-10-14 21:29:40 +00:00
Douglas Gregor 3c74d41d27 Testing and some minor fixes for explicit template instantiation.
llvm-svn: 84129
2009-10-14 20:14:33 +00:00
Mike Stump b21c4eede4 Shift the vcall slots for non-virtual bases of a virtual base, up into
the virtual base so they can be reused properly.  Don't reuse vcall
slots across a virtual boundary.  WIP.  I have a testcase, but there
are still things that need to be fixed before the testcase can go in.

llvm-svn: 84120
2009-10-14 18:14:51 +00:00
Douglas Gregor 568a071dd2 When mapping from an injected-class-name to its corresponding
template, make sure to get the template that corresponds to *this*
declaration of the class template or specialization, rather than the
canonical specialization. Fixes PR5187.

llvm-svn: 84119
2009-10-14 17:30:58 +00:00
Rafael Espindola 0a1ac331a3 Add support for having different c++ search dirs with -m32 and -m64. So far
this is only used in darwin10, 64 bit ubuntu 9.10 and 64 bit openSUSE 11.1.

llvm-svn: 84115
2009-10-14 17:09:44 +00:00
Devang Patel f33cfaf760 Copy metadata associated with CI
llvm-svn: 84114
2009-10-14 17:03:29 +00:00
Douglas Gregor 4aa2dc41dc Implement support for overloaded operator uses that result to a call
to a member operator template. We missed updating this call site when
adding support for function templates; bug exposed by a test for
PR5072.

llvm-svn: 84111
2009-10-14 16:50:13 +00:00
Duncan Sands cef56992b0 There is now only one version of eh.selector and eh.typeid.for.
Fix the clang build.

llvm-svn: 84107
2009-10-14 16:13:30 +00:00
Sebastian Redl a44822fdb6 Have the exception specification checkers take partial diagnostics. Use this to merge two diagnostics.
llvm-svn: 84105
2009-10-14 16:09:29 +00:00
Sanjiv Gupta 84a0287497 Few targets like PIC16 mangle the names of global variables, so retrieve the name
from Var itself rather than the decl for DebugInfo metadata.

llvm-svn: 84102
2009-10-14 15:08:34 +00:00
Sebastian Redl 184edcadbd Use CanQualType in the exception specification verification type sets.
llvm-svn: 84101
2009-10-14 15:06:25 +00:00
Chris Lattner a3d4f16b12 Teach Lexer::MeasureTokenLength to be able to measure the
length of comment tokens.  Patch by Abramo Bagnara!

llvm-svn: 84100
2009-10-14 15:04:18 +00:00
Sebastian Redl 7eb5d377d7 Use partial diagnostics properly in call to RequireCompleteType. Among other things, this means we get a note on the declaration of the incomplete type when it is used in an exception specification.
llvm-svn: 84099
2009-10-14 14:59:48 +00:00
Sebastian Redl 075b21d4dc Do exception spec compatibility tests for member pointers, too.
llvm-svn: 84098
2009-10-14 14:38:54 +00:00
Zhongxing Xu 8679481408 Now StoreManager::CastRegion() takes a MemRegion, returns a MemRegion.
llvm-svn: 84081
2009-10-14 06:55:01 +00:00
Chris Lattner 4f8a2e22c0 fix some cfstring related issues:
1) -fwritable-string does affect the non-utf16 version of cfstrings
   just not the utf16 ones.
2) utf16 strings should always be marked constant, as the __TEXT segment
   is readonly.
3) The name of the global doesn't matter, remove it from TargetInfo.
4) Trust the asmprinter to drop cstrings into the right section, like llvmgcc does now.

This fixes rdar://7115750

llvm-svn: 84077
2009-10-14 05:55:45 +00:00
Chris Lattner 734351d214 unbreak test/CodeGen/builtins.c, reverting Devang's change.
llvm-svn: 84075
2009-10-14 05:49:21 +00:00
Zhongxing Xu 9eb2706101 Remove dead code.
llvm-svn: 84073
2009-10-14 05:07:51 +00:00
Zhongxing Xu 7d6387bb24 * Remove unused GRState* parameter
* Make all Base value the last argument.

llvm-svn: 84071
2009-10-14 03:33:08 +00:00
Fariborz Jahanian 31481d8b22 Handle ambiguity of reference initialization.
Removes a FIXME.

llvm-svn: 84068
2009-10-14 00:52:43 +00:00
Ted Kremenek b4ec3fc42d retain/release checker: Recognize that calls to
'CVPixelBufferCreateWithPlanarBytes()' and
'CVPixelBufferCreateWithBytes' (Core Video API) can indirectly release
a pixel buffer object via a callback.

This fixes <rdar://problem/7283567>.

llvm-svn: 84064
2009-10-14 00:27:24 +00:00
Douglas Gregor 3362bde8ec Remove some non-ASCII characters
llvm-svn: 84058
2009-10-13 23:52:38 +00:00
Douglas Gregor a14b43bba8 Member function templates (and instantiations/specializations thereof)
are never copy constructors or copy assignment operators.

llvm-svn: 84057
2009-10-13 23:45:19 +00:00
Douglas Gregor 15e5602e59 Improve diagnostics when the parser encounters a declarator with an
unknown type name, e.g.,

  foo::bar x;

when "bar" does not refer to a type in "foo". 

With this change, the parser now calls into the action to perform
diagnostics and can try to recover by substituting in an appropriate
type. For example, this allows us to easily diagnose some missing
"typename" specifiers, which we now do:

  test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
        prior to dependent type name 'A<T>::type'
  A<T>::type A<T>::f() { return type(); }
  ^~~~~~~~~~
  typename 

Fixes PR3990.

llvm-svn: 84053
2009-10-13 23:27:22 +00:00
Edward O'Callaghan f258caa718 Fix for PR 5181.
llvm-svn: 84051
2009-10-13 23:05:14 +00:00
Devang Patel 3b3f0f6b65 Check void type before using replaceAllUsesWith().
llvm-svn: 84050
2009-10-13 22:59:11 +00:00
Anders Carlsson fbd2d49398 The operator loc points to the operator, not the function decl.
llvm-svn: 84048
2009-10-13 22:55:59 +00:00
Ted Kremenek 80816acf9b retain/release checker: retained objects passed to pthread_create (as
the data argument) should not be tracked further until we support full IPA.

(fixes <rdar://problem/7299394>)

llvm-svn: 84047
2009-10-13 22:55:33 +00:00
Mike Stump 284312176a Refine handling for non-virtual bases in return value adjustments for
covariant thunks.  WIP.

llvm-svn: 84046
2009-10-13 22:54:56 +00:00
Anders Carlsson e4f4b5e919 Check the return type of binary operators and the arrow operator.
llvm-svn: 84043
2009-10-13 22:43:21 +00:00
Anders Carlsson 834facc2b0 Check the return type of operator[]() and fix a thinko that lead to a crash in SemaCXX/overloaded-operator.cpp.
llvm-svn: 84041
2009-10-13 22:22:09 +00:00
Chris Lattner a2f9bd5339 fix test/CodeGen/statements.c on 32-bit hosts.
llvm-svn: 84039
2009-10-13 22:12:09 +00:00
Anders Carlsson 3d5829cd4f More return type checking.
llvm-svn: 84034
2009-10-13 21:49:31 +00:00
Mike Stump 7373095ebf Ensure we sign extend.
llvm-svn: 84031
2009-10-13 21:31:09 +00:00
Anders Carlsson f64a3dae04 Diagnose invalid return types for unary operators.
llvm-svn: 84030
2009-10-13 21:19:37 +00:00
Douglas Gregor e40876a50c Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.

llvm-svn: 84028
2009-10-13 21:16:44 +00:00
Anders Carlsson 8523d20af3 Pass the right SourceLocation to Actions.ActOnOverloadedOperatorReferenceExpr and Actions.ActOnConversionOperatorReferenceExpr. Update incomplete-call.cpp test.
llvm-svn: 84026
2009-10-13 21:02:07 +00:00
John Thompson 4334ce6bda Fixes pth.c on Windows.
llvm-svn: 84007
2009-10-13 18:51:32 +00:00
Anders Carlsson 6bfee8f3e3 Don't assume that the LHS and RHS of a member pointer expression is a DeclRefExpr. Fixes PR5177.
llvm-svn: 83986
2009-10-13 17:41:28 +00:00
Mike Stump ad47e7ea81 Remove FIXME. We construct VBIndex very early, before any calls to OverrideMethod.
llvm-svn: 83981
2009-10-13 17:23:44 +00:00
Douglas Gregor 62e10f0bdc Diagnose attempts to add default function arguments to a
specialization. This completes C++ [temp.expl.spec]!

llvm-svn: 83980
2009-10-13 17:02:54 +00:00
Devang Patel 9f73552852 Remove extra white space line.
llvm-svn: 83979
2009-10-13 17:02:38 +00:00
Devang Patel 7468489deb Do not check use_empty() before invoking replaceAllUsesWith().
Let replaceAllUsesWith() adjust VHs even though there are no uses.

llvm-svn: 83978
2009-10-13 17:02:04 +00:00
Edward O'Callaghan fc460554f6 -funit-at-a-time is the default however some current makefiles pass -fno-unit-at-a-time which is ignored by GCC, we should warn about this not error out.
llvm-svn: 83976
2009-10-13 16:41:34 +00:00
Douglas Gregor cf91555cb8 When explicitly specializing a member that is a template, mark the
template as a specialization. For example, this occurs with:

  template<typename T>
  struct X {
    template<typename U> struct Inner { /* ... */ };
  };

  template<> template<typename T>
  struct X<int>::Inner {
    T member;
  };

We need to treat templates that are member specializations as special
in two contexts:

  - When looking for a definition of a member template, we look
    through the instantiation chain until we hit the primary template
    *or a member specialization*. This allows us to distinguish
    between the primary "Inner" definition and the X<int>::Inner
    definition, above.
  - When computing all of the levels of template arguments needed to
    instantiate a member template, don't add template arguments
    from contexts outside of the instantiation of a member
    specialization, since the user has already manually substituted
    those arguments.

Fix up the existing test for p18, which was actually wrong (but we
didn't diagnose it because of our poor handling of member
specializations of templates), and add a new test for member
specializations of templates.

llvm-svn: 83974
2009-10-13 16:30:37 +00:00
Douglas Gregor 3a88c1d784 Improve the internal representation and semantic analysis of friend
function templates.

This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation. 

Oh, and make sure that explicit specialization declarations are not
friends.

llvm-svn: 83970
2009-10-13 14:39:41 +00:00
Mike Stump 87876a0053 Refine handling for return value conversions with respect to virtual
offsets for covariant thunks.

llvm-svn: 83965
2009-10-13 10:55:21 +00:00
Benjamin Kramer abd5b90e4c Simplify pointer creation with the new Type::getInt*Ptr methods.
llvm-svn: 83964
2009-10-13 10:07:13 +00:00
Chris Lattner 3eb172a02b Teach sema and codegen about the difference between address of labels,
which is a common idiom to improve PIC'ness of code using the addr of
label extension.  This implementation is a gross hack, but the only other
alternative would be to teach evalutate about this horrid combination.
While GCC allows things like "&&foo - &&bar + 1", people don't use this
in practice.  This implements PR5131.

llvm-svn: 83957
2009-10-13 07:14:16 +00:00
Chris Lattner 2bb5cb490c reimplement codegen for indirect goto with the following advantages:
1. CGF now has fewer bytes of state (one pointer instead of a vector).
2. The generated code is determinstic, instead of getting labels in
   'map order' based on pointer addresses.
3. Clang now emits one 'indirect goto switch' for each function, instead
   of one for each indirect goto.  This fixes an M*N = N^2 IR size issue
   when there are lots of address-taken labels and lots of indirect gotos.
4. This also makes the default cause do something useful, reducing the
   size of the jump table needed (by one).

llvm-svn: 83952
2009-10-13 06:55:33 +00:00
Chris Lattner 92ae16b0ae number address-taken labels from 1. This allows 0 to be used as a sentinel
for a null pointer.  In other words, "&&foo != NULL" will always work out to
true.

llvm-svn: 83948
2009-10-13 06:04:29 +00:00
Chris Lattner dd7eaad7d4 Use the new Type::getInt8PtrTy method. This should probably be used in a lot
more places in clang codegen now.

llvm-svn: 83947
2009-10-13 06:02:42 +00:00
Chris Lattner 1a6babf1f4 make the diagnostic in the 'unused result' warning more precise
about the reason, rdar://7186119.

llvm-svn: 83940
2009-10-13 04:53:48 +00:00
Chris Lattner f315471e24 fix PR4938 by recognizing % as a modifier on outputs,
previously we only recognized it on inputs.

llvm-svn: 83939
2009-10-13 04:32:07 +00:00
Zhongxing Xu 88dd1ff0d7 Now we can call into another function with the CallInliner transfer function.
llvm-svn: 83936
2009-10-13 02:36:42 +00:00
Zhongxing Xu daa4176926 Add an initial implementation of EnterStackFrame() to the StoreManager.
llvm-svn: 83934
2009-10-13 02:24:55 +00:00
Devang Patel 5b294f4330 Enable "debug info attached to an instruction" mode.
llvm-svn: 83928
2009-10-12 23:31:25 +00:00
Douglas Gregor ef06ccf8d0 When declaring a class template whose name is qualified, make sure
that the scope in which it is being declared is complete. Also, when
instantiating a member class template's ClassTemplateDecl, be sure to
delay type creation so that the resulting type is dependent. Ick.

llvm-svn: 83923
2009-10-12 23:11:44 +00:00
Devang Patel dac79decf3 There is no need to attach debug location info with alloca instruction.
llvm-svn: 83913
2009-10-12 22:29:02 +00:00
Devang Patel 551e112e99 Encode long double.
llvm-svn: 83912
2009-10-12 22:28:31 +00:00
Douglas Gregor ca027af608 Permit explicit specialization of member functions of class templates
that are declarations (rather than definitions). Also, be sure to set
the access specifiers properly when instantiating the declarations of
member function templates.

llvm-svn: 83911
2009-10-12 22:27:17 +00:00
John McCall e724ae92a8 More appropriate API usage.
llvm-svn: 83910
2009-10-12 22:25:59 +00:00
John McCall d5707abdfd Implement -Wparentheses: warn about using assignments in contexts that require
conditions.  Add a fixit to insert the parentheses.  Also fix a very minor
possible memory leak in 'for' conditions.

Fixes PR 4876 and rdar://problem/7289172

llvm-svn: 83907
2009-10-12 21:59:07 +00:00
Anders Carlsson 1d116976b4 Store the key function of a record decl inside CGRecordLayout.
llvm-svn: 83900
2009-10-12 21:16:22 +00:00
Ted Kremenek 289ae4f454 Use a BumpPtrAllocator to allocate all aspects of CFG, including CFGBlocks, successor and predecessor vectors, etc.
Speedup: when doing 'clang-cc -analyze -dump-cfg' (without actual printing, just
CFG building) on the amalgamated SQLite source (all of SQLite in one source
file), runtime reduced by 9%.

This fixes: <rdar://problem/7250745>

llvm-svn: 83899
2009-10-12 20:55:07 +00:00
Mike Stump b9a9a7c0ad Fixup windows include paths. Patch by John Thompson.
llvm-svn: 83898
2009-10-12 20:50:45 +00:00
Douglas Gregor 06db9f50a2 Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.

llvm-svn: 83890
2009-10-12 20:18:28 +00:00
Fariborz Jahanian e7196431c1 Handle built-in unary operators when reporting ambiguities.
wip - To prune excessive reporting.

llvm-svn: 83889
2009-10-12 20:11:40 +00:00
Anders Carlsson a1b54fdbe1 Even more devirtualization cleverness.
llvm-svn: 83886
2009-10-12 19:59:15 +00:00
Anders Carlsson 2a01709204 More devirtualization improvements.
llvm-svn: 83883
2009-10-12 19:51:33 +00:00
Anders Carlsson b61301f353 Devirtualize calls on temporaries. A().f() for example.
llvm-svn: 83882
2009-10-12 19:45:47 +00:00
Anders Carlsson d7432dfb0a Factor out devirtualization checking into a separate function and make it handle references correctly.
llvm-svn: 83880
2009-10-12 19:41:04 +00:00
Fariborz Jahanian 65694b413d Use CanQualType (instead of QualType) to store collection of visible
canonical conversion types.

llvm-svn: 83869
2009-10-12 18:36:50 +00:00
Fariborz Jahanian 574de2c5a4 If built-in operators could not be selected because of ambiguity in
user-defined type conversions, issue list of ambiguites in addition 
to the diagnostic. So, clang now issues the following:

b.cpp:19:19: error: left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'struct C1'
        int i = c1->*pmf;
                ~~^
b.cpp:19:19: note: because of ambiguity in conversion of 'struct C1' to 'struct E *'
b.cpp:5:5: note: candidate function
    operator E*();
    ^
b.cpp:11:5: note: candidate function
    operator E*();
    ^

llvm-svn: 83862
2009-10-12 17:51:19 +00:00
Edward O'Callaghan e4ab8eacf7 Typo in AddGnuCPlusPlusIncludePaths.
llvm-svn: 83847
2009-10-12 12:02:47 +00:00
Anders Carlsson b5296558f1 If the base type of a member call is a record type we don't need to emit a virtual call.
llvm-svn: 83816
2009-10-11 23:55:52 +00:00
Benjamin Kramer bb0a07bf92 Remove dead variable.
llvm-svn: 83808
2009-10-11 22:57:54 +00:00
Benjamin Kramer 2e8301dd62 Add CGVtable.cpp to CMakeLists.
llvm-svn: 83800
2009-10-11 22:22:38 +00:00
Anders Carlsson 2bb27f53e0 Move the vtable builder to CGVtable.cpp, general cleanup.
llvm-svn: 83798
2009-10-11 22:13:54 +00:00
Anders Carlsson 2295f31810 Change mangleCXXVtable and mangleCXXRtti to take CXXRecordDecls instead of QualTypes.
llvm-svn: 83793
2009-10-11 21:24:51 +00:00
Sebastian Redl 6e4c871855 Types appearing more than once in a spec shouldn't matter.
llvm-svn: 83766
2009-10-11 09:11:23 +00:00
Sebastian Redl 4915e63d3b Test exception spec compatibility on return type and parameters.
Along the way, use RequireCompleteType when testing exception spec types.
Separate all the ugly spec stuff into its own file.

llvm-svn: 83764
2009-10-11 09:03:14 +00:00
Zhongxing Xu b8edf2a4dd Introduces a new BindingVal which combines direct and
default binding for regions. This allows us to simply a lot of code. A
further simplification could be done is that many methods of
regionstore can only work on Store instead of GRState. 

llvm-svn: 83762
2009-10-11 08:08:02 +00:00
Anders Carlsson 6ce51fdf43 Move our (non-existing) RTTI emission code into CGRtti.cpp. No functionality change.
llvm-svn: 83732
2009-10-10 20:49:04 +00:00
Fariborz Jahanian 07ca72725a Generate weak read barriers when reading a weak __block
variable inside the block.

llvm-svn: 83729
2009-10-10 20:07:56 +00:00
Sebastian Redl 5d43164bc2 Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.

llvm-svn: 83710
2009-10-10 12:04:10 +00:00
John McCall 6538c93050 Qualified lookup through using declarations. Diagnose a new type of ambiguity.
Split the various ambiguous result enumerators into their own enum.  Tests
for most of C++ [namespace.qual].

llvm-svn: 83700
2009-10-10 05:48:19 +00:00
Anders Carlsson c4859baea4 Check that the return type is complete when calling a member function.
llvm-svn: 83694
2009-10-10 00:06:20 +00:00
Anders Carlsson 7f84ed9287 Add CheckCallReturnType and start using it for regular call expressions. This will improve error messages. For
struct B;

B f();

void g() {
f();
}

We now get

t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B'
  f();
  ^~~
t.cpp:3:3: note: 'f' declared here
B f();
  ^
t.cpp:1:8: note: forward declaration of 'struct B'
struct B;
       ^

llvm-svn: 83692
2009-10-09 23:51:55 +00:00
Douglas Gregor b385b7c62e Dead Code Elimination
llvm-svn: 83686
2009-10-09 22:56:12 +00:00
Douglas Gregor 7d195b93d8 Add some FIXMEs
llvm-svn: 83685
2009-10-09 22:54:25 +00:00
Douglas Gregor 58acf32af2 Minor tweaks for code-completion:
- Filter out unnamed declarations
  - Filter out declarations whose names are reserved for the
  implementation (e.g., __bar, _Foo) 
  - Place OVERLOAD: or COMPLETION: at the beginning of each
  code-completion result, so we can easily separate them from other
  compilation results.

llvm-svn: 83680
2009-10-09 22:16:47 +00:00
Devang Patel 3028a43f57 Revert 83567.
llvm-svn: 83676
2009-10-09 22:06:15 +00:00
John McCall 9f3059a192 Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines.  Call out uses which assume a single
result.

llvm-svn: 83674
2009-10-09 21:13:30 +00:00
Douglas Gregor 7f34baeb4b When declaring a friend class template, we may end up finding an
injected-class-name (e.g., when we're referring to other
specializations of the current class template). Make sure that we see
the template rather than the injected-class-name. Fixes PR4768.

llvm-svn: 83672
2009-10-09 21:11:42 +00:00
Mike Stump 1ba6edb030 Efficiency refinements.
llvm-svn: 83666
2009-10-09 20:16:49 +00:00
Mike Stump e752333c66 Push all the way out to 80.
llvm-svn: 83664
2009-10-09 19:42:16 +00:00