[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-12-20 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-12-20 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Submitted as c1e7e4500c6e3b921f5e0cda8ba8d8d66e086db6. https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] c1e7e45 - Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (#110523)

2024-12-20 Thread Aaron Puchert via cfe-commits
Author: Malek Ben Slimane Date: 2024-12-20T23:49:03+01:00 New Revision: c1e7e4500c6e3b921f5e0cda8ba8d8d66e086db6 URL: https://github.com/llvm/llvm-project/commit/c1e7e4500c6e3b921f5e0cda8ba8d8d66e086db6 DIFF: https://github.com/llvm/llvm-project/commit/c1e7e4500c6e3b921f5e0cda8ba8d8d66e086db6.d

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: With my change reverted, the test lives in `compiler-rt/test/sanitizer_common`, where we get an additional `--sysroot=` argument. This comes from `compiler-rt/test/sanitizer_common/lit.site.cfg.py.in`: ```python # Tool-specific config options. config.name_suffix = "@CONFIG_N

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: With my change reverted I get the failure as well: ``` FAIL: SanitizerCommon-msan-x86_64-Linux :: Linux/dn_expand.cpp (5088 of 5094) TEST 'SanitizerCommon-msan-x86_64-Linux :: Linux/dn_expand.cpp' FAILED Exit Code: 1 Command Output (

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: That configuration output is from `compiler-rt`, but we need it in `llvm`. In `llvm/lib/ExecutionEngine/Orc/CMakeLists.txt`: ```cmake if( CMAKE_HOST_UNIX AND HAVE_LIBRT ) set(rt_lib rt) endif() ``` We have `CMAKE_HOST_UNIX` = 1, but `HAVE_LIBRT` is empty. It comes from `ch

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Without these two options, the build fails for me: ``` FAILED: bin/llvm-jitlink : && /usr/bin/clang++ --sysroot=/home/aaron/chrome-sysroot -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -W

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Where do I find these? ``` -DRUNTIMES_i386-unknown-linux-gnu_CMAKE_SYSROOT=/usr/local/google/home/ayzhao/src/chromium/src/third_party/llvm-build-tools/debian_bullseye_i386_sysroot \ -DBUILTINS_i386-unknown-linux-gnu_CMAKE_SYSROOT=/usr/local/google/home/ayzhao/src/chromium/src

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-15 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Specifically, this is the output: ``` Uninitialized bytes in strcmp at offset 0 inside [0x7fffe1e0, 12) ==1131638==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x5565c159 in testWrite() /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/ms

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-15 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: @nico, could you provide some more information? This didn't break on the lab.llvm.org infrastructure, and I'm not sure what's different in your build. Locally I also used a Release build with assertions on x86_64 on Linux. For what it's worth, the change simply moves the in

[clang] Thread safety analysis: Fix substitution for operator calls (PR #116487)

2024-12-14 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/116487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Handle __builtin_memcmp (PR #119544)

2024-12-12 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Check out https://lab.llvm.org/buildbot/#/builders/13/builds/4041: ``` RUN: at line 1: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/clang -cc1 -internal-isystem /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/lib/clan

[clang] [clang][bytecode] Handle __builtin_bcmp (PR #119678)

2024-12-12 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Check out https://lab.llvm.org/buildbot/#/builders/13/builds/4041: ``` RUN: at line 1: /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/bin/clang -cc1 -internal-isystem /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/stage1/lib/clan

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-12 Thread Aaron Puchert via cfe-commits
@@ -1410,7 +1410,7 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, // libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv // requirement. if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() && - !TC.getTriple().isMusl())

[clang] Cache SanitizerArgs in Clang driver (NFC) (PR #119442)

2024-12-12 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/119442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Cache SanitizerArgs in Clang driver (NFC) (PR #119442)

2024-12-10 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/119442 The name getSanitizerArgs seems to mislead callers that this is a cheap function, but it extracts the SanitizerArgs each time it is called. So we try to reuse it a bit more. >From fdcd8a22e13f0feb665b76a8

[clang] 3376bad - Eliminate duplicate call in Clang driver (NFC)

2024-12-10 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-12-10T20:01:19+01:00 New Revision: 3376bad13216da8950bcdeb564df26d5ce4c12bc URL: https://github.com/llvm/llvm-project/commit/3376bad13216da8950bcdeb564df26d5ce4c12bc DIFF: https://github.com/llvm/llvm-project/commit/3376bad13216da8950bcdeb564df26d5ce4c12bc.diff

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-09 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/119071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert updated https://github.com/llvm/llvm-project/pull/119071 >From 2b0071ca68164abdf2e9e174c1ecd2c166aa8815 Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Sat, 7 Dec 2024 14:58:04 +0100 Subject: [PATCH] Move interceptors for libresolv functions to MSan The funct

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert updated https://github.com/llvm/llvm-project/pull/119071 >From fdc60e8335dd68f08d6afbe4b281a7a278120f7a Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Sat, 7 Dec 2024 14:58:04 +0100 Subject: [PATCH] Move interceptors for libresolv functions to MSan The funct

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
@@ -1410,7 +1410,7 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, // libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv // requirement. if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() && - !TC.getTriple().isMusl())

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert updated https://github.com/llvm/llvm-project/pull/119071 >From cf38afeed8ede6b77adf836ecb51a9bb0ae6 Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Sat, 7 Dec 2024 14:58:04 +0100 Subject: [PATCH] Move interceptors for libresolv functions to MSan The funct

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert commented: Regarding the removed test: there is still the MSan-specific test [compiler-rt/test/msan/Linux/b64.cpp](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/msan/Linux/b64.cpp). https://github.com/llvm/llvm-project/pull/119071 __

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/119071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-07 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/119071 The functions are not relevant for most sanitizers and only required for MSan to see which regions have been written to. This eliminates a link dependency for all other sanitizers and fixes #59007: while `

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-12-04 Thread Aaron Puchert via cfe-commits
@@ -336,6 +336,31 @@ Improvements to Clang's diagnostics local variables passed to function calls using the ``[[clang::musttail]]`` attribute. +- The `Thread Safety Analysis `_ now supports passing scoped capabilitie

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-11-29 Thread Aaron Puchert via cfe-commits
@@ -336,6 +336,40 @@ Improvements to Clang's diagnostics local variables passed to function calls using the ``[[clang::musttail]]`` attribute. +- The Thread Safety Analysis (#GH110523) now supports passing scoped capabilities into functions: + an attribute on the scoped

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-11-29 Thread Aaron Puchert via cfe-commits
@@ -336,6 +336,40 @@ Improvements to Clang's diagnostics local variables passed to function calls using the ``[[clang::musttail]]`` attribute. +- The Thread Safety Analysis (#GH110523) now supports passing scoped capabilities into functions: + an attribute on the scoped

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-11-29 Thread Aaron Puchert via cfe-commits
@@ -336,6 +336,40 @@ Improvements to Clang's diagnostics local variables passed to function calls using the ``[[clang::musttail]]`` attribute. +- The Thread Safety Analysis (#GH110523) now supports passing scoped capabilities into functions: + an attribute on the scoped

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-11-29 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert commented: @AaronBallman, please also have a look at the Release Note. https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-11-29 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-25 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: aaronpuchert wrote: Maybe a single-pass algorithm would be better in the end: we find the first declaration, collect all attributes into a variety of of `CapExprSet`s, and then go through all successor declarations and check their attributes ag

[clang] Revert "[AIX] Fix AIX BuildBot failure as AIX linker doesn't support version script." (PR #117444)

2024-11-24 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/117444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AIX] Fix AIX BuildBot failure as AIX linker doesn't support version script. (PR #117342)

2024-11-22 Thread Aaron Puchert via cfe-commits
@@ -48,11 +48,13 @@ add_clang_library(clang-cpp ${_OBJECTS} LINK_LIBS ${_DEPS}) +# AIX linker does not support version script +if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX") + configure_file(simple_version_script.map.in simple

[clang] [AIX] Fix AIX BuildBot failure as AIX linker doesn't support version script. (PR #117342)

2024-11-22 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Doesn't eaa0a21d21962280dc2c03a09152510f6162a576 already fix this? If `CMAKE_SYSTEM_NAME` is `Linux`, it can probably not be `AIX` at the same time, right? See also the discussion on #116556. Do you mind if I revert this? https://github.com/llvm/llvm-project/pull/117342 __

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-21 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: We don't run into the same issue with the `LLVM` library because `LLVM_BUILD_LLVM_DYLIB` defaults to off. There is no counterpart toggle for `clang-cpp`, so it's being built on the bot. I suppose that with `-DLLVM_BUILD_LLVM_DYLIB=ON` the bot would also run into issues with

[clang] eaa0a21 - Limit symbol versioning in clang-cpp to Linux for now

2024-11-21 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-11-21T23:53:11+01:00 New Revision: eaa0a21d21962280dc2c03a09152510f6162a576 URL: https://github.com/llvm/llvm-project/commit/eaa0a21d21962280dc2c03a09152510f6162a576 DIFF: https://github.com/llvm/llvm-project/commit/eaa0a21d21962280dc2c03a09152510f6162a576.diff

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-21 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: > LLVM Buildbot has detected a new failure on builder `clang-ppc64-aix` running > on `aix-ppc64` while building `clang,llvm` at step 3 "clean-build-dir". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/64/builds/1496 > Here is the relevant piec

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-21 Thread Aaron Puchert via cfe-commits
@@ -4054,7 +4054,9 @@ def warn_acquired_before : Warning< def warn_acquired_before_after_cycle : Warning< "cycle in acquired_before/after dependencies, starting with '%0'">, InGroup, DefaultIgnore; - +def warn_attribute_mismatch : Warning< + "attribute mismatch between fun

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-21 Thread Aaron Puchert via cfe-commits
@@ -2263,6 +2265,27 @@ static bool neverReturns(const CFGBlock *B) { return false; } +void ThreadSafetyAnalyzer::checkMismatchedFunctionAttrs(const NamedDecl *ND) { + auto collectCapabilities = [&](const Decl *D) { +CapExprSet Caps; +for (const auto *A : D->specific

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-21 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert commented: I've thought a bit more about what inheritance means for this and I think it makes our job easier. We can probably collect capabilities on the first declaration and then just check that the non-inherited attributes on subsequent declarations are alrea

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-21 Thread Aaron Puchert via cfe-commits
@@ -2263,6 +2265,27 @@ static bool neverReturns(const CFGBlock *B) { return false; } +void ThreadSafetyAnalyzer::checkMismatchedFunctionAttrs(const NamedDecl *ND) { + auto collectCapabilities = [&](const Decl *D) { +CapExprSet Caps; +for (const auto *A : D->specific

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-21 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/67520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: @tstellar, seems like we both overlooked the `if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")`. Any objections to relanding the patch with that additional condition? https://github.com/llvm/llvm-project/pull/116556 ___ cfe-commits ma

[clang] b246d5f - Disable symbol versions for clang-cpp also with MSVC

2024-11-19 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-11-20T03:43:55+01:00 New Revision: b246d5f0556114d9a454bf2471f9c0577f1dce2f URL: https://github.com/llvm/llvm-project/commit/b246d5f0556114d9a454bf2471f9c0577f1dce2f DIFF: https://github.com/llvm/llvm-project/commit/b246d5f0556114d9a454bf2471f9c0577f1dce2f.diff

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Went with a version that resembles the following condition and is a bit shorter. https://github.com/llvm/llvm-project/pull/116556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] 461e58e - Introduce symbol versioning for clang-cpp (#116556)

2024-11-19 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-11-20T03:28:54+01:00 New Revision: 461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c URL: https://github.com/llvm/llvm-project/commit/461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c DIFF: https://github.com/llvm/llvm-project/commit/461e58e75dc3e2a0d6e0448c1ebcb8bd14e3d65c.diff

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-19 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Same for `if (MSVC)`. So let's make this: ```cmake if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT MSVC AND NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW) ``` https://github.com/llvm/llvm-project/pull/116556 ___ cfe-commits mai

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-19 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/116556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 30fad6a - Thread safety analysis: Implement MutexLocker factory functions in documentation

2024-11-19 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-11-19T17:19:35+01:00 New Revision: 30fad6a97611ac397bdaa429730851f53752d013 URL: https://github.com/llvm/llvm-project/commit/30fad6a97611ac397bdaa429730851f53752d013 DIFF: https://github.com/llvm/llvm-project/commit/30fad6a97611ac397bdaa429730851f53752d013.diff

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: @nikic, thanks for letting me know! That is indeed pretty much the same change. @tstellar, maybe you want to copy the change to `llvm/CMakeLists.txt`, otherwise I'd close this. https://github.com/llvm/llvm-project/pull/116556 ___

[clang] 3155199 - Thread safety analysis: Eliminate unneeded const_cast, NFC

2024-11-17 Thread Aaron Puchert via cfe-commits
Author: Aaron Puchert Date: 2024-11-17T22:40:09+01:00 New Revision: 315519917368dce841f1cb1e7b296846d13497c3 URL: https://github.com/llvm/llvm-project/commit/315519917368dce841f1cb1e7b296846d13497c3 DIFF: https://github.com/llvm/llvm-project/commit/315519917368dce841f1cb1e7b296846d13497c3.diff

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/116556 The situation that required symbol versions on the LLVM shared library can also happen for clang-cpp, although it is less common: different tools require different versions of the library, and through tran

[clang] Thread safety analysis: Fix substitution for operator calls (PR #116487)

2024-11-16 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/116487 For operator calls that go to methods we need to substitute the first parameter for "this" and the following parameters into the function parameters, instead of substituting all of them into the parameters

[clang] [clang] Catch missing format attributes (PR #105479)

2024-11-14 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,217 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// This function is called only if function call is not inside template body. +// TODO: Add call

[clang] [clang][Analysis][NFC] Let isConfigurationValue take Expr (PR #116266)

2024-11-14 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: Formatting is intentional, I don't want to reformat lines that I didn't touch. https://github.com/llvm/llvm-project/pull/116266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [clang][Analysis][NFC] Let isConfigurationValue take Expr (PR #116266)

2024-11-14 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert created https://github.com/llvm/llvm-project/pull/116266 The only non-`Expr` Terminator is `ObjCForCollectionStmt`, but that is arguably just a modelling issue, and we return false for every non-`Expr` anyway. Letting the caller cast to `Expr` removes lots of `d

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-12 Thread Aaron Puchert via cfe-commits
@@ -2073,6 +2073,18 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler { Warnings.emplace_back(std::move(Warning), getNotes()); } + void handleAttributeMismatch(const NamedDecl *ThisDecl, + const NamedDecl *Pre

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-12 Thread Aaron Puchert via cfe-commits
@@ -2249,7 +2249,7 @@ void fooF1(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) { f->a = 1; } -void fooF2(Foo *f); +void fooF2(Foo *f); // expected-warning {{attribute mismatch between function declarations of 'fooF2'}} void fooF2(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) { -

[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)

2024-11-12 Thread Aaron Puchert via cfe-commits
@@ -2282,6 +2308,9 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { const NamedDecl *D = walker.getDecl(); CurrentFunction = dyn_cast(D); + if (isa(D)) aaronpuchert wrote: The way I understand this, `isa` checks if the argument is a

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-10-21 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert approved this pull request. This looks great! Let's wait a bit for the other reviewers, but otherwise I'm ready to merge it. https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@list

[clang] [clang] Catch missing format attributes (PR #105479)

2024-10-15 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,217 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// This function is called only if function call is not inside template body. +// TODO: Add call

[clang] [clang] Catch missing format attributes (PR #105479)

2024-10-15 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,217 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// This function is called only if function call is not inside template body. +// TODO: Add call

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-08 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2249,7 +2249,7 @@ void fooF1(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) { f

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-08 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2282,6 +2308,9 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContex

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-08 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: aaronpuchert wrote: We don't deduplicate "requires" attributes but check them directly. The resu

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-10-08 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-07 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: aaronpuchert wrote: > Is there any sort of facility to deduplicate capabilities? The exist

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-02 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2263,6 +2265,28 @@ static bool neverReturns(const CFGBlock *B) { return false; } +void ThreadSafetyAnalyzer::checkMismat

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-02 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2263,6 +2265,28 @@ static bool neverReturns(const CFGBlock *B) { return false; } +void ThreadSafetyAnalyzer::checkMismat

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-02 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -26,6 +26,7 @@ namespace clang { class AnalysisDeclContext; class FunctionDecl; class NamedDecl; +class Attr; --

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-02 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2282,6 +2306,9 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { const NamedDecl *D = walker.getDecl();

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-10-01 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -5794,6 +5794,30 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); D->addAttr(RCA); + + if (const auto *FD = dy

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -1915,6 +1936,101 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D, } } + std::optional Args; + if (Exp) { +if (const auto *CE = dyn_cast(Exp)) + Args = CE->arguments(); +else if (const auto *CE = dyn_cast(Exp)) + Args = CE->ar

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -3171,6 +3171,372 @@ void lockUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) { } // end namespace ScopedUnlock +namespace PassingScope { + +class SCOPED_LOCKABLE RelockableScope { +public: + RelockableScope(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu); + void Release() UNLOCK_FUNCTION(

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -3171,6 +3171,372 @@ void lockUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) { } // end namespace ScopedUnlock +namespace PassingScope { + +class SCOPED_LOCKABLE RelockableScope { +public: + RelockableScope(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu); + void Release() UNLOCK_FUNCTION(

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -1915,6 +1936,101 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D, } } + std::optional Args; + if (Exp) { +if (const auto *CE = dyn_cast(Exp)) + Args = CE->arguments(); +else if (const auto *CE = dyn_cast(Exp)) + Args = CE->ar

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -1915,6 +1936,101 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D, } } + std::optional Args; + if (Exp) { +if (const auto *CE = dyn_cast(Exp)) + Args = CE->arguments(); +else if (const auto *CE = dyn_cast(Exp)) + Args = CE->ar

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -305,6 +337,16 @@ deadlock can occur if the function acquires the mutex a second time. mu.Unlock(); } + void exclude(MutexLocker& scope LOCKS_EXCLUDED(mu)){ aaronpuchert wrote: ```suggestion void exclude(MutexLocker& scope LOCKS_EXCLUDED(mu)) { `

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -1915,6 +1936,101 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D, } } + std::optional Args; + if (Exp) { +if (const auto *CE = dyn_cast(Exp)) + Args = CE->arguments(); +else if (const auto *CE = dyn_cast(Exp)) + Args = CE->ar

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
@@ -211,17 +214,35 @@ must be held on entry to the function, *and must still be held on exit*. mu1.Unlock(); } + void require(MutexLocker& scope REQUIRES(mu1)) { +scope.Unlock(); +a=0; // Warning! Requires mu1. aaronpuchert wrote: Nitpick: sp

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert commented: One more idea for a test: can a parameter attribute reference another parameter? Then we could try something like ```c++ struct ObjectWithMutex { Mutex mu; }; void releaseMember(ObjectWithMutex& object, ReleasableMutexLock& scope EXCLUSIVE_UNLOCK_FUNCT

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-30 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -5794,6 +5794,30 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); D->addAttr(RCA); + + if (const auto *FD = dy

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-30 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/aaronpuchert commented: So the semantics here are: if there is any `requires_capability` attribute on a function, it needs to exactly match the set of `requires_capability` attributes on every previou

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-30 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -5794,6 +5794,30 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); D->addAttr(RCA); + + if (const auto *FD = dy

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-30 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/aaronpuchert edited https://github.com/llvm/llvm-project/pull/67520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

2024-09-30 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: @delesley, your input on the conceptual side would also be appreciated as this is a substantial addition. https://github.com/llvm/llvm-project/pull/110523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-27 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert approved this pull request. That seems sensible to me. The absolute path also makes sense because target properties could be requested from a different directory, and then a relative path wouldn't work anymore. https://github.com/llvm/llvm-project/pull/109926 __

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-25 Thread Aaron Puchert via cfe-commits
@@ -221,8 +221,10 @@ if( ENABLE_RUNTIME_SUBNORMAL ) TARGET ${file} INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll ) -install( FILES $ ARCHIVE - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) +install( + FILES ${CMAKE_CURRENT_BINARY_D

[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-09-21 Thread Aaron Puchert via cfe-commits
@@ -167,12 +181,14 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTAL install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) - add_library( subnormal_use_default STATIC -generic/

[clang] Thread Safety Analysis: Differentiate between lock sets at real join points and expected/actual sets at function end (PR #105526)

2024-09-12 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: The warning is arguably wrong, and this might even be considered a regression. However, operations on asserted capabilities have been an issue before this change, and this worked for scoped capabilities only accidentally. If you do this without a scoped capability, you get

[clang] [clang] Catch missing format attributes (PR #105479)

2024-09-09 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,230 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// Returns vector of format attributes. There are no two attributes with same +// arguments in r

[clang] [clang] Catch missing format attributes (PR #105479)

2024-09-09 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,230 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// Returns vector of format attributes. There are no two attributes with same +// arguments in r

[clang] [clang-tools-extra] thread-safety: Support the new capability-based names for all related attributes. (PR #99919)

2024-09-06 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: You should also adapt the warning message for `warn_thread_attribute_not_on_capability_member` and the test `SemaCXX/warn-thread-safety-parsing.cpp`. https://github.com/llvm/llvm-project/pull/99919 ___ cfe-commits mailing list cfe

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-05 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: > > That might not be enough. A function might not be used (or even referenced) > > in the TU that defines it, but only in other TUs. But it would certainly > > catch a number of issues already. > > Right, though catching that ends up being pretty impossible. The most you

[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

2024-09-05 Thread Aaron Puchert via cfe-commits
aaronpuchert wrote: That might not be enough. A function might not be used (or even referenced) in the TU that defines it, but only in other TUs. But it would certainly catch a number of issues already. https://github.com/llvm/llvm-project/pull/67520 ___

[clang] Thread Safety Analysis: Differentiate between lock sets at real join points and expected/actual sets at function end (PR #105526)

2024-09-04 Thread Aaron Puchert via cfe-commits
https://github.com/aaronpuchert closed https://github.com/llvm/llvm-project/pull/105526 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Catch missing format attributes (PR #105479)

2024-09-02 Thread Aaron Puchert via cfe-commits
@@ -0,0 +1,176 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=expected,beforeCxx2b -Wmissing-format-attribute %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2b -Wmissing-format-attribute %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 -Wmissing-format-attribute %s +

[clang] [clang] Catch missing format attributes (PR #105479)

2024-09-02 Thread Aaron Puchert via cfe-commits
@@ -5335,6 +5335,217 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); } +// This function is called only if function call is not inside template body. +// TODO: Add call

  1   2   3   >