
Followup to #125526. This expands the logic of the unique-object-duplication warning so that it also works for windows code. For the most part, the logic is unchanged, merely substituting "has no import/export annotation" in place of "has hidden visibility". However, there are some small inconsistencies between the two; namely, visibility is propagated through nested classes, while import/export annotations aren't. This PR: 1. Updates the logic for the warning to account for the differences between posix and windows 2. Changes the warning message and documentation appropriately 3. Updates the tests to cover windows, and adds new test cases for the places where behavior differs. This PR was tested by building chromium (cross compiling linux->windows) with the changes in place. After accounting for the differences in semantics, no new warnings were discovered.
18 lines
722 B
C++
18 lines
722 B
C++
// RUN: %clang_cc1 -fsyntax-only -Wunique-object-duplication -Wno-unused-value \
|
|
// RUN: -verify -triple=x86_64-pc-linux-gnu %s
|
|
// RUN: %clang_cc1 -fsyntax-only -Wunique-object-duplication -Wno-unused-value \
|
|
// RUN: -verify=hidden -triple=x86_64-pc-linux-gnu -fvisibility=hidden %s
|
|
// RUN: %clang_cc1 -fsyntax-only -Wunique-object-duplication -Wno-unused-value \
|
|
// RUN: -verify=windows -triple=x86_64-windows-msvc -DWINDOWS_TEST -fdeclspec %s
|
|
|
|
#include "unique_object_duplication.h"
|
|
|
|
// Everything in these namespaces here is defined in the cpp file,
|
|
// so won't get duplicated
|
|
|
|
namespace GlobalTest {
|
|
float Test::allowedStaticMember1 = 2.3;
|
|
}
|
|
|
|
bool disallowed4 = true;
|
|
constexpr inline bool disallowed5 = true; |