Commit Graph

9284 Commits

Author SHA1 Message Date
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
Axel Naumann 04ca7e181f Passing const Triple& is sufficient for AddDefaultSystemIncludePaths()
llvm-svn: 83663
2009-10-09 19:37:12 +00:00
Mike Stump fc8ff639cb Allow customization for the producer information in the debug output.
llvm-svn: 83659
2009-10-09 18:38:12 +00:00
Mike Stump 727170d2d8 Allow customization for the version line.
llvm-svn: 83652
2009-10-09 17:31:54 +00:00
Fariborz Jahanian 0fe5e0308e Produce good looking diagnostics on ambiguous built-in operators.
Now we produce things like:
bug1.cpp:21:11: error: use of overloaded operator '->*' is ambiguous
        int i = c->*pmf;        // expected-error {{use of overloaded operator '->*' is ambiguous}} \
                ~^  ~~~
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int const struct A::*')
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int restrict struct A::*')
...

Still need to look at an issue (indicated as FIXME in the test case).

llvm-svn: 83650
2009-10-09 17:09:58 +00:00
Fariborz Jahanian 4dc1246d87 Use the new API for applying the qualifiers on built-in '->*'
operator's types.

llvm-svn: 83648
2009-10-09 16:34:40 +00:00
Zhongxing Xu e77cd12f10 Make the behavior explicit by not using the method call.
llvm-svn: 83611
2009-10-09 02:18:31 +00:00
Zhongxing Xu fd15882213 Remove unused code.
llvm-svn: 83610
2009-10-09 02:12:00 +00:00
Mike Stump 0d479e6653 Avoid warning.
llvm-svn: 83609
2009-10-09 01:25:47 +00:00
Fariborz Jahanian 29f9d39568 Improve on reporting ambiguity involving built-in candidates.
I still don't like it but it is improvement over what we had.

llvm-svn: 83603
2009-10-09 00:13:15 +00:00
Mike Stump acdc3158b3 Add a refactor pointer...
llvm-svn: 83599
2009-10-08 23:57:53 +00:00
Steve Naroff 3b08630b06 - Fixup SortCodeCompleteResult() to properly sort keywords on Mac OS (compare was system dependent). Worked on Linux, failed on Mac OS (which caused the recently added testcase to fail on Linux).
- Sort results in testcase.

llvm-svn: 83597
2009-10-08 23:45:10 +00:00
Mike Stump 904ad90bc8 Set up include paths for VC++ and Cygwin headers, along with the
existing MinGW headers, plus the newer 4.4.0 version.  Patch by John
Thompson.

llvm-svn: 83594
2009-10-08 23:29:47 +00:00
Mike Stump af9afe9bc9 "Someone pointed out that in my previous Targets.cpp patch I didn't
handle the long size difference for one of the Windows targets."  Patch
by John Thompson.

llvm-svn: 83592
2009-10-08 23:00:00 +00:00
Mike Stump c99c022841 This fixes support for complex literals, reworked to avoid a goto, and
to add a flag noting the presence of a Microsoft extension suffix (i8,
i16, i32, i64).  Patch by John Thompson.

llvm-svn: 83591
2009-10-08 22:55:36 +00:00
Fariborz Jahanian 8ae5b0a18b Fix up error reporting when object cannot be constructed
because of missing default constructor of a member.
Fixes pr5154.

