[cfe-commits] r85070 - in /cfe/trunk/lib/Sema: SemaDecl.cpp SemaType.cpp
Chris Lattner
sabre at nondot.org
Sun Oct 25 15:09:09 PDT 2009
Author: lattner
Date: Sun Oct 25 17:09:09 2009
New Revision: 85070
URL: http://llvm.org/viewvc/llvm-project?rev=85070&view=rev
Log:
move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType. getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted. This is also needed by two upcoming enhancements.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=85070&r1=85069&r2=85070&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct 25 17:09:09 2009
@@ -95,7 +95,7 @@
case LookupResult::FoundOverloaded:
return 0;
- case LookupResult::Ambiguous: {
+ case LookupResult::Ambiguous:
// Recover from type-hiding ambiguities by hiding the type. We'll
// do the lookup again when looking for an object, and we can
// diagnose the error then. If we don't do this, then the error
@@ -131,7 +131,6 @@
// perform the name lookup again.
DiagnoseAmbiguousLookup(Result, DeclarationName(&II), NameLoc);
break;
- }
case LookupResult::Found:
IIDecl = Result.getFoundDecl();
@@ -142,9 +141,6 @@
QualType T;
if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
- // Check whether we can use this type.
- (void)DiagnoseUseOfDecl(IIDecl, NameLoc);
-
// C++ [temp.local]p2:
// Within the scope of a class template specialization or
// partial specialization, when the injected-class-name is
@@ -164,9 +160,6 @@
T = getQualifiedNameType(*SS, T);
} else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) {
- // Check whether we can use this interface.
- (void)DiagnoseUseOfDecl(IIDecl, NameLoc);
-
T = Context.getObjCInterfaceType(IDecl);
} else
return 0;
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=85070&r1=85069&r2=85070&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sun Oct 25 17:09:09 2009
@@ -58,11 +58,11 @@
return false;
if (D.getNumTypeObjects() == 0)
- return true;
+ return true; // ^{ ... }
if (D.getNumTypeObjects() == 1 &&
D.getTypeObject(0).Kind == DeclaratorChunk::Function)
- return true;
+ return true; // ^(int X, float Y) { ... }
return false;
}
@@ -228,7 +228,7 @@
case DeclSpec::TST_enum:
case DeclSpec::TST_union:
case DeclSpec::TST_struct: {
- Decl *D = static_cast<Decl *>(DS.getTypeRep());
+ TypeDecl *D = cast_or_null<TypeDecl>(static_cast<Decl *>(DS.getTypeRep()));
if (!D) {
// This can happen in C++ with ambiguous lookups.
Result = Context.IntTy;
@@ -236,11 +236,14 @@
break;
}
+ // If the type is deprecated or unavailable, diagnose it.
+ TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc());
+
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
- DS.getTypeSpecSign() == 0 &&
- "Can't handle qualifiers on typedef names yet!");
+ DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!");
+
// TypeQuals handled by caller.
- Result = Context.getTypeDeclType(cast<TypeDecl>(D));
+ Result = Context.getTypeDeclType(D);
// In C++, make an ElaboratedType.
if (TheSema.getLangOptions().CPlusPlus) {
@@ -290,9 +293,22 @@
}
// If this is a reference to an invalid typedef, propagate the invalidity.
- if (TypedefType *TDT = dyn_cast<TypedefType>(Result))
+ if (TypedefType *TDT = dyn_cast<TypedefType>(Result)) {
if (TDT->getDecl()->isInvalidDecl())
TheDeclarator.setInvalidType(true);
+
+ // If the type is deprecated or unavailable, diagnose it.
+ TheSema.DiagnoseUseOfDecl(TDT->getDecl(), DS.getTypeSpecTypeLoc());
+ } else if (ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(Result)) {
+ // If the type is deprecated or unavailable, diagnose it.
+ TheSema.DiagnoseUseOfDecl(OIT->getDecl(), DS.getTypeSpecTypeLoc());
+ } else if (ObjCObjectPointerType *DPT =
+ dyn_cast<ObjCObjectPointerType>(Result)) {
+ // If the type is deprecated or unavailable, diagnose it.
+ if (ObjCInterfaceDecl *D = DPT->getInterfaceDecl())
+ TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc());
+ }
+
// TypeQuals handled by caller.
break;
More information about the cfe-commits
mailing list