[cfe-commits] r103775 - in /cfe/trunk: include/clang/AST/TypeLoc.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaType.cpp lib/Sema/TreeTransform.h

Daniel Dunbar daniel at zuster.org
Fri May 14 09:34:09 PDT 2010


Author: ddunbar
Date: Fri May 14 11:34:09 2010
New Revision: 103775

URL: http://llvm.org/viewvc/llvm-project?rev=103775&view=rev
Log:
Revert r103770, "Added basic source locations to Elaborated and DependentName
types.", it is breaking Clang bootstrap.

Modified:
    cfe/trunk/include/clang/AST/TypeLoc.h
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHWriter.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Fri May 14 11:34:09 2010
@@ -269,16 +269,6 @@
     return TypeClass::classof(Ty);
   }
 
-  static bool classof(const TypeLoc *TL) {
-    return Derived::classofType(TL->getTypePtr());
-  }
-  static bool classof(const UnqualTypeLoc *TL) {
-    return Derived::classofType(TL->getTypePtr());
-  }
-  static bool classof(const Derived *TL) {
-    return true;
-  }
-
   TypeLoc getNextTypeLoc() const {
     return getNextTypeLoc(asDerived()->getInnerType());
   }
@@ -1241,75 +1231,18 @@
                                                          DecltypeType> {
 };
 
-// FIXME: locations for the nested name specifier should be put in
-// NestedNameSpecifier
-struct ElaboratedLocInfo {
-  SourceLocation KeywordLoc;
-};
-
-class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
-                                                 ElaboratedTypeLoc,
-                                                 ElaboratedType,
-                                                 ElaboratedLocInfo> {
-public:
-  SourceLocation getKeywordLoc() const {
-    return this->getLocalData()->KeywordLoc;
-  }
-  void setKeywordLoc(SourceLocation Loc) {
-    this->getLocalData()->KeywordLoc = Loc;
-  }
-
-  SourceRange getSourceRange() const {
-    return SourceRange(getKeywordLoc(), getKeywordLoc());
-  }
-
-  void initializeLocal(SourceLocation Loc) {
-    setKeywordLoc(Loc);
-  }
-
-  TypeLoc getNamedTypeLoc() const {
-    return getInnerTypeLoc();
-  }
-
-  QualType getInnerType() const {
-    return getTypePtr()->getNamedType();
-  }
-};
-
-// FIXME: locations for the nested name specifier should be put in
-// NestedNameSpecifier
-struct DependentNameLocInfo {
-  SourceLocation KeywordLoc;
-  SourceLocation NameLoc;
+// FIXME: locations for the nested name specifier;  at the very least,
+// a SourceRange.
+class ElaboratedTypeLoc :
+    public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
+                                     ElaboratedTypeLoc,
+                                     ElaboratedType> {
 };
 
-class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
-                                                    DependentNameTypeLoc,
-                                                    DependentNameType,
-                                                    DependentNameLocInfo> {
-public:
-  SourceLocation getKeywordLoc() const {
-    return this->getLocalData()->KeywordLoc;
-  }
-  void setKeywordLoc(SourceLocation Loc) {
-    this->getLocalData()->KeywordLoc = Loc;
-  }
-
-  SourceLocation getNameLoc() const {
-    return this->getLocalData()->NameLoc;
-  }
-  void setNameLoc(SourceLocation Loc) {
-    this->getLocalData()->NameLoc = Loc;
-  }
-
-  SourceRange getSourceRange() const {
-    return SourceRange(getKeywordLoc(), getNameLoc());
-  }
-
-  void initializeLocal(SourceLocation Loc) {
-    setKeywordLoc(Loc);
-    setNameLoc(Loc);
-  }
+// FIXME: locations for the typename keyword and nested name specifier.
+class DependentNameTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
+                                                         DependentNameTypeLoc,
+                                                         DependentNameType> {
 };
 
 }

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Fri May 14 11:34:09 2010
@@ -2354,13 +2354,12 @@
                                           Record, Idx));
 }
 void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
-  TL.setKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+  TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
 }
 void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
   TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
 }
 void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
-  TL.setKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
 }
 void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Fri May 14 11:34:09 2010
