[cfe-commits] r67821 - in /cfe/trunk/lib/Sema: Sema.h SemaAccess.cpp SemaInherit.cpp
Anders Carlsson
andersca at mac.com
Thu Mar 26 22:05:06 PDT 2009
Author: andersca
Date: Fri Mar 27 00:05:05 2009
New Revision: 67821
URL: http://llvm.org/viewvc/llvm-project?rev=67821&view=rev
Log:
Add a stubbed out CheckBaseClassAccess method.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/lib/Sema/SemaInherit.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=67821&r1=67820&r2=67821&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Mar 27 00:05:05 2009
@@ -1616,13 +1616,6 @@
FunctionDecl::StorageClass& SC);
DeclTy *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
- /// SetMemberAccessSpecifier - Set the access specifier of a member.
- /// Returns true on error (when the previous member decl access specifier
- /// is different from the new member decl access specifier).
- bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
- NamedDecl *PrevMemberDecl,
- AccessSpecifier LexicalAS);
-
//===--------------------------------------------------------------------===//
// C++ Derived Classes
//
@@ -1652,6 +1645,18 @@
SourceLocation Loc, SourceRange Range);
std::string getAmbiguousPathsDisplayString(BasePaths &Paths);
+ //===--------------------------------------------------------------------===//
+ // C++ Access Control
+ //
+
+ bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
+ NamedDecl *PrevMemberDecl,
+ AccessSpecifier LexicalAS);
+
+ bool CheckBaseClassAccess(QualType Derived, QualType Base,
+ BasePaths& Paths, SourceLocation AccessLoc);
+
+
enum AbstractDiagSelID {
AbstractNone = -1,
AbstractReturnType,
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=67821&r1=67820&r2=67821&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Fri Mar 27 00:05:05 2009
@@ -1,4 +1,4 @@
-//===---- SemaInherit.cpp - C++ Access Control ------------------*- C++ -*-===//
+//===---- SemaAccess.cpp - C++ Access Control -------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,6 +14,9 @@
#include "Sema.h"
using namespace clang;
+/// SetMemberAccessSpecifier - Set the access specifier of a member.
+/// Returns true on error (when the previous member decl access specifier
+/// is different from the new member decl access specifier).
bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
NamedDecl *PrevMemberDecl,
AccessSpecifier LexicalAS) {
@@ -37,3 +40,10 @@
MemberDecl->setAccess(PrevMemberDecl->getAccess());
return false;
}
+
+/// CheckBaseClassAccess - Check that a derived class can access its base class
+/// and report an error if it can't. [class.access.base]
+bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
+ BasePaths& Paths, SourceLocation AccessLoc) {
+ return false;
+}
Modified: cfe/trunk/lib/Sema/SemaInherit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInherit.cpp?rev=67821&r1=67820&r2=67821&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInherit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInherit.cpp Fri Mar 27 00:05:05 2009
@@ -202,7 +202,7 @@
/// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
/// conversion (where Derived and Base are class types) is
/// well-formed, meaning that the conversion is unambiguous (and
-/// FIXME: that all of the base classes are accessible). Returns true
+/// that all of the base classes are accessible). Returns true
/// and emits a diagnostic if the code is ill-formed, returns false
/// otherwise. Loc is the location where this routine should point to
/// if there is an error, and Range is the source range to highlight
@@ -214,15 +214,17 @@
// ambiguous. This is slightly more expensive than checking whether
// the Derived to Base conversion exists, because here we need to
// explore multiple paths to determine if there is an ambiguity.
- BasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/false,
+ BasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
/*DetectVirtual=*/false);
bool DerivationOkay = IsDerivedFrom(Derived, Base, Paths);
assert(DerivationOkay &&
"Can only be used with a derived-to-base conversion");
(void)DerivationOkay;
- if (!Paths.isAmbiguous(Context.getCanonicalType(Base).getUnqualifiedType()))
- return false;
+ if (!Paths.isAmbiguous(Context.getCanonicalType(Base).getUnqualifiedType())) {
+ // Check that the base class can be accessed.
+ return CheckBaseClassAccess(Derived, Base, Paths, Loc);
+ }
// We know that the derived-to-base conversion is ambiguous, and
// we're going to produce a diagnostic. Perform the derived-to-base
More information about the cfe-commits
mailing list