Skip to content

Commit 499c838

Browse files
committed
Fix remaining breaks, add a test case for LTO visibility
1 parent b2686ca commit 499c838

File tree

8 files changed

+55
-7
lines changed

8 files changed

+55
-7
lines changed

strings/base_activation.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,14 @@ namespace winrt::impl
257257
}
258258

259259
private:
260-
261-
size_t& m_count;
260+
#ifdef __clang__
261+
#pragma clang diagnostic push
262+
#pragma clang diagnostic ignored "-Wunused-private-field"
263+
#endif
264+
size_t& m_count; // Field is unused when WINRT_NO_MODULE_LOCK is defined.
265+
#ifdef __clang__
266+
#pragma clang diagnostic pop
267+
#endif
262268
};
263269

264270
struct factory_cache_entry_base

test/test/clang_only.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "pch.h"
2+
#include <winrt/Windows.Storage.Pickers.h>
3+
4+
#ifdef __clang__
5+
6+
using namespace winrt;
7+
using namespace Windows::Foundation;
8+
using namespace Windows::Storage::Pickers;
9+
10+
// winrt::fire_and_forget PickImage()
11+
// {
12+
// FileOpenPicker picker{};
13+
// picker.ViewMode(PickerViewMode::Thumbnail);
14+
// picker.FileTypeFilter().Append(L".png"); // <--- crash occurred here
15+
// }
16+
17+
TEST_CASE("clang_library")
18+
{
19+
// PickImage();
20+
21+
FileOpenPicker picker{};
22+
picker.ViewMode(PickerViewMode::Thumbnail);
23+
picker.FileTypeFilter().Append(L".png"); // <--- crash occurred here
24+
25+
REQUIRE(true);
26+
}
27+
28+
#endif // __clang__

test/test/test.vcxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
9595
<WarningLevel>Level4</WarningLevel>
9696
<TreatWarningAsError>true</TreatWarningAsError>
97+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -O3 -flto -fwhole-program-vtables</AdditionalOptions>
9798
</ClCompile>
9899
<Link>
99100
<SubSystem>Console</SubSystem>
@@ -116,6 +117,7 @@
116117
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
117118
<WarningLevel>Level4</WarningLevel>
118119
<TreatWarningAsError>true</TreatWarningAsError>
120+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -flto -fwhole-program-vtables</AdditionalOptions>
119121
</ClCompile>
120122
<Link>
121123
<SubSystem>Console</SubSystem>
@@ -136,6 +138,7 @@
136138
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
137139
<WarningLevel>Level4</WarningLevel>
138140
<TreatWarningAsError>true</TreatWarningAsError>
141+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -flto -fwhole-program-vtables</AdditionalOptions>
139142
</ClCompile>
140143
<Link>
141144
<SubSystem>Console</SubSystem>
@@ -156,6 +159,7 @@
156159
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
157160
<WarningLevel>Level4</WarningLevel>
158161
<TreatWarningAsError>true</TreatWarningAsError>
162+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -flto -fwhole-program-vtables</AdditionalOptions>
159163
</ClCompile>
160164
<Link>
161165
<SubSystem>Console</SubSystem>
@@ -178,6 +182,7 @@
178182
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
179183
<WarningLevel>Level4</WarningLevel>
180184
<TreatWarningAsError>true</TreatWarningAsError>
185+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -O3 -flto -fwhole-program-vtables</AdditionalOptions>
181186
</ClCompile>
182187
<Link>
183188
<SubSystem>Console</SubSystem>
@@ -202,6 +207,7 @@
202207
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
203208
<WarningLevel>Level4</WarningLevel>
204209
<TreatWarningAsError>true</TreatWarningAsError>
210+
<AdditionalOptions Condition="'$(Clang)'=='1'">%(AdditionalOptions) -O3 -flto -fwhole-program-vtables</AdditionalOptions>
205211
</ClCompile>
206212
<Link>
207213
<SubSystem>Console</SubSystem>
@@ -234,6 +240,7 @@
234240
<ClCompile Include="box_delegate.cpp" />
235241
<ClCompile Include="box_guid.cpp" />
236242
<ClCompile Include="capture.cpp" />
243+
<ClCompile Include="clang_only.cpp" />
237244
<ClCompile Include="coro_foundation.cpp">
238245
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
239246
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>

test/test_component_base/HierarchyA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
namespace winrt::test_component_base::implementation
55
{
6-
HierarchyA::HierarchyA(hstring const& name)
6+
HierarchyA::HierarchyA(hstring const& /*name*/)
77
{
88
throw hresult_not_implemented();
99
}
10-
HierarchyA::HierarchyA(int32_t dummy, hstring const& name)
10+
HierarchyA::HierarchyA(int32_t /*dummy*/, hstring const& /*name*/)
1111
{
1212
throw hresult_not_implemented();
1313
}

test/test_component_base/HierarchyB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace winrt::test_component_base::implementation
77
{
8-
HierarchyB::HierarchyB(hstring const& name)
8+
HierarchyB::HierarchyB(hstring const& /*name*/)
99
{
1010
throw hresult_not_implemented();
1111
}

test/test_component_derived/Nested.HierarchyD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace winrt::test_component_derived::Nested::implementation
55
{
6-
HierarchyD::HierarchyD(hstring const& name)
6+
HierarchyD::HierarchyD(hstring const& /*name*/)
77
{
88
throw hresult_not_implemented();
99
}

test/test_cpp20_no_sourcelocation/custom_error.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ TEST_CASE("custom_error_logger")
5353
REQUIRE(s_loggerArgs.functionName == nullptr);
5454

5555
REQUIRE(s_loggerArgs.returnAddress);
56-
REQUIRE(s_loggerArgs.result == 0x80000018); // E_ILLEGAL_DELEGATE_ASSIGNMENT)
56+
REQUIRE(s_loggerArgs.result == static_cast<int32_t>(0x80000018)); // E_ILLEGAL_DELEGATE_ASSIGNMENT)
5757

5858
// Remove global handler
5959
winrt_throw_hresult_handler = nullptr;

test/test_module_lock_none/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ TEST_CASE("module_lock_none")
5757

5858
// Validates that test_component_base is pinned by virtue of it defining WINRT_NO_MODULE_LOCK.
5959

60+
#ifdef __clang__
61+
#pragma clang diagnostic push
62+
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
63+
#endif
6064
auto can_unload = reinterpret_cast<HRESULT(__stdcall*)()>(GetProcAddress(LoadLibraryA("test_component_base.dll"), "DllCanUnloadNow"));
6165
REQUIRE(can_unload() == S_FALSE);
6266

6367
auto cannot_unload = reinterpret_cast<HRESULT(__stdcall*)()>(GetProcAddress(LoadLibraryA("test_component_derived.dll"), "DllCanUnloadNow"));
6468
REQUIRE(cannot_unload() == S_OK);
69+
#ifdef __clang__
70+
#pragma clang diagnostic pop
71+
#endif
6572
}
6673

6774
int main(int const argc, char** argv)

0 commit comments

Comments
 (0)