Commit Graph

4791 Commits

Author SHA1 Message Date
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
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
Chris Lattner 2c02111000 convert this to FileCheck, PR5232
llvm-svn: 84466
2009-10-19 06:45:49 +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
Anders Carlsson 63404d2861 Convert temporaries.cpp to using FileCheck.
llvm-svn: 84446
2009-10-18 21:11:11 +00:00
Nate Begeman 72eabcb5b1 Add test for OpenCL vector initializer codegen
llvm-svn: 84445
2009-10-18 21:04:35 +00:00
Anders Carlsson 3af1ba73b3 Rename temp-1.cpp to temporaries.cpp.
llvm-svn: 84443
2009-10-18 20:58:38 +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
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
Nuno Lopes ff3507b951 add support for codegening CXXZeroInitValueExprs
llvm-svn: 84418
2009-10-18 15:18:11 +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
Chris Lattner 9b24e8aba6 daniel really wants this in the testsuite.
llvm-svn: 84354
2009-10-17 20:37:18 +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
Sebastian Redl 5371aed18c Add a DR437 testcase, but disable it for now, since it fails.
llvm-svn: 84345
2009-10-17 18:31:05 +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
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
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
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
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
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
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
Ted Kremenek dae45e9079 Add a few passing test cases for finding leaks of retained objects stored to arrays (<rdar://problem/7283470>).
llvm-svn: 84221
2009-10-15 23:44:02 +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 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
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
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
John Thompson 146b025c39 Sorry! Accidentally checked in experimental change.
llvm-svn: 84183
2009-10-15 14:34:41 +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 bf186694b0 Make this at least compile.
llvm-svn: 84167
2009-10-15 02:10:57 +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
John Thompson 3254182bfa Removed math.h include, as Windows math.h has a compile error.
llvm-svn: 84160
2009-10-15 00:39:58 +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 b81005dffc Check the implicit instantiation of a static data member of a class
template that has no out-of-line definition.

llvm-svn: 84141
2009-10-14 21:33:19 +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