llvm-svn: 83583
2009-10-08 22:15:49 +00:00
Douglas Gregor 01249503fe Installation of Clang libraries and headers, from Axel Naumann!
llvm-svn: 83582
2009-10-08 22:15:31 +00:00
Steve Naroff 936354c62a Add code completion support for ObjC property declarations/attributes.
llvm-svn: 83579
2009-10-08 21:55:05 +00:00
Douglas Gregor 3beaf9bbcd Implement support for -Wunused-variable, from Oscar Bonilla!
llvm-svn: 83577
2009-10-08 21:35:42 +00:00
Devang Patel abf71fa9fc Record location info before emiting alloca for arguments. This allows arguments to have proper location info.
llvm-svn: 83567
2009-10-08 18:53:37 +00:00
Fariborz Jahanian 03b4f666ed Implement [expr.mptr.oper]p6 for '->*' operator.
llvm-svn: 83562
2009-10-08 18:00:39 +00:00
Ted Kremenek 490b8c0f5b Remove use of std::ofstream in HTMLDiagnostics.cpp.
llvm-svn: 83560
2009-10-08 17:44:41 +00:00
Anders Carlsson a18ed9b113 If a global initializer has a non-trivial constructor or destructor, we never want to defer generation of it, even if it is declared static.
With this change we're finally able to compile and run the (infamous)

#include <string>
#include <iostream>

int main(int argc, char **argv) {
  std::cout << "Hello, World" << std::endl;
}

$ clang hello.cpp -lstdc++ -o hello
$ ./hello 
Hello, World

llvm-svn: 83559
2009-10-08 17:28:59 +00:00
Anders Carlsson 3482b819db Mangle std::basic_ostream<char, std::char_traits<char>> as So.
llvm-svn: 83557
2009-10-08 17:20:26 +00:00
Douglas Gregor eeffde3a1d Add more testing for the properties of explicit specialization.
Also, eliminate a redundant diagnostic by marking a variable declared
with incomplete type as an invalid declaration.

llvm-svn: 83553
2009-10-08 16:41:22 +00:00
Fariborz Jahanian 4ff5f05782 Refactoring to further simplify collection of visible conversion
functions.

llvm-svn: 83552
2009-10-08 16:33:37 +00:00
Douglas Gregor 19c52729ed Don't complain about out-of-line explicit specializations of member
function and member function templates that are not definitions. Add
more tests to ensure that explicit specializations of member function
templates prevent instantiation.

llvm-svn: 83550
2009-10-08 15:54:21 +00:00
Douglas Gregor bbe8f46621 Improve checking for specializations of member classes of class
templates, and keep track of how those member classes were
instantiated or specialized. 

Make sure that we don't try to instantiate an explicitly-specialized
member class of a class template, when that explicit specialization
was a declaration rather than a definition.

llvm-svn: 83547
2009-10-08 15:14:33 +00:00
Douglas Gregor 86d142a801 For instantiations of static data members of class templates, keep
track of the kind of specialization or instantiation. Also, check the
scope of the specialization and ensure that a specialization
declaration without an initializer is not a definition.

llvm-svn: 83533
2009-10-08 07:24:58 +00:00
Douglas Gregor c093c1de2b Make sure to set the template specialization kind of an explicit
template instantiation of a member function of a class template.
FIXME -= 2;

llvm-svn: 83520
2009-10-08 01:19:17 +00:00
Douglas Gregor e3dfd4826b Only perform an implicit instantiation of a function if its template
specialization kind is TSK_ImplicitInstantiation. Previously, we would
end up implicitly instantiating functions that had explicit
specialization declarations or explicit instantiation declarations
(with no corresponding definitions).

llvm-svn: 83511
2009-10-08 00:14:38 +00:00
Douglas Gregor d801b06232 Keep track of whether a member function instantiated from a member
function of a class template was implicitly instantiated, explicitly
instantiated (declaration or definition), or explicitly
specialized. The same MemberSpecializationInfo structure will be used
for static data members and member classes as well.

llvm-svn: 83509
2009-10-07 23:56:10 +00:00
John McCall c3987485f2 Refactoring around friend class templates. Better error message for friend enums.
Don't create a new declaration for friend classes if a declaration already exists.

llvm-svn: 83505
2009-10-07 23:34:25 +00:00
Douglas Gregor 5c0405d484 Type checking for specializations of member functions of class
templates. Previously, these weren't handled as specializations at
all. The AST for representing these as specializations is still a work
in progress.

llvm-svn: 83498
2009-10-07 22:35:40 +00:00
Anders Carlsson 6c966c458a Handle MemberExprs in ResolveAddressOfOverloadedFunction.
llvm-svn: 83495
2009-10-07 22:26:29 +00:00
John McCall fe8dc76f80 Dead code elimination.
llvm-svn: 83492
2009-10-07 22:04:40 +00:00
Fariborz Jahanian 3ee21f1b91 Fixes problem in finding visible convertion functions of a class
where matching conversion types in base classes were still visible.
Plus refactoring and cleanup.
Added a test case.

llvm-svn: 83485
2009-10-07 20:43:36 +00:00
Douglas Gregor 40fb74484e Diagnose explicit instantiations and specializations that occur in class scope
llvm-svn: 83473
2009-10-07 17:30:37 +00:00
Fariborz Jahanian ae01f78a31 When building candidate set for built-ins; when looking for
convesion functions, look in base classes to.
(Removes a FIXME).

llvm-svn: 83472
2009-10-07 17:26:09 +00:00
Douglas Gregor e4b05168f6 Class template partial specializations can be declared anywhere that
its definition may be defined, including in a class.

Also, put in an assertion when trying to instantiate a class template
partial specialization of a member template, which is not yet
implemented.

llvm-svn: 83469
2009-10-07 17:21:34 +00:00
Fariborz Jahanian 12df37c5d7 Removed couple of unnecessary canonicalization
per Doug's obsevation.

llvm-svn: 83464
2009-10-07 16:56:50 +00:00
Ted Kremenek 7881ac97a5 Revert r83443.
llvm-svn: 83451
2009-10-07 03:21:11 +00:00
Anders Carlsson 1e39bd944b Mangle anonymous structs/unions correctly. Fixes PR5139.
llvm-svn: 83448
2009-10-07 01:45:02 +00:00
Mike Stump db9fca7735 Fixup pathnames.
llvm-svn: 83443
2009-10-07 01:11:54 +00:00
Anders Carlsson ff971e8bf4 Add a MangleContext and pass it to all mangle functions. It will be used for keeping state, such as identifiers assigned to anonymous structs as well as scope encoding.
llvm-svn: 83442
2009-10-07 01:06:45 +00:00
Ted Kremenek c3661decc3 Change ExplodedNode to have its NodeGroups all BumpPtrAllocated, avoiding malloc() traffic when adding successors/predecessors to a node. This was done by introducing BumpVector, which is essentially SmallVector with all memory being BumpPtrAllocated (this can certainly be cleaned up or moved into llvm/ADT).
This change yields a 1.8% speed increase when running the analyzer (with -analyzer-store=region) on a small benchmark file.

llvm-svn: 83439
2009-10-07 00:42:52 +00:00
Douglas Gregor 548886518d Refactor checking of the scope of explicit template specialization
declarations and explicit template instantiations, improving
diagnostics and making the code usable for function template
specializations (as well as class template specializations and partial
specializations). 

llvm-svn: 83436
2009-10-07 00:13:32 +00:00
Mike Stump 512c5b770f Fix eof.
llvm-svn: 83433
2009-10-06 23:38:59 +00:00
Fariborz Jahanian 34d93dcddd Patch to implement C++ [over.built]p11 of overload resolution.
Doug, please review. There is a FIXME in the test case with a question
which is unrelated to this patch (that is, error is issued
before set of builtins are added to the candidate list).

llvm-svn: 83429
2009-10-06 23:08:05 +00:00
Anders Carlsson b703fd2216 Uncomment some commented out code.
llvm-svn: 83428
2009-10-06 23:02:00 +00:00
Anders Carlsson c6d171ec77 Change GetAddressCXXOfBaseClass to use CXXBasePaths for calculating base class offsets. Fix the code to handle virtual bases as well.
llvm-svn: 83426
2009-10-06 22:43:30 +00:00
Anders Carlsson 11d00cf972 When mangling names, always use the canonical decl. Fixes PR5144.
llvm-svn: 83420
2009-10-06 21:58:01 +00:00
Devang Patel 542ab5f551 InsertSubprogramStart if ATTACH_DEBUG_INFO_TO_AN_INSN is not defined.
llvm-svn: 83419
2009-10-06 21:53:41 +00:00
Douglas Gregor 27c26e9a09 Test explicit specialization for all of the various cases where
explicit specializations can occur. Also, fix a minor recovery bug
where we should allow declarations coming from the parser to be NULL.

