From: Abramo Bagnara Date: Thu, 20 May 2010 10:00:11 +0000 (+0000) Subject: Renamed misleading getSourceRange -> getLocalSourceRange and getFullSourceRange ... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd054dba8a3023821f2a0951b0fae05e3522a7c9;p=clang Renamed misleading getSourceRange -> getLocalSourceRange and getFullSourceRange -> getSourceRange for TypeLoc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104220 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index ec9423664e..0a3a5d45a5 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -86,20 +86,20 @@ public: } /// \brief Get the full source range. - SourceRange getFullSourceRange() const { - SourceLocation End = getSourceRange().getEnd(); + SourceRange getSourceRange() const { + SourceLocation End = getLocalSourceRange().getEnd(); TypeLoc Cur = *this; while (true) { TypeLoc Next = Cur.getNextTypeLoc(); if (Next.isNull()) break; Cur = Next; } - return SourceRange(Cur.getSourceRange().getBegin(), End); + return SourceRange(Cur.getLocalSourceRange().getBegin(), End); } /// \brief Get the local source range. - SourceRange getSourceRange() const { - return getSourceRangeImpl(*this); + SourceRange getLocalSourceRange() const { + return getLocalSourceRangeImpl(*this); } /// \brief Returns the size of the type source info data block. @@ -138,7 +138,7 @@ public: private: static void initializeImpl(TypeLoc TL, SourceLocation Loc); static TypeLoc getNextTypeLocImpl(TypeLoc TL); - static SourceRange getSourceRangeImpl(TypeLoc TL); + static SourceRange getLocalSourceRangeImpl(TypeLoc TL); }; /// \brief Return the TypeLoc for a type source info. @@ -174,7 +174,7 @@ public: /// type qualifiers. class QualifiedTypeLoc : public TypeLoc { public: - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(); } @@ -377,7 +377,7 @@ public: void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getNameLoc(), getNameLoc()); } void initializeLocal(SourceLocation Loc) { @@ -429,7 +429,7 @@ public: return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0; } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getBuiltinLoc(), getBuiltinLoc()); } @@ -631,7 +631,7 @@ public: return getInnerTypeLoc(); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getLAngleLoc(), getRAngleLoc()); } @@ -675,7 +675,7 @@ public: getLocalData()->NameLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getNameLoc()); } @@ -705,7 +705,7 @@ public: return this->getInnerTypeLoc(); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getSigilLoc(), getSigilLoc()); } @@ -848,7 +848,7 @@ public: return getInnerTypeLoc(); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getLParenLoc(), getRParenLoc()); } @@ -921,7 +921,7 @@ public: return getInnerTypeLoc(); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getLBracketLoc(), getRBracketLoc()); } @@ -1026,7 +1026,7 @@ public: memcpy(Data, Loc.Data, size); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getTemplateNameLoc(), getRAngleLoc()); } @@ -1154,7 +1154,7 @@ public: setRParenLoc(range.getEnd()); } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { return SourceRange(getTypeofLoc(), getRParenLoc()); } @@ -1175,7 +1175,7 @@ public: // Reimplemented to account for GNU/C++ extension // typeof unary-expression // where there are no parentheses. - SourceRange getSourceRange() const; + SourceRange getLocalSourceRange() const; }; class TypeOfTypeLoc @@ -1222,7 +1222,7 @@ public: this->getLocalData()->QualifierRange = Range; } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { if (getKeywordLoc().isValid()) if (getQualifierRange().getEnd().isValid()) return SourceRange(getKeywordLoc(), getQualifierRange().getEnd()); @@ -1284,7 +1284,7 @@ public: this->getLocalData()->NameLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getLocalSourceRange() const { if (getKeywordLoc().isValid()) return SourceRange(getKeywordLoc(), getNameLoc()); else diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 9d756950fa..6ed08d1e1e 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2950,7 +2950,7 @@ TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) { return 0; return ToContext.getTrivialTypeSourceInfo(T, - FromTSI->getTypeLoc().getFullSourceRange().getBegin()); + FromTSI->getTypeLoc().getSourceRange().getBegin()); } Decl *ASTImporter::Import(Decl *FromD) { diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index c813a47f6b..b8bd310992 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -536,7 +536,7 @@ SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const { while (true) { TypeLoc NextTL = TL.getNextTypeLoc(); if (!NextTL) - return TL.getSourceRange().getBegin(); + return TL.getLocalSourceRange().getBegin(); TL = NextTL; } } diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 8d9be130b1..47ff957fa3 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -777,7 +777,7 @@ SourceLocation CXXBaseOrMemberInitializer::getSourceLocation() const { if (isMemberInitializer()) return getMemberLocation(); - return getBaseClassLoc().getSourceRange().getBegin(); + return getBaseClassLoc().getLocalSourceRange().getBegin(); } SourceRange CXXBaseOrMemberInitializer::getSourceRange() const { diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index 7dd2aff6fb..98a724aeee 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -259,7 +259,7 @@ TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC, } SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { - return DefaultArgument->getTypeLoc().getFullSourceRange().getBegin(); + return DefaultArgument->getTypeLoc().getSourceRange().getBegin(); } unsigned TemplateTypeParmDecl::getDepth() const { diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 1e8d61a216..d0a0cf1107 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -144,7 +144,7 @@ Stmt::child_iterator CXXPseudoDestructorExpr::child_end() { PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) : Type(Info) { - Location = Info->getTypeLoc().getSourceRange().getBegin(); + Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); } QualType CXXPseudoDestructorExpr::getDestroyedType() const { @@ -157,7 +157,7 @@ QualType CXXPseudoDestructorExpr::getDestroyedType() const { SourceRange CXXPseudoDestructorExpr::getSourceRange() const { SourceLocation End = DestroyedType.getLocation(); if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) - End = TInfo->getTypeLoc().getSourceRange().getEnd(); + End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); return SourceRange(Base->getLocStart(), End); } diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index 0bf9f2fb7c..1c775efe57 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -103,7 +103,7 @@ SourceRange TemplateArgumentLoc::getSourceRange() const { return getSourceDeclExpression()->getSourceRange(); case TemplateArgument::Type: - return getTypeSourceInfo()->getTypeLoc().getFullSourceRange(); + return getTypeSourceInfo()->getTypeLoc().getSourceRange(); case TemplateArgument::Template: if (getTemplateQualifierRange().isValid()) diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index e66738a65d..678a0f0475 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -27,13 +27,13 @@ namespace { #define ABSTRACT_TYPELOC(CLASS, PARENT) #define TYPELOC(CLASS, PARENT) \ SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \ - return TyLoc.getSourceRange(); \ + return TyLoc.getLocalSourceRange(); \ } #include "clang/AST/TypeLocNodes.def" }; } -SourceRange TypeLoc::getSourceRangeImpl(TypeLoc TL) { +SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) { if (TL.isNull()) return SourceRange(); return TypeLocRanger().Visit(TL); } @@ -140,7 +140,7 @@ bool TypeSpecTypeLoc::classof(const TypeLoc *TL) { // Reimplemented to account for GNU/C++ extension // typeof unary-expression // where there are no parentheses. -SourceRange TypeOfExprTypeLoc::getSourceRange() const { +SourceRange TypeOfExprTypeLoc::getLocalSourceRange() const { if (getRParenLoc().isValid()) return SourceRange(getTypeofLoc(), getRParenLoc()); else diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp index 091bc78c26..bd3b5ee8bf 100644 --- a/lib/Index/ASTLocation.cpp +++ b/lib/Index/ASTLocation.cpp @@ -69,7 +69,7 @@ SourceRange ASTLocation::getSourceRange() const { case N_NamedRef: return SourceRange(AsNamedRef().Loc, AsNamedRef().Loc); case N_Type: - return AsTypeLoc().getSourceRange(); + return AsTypeLoc().getLocalSourceRange(); } return SourceRange(); diff --git a/lib/Index/ResolveLocation.cpp b/lib/Index/ResolveLocation.cpp index 8ef8f3ba7f..ccd7a126b4 100644 --- a/lib/Index/ResolveLocation.cpp +++ b/lib/Index/ResolveLocation.cpp @@ -51,7 +51,7 @@ protected: return CheckRange(D->getSourceRange()); } RangePos CheckRange(Stmt *Node) { return CheckRange(Node->getSourceRange()); } - RangePos CheckRange(TypeLoc TL) { return CheckRange(TL.getSourceRange()); } + RangePos CheckRange(TypeLoc TL) { return CheckRange(TL.getLocalSourceRange()); } template bool isBeforeLocation(T Node) { diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 8cbe92af40..b32055a8a4 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1369,7 +1369,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, for (unsigned i = 0; i < NumArgs; i++) HasDependentArg |= Args[i]->isTypeDependent(); - SourceLocation BaseLoc = BaseTInfo->getTypeLoc().getSourceRange().getBegin(); + SourceLocation BaseLoc = BaseTInfo->getTypeLoc().getLocalSourceRange().getBegin(); if (BaseType->isDependentType() || HasDependentArg) { // Can't check initialization for a base of dependent type or when // any of the arguments are type-dependent expressions. @@ -1393,7 +1393,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, if (!BaseType->isRecordType()) return Diag(BaseLoc, diag::err_base_init_does_not_name_class) - << BaseType << BaseTInfo->getTypeLoc().getSourceRange(); + << BaseType << BaseTInfo->getTypeLoc().getLocalSourceRange(); // C++ [class.base.init]p2: // [...] Unless the mem-initializer-id names a nonstatic data @@ -1414,7 +1414,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, // class, the mem-initializer is ill-formed. if (DirectBaseSpec && VirtualBaseSpec) return Diag(BaseLoc, diag::err_base_init_direct_and_virtual) - << BaseType << BaseTInfo->getTypeLoc().getSourceRange(); + << BaseType << BaseTInfo->getTypeLoc().getLocalSourceRange(); // C++ [base.class.init]p2: // Unless the mem-initializer-id names a nonstatic data membeer of the // constructor's class ot a direst or virtual base of that class, the @@ -1422,7 +1422,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, if (!DirectBaseSpec && !VirtualBaseSpec) return Diag(BaseLoc, diag::err_not_direct_base_or_virtual) << BaseType << Context.getTypeDeclType(ClassDecl) - << BaseTInfo->getTypeLoc().getSourceRange(); + << BaseTInfo->getTypeLoc().getLocalSourceRange(); CXXBaseSpecifier *BaseSpec = const_cast(DirectBaseSpec); @@ -5504,7 +5504,7 @@ FriendDecl *Sema::CheckFriendTypeDecl(SourceLocation FriendLoc, assert(TSInfo && "NULL TypeSourceInfo for friend type declaration"); QualType T = TSInfo->getType(); - SourceRange TypeRange = TSInfo->getTypeLoc().getSourceRange(); + SourceRange TypeRange = TSInfo->getTypeLoc().getLocalSourceRange(); if (!getLangOptions().CPlusPlus0x) { // C++03 [class.friend]p2: diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 67c2fcbb9e..320b24227a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6645,7 +6645,7 @@ Sema::OwningExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, SourceLocation RParenLoc) { QualType ArgTy = TInfo->getType(); bool Dependent = ArgTy->isDependentType(); - SourceRange TypeRange = TInfo->getTypeLoc().getSourceRange(); + SourceRange TypeRange = TInfo->getTypeLoc().getLocalSourceRange(); // We must have at least one component that refers to the type, and the first // one is known to be a field designator. Verify that the ArgTy represents diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 5849382050..4bc4ca1e94 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2788,12 +2788,12 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base, if (DestructedTypeInfo) { QualType DestructedType = DestructedTypeInfo->getType(); SourceLocation DestructedTypeStart - = DestructedTypeInfo->getTypeLoc().getSourceRange().getBegin(); + = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(); if (!DestructedType->isDependentType() && !ObjectType->isDependentType() && !Context.hasSameUnqualifiedType(DestructedType, ObjectType)) { Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch) << ObjectType << DestructedType << BaseE->getSourceRange() - << DestructedTypeInfo->getTypeLoc().getSourceRange(); + << DestructedTypeInfo->getTypeLoc().getLocalSourceRange(); // Recover by setting the destructed type to the object type. DestructedType = ObjectType; @@ -2815,10 +2815,10 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base, if (!ScopeType->isDependentType() && !ObjectType->isDependentType() && !Context.hasSameType(ScopeType, ObjectType)) { - Diag(ScopeTypeInfo->getTypeLoc().getSourceRange().getBegin(), + Diag(ScopeTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(), diag::err_pseudo_dtor_type_mismatch) << ObjectType << ScopeType << BaseE->getSourceRange() - << ScopeTypeInfo->getTypeLoc().getSourceRange(); + << ScopeTypeInfo->getTypeLoc().getLocalSourceRange(); ScopeType = QualType(); ScopeTypeInfo = 0; diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 0b058be579..dd402b074d 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -718,7 +718,7 @@ Sema::OwningExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, } SourceLocation Loc = SuperLoc.isValid()? SuperLoc - : ReceiverTypeInfo->getTypeLoc().getSourceRange().getBegin(); + : ReceiverTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(); // Find the class to which we are sending this message. ObjCInterfaceDecl *Class = 0; diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 3242f70f12..8eab30bd36 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1090,7 +1090,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, DiagnoseDefaultTemplateArgument(*this, TPC, NewTypeParm->getLocation(), NewTypeParm->getDefaultArgumentInfo()->getTypeLoc() - .getFullSourceRange())) + .getSourceRange())) NewTypeParm->removeDefaultArgument(); // Merge default arguments for template type parameters. @@ -2350,17 +2350,17 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param, else if (const RecordType *RecordT = Arg->getAs()) Tag = RecordT; if (Tag && Tag->getDecl()->getDeclContext()->isFunctionOrMethod()) { - SourceRange SR = ArgInfo->getTypeLoc().getFullSourceRange(); + SourceRange SR = ArgInfo->getTypeLoc().getSourceRange(); return Diag(SR.getBegin(), diag::err_template_arg_local_type) << QualType(Tag, 0) << SR; } else if (Tag && !Tag->getDecl()->getDeclName() && !Tag->getDecl()->getTypedefForAnonDecl()) { - SourceRange SR = ArgInfo->getTypeLoc().getFullSourceRange(); + SourceRange SR = ArgInfo->getTypeLoc().getSourceRange(); Diag(SR.getBegin(), diag::err_template_arg_unnamed_type) << SR; Diag(Tag->getDecl()->getLocation(), diag::note_template_unnamed_type_here); return true; } else if (Context.hasSameUnqualifiedType(Arg, Context.OverloadTy)) { - SourceRange SR = ArgInfo->getTypeLoc().getFullSourceRange(); + SourceRange SR = ArgInfo->getTypeLoc().getSourceRange(); return Diag(SR.getBegin(), diag::err_template_arg_overload_type) << SR; } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index d0773565a9..5db4f2b5dd 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2539,7 +2539,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) { if (const DeclaratorDecl *DD = dyn_cast(D)) { if (TypeSourceInfo *TI = DD->getTypeSourceInfo()) { TypeLoc TL = TI->getTypeLoc(); - SourceLocation TLoc = TL.getFullSourceRange().getBegin(); + SourceLocation TLoc = TL.getSourceRange().getBegin(); if (TLoc.isValid() && SrcMgr.isBeforeInTranslationUnit(TLoc, L)) cursorRange.setBegin(TLoc);