r314235 - Allow IUnknown/IInterface types to come from extern C++

Keane, Erich via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 26 13:07:00 PDT 2017


Ah! Sorry, I didn't realize that isExternCXXContext actually searched the entire search-set!  Followup patch coming  Thanks for the heads up!

-----Original Message-----
From: Friedman, Eli [mailto:efriedma at codeaurora.org] 
Sent: Tuesday, September 26, 2017 12:06 PM
To: Keane, Erich <erich.keane at intel.com>; cfe-commits at lists.llvm.org
Subject: Re: r314235 - Allow IUnknown/IInterface types to come from extern C++

On 9/26/2017 11:55 AM, Erich Keane via cfe-commits wrote:
> Author: erichkeane
> Date: Tue Sep 26 11:55:16 2017
> New Revision: 314235
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
> Log:
> Allow IUnknown/IInterface types to come from extern C++
>
> It was brought up in response to my last implementation for this 
> struct-as-interface features that at least 1 header in the MS SDK uses 
> "extern C++" around an IUnknown declaration.
>
> The previous implementation demanded that this type exist in the 
> TranslationUnit DeclContext.  This small change simply also allows in 
> the situation where we're extern "C++".
>
> Modified:
>      cfe/trunk/lib/AST/DeclCXX.cpp
>      cfe/trunk/test/SemaCXX/ms-iunknown.cpp
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=
> 314235&r1=314234&r2=314235&view=diff
> ======================================================================
> ========
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
> @@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
>   
>     // Check "Special" types.
>     const auto *Uuid = getAttr<UuidAttr>();
> -  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
> +  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
> +                             getDeclContext()->isExternCXXContext()) 
> + &&

Do you need to check that the "extern C++" is actually a direct child of the translation unit?  Consider, e.g. `namespace X { extern "C++"`...

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the cfe-commits mailing list