llvm-svn: 83416
2009-10-06 21:27:51 +00:00
Devang Patel 5d90d62701 Add support to attach debug info to an instruction.
This is not yet enabled.

llvm-svn: 83399
2009-10-06 18:36:08 +00:00
Anders Carlsson 6b7378bbe1 Emit the destructor epilogue in a cleanup block so a return from a destructor body still calls the epilogue.
llvm-svn: 83397
2009-10-06 18:09:57 +00:00
Douglas Gregor 36d1b14dde Refactor the code that walks a C++ inheritance hierarchy, searching
for bases, members, overridden virtual methods, etc. The operations
isDerivedFrom and lookupInBases are now provided by CXXRecordDecl,
rather than by Sema, so that CodeGen and other clients can use them
directly.

llvm-svn: 83396
2009-10-06 17:59:45 +00:00
Anders Carlsson 80ef6f1a46 Pass the right type to GetAddrOfFunction when getting functions for the VTable. Fixes PR5021.
llvm-svn: 83395
2009-10-06 17:54:23 +00:00
Rafael Espindola 7787d79c7b Add the -nostdclanginc option to clang (the driver).
llvm-svn: 83377
2009-10-06 12:45:37 +00:00
Ted Kremenek d5cf21a57b Fix 'clang-cc -analyzer-display-progress' by flushing standard error after printing the name of the analyzed function.
llvm-svn: 83369
2009-10-06 03:49:25 +00:00
Ted Kremenek 2f935535b1 Fix crash introduced by r83358 where a symbol could be eagerly
evaluated to an APSInt with a different bitwidth than the other
operand in a binary expression.

llvm-svn: 83368
2009-10-06 03:44:49 +00:00
Ted Kremenek 8ec5771dcb Fix: <rdar://problem/7275774> Static analyzer warns about NULL pointer when
adding assert

This fix required a few changes:

SimpleSValuator:
- Eagerly replace a symbolic value with its constant value in EvalBinOpNN
  when it is constrained to a constant.  This allows us to better constant fold
  values along a path.
- Handle trivial case of '<', '>' comparison of pointers when the two pointers
  are exactly the same.

RegionStoreManager:

llvm-svn: 83358
2009-10-06 01:39:48 +00:00
Rafael Espindola c3031a9643 Refactor the c++ include path a bit.
llvm-svn: 83357
2009-10-06 01:33:02 +00:00
Devang Patel faf7e9ad24 Set appropriate context for a global variable while emitting debug info.
llvm-svn: 83352
2009-10-06 00:35:31 +00:00
Fariborz Jahanian 333bb733a5 Refixed pr5086 by letting Expr::isNullPointerConstant
handle checking for a null pointer for a zero-valued
enumerator; moving the test case from CodeGen to Sema.

llvm-svn: 83350
2009-10-06 00:09:31 +00:00
Mike Stump 916c006735 Fix thinko and simplify.
llvm-svn: 83342
2009-10-05 23:08:21 +00:00
Mike Stump 3472ae5bac Ensure we have atleast 2-byte alignment for member functions.
llvm-svn: 83337
2009-10-05 22:49:20 +00:00
Mike Stump c5e153c50e Respect alignments better.
llvm-svn: 83328
2009-10-05 21:58:44 +00:00
Fariborz Jahanian 8764c74784 tweaked my last patch to 1) preserve the protocol in
extension class's protocol list so its AST is complete.
2) Because of this no need to issue warning on unimplemeted
methods coming from the extended class protocols
because warning is issued when class definition is seen.

