<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - error: cannot resolve lock expression [-Werror,-Wthread-safety-analysis]"
   href="https://bugs.llvm.org/show_bug.cgi?id=38896">38896</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>error: cannot resolve lock expression [-Werror,-Wthread-safety-analysis]
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lukasza@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20863" name="attach_20863" title="thread_annotations_unittest2.mm">attachment 20863</a> <a href="attachment.cgi?id=20863&action=edit" title="thread_annotations_unittest2.mm">[details]</a></span>
thread_annotations_unittest2.mm

Context: <a href="https://crbug.com/881875">https://crbug.com/881875</a>

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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>