1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <osl/mutex.hxx>
13 static std::mutex gSolarMutex
;
17 std::unique_lock
<std::mutex
> lock
;
32 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
34 SolarMutexGuard guard
;
37 // no warning expected
40 SolarMutexGuard guard
;
48 int free_function() { return 1; }
53 osl::Mutex m_aOslMutex
;
57 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
59 std::unique_lock
guard(m_aMutex
);
63 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
65 std::scoped_lock
guard(m_aMutex
);
68 // no warning expected
71 std::scoped_lock
guard(m_aMutex
);
75 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
77 ::osl::Guard
<::osl::Mutex
> aGuard(m_aOslMutex
);
82 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
84 std::unique_lock
guard(m_aMutex
);
85 return free_function();
88 osl::Mutex
& getOslMutex() { return m_aOslMutex
; }
90 // expected-error@+1 {{unnecessary locking [loplugin:unnecessarylocking]}}
92 ::osl::Guard
<::osl::Mutex
> aGuard(getOslMutex());
98 // Calling anything on VCLUnoHelper means we need the SolarMutex
102 static int CreateToolkit();
106 // no warning expected
109 SolarMutexGuard guard
;
110 VCLUnoHelper::CreateToolkit();
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */