From 99eda60b49e6c483f8548eb69709d8b5a7bed7b8 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Tue, 26 Sep 2017 18:55:16 +0000 Subject: [PATCH] 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++". llvm-svn: 314235 --- clang/lib/AST/DeclCXX.cpp | 3 ++- clang/test/SemaCXX/ms-iunknown.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index d63d42c..e85ab41 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() const { // Check "Special" types. const auto *Uuid = getAttr(); - if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() && + if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() || + getDeclContext()->isExternCXXContext()) && ((getName() == "IUnknown" && Uuid->getGuid() == "00000000-0000-0000-C000-000000000046") || (getName() == "IDispatch" && diff --git a/clang/test/SemaCXX/ms-iunknown.cpp b/clang/test/SemaCXX/ms-iunknown.cpp index c965a4c..f73864d 100644 --- a/clang/test/SemaCXX/ms-iunknown.cpp +++ b/clang/test/SemaCXX/ms-iunknown.cpp @@ -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 {}; -- 2.7.4