[cfe-commits] r147281 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/typedef-redecl.cpp

Douglas Gregor dgregor at apple.com
Sun Jan 1 10:11:07 PST 2012


On Dec 26, 2011, at 2:42 PM, Rafael Espindola wrote:

> Author: rafael
> Date: Mon Dec 26 16:42:47 2011
> New Revision: 147281
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=147281&view=rev
> Log:
> Delay checking of typedefs of dependent types. Fixes PR11630.
> 
> Modified:
>    cfe/trunk/include/clang/Sema/Sema.h
>    cfe/trunk/lib/Sema/SemaDecl.cpp
>    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>    cfe/trunk/test/SemaCXX/typedef-redecl.cpp
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=147281&r1=147280&r2=147281&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Dec 26 16:42:47 2011
> @@ -1326,6 +1326,7 @@
>   /// Subroutines of ActOnDeclarator().
>   TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
>                                 TypeSourceInfo *TInfo);
> +  bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New);
>   void MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls);
>   bool MergeFunctionDecl(FunctionDecl *New, Decl *Old);
>   bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old);
> 
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=147281&r1=147280&r2=147281&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Dec 26 16:42:47 2011
> @@ -1368,6 +1368,30 @@
>   return New;
> }
> 
> +bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
> +  QualType OldType;
> +  if (TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
> +    OldType = OldTypedef->getUnderlyingType();
> +  else
> +    OldType = Context.getTypeDeclType(Old);
> +  QualType NewType = New->getUnderlyingType();
> +
> +  if (OldType != NewType &&
> +      !OldType->isDependentType() &&
> +      !NewType->isDependentType() &&
> +      Context.getCanonicalType(OldType) !=
> +      Context.getCanonicalType(NewType)) {

I know this is code you moved rather than wrote, but the last condition is better spelled as

	Context.hasSameType(OldType, NewType)

Otherwise, looks great!

	- Doug




More information about the cfe-commits mailing list