[cfe-commits] r61058 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaType.cpp test/SemaCXX/nested-name-spec.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Tue Dec 16 08:06:52 PST 2008


Douglas Gregor wrote:
> Author: dgregor
> Date: Mon Dec 15 17:53:10 2008
> New Revision: 61058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=61058&view=rev
> Log:
> Diagnose erroneous uses of out-of-line member definitions and scope
> specifiers. Specifically: 
>   * Determine when an out-of-line function definition does not match
>     any declaration within the class or namespace (including coping
>     with overloaded functions).
>   * Complain about typedefs and parameters that have scope specifiers.
>   * Complain about out-of-line declarations that aren't also
>   definitions.
>   * Complain about non-static data members being declared out-of-line.
>   * Allow cv-qualifiers on out-of-line member function definitions.
>
>  
> +/// isNearlyMatchingMemberFunction - Determine whether the C++ member
> +/// functions Declaration and Definition are "nearly" matching. This
> +/// heuristic is used to improve diagnostics in the case where an
> +/// out-of-line member function definition doesn't match any
> +/// declaration within the class.
> +static bool isNearlyMatchingMemberFunction(ASTContext &Context,
> +                                           FunctionDecl *Declaration,
> +                                           FunctionDecl *Definition) {
> +  if (Declaration->param_size() != Definition->param_size())
> +    return false;
> +  for (unsigned Idx = 0; Idx < Declaration->param_size(); ++Idx) {
> +    QualType DeclParamTy = Declaration->getParamDecl(Idx)->getType();
> +    QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
> +
> +    DeclParamTy = Context.getCanonicalType(DeclParamTy.getNonReferenceType());
> +    DefParamTy = Context.getCanonicalType(DefParamTy.getNonReferenceType());
> +    if (DeclParamTy.getUnqualifiedType() != DefParamTy.getUnqualifiedType())
> +      return false;
> +  }
> +
> +  return true;
> +}
> +
>   
Do we already support cv qualifiers on member functions? Because that's 
another thing that's very easy to get wrong and deserves a special note 
in the diagnostic.

Sebastian



More information about the cfe-commits mailing list