diff options
-rw-r--r-- | include/clang/AST/DeclarationName.h | 20 | ||||
-rw-r--r-- | lib/AST/DeclarationName.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 6 |
4 files changed, 16 insertions, 19 deletions
diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index f359499b14..6146525406 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -109,8 +109,8 @@ private: /// CXXSpecialName, returns a pointer to it. Otherwise, returns /// a NULL pointer. CXXSpecialName *getAsCXXSpecialName() const { - if (getNameKind() >= CXXConstructorName && - getNameKind() <= CXXConversionFunctionName) + NameKind Kind = getNameKind(); + if (Kind >= CXXConstructorName && Kind <= CXXConversionFunctionName) return reinterpret_cast<CXXSpecialName *>(Ptr & ~PtrMask); return 0; } @@ -156,14 +156,8 @@ private: friend class DeclarationNameTable; friend class NamedDecl; - /// getFETokenInfoAsVoid - Retrieves the front end-specified pointer - /// for this name as a void pointer. - void *getFETokenInfoAsVoid() const { - if (getNameKind() == Identifier) - return getAsIdentifierInfo()->getFETokenInfo<void>(); - return getFETokenInfoAsVoidSlow(); - } - + /// getFETokenInfoAsVoidSlow - Retrieves the front end-specified pointer + /// for this name as a void pointer if it's not an identifier. void *getFETokenInfoAsVoidSlow() const; public: @@ -273,7 +267,11 @@ public: /// declaration names, including normal identifiers and C++ /// constructors, destructors, and conversion functions. template<typename T> - T *getFETokenInfo() const { return static_cast<T*>(getFETokenInfoAsVoid()); } + T *getFETokenInfo() const { + if (const IdentifierInfo *Info = getAsIdentifierInfo()) + return Info->getFETokenInfo<T>(); + return static_cast<T*>(getFETokenInfoAsVoidSlow()); + } void setFETokenInfo(void *T); diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index 9eadf32543..28188d91c1 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -281,7 +281,7 @@ IdentifierInfo *DeclarationName::getCXXLiteralIdentifier() const { void *DeclarationName::getFETokenInfoAsVoidSlow() const { switch (getNameKind()) { case Identifier: - llvm_unreachable("Handled by getFETokenInfoAsVoid()"); + llvm_unreachable("Handled by getFETokenInfo()"); case CXXConstructorName: case CXXDestructorName: diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 9143eb282f..3e1899c762 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1504,15 +1504,14 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, Decl *Member; if (isInstField) { CXXScopeSpec &SS = D.getCXXScopeSpec(); + IdentifierInfo *II = Name.getAsIdentifierInfo(); // Data members must have identifiers for names. - if (Name.getNameKind() != DeclarationName::Identifier) { + if (!II) { Diag(Loc, diag::err_bad_variable_name) << Name; return 0; } - - IdentifierInfo *II = Name.getAsIdentifierInfo(); // Member field could not be with "template" keyword. // So TemplateParameterLists should be empty in this case. @@ -4469,7 +4468,7 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) { if (Diags.getDiagnosticLevel(diag::warn_overloaded_virtual, MD->getLocation()) == DiagnosticsEngine::Ignored) return; - if (MD->getDeclName().getNameKind() != DeclarationName::Identifier) + if (!MD->getDeclName().isIdentifier()) return; CXXBasePaths Paths(/*FindAmbiguities=*/true, // true to look in all bases. diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 0fbfc2a278..3a4f3dd883 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -1398,14 +1398,14 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, bool Super) { const ObjCInterfaceType *IFaceT = OPT->getInterfaceType(); ObjCInterfaceDecl *IFace = IFaceT->getDecl(); - - if (MemberName.getNameKind() != DeclarationName::Identifier) { + + IdentifierInfo *Member = MemberName.getAsIdentifierInfo(); + if (!Member) { Diag(MemberLoc, diag::err_invalid_property_name) << MemberName << QualType(OPT, 0); return ExprError(); } - IdentifierInfo *Member = MemberName.getAsIdentifierInfo(); SourceRange BaseRange = Super? SourceRange(SuperLoc) : BaseExpr->getSourceRange(); if (RequireCompleteType(MemberLoc, OPT->getPointeeType(), |