r314235 - Allow IUnknown/IInterface types to come from extern C++
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 26 11:55:16 PDT 2017
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()) &&
((getName() == "IUnknown" &&
Uuid->getGuid() == "00000000-0000-0000-C000-000000000046") ||
(getName() == "IDispatch" &&
Modified: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown.cpp?rev=314235&r1=314234&r2=314235&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp Tue Sep 26 11:55:16 2017
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
-struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {
+extern "C++" struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {
void foo();
};
struct IPropertyPageBase : public IUnknown {};
More information about the cfe-commits
mailing list