diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-08-26 22:33:56 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-08-26 22:33:56 +0000 |
| commit | f68079e77ba06b434539cda8797e7aaaf9ef9028 (patch) | |
| tree | 208cd11afd0f880b6861ae8f323a932c4c49a4d7 /clang/lib | |
| parent | 4fa923c5bc559ad747f5ea2cf68c1c270044f34b (diff) | |
| download | bcm5719-llvm-f68079e77ba06b434539cda8797e7aaaf9ef9028.tar.gz bcm5719-llvm-f68079e77ba06b434539cda8797e7aaaf9ef9028.zip | |
Add a RequireCompleteType variant that takes a PartialDiagnostic. The old RequireCompleteType now creates a PartialDiagnostic and calls the new function.
llvm-svn: 80165
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 18 |
3 files changed, 30 insertions, 5 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 24c5e09f434..0d9ad12edab 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -19,6 +19,7 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" using namespace clang; @@ -362,6 +363,15 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() { } } +Sema::SemaDiagnosticBuilder +Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) { + SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID())); + PD.Emit(Builder); + + return Builder; +} + void Sema::ActOnComment(SourceRange Comment) { Context.Comments.push_back(Comment); } + diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 5b7a247e25a..324090556fc 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -401,6 +401,9 @@ public: return SemaDiagnosticBuilder(DB, *this, DiagID); } + /// \brief Emit a partial diagnostic. + SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD); + virtual void DeleteExpr(ExprTy *E); virtual void DeleteStmt(StmtTy *S); @@ -484,7 +487,9 @@ public: SourceRange Range1 = SourceRange(), SourceRange Range2 = SourceRange(), QualType PrintType = QualType()); - + bool RequireCompleteType(SourceLocation Loc, QualType T, + const PartialDiagnostic &PD); + QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T); QualType BuildTypeofExprType(Expr *E); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 49946ac1c36..7775c25142e 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -18,6 +18,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/TypeLoc.h" #include "clang/AST/Expr.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Parse/DeclSpec.h" #include "llvm/ADT/SmallPtrSet.h" using namespace clang; @@ -1772,6 +1773,18 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) { bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, SourceRange Range1, SourceRange Range2, QualType PrintType) { + if (!PrintType.isNull()) + return RequireCompleteType(Loc, T, + PDiag(diag) << Range1 << Range2 << PrintType); + + return RequireCompleteType(Loc, T, + PDiag(diag) << Range1 << Range2); +} + +bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, + const PartialDiagnostic &PD) { + unsigned diag = PD.getDiagID(); + // FIXME: Add this assertion to help us flush out problems with // checking for dependent types and type-dependent expressions. // @@ -1816,11 +1829,8 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, if (diag == 0) return true; - if (PrintType.isNull()) - PrintType = T; - // We have an incomplete type. Produce a diagnostic. - Diag(Loc, diag) << PrintType << Range1 << Range2; + Diag(Loc, PD) << T; // If the type was a forward declaration of a class/struct/union // type, produce |

