[PATCH] Sema: Check dll attributes on static data members

Hans Wennborg hans at chromium.org
Wed May 28 11:43:57 PDT 2014


Thanks! Looks good to me, I only have one comment:

> --- a/lib/Sema/SemaDecl.cpp
> +++ b/lib/Sema/SemaDecl.cpp
> @@ -4907,10 +4907,10 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
>    // A redeclaration is not allowed to drop a dllimport attribute, the only
>    // exception being inline function definitions.
>    // NB: MSVC converts such a declaration to dllexport.
> -  bool IsInline =
> -      isa<FunctionDecl>(NewDecl) && cast<FunctionDecl>(NewDecl)->isInlined();
> -
> -  if (OldImportAttr && !HasNewAttr && !IsInline) {
> +  auto *NewFD = dyn_cast<FunctionDecl>(NewDecl);
> +  auto *NewVD = dyn_cast<VarDecl>(NewDecl);
> +  if (OldImportAttr && !HasNewAttr && !(NewFD && NewFD->isInlined()) &&
> +      !(NewVD && NewVD->isStaticDataMember())) {

I wish the definition of IsInline above could have been shorter, but
it did make the if statement easier to read. I think if the statement
looke like this, it would be much easier to parse:

  if (OldImportAttr && !HasNewAttr && !IsInline && !IsStatisDatamember) {



More information about the cfe-commits mailing list