llvm-svn: 83326
2009-10-05 21:32:49 +00:00
Douglas Gregor d54f3a1e58 Encode the Clang branch and Subversion revision into a PCH file, and
assume that PCH files from different Clang revisions are not
compatible. Addresses <rdar://problem/7266572>.

llvm-svn: 83323
2009-10-05 21:07:28 +00:00
Fariborz Jahanian 092cd6e624 Patch to implement Protocols on class extensions.
<rdar://problem/7269631> Protocols on class extensions don't work

llvm-svn: 83322
2009-10-05 20:41:32 +00:00
Douglas Gregor 1b7035da6f Provide a common set of routines in Version.h that return Subversion
branch/revision information. Use that information in the driver,
rather than one-off branch/revision computation. 

llvm-svn: 83321
2009-10-05 20:33:49 +00:00
Douglas Gregor 7550a6c186 Pre-commit commit to get URL keyword expansion for Clang version information
llvm-svn: 83319
2009-10-05 18:52:24 +00:00
Benjamin Kramer dde0fee82e Use new predicates for some type equality tests.
llvm-svn: 83303
2009-10-05 13:47:21 +00:00
Anders Carlsson d5931cd2b7 Pass the canonical method decl to GetVtableIndex. Fixes PR5120.
llvm-svn: 83272
2009-10-03 19:56:56 +00:00
Anders Carlsson 2ee3c011d9 Implement code generation of member function pointer calls. Fixes PR5121.
llvm-svn: 83271
2009-10-03 19:43:08 +00:00
Anders Carlsson 61914b512a Create CXXMemberCallExpr for pointer-to-member calls.
llvm-svn: 83268
2009-10-03 17:40:22 +00:00
Anders Carlsson de55f647ff Ignore No-op casts when evaluating lvalue expressions. Fixes PR5122.
llvm-svn: 83267
2009-10-03 16:30:22 +00:00
Anders Carlsson c46bf276e1 Teach AggExprEmitter about pointers to member functions.
llvm-svn: 83266
2009-10-03 15:43:24 +00:00
Anders Carlsson 3162e4945a Handle base-to-derived casts of member function pointers in CGExprConstant.cpp
llvm-svn: 83265
2009-10-03 15:13:22 +00:00
Anders Carlsson 128a5d5147 Handle members to function pointers in CGExprConstant.
llvm-svn: 83264
2009-10-03 15:02:02 +00:00
Anders Carlsson 32bfb1ce8f Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
llvm-svn: 83263
2009-10-03 14:56:57 +00:00
Anders Carlsson 8a744ad8a6 Don't update the struct alignment when adding fields to a packed struct. Fixes PR5118.
llvm-svn: 83235
2009-10-02 04:52:12 +00:00
Mike Stump 581b9ad124 More magic pixie dust.
llvm-svn: 83232
2009-10-02 02:30:50 +00:00
Mike Stump 440af3d903 Fix up debug information for block pointers a bit more.
llvm-svn: 83231
2009-10-02 02:23:37 +00:00
Anders Carlsson 39e3eb12ae When building constant structs, check if the resulting LLVM struct will be bigger than the record layout size and use a packed struct if that's the case. Fixes PR5108.
llvm-svn: 83230
2009-10-02 02:15:20 +00:00
Douglas Gregor f343fd8929 Make sure to free the explicit template arguments provided for an
explicit instantiation. Also, tighten up reference-count checking to
help catch these issues earlier. Fixes PR5069.

llvm-svn: 83225
2009-10-01 23:51:25 +00:00
Steve Naroff bb69c94798 - Remove Sema::FindMethodInNestedImplementations().
- Add ObjCInterfaceDecl::lookupPrivateInstanceMethod().
- Convert clients.

No functionality change - One less method in Sema:-)

