[llvm-bugs] [Bug 38896] New: error: cannot resolve lock expression [-Werror, -Wthread-safety-analysis]
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 10 11:52:16 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38896
Bug ID: 38896
Summary: error: cannot resolve lock expression
[-Werror,-Wthread-safety-analysis]
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: lukasza at chromium.org
CC: llvm-bugs at lists.llvm.org
Created attachment 20863
--> https://bugs.llvm.org/attachment.cgi?id=20863&action=edit
thread_annotations_unittest2.mm
Context: https://crbug.com/881875
I get an unexpected compile error when 1) an AutoLock class is annotated with
__attribute__(scoped_lockable) and 2) the AutoLock class is used in ObjC:
export DEVELOPER_DIR=/Users/lukasza/src/chromium/src/build/mac_files/Xcode.app;
/Users/lukasza/goma/gomacc
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF
obj/base/base_unittests/thread_annotations_unittest2.o.d -DSYSTEM_NATIVE_UTF8
-DV8_DEPRECATION_WARNINGS -DDCHECK_ALWAYS_ON=1 -DNO_TCMALLOC
-DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL
-DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED
-D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -DCR_XCODE_VERSION=0832
-DCR_CLANG_REVISION=\"340925-1\" -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD
-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND
-DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGTEST_API_= -DGTEST_HAS_POSIX_RE=0
-DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0 -DU_USING_ICU_NAMESPACE=0
-DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DUCHAR_TYPE=uint16_t -DUNIT_TEST
-I../.. -Igen -I../../third_party/googletest/custom
-I../../third_party/googletest/src/googletest/include
-I../../third_party/ced/src -I../../third_party/icu/source/common
-I../../third_party/icu/source/i18n -I../../third_party/googletest/custom
-I../../third_party/googletest/src/googlemock/include -fno-strict-aliasing
-fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__=
-D__TIMESTAMP__= -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm
-Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64
-Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety
-Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter
-Wno-c++11-narrowing -Wno-covered-switch-default
-Wno-unneeded-internal-declaration -Wno-undefined-var-template
-Wno-nonportable-include-path -Wno-user-defined-warnings
-Wno-unused-lambda-capture -Wno-null-pointer-arithmetic
-Wno-enum-compare-switch -Wno-ignored-pragma-optimize -O2
-fno-omit-frame-pointer -gdwarf-2 -isysroot
../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-mmacosx-version-min=10.9.0 -fvisibility=hidden -Xclang -load -Xclang
../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib
-Xclang -add-plugin -Xclang find-bad-constructs -Xclang
-plugin-arg-find-bad-constructs -Xclang enforce-in-thirdparty-webkit -Xclang
-plugin-arg-find-bad-constructs -Xclang check-enum-max-value -Wheader-hygiene
-Wstring-conversion -Wtautological-overlap-compare -Wno-shorten-64-to-32
-Wno-inconsistent-missing-override -std=c++14 -stdlib=libc++
-fobjc-call-cxx-cdtors -Wobjc-missing-property-synthesis -fno-exceptions
-fno-rtti -fvisibility-inlines-hidden -c
../../base/thread_annotations_unittest2.mm -o
obj/base/base_unittests/thread_annotations_unittest2.o
../../base/thread_annotations_unittest2.mm:34:12: error: cannot resolve lock
expression [-Werror,-Wthread-safety-analysis]
AutoLock lock(lock_);
^~~~
1 error generated.
Repro attached and (for convenience) inlined here:
1 #import <Foundation/Foundation.h>
2
3 class __attribute__((lockable)) Lock {
4 public:
5 void Acquire() __attribute__((exclusive_lock_function())) {}
6 void Release() __attribute__((unlock_function())) {}
7 };
8
9 class __attribute__((scoped_lockable)) AutoLock {
10 public:
11 AutoLock(Lock& lock)__attribute__((exclusive_lock_function(lock)))
12 : lock_(lock) {
13 lock.Acquire();
14 }
15 ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
16
17 private:
18 Lock& lock_;
19 };
20
21 @interface MyInterface : NSObject {
22 @private
23 Lock lock_;
24 int value_;
25 }
26
27 - (void)incrementValue;
28
29 @end
30
31 @implementation MyInterface
32
33 - (void)incrementValue {
34 AutoLock lock(lock_);
35 value_ += 1;
36 }
37
38 @end
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180910/3e84681e/attachment.html>
More information about the llvm-bugs
mailing list