Commit Graph

37 Commits

Author SHA1 Message Date
Richard Smith d80b2d57cf Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.

llvm-svn: 168477
2012-11-22 00:24:47 +00:00
Douglas Gregor dc97457178 Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.

llvm-svn: 167668
2012-11-10 07:24:09 +00:00
Douglas Gregor 6200470112 Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>

llvm-svn: 167651
2012-11-10 01:18:17 +00:00
Ted Kremenek 26774b15f6 Convert a few more getAs cases to castAs where we immediately call a member function.
llvm-svn: 163684
2012-09-12 06:50:29 +00:00
Douglas Gregor 18e1b52964 Switch a SmallPtrSet/SmallVector pair over to SetVector.
llvm-svn: 163600
2012-09-11 07:19:42 +00:00
Ted Kremenek 2883175e4c Change a bunch of cases where we do "getAs<...>->doSomething()" to
"castAs<...>->doSomething()".  The analyzer was flagging these
as potential null dereferences, which is technically true.  The
invariants appear to be that these casts should never fail, so
let's use castAs<> instead and avoid a runtime check.

llvm-svn: 162468
2012-08-23 20:46:57 +00:00
Douglas Gregor 7bdc8ae20b array_pod_sort on the addresses of declaration pointers leads to
inconsistent ordering of results; instead, use use SmallPtrSet to
eliminate duplicates.

llvm-svn: 162429
2012-08-23 05:05:18 +00:00
Jordan Rose 55edf5ff14 Constify CXXRecordDecl::isVirtuallyDerivedFrom.
No functionality change. A couple ugly const_casts because the ancestor
search code is used for other purposes as well.

llvm-svn: 161509
2012-08-08 18:23:20 +00:00
Benjamin Kramer 2ef3031496 Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used instead.
No functionality change.

llvm-svn: 159719
2012-07-04 18:45:14 +00:00
Benjamin Kramer ea388a2832 PR12962: Fix a rare use after free when collecting virtual overrides.
The DenseMap reallocates after 64 insertions so this only happened in
large test cases under very specific circumstances.

llvm-svn: 157549
2012-05-27 22:41:08 +00:00
Benjamin Kramer c232b77556 Actually remove the duplicated elements from the vector.
llvm-svn: 151270
2012-02-23 18:35:56 +00:00
Benjamin Kramer 91c6b6a933 Unique CXXBasePath decls with the SmallVector/pod_sort/std::unique idiom instead of employing a wasteful std::set.
llvm-svn: 151255
2012-02-23 15:18:31 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
John McCall 388ef53234 Fix some corner cases in the __is_base_of logic.
llvm-svn: 124505
2011-01-28 22:02:36 +00:00
Anders Carlsson 7f95cd1817 Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.
llvm-svn: 120133
2010-11-24 23:12:57 +00:00
Anders Carlsson abb3b21b3b Fix typo.
llvm-svn: 120130
2010-11-24 22:55:29 +00:00
Anders Carlsson 4131f00a1f Add CXXRecordDecl::getIndirectPrimaryBases.
llvm-svn: 120129
2010-11-24 22:50:27 +00:00
Anders Carlsson 15722da2dc Add a short circuit in isVirtuallyDerivedFrom.
llvm-svn: 105457
2010-06-04 01:40:08 +00:00
Anders Carlsson a2f74f3c98 Add all final overriders to the map.
llvm-svn: 105374
2010-06-03 01:00:02 +00:00
Douglas Gregor 27ac429624 Use CanQualType to enforce the use of a canonical type argument to
CXXBasePaths::isAmbiguous(), rather than just asserting that we have a
canonical type. Fixes PR7176.

llvm-svn: 104374
2010-05-21 20:29:55 +00:00
Douglas Gregor 4165bd6772 Implement computation of the final overriders for each virtual
function within a class hierarchy (C++ [class.virtual]p2).

We use the final-overrider computation to determine when a particular
class is ill-formed because it has multiple final overriders for a
given virtual function (e.g., because two virtual functions override
the same virtual function in the same virtual base class). Fixes
PR5973.

We also use the final-overrider computation to determine which virtual
member functions are pure when determining whether a class is
abstract or diagnosing the improper use of an abstract class. The
prior approach to determining whether there were any pure virtual
functions in a class didn't cope with virtual base class subobjects
properly, and could not easily be fixed to deal with the oddities of
subobject hiding. Fixes PR6631.

llvm-svn: 99351
2010-03-23 23:47:56 +00:00
Douglas Gregor 3e637467d7 Implement name hiding for names found through virtual base subobjects
that are hidden by other derived base subobjects reached along a
lookup path that does *not* pass through the hiding subobject (C++
[class.member.lookup]p6). Fixes PR6462.

llvm-svn: 97640
2010-03-03 04:38:46 +00:00
Douglas Gregor 0555f7eefa Refactor CXXRecordDecl::lookupInBases() to push the recursion down a
level. No functionality change, and it obeys access control this
time.

llvm-svn: 97634
2010-03-03 02:18:00 +00:00
Douglas Gregor 77709906a4 Revert r97618. Access control sucks
llvm-svn: 97621
2010-03-03 01:13:25 +00:00
Douglas Gregor a62a5237fc Factor out the recursive lookup into C++ base classes into a separate,
static function. No functionality change.

llvm-svn: 97618
2010-03-03 01:02:31 +00:00
Douglas Gregor 0a5a2216e2 Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.

llvm-svn: 95836
2010-02-11 01:04:33 +00:00
John McCall 6f891400c2 Reset the found-virtual-base state unless the *current* base produces a path,
not *any* base up to now has produced a path.  Fixes PR 6254.

I'll do the access-control part of this patch RSN.

llvm-svn: 95638
2010-02-09 00:57:12 +00:00
John McCall 553c0796ee Implement elementary access control.
llvm-svn: 94268
2010-01-23 00:46:32 +00:00
John McCall 401982f56c First pass at collecting access-specifier information along inheritance paths.
Triggers lots of assertions about missing access information;  fix them.

Will actually consume this information soon.

llvm-svn: 94038
2010-01-20 21:53:11 +00:00
Anders Carlsson f9812782b7 In CXXRecordDecl::forallBases, add the base to the "queue", so we walk more than one heirarchy of classes. John, please review.
llvm-svn: 90948
2009-12-09 04:26:02 +00:00
John McCall ddabf1a946 Add CXXRecordDecl::forallBases to walk an inheritance hierarchy with non-lookup
semantics and CXXRecordDecl::isProvablyNotDerivedFrom to assist with
pre-instantiation diagnostics.

llvm-svn: 90842
2009-12-08 07:42:38 +00:00
Douglas Gregor 1b8fe5b716 First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:

  typedef const int CInt;
  typedef CInt Self;

Self.isConstQualified() currently returns false!

Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions: 

  - the "local" version only returns qualifiers on this particular
    QualType instance
  - the "normal" version that will eventually combine qualifiers from this
    QualType instance with the qualifiers on the canonical type to
    produce the full set of qualifiers.

This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
  
  Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()

expressions over to 

  Context.hasSameUnqualifiedType(T1, T2)

llvm-svn: 88969
2009-11-16 21:35:15 +00:00
John McCall 84c16cf824 Random const correctness, and incidentally use computeDeclContext when building
a using declaration.

llvm-svn: 86942
2009-11-12 03:15:40 +00:00
John McCall b692a098c6 Canonicality is a property of qualified types, not unqualified types.
llvm-svn: 84891
2009-10-22 20:10:53 +00:00
Mike Stump 512c5b770f Fix eof.
llvm-svn: 83433
2009-10-06 23:38:59 +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