llvm-svn: 83224
2009-10-01 23:46:04 +00:00
Douglas Gregor 78b691a458 When the return type of a function is dependent, don't perform any
of the flow-control checks for falling off the end of a function,
since the return type may instantiate to void. Similarly, if a
return statement has an expression and the return type of the function
is void, don't complain if the expression is type-dependent, since
that type could instantiate to void.

Fixes PR5071.

llvm-svn: 83222
2009-10-01 23:25:31 +00:00
Mike Stump 017460ab6c Implement a FIXME. This improves codegen just a tad.
llvm-svn: 83221
2009-10-01 22:29:41 +00:00
Fariborz Jahanian a0f91ad59c enumerator value of 0 is not a null pointer constant for
deciding const of null pointer conversion. Fixes PR5086.

llvm-svn: 83217
2009-10-01 22:10:15 +00:00
Douglas Gregor 369acf9304 CodeGen may see out-of-line declarations of the various special member
functions when they are explicitly declared, e.g., via a function
template specialization or explicit template instantiation
declaration. Don't try to synthesize bodies for the special member
functions in this case; rather, check whether we have an implicit
declaration and, if so, synthesize the appropriate function
body. Fixes PR5084.

llvm-svn: 83212
2009-10-01 20:44:19 +00:00
Fariborz Jahanian b3c44f9ee9 Patch to implement static casting which requires one
user-defined type conversion. Fixes PR5040.

llvm-svn: 83211
2009-10-01 20:39:51 +00:00
Fariborz Jahanian e4b21aba44 Set __EXCEPTIONS by checking on darwin's triple.
Patch by Rafael Espindola.

llvm-svn: 83209
2009-10-01 20:30:46 +00:00
Ted Kremenek 5c22e110a1 Fix bad grammar in static analyzer diagnostic. Reported by Robert Purves!
llvm-svn: 83204
2009-10-01 17:31:50 +00:00
Rafael Espindola 00a665751d Move the "needs exception support" logic to clang. This also fixes
-fno-exceptions in C++ code. We used to always define __EXCEPTIONS in
C++.

llvm-svn: 83199
2009-10-01 13:33:33 +00:00
Douglas Gregor e364e7bc2b Fix a lame regression in IR gen for C++ delete expressions. PR5102
llvm-svn: 83195
2009-10-01 05:49:51 +00:00
Mike Stump 7d69911a1f A couple of refinements for laying out debug information for
BlockDeclRefDecls.

llvm-svn: 83185
2009-10-01 00:27:30 +00:00
John McCall 4fa5342758 Anonymous namespaces, sema + codegen. A lot of semantics are still broken,
apparently because using directives aren't quite working correctly.

llvm-svn: 83184
2009-10-01 00:25:31 +00:00
Douglas Gregor 42909754f6 Improve template argument deduction in the case where the parameter
type is a template-id (e.g., basic_ostream<CharT, Traits>) and the
argument type is a class that has a derived class matching the
parameter type. Previously, we were giving up on template argument
deduction too early.

llvm-svn: 83177
2009-09-30 22:13:51 +00:00
Douglas Gregor 66950a32d9 When overload resolution fails for an overloaded operator, show the
overload candidates (but not the built-in ones). We still rely on the
underlying built-in semantic analysis to produce the initial
diagnostic, then print the candidates following that diagnostic. 

One side advantage of this approach is that we can perform more validation
of C++'s operator overloading with built-in candidates vs. the
semantic analysis for those built-in operators: when there are no
viable candidates, we know to expect an error from the built-in
operator handling code. Otherwise, we are not modeling the built-in
semantics properly within operator overloading. This is checked as:

      assert(Result.isInvalid() && 
             "C++ binary operator overloading is missing
             candidates!");
      if (Result.isInvalid())
        PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);

The assert() catches cases where we're wrong in a +Asserts build. The
"if" makes sure that, if this happens in a production clang
(-Asserts), we still build the proper built-in operator and continue
on our merry way. This is effectively what happened before this
change, but we've added the assert() to catch more flies.

llvm-svn: 83175
2009-09-30 21:46:01 +00:00