@@ -396,13 +396,12 @@
     Writer.AddTemplateArgumentLoc(TL.getArgLoc(i), Record);
 }
 void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
-  Writer.AddSourceLocation(TL.getKeywordLoc(), Record);
+  Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
 void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
 void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
-  Writer.AddSourceLocation(TL.getKeywordLoc(), Record);
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
 void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri May 14 11:34:09 2010
@@ -5184,18 +5184,16 @@
 
 static void FillTypeLoc(DependentNameTypeLoc TL,
                         SourceLocation TypenameLoc,
-                        SourceRange QualifierRange,
-                        SourceLocation NameLoc) {
-  // FIXME: qualifier range
-  TL.setKeywordLoc(TypenameLoc);
-  TL.setNameLoc(NameLoc);
+                        SourceRange QualifierRange) {
+  // FIXME: typename, qualifier range
+  TL.setNameLoc(TypenameLoc);
 }
 
 static void FillTypeLoc(ElaboratedTypeLoc TL,
                         SourceLocation TypenameLoc,
                         SourceRange QualifierRange) {
-  // FIXME: qualifier range and inner locations.
-  TL.setKeywordLoc(TypenameLoc);
+  // FIXME: typename, qualifier range
+  TL.setNameLoc(TypenameLoc);
 }
 
 Sema::TypeResult
@@ -5215,7 +5213,7 @@
   if (isa<DependentNameType>(T)) {
     DependentNameTypeLoc TL = cast<DependentNameTypeLoc>(TSI->getTypeLoc());
     // FIXME: fill inner type loc
-    FillTypeLoc(TL, TypenameLoc, SS.getRange(), IdLoc);
+    FillTypeLoc(TL, TypenameLoc, SS.getRange());
   } else {
     ElaboratedTypeLoc TL = cast<ElaboratedTypeLoc>(TSI->getTypeLoc());
     // FIXME: fill inner type loc
@@ -5251,7 +5249,7 @@
   TypeSourceInfo *TSI = Context.CreateTypeSourceInfo(T);
   DependentNameTypeLoc TL = cast<DependentNameTypeLoc>(TSI->getTypeLoc());
   // FIXME: fill inner type loc
-  FillTypeLoc(TL, TypenameLoc, SS.getRange(), TemplateLoc);
+  FillTypeLoc(TL, TypenameLoc, SS.getRange());
   return CreateLocInfoType(T, TSI).getAsOpaquePtr();
 }
 
@@ -5428,41 +5426,13 @@
   } else
     Result = getDerived().RebuildDependentNameType(T->getKeyword(),
                                                    NNS, T->getIdentifier(),
-                                                   TL.getSourceRange());
+                                                  SourceRange(TL.getNameLoc()));
 
   if (Result.isNull())
     return QualType();
 
-  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
-    QualType NamedT = ElabT->getNamedType();
-    if (isa<TypedefType>(NamedT)) {
-      TypedefTypeLoc NamedTLoc = TLB.push<TypedefTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<RecordType>(NamedT)) {
-      RecordTypeLoc NamedTLoc = TLB.push<RecordTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<EnumType>(NamedT)) {
-      EnumTypeLoc NamedTLoc = TLB.push<EnumTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<TemplateSpecializationType>(NamedT)) {
-      TemplateSpecializationTypeLoc NamedTLoc
-        = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
-      // FIXME: fill locations
-      NamedTLoc.initializeLocal(SourceLocation());
-    }
-    else
-      llvm_unreachable("Unexpected type");
-    ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
-    NewTL.setKeywordLoc(TL.getKeywordLoc());
-  }
-  else {
-    DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
-    NewTL.setKeywordLoc(TL.getKeywordLoc());
-    NewTL.setNameLoc(TL.getNameLoc());
-  }
+  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
+  NewTL.setNameLoc(TL.getNameLoc());
   return Result;
 }
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 14 11:34:09 2010
@@ -1455,15 +1455,9 @@
         return;
       }
 
-      TypeLoc OldTL = TInfo->getTypeLoc();
-      if (TInfo->getType()->getAs<ElaboratedType>()) {
-        ElaboratedTypeLoc ElabTL = cast<ElaboratedTypeLoc>(OldTL);
-        TemplateSpecializationTypeLoc NamedTL =
-          cast<TemplateSpecializationTypeLoc>(ElabTL.getNamedTypeLoc());
-        TL.copy(NamedTL);
-      }
-      else
-        TL.copy(cast<TemplateSpecializationTypeLoc>(OldTL));
+      TemplateSpecializationTypeLoc OldTL =
+        cast<TemplateSpecializationTypeLoc>(TInfo->getTypeLoc());
+      TL.copy(OldTL);
     }
     void VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
       assert(DS.getTypeSpecType() == DeclSpec::TST_typeofExpr);
@@ -1494,23 +1488,6 @@
           TL.setBuiltinLoc(DS.getTypeSpecWidthLoc());
       }
     }
-    void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
-      ElaboratedTypeKeyword Keyword
-        = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
-      TL.setKeywordLoc(Keyword != ETK_None
-                       ? DS.getTypeSpecTypeLoc()
-                       : SourceLocation());
-      Visit(TL.getNextTypeLoc().getUnqualifiedLoc());
-    }
-    void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
-      ElaboratedTypeKeyword Keyword
-        = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType());
-      TL.setKeywordLoc(Keyword != ETK_None
-                       ? DS.getTypeSpecTypeLoc()
-                       : SourceLocation());
-      TL.setNameLoc(DS.getTypeSpecTypeLoc());
-    }
-
     void VisitTypeLoc(TypeLoc TL) {
       // FIXME: add other typespec types and change this to an assert.
       TL.initialize(DS.getTypeSpecTypeLoc());

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=103775&r1=103774&r2=103775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri May 14 11:34:09 2010
@@ -3247,22 +3247,22 @@
 TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
                                                 ElaboratedTypeLoc TL,
                                                 QualType ObjectType) {
-  QualType Named = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
-  if (Named.isNull())
-    return QualType();
-
   ElaboratedType *T = TL.getTypePtr();
 
   NestedNameSpecifier *NNS = 0;
   // NOTE: the qualifier in an ElaboratedType is optional.
   if (T->getQualifier() != 0) {
     NNS = getDerived().TransformNestedNameSpecifier(T->getQualifier(),
-                                                    /* FIXME */ SourceRange(),
+                                                    SourceRange(),
                                                     ObjectType);
     if (!NNS)
       return QualType();
   }
 
+  QualType Named = getDerived().TransformType(T->getNamedType());
+  if (Named.isNull())
+    return QualType();
+
   QualType Result = TL.getType();
   if (getDerived().AlwaysRebuild() ||
       NNS != T->getQualifier() ||
@@ -3273,7 +3273,7 @@
   }
 
   ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
-  NewTL.setKeywordLoc(TL.getKeywordLoc());
+  NewTL.setNameLoc(TL.getNameLoc());
 
   return Result;
 }
@@ -3315,36 +3315,9 @@
   if (Result.isNull())
     return QualType();
 
-  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
-    QualType NamedT = ElabT->getNamedType();
-    if (isa<TypedefType>(NamedT)) {
-      TypedefTypeLoc NamedTLoc = TLB.push<TypedefTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<RecordType>(NamedT)) {
-      RecordTypeLoc NamedTLoc = TLB.push<RecordTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<EnumType>(NamedT)) {
-      EnumTypeLoc NamedTLoc = TLB.push<EnumTypeLoc>(NamedT);
-      NamedTLoc.setNameLoc(TL.getNameLoc());
-    }
-    else if (isa<TemplateSpecializationType>(NamedT)) {
-      TemplateSpecializationTypeLoc NamedTLoc
-        = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
-      // FIXME: fill locations
-      NamedTLoc.initializeLocal(SourceLocation());
-    }
-    else
-      llvm_unreachable("Unexpected type");
-    ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
-    NewTL.setKeywordLoc(TL.getKeywordLoc());
-  }
-  else {
-    DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
-    NewTL.setKeywordLoc(TL.getKeywordLoc());
-    NewTL.setNameLoc(TL.getNameLoc());
-  }
+  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
+  NewTL.setNameLoc(TL.getNameLoc());
+
   return Result;
 }
 





More information about the cfe-commits mailing list