diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-13 21:11:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-13 21:11:42 +0000 |
commit | 49d216db155b50a266ea945a240c019f7cefc15e (patch) | |
tree | 2c9c4574897243b97a25153cb27f7da7ccb433fd /clang/lib/Sema/SemaInherit.cpp | |
parent | 3b204e4c2e0669ff570214ef6f2771c532114de7 (diff) | |
download | bcm5719-llvm-49d216db155b50a266ea945a240c019f7cefc15e.tar.gz bcm5719-llvm-49d216db155b50a266ea945a240c019f7cefc15e.zip |
Add a new, more advanced CheckDerivedToBaseConversion that takes custom diagnostic IDs.
llvm-svn: 71720
Diffstat (limited to 'clang/lib/Sema/SemaInherit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInherit.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaInherit.cpp b/clang/lib/Sema/SemaInherit.cpp index 8239f54d68a..1f3433e1669 100644 --- a/clang/lib/Sema/SemaInherit.cpp +++ b/clang/lib/Sema/SemaInherit.cpp @@ -236,9 +236,12 @@ bool Sema::LookupInBases(CXXRecordDecl *Class, /// otherwise. Loc is the location where this routine should point to /// if there is an error, and Range is the source range to highlight /// if there is an error. -bool +bool Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, - SourceLocation Loc, SourceRange Range) { + unsigned InaccessibleBaseID, + unsigned AmbigiousBaseConvID, + SourceLocation Loc, SourceRange Range, + DeclarationName Name) { // First, determine whether the path from Derived to Base is // ambiguous. This is slightly more expensive than checking whether // the Derived to Base conversion exists, because here we need to @@ -252,7 +255,8 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, if (!Paths.isAmbiguous(Context.getCanonicalType(Base).getUnqualifiedType())) { // Check that the base class can be accessed. - return CheckBaseClassAccess(Derived, Base, Paths, Loc); + return CheckBaseClassAccess(Derived, Base, InaccessibleBaseID, Paths, Loc, + Name); } // We know that the derived-to-base conversion is ambiguous, and @@ -273,11 +277,21 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, // to each base class subobject. std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths); - Diag(Loc, diag::err_ambiguous_derived_to_base_conv) - << Derived << Base << PathDisplayStr << Range; + Diag(Loc, AmbigiousBaseConvID) + << Derived << Base << PathDisplayStr << Range << Name; return true; } +bool +Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, + SourceLocation Loc, SourceRange Range) { + return CheckDerivedToBaseConversion(Derived, Base, + diag::err_conv_to_inaccessible_base, + diag::err_ambiguous_derived_to_base_conv, + Loc, Range, DeclarationName()); +} + + /// @brief Builds a string representing ambiguous paths from a /// specific derived class to different subobjects of the same base /// class. |