[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-10-25 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > > The ; did you mean to use BAR? version was accidentally emitted in some > > cases where it didn't make sense to do so, but the tests still passed > > because the diagnostic did contain cannot use FOO in context asdf. > > > > There's a `FileCheck` flag to enforce this: `-

[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/110772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Revert "[Utils] Add new --update-tests flag to llvm-lit" (PR #110772)

2024-10-01 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/110772 Reverts llvm/llvm-project#108425 >From 133d368b16d11e44bc3fca92a042cf5ad0ce8dd1 Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Tue, 1 Oct 2024 17:14:31 -0700 Subject: [PATCH] Revert "[Utils] Add new -

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-10-01 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/108425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-28 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > Thank you. This pretty much LGTM, but it just occurred to me that there's a > docs/CommandGuide/lit.rst which should be updated to document the new option. Done > As update-verify-tests was reverted, can you rebase this to just the > update_test_checks support? On the LLVM s

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-28 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 6cdb6bec945725d69d1073deeb53b7485c7e40cd Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/3] [Utils] Add --update-tests to lit This adds a flag to

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-28 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 6cdb6bec945725d69d1073deeb53b7485c7e40cd Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/2] [Utils] Add --update-tests to lit This adds a flag to

[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits
@@ -759,7 +759,24 @@ relationship must hold even after any of these related variables are updated. To this end, the model requires that assignments to ``buf`` and ``count`` must be side by side, with no side effects between them. This prevents ``buf`` and ``count`` from tempor

[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn commented: Overall looks good, just a small clarification https://github.com/llvm/llvm-project/pull/106147 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/106147 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn commented: You may want to add some tests with annotated pointers to verify that you treat them correctly, e.g. `_Nullable` https://github.com/llvm/llvm-project/pull/109496 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Henrik G. Olsson via cfe-commits
@@ -789,7 +791,7 @@ AST_MATCHER_P(CallExpr, hasUnsafePrintfStringArg, if (!FristParmTy->isPointerType()) return false; // possibly some user-defined printf function - QualType FirstPteTy = (cast(FristParmTy))->getPointeeType(); + QualType FirstPteTy = FristParmTy->getA

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/109496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-09-19 Thread Henrik G. Olsson via cfe-commits
@@ -443,6 +443,426 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +AST_MATCHER_P(CallExpr, hasNumArgs, unsigned, Num) { + return Node.getNumArgs() == Num; +} + +namespace libc_func_matchers { +// Under `libc_func_matchers`, define a set of matche

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-09-18 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: This change leads to a crash in the following case: ``` struct S { }; union U { struct S s; int x; }; void foo() { union U bar = {}; } ``` `isEmptyRecordForLayout` returns false for `union U` because the recursive call for `U::x` returns false. This means we call `I

[clang] Revert update-verify-tests.py (PR #109171)

2024-09-18 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/109171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert update-verify-tests.py (PR #109171)

2024-09-18 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/109171 This reverts commits c96ee0ffaf5ee7afa1f4b0be0662852f57b47244 and 9ceb9676678ad979a0b767450855d7852ce6a553. Discussion in github PR #108658. >From 0c8a40ed24b0b5f319fd2fb49a27703dc7f1 Mon Sep 17 00:00:00

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-18 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > > > > > > > > > +1, it's why I stopped recommending this approach in my reviews. > > While I agree for the most part, there are quite a few diagnostics that are > absurdly verbose (particularly ones with "did you mean to FLOOP it?"). I > think partial matches are good/fine

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-18 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > In fact, we used to have guidance that only the very first instance of the > diagnostic should be spelled out fully, and all subsequent ones should be > limited to just the bare minimum needed to identify what the diagnostic is. > That's why there are hundreds of instances o

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-17 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > > But for clang -verify you have to add checkers for exactly the emitted > > diagnostics. No more or less. So the only real question is on which line to > > place them. > > I don't think it's that simple at least for some tests. We have tests that > run in `-verify` mode mul

[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)

2024-09-17 Thread Henrik G. Olsson via cfe-commits
@@ -186,4 +218,370 @@ bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, return false; } +SourceRange Sema::BoundsSafetySourceRangeFor(const CountAttributedType *CATy) { hnrklssn wrote: [#108631](https://github.com/llvm/llvm-pr

[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

2024-09-17 Thread Henrik G. Olsson via cfe-commits
@@ -5125,24 +5127,54 @@ QualType ASTContext::getUnresolvedUsingType( QualType ASTContext::getAttributedType(attr::Kind attrKind, QualType modifiedType, - QualType equivalentType) const { +

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-17 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > As a CFE reviewer, I very much hate the existence of this script (and the > CodeGen equivalents, but that is a separate discussion). > > This existing means I can no longer trust that a test is a reflection of what > the author intended to write, as they might have just run t

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/5] [Utils] Add --update-tests to lit This adds a flag to

[clang] fix update-verify-tests test suite for AIX (PR #108871)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/108871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/5] [Utils] Add --update-tests to lit This adds a flag to

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/4] [Utils] Add --update-tests to lit This adds a flag to

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
@@ -2,3 +2,15 @@ config.substitutions = list(config.substitutions) config.substitutions.insert( 0, (r"%clang\b", """*** Do not use the driver in Sema tests. ***""") ) + +if lit_config.update_tests: +import sys +import os + +curdir = os.path.dirname(os.path.realp

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/3] [Utils] Add --update-tests to lit This adds a flag to

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > Hi, `--strip-trailing-cr` isn't a supported option with diff on AIX. Would > you be able to adapt the tests? > > https://lab.llvm.org/buildbot/#/builders/64/builds/985 This should fix it: https://github.com/llvm/llvm-project/pull/108871 https://github.com/llvm/llvm-project/p

[clang] fix update-verify-tests test suite for AIX (PR #108871)

2024-09-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/108871 The diff command on AIX doesn't support the --strip-trailing-cr flag. The internal python implementation does, so execute the tests in the update-verify-tests test suite using the internal shell for compatibil

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/2] [Utils] Add --update-tests to lit This adds a flag to

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 451a178dbb461e6b3dd264be6ede0aa26283dbbe Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/2] [Utils] Add --update-tests to lit This adds a flag to

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/108658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/108425 >From 11c5fe752a880dfa220abdf46ad9ba1a8be66b37 Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Wed, 28 Aug 2024 23:30:49 -0700 Subject: [PATCH 1/2] [Utils] Add --update-tests to lit This adds a flag to

[clang] Reland "[Utils] add update-verify-tests.py" (#108630)" (PR #108658)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/108658 This relands commit d4f41befb7256f8e8378ae358b2b3d802454d6a4 which was reverted by b7e585b95e241d0506b6f71d53ff5b6e72a9c8f4. This version ignores differences in line endings in the diff tests to make sure the

[clang] [Utils] add update-verify-tests.py (PR #97369)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Very sorry about the CI oversight on my part! Thanks for reverting, I was in a meeting. Looks like I was bitten by Windows line endings again... https://github.com/llvm/llvm-project/pull/97369 ___ cfe-commits mailing list cfe-commits@l

[clang] [Utils] add update-verify-tests.py (PR #97369)

2024-09-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/97369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Utils] Add new --update-tests flag to llvm-lit (PR #108425)

2024-09-12 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Note that the first 4 commits are from https://github.com/llvm/llvm-project/pull/97369; only the last 2 are new. I'll merge that tomorrow when I have more time to be ready to revert in case something should happen. https://github.com/llvm/llvm-project/pull/108425 _

[clang] [Utils] add update-verify-tests.py (PR #97369)

2024-09-11 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/97369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Utils] add --update-tests flag to llvm-lit (PR #97369)

2024-09-11 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/97369 >From d93d77e193f235d12d4de4a4b184c458508fa8df Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Mon, 1 Jul 2024 18:19:09 -0700 Subject: [PATCH 1/4] [Utils] add update-verify-tests.py Adds a python script

[clang] [llvm] [Utils] add --update-tests flag to llvm-lit (PR #97369)

2024-09-10 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > I think the integration into lit is okay. The diff updater seems neat, but I > think it could be taken into a separate change, see also the inline comment. > In general, I think this PR really does three separate things, that ought to > be in separate changes: > > * Add

[clang] [llvm] [Utils] add --update-tests flag to llvm-lit (PR #97369)

2024-09-10 Thread Henrik G. Olsson via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -verify %s +// RUN: diff %s %s.expected hnrklssn wrote: The files in the `Inputs` directory are not discovered by lit, so this doesn't actually run the RUN lines. Instead a copy is made, and a new lit instance is launched to

[clang] [llvm] [Utils] add --update-tests flag to llvm-lit (PR #97369)

2024-09-04 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Added tests and updated the script. Instead of only being a free-standing script it's now (along with the UTC scripts) integrated into llvm-lit to automatically detect which script can update a failing test, using the new flag `--update-tests`. https://github.com/llvm/llvm-pro

[clang] [llvm] [Utils] add --update-tests flag to llvm-lit (PR #97369)

2024-09-04 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/97369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-08-21 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Regarding there not being a `no-wraps` attribute. What happens with code like this? Is the attribute lost or casted away during the addition? ``` wrapping_int a = INT_MAX; a = (int) a + 1; ``` Does it affect converting a number too large to fit in the target type? ``` wrapping_i

[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > If you take a close look at the existing set of `Sema` parts, it's almost > entirely comprised of other languages or language extensions (from C and C++ > standpoint) and backends. They were considered natural enough to be split off > `Sema`, which, among other things, means

[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn approved this pull request. LGTM, might want to give the rest some time to have a look though https://github.com/llvm/llvm-project/pull/98954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-07-09 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-07-09 Thread Henrik G. Olsson via cfe-commits
@@ -8320,6 +8320,15 @@ static const RecordDecl *GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD) { return RD; } +static CountAttributedType::DynamicCountPointerKind +getCountAttrKind(bool CountInBytes, bool OrNull) { hnrklssn wrote: I guess it could b

[clang] [UVT] add update-verify-tests.py (PR #97369)

2024-07-02 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > This is a nice addition, but I think it should follow the conventions > established by the existing update_*_test_checks.py scripts as much as > possible, at least: > > * Ability to parse RUN lines, re-execute them autonomously, and modify > test files in place based on

[clang] [UVT] add update-verify-tests.py (PR #97369)

2024-07-01 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/97369 >From bc2f0757cfa08a8f26b9934929a0045d5e0ffd93 Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Mon, 1 Jul 2024 18:19:09 -0700 Subject: [PATCH 1/2] [UVT] add update-verify-tests.py Adds a python script t

[clang] [UVT] add update-verify-tests.py (PR #97369)

2024-07-01 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/97369 Adds a python script to automatically take output from a failed clang -verify test and update the test case(s) to expect the new behaviour. >From bc2f0757cfa08a8f26b9934929a0045d5e0ffd93 Mon Sep 17 00:00:00 200

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-07-01 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: @delcypher @rapidsna updated __sized_by(_or_null) to only allow types with unknown size if incomplete https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (PR #95455)

2024-06-13 Thread Henrik G. Olsson via cfe-commits
@@ -3330,6 +3340,118 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo &AttrName, SourceLocation AttrNameLoc, +ParsedAttrib

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-31 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Rebased on main after @delcypher's patch was relanded. Addressing comments now. https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-31 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn updated https://github.com/llvm/llvm-project/pull/93231 >From 5c5a28415f2cc10525f07784e6896718cc38624f Mon Sep 17 00:00:00 2001 From: "Henrik G. Olsson" Date: Thu, 23 May 2024 11:44:41 -0700 Subject: [PATCH] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_b

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Henrik G. Olsson via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema &S, FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl &Decls) { +static bool +CheckCountedByAttrOnField(Sema &S, FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Henrik G. Olsson via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema &S, FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl &Decls) { +static bool +CheckCountedByAttrOnField(Sema &S, FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Henrik G. Olsson via cfe-commits
@@ -425,6 +425,12 @@ Attribute Changes in Clang size_t count; }; +- The attributes ``sized_by``, ``counted_by_or_null`` and ``sized_by_or_null``` + have been added as variants on ``counted_by``, each with slightly different semantics. + ``sized_by`` takes a byte

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Henrik G. Olsson via cfe-commits
@@ -8697,9 +8708,10 @@ static bool CheckCountedByAttrOnField( InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER; } - if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) { + if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Henrik G. Olsson via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs, bool EnterScope, +

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Henrik G. Olsson via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs, bool EnterScope, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Blocked by pointer support for `counted_by` reverted. It's being relanded in #93121 https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/93231 The attributes `sized_by`, `counted_by_or_null` and `sized_by_or_null` have been added as variants on `counted_by`, each with slightly different semantics. `sized_by` takes a byte size parameter instead of an

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Henrik G. Olsson via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs, bool EnterScope, +

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-02 Thread Henrik G. Olsson via cfe-commits
@@ -8588,31 +8588,71 @@ static const RecordDecl *GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD) { return RD; } -static bool -CheckCountExpr(Sema &S, FieldDecl *FD, Expr *E, - llvm::SmallVectorImpl &Decls) { +enum class CountedByInvalidPointeeTypeKind {

[clang] Turn 'counted_by' into a type attribute and parse it into 'CountAttributedType' (PR #78000)

2024-02-27 Thread Henrik G. Olsson via cfe-commits
@@ -2000,6 +2001,21 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { unsigned NumExpansions; }; + class CountAttributedTypeBitfields { +friend class CountAttributedType; + +LLVM_PREFERRED_TYPE(TypeBitfields) +unsigned : NumTypeBits; +

[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2023-11-17 Thread Henrik G. Olsson via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: hnrklssn wrote: LGTM, but someone else should approve also. https://github.com/llvm/llvm-project/pull/70772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [clang][AST] Invalidate DecompositionDecl if it has invalid initializer. (PR #72428)

2023-11-17 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > > What differentiates the DecompositionDecl such that we need to mark the > > decl invalid when there's an error in the RHS, while for other decls we > > don't? It seems inconsistent. > > > > DecompositionDecl (aka structure binding) is special here, a legal > Decompositio

[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/67519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-16 Thread Henrik G. Olsson via cfe-commits
@@ -4,7 +4,8 @@ // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list -// RUN: %clang_cc1 -fprofile

[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-16 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn requested changes to this pull request. https://github.com/llvm/llvm-project/pull/67519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Sema::isSimpleTypeSpecifier return true for _Bool in c99 (PR #72204)

2023-11-16 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: There's a dup of `Sema::isSimpleTypeSpecifier` in `FormatToken.cpp` that you may want to update also: `FormatToken::isSimpleTypeSpecifier`. Perhaps that'll make testing easier? https://github.com/llvm/llvm-project/pull/72204 ___ cfe-c

[clang] [clang][AST] Invalidate DecompositionDecl if it has invalid initializer. (PR #72428)

2023-11-16 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: What differentiates the DecompositionDecl such that we need to mark the decl invalid when there's an error in the RHS, while for other decls we don't? It seems inconsistent. https://github.com/llvm/llvm-project/pull/72428 ___ cfe-comm

[clang] [llvm] Recommit changes to global checks (PR #71171)

2023-11-13 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/71171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Recommit changes to global checks (PR #71171)

2023-11-13 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: >I'd run ./llvm/utils/update_any_test_checks.py once and see if the tests pass >afterwards. Then do it again to ensure the nasty ordering and duplication issues are gone for good. All tests that fail after running update_any_test_checks.py also fail when running it without thi

[llvm] [clang] Recommit changes to global checks (PR #71171)

2023-11-03 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: > I think if the issues with the original commit are resolved, this is good to > go. > > Did you verify we can properly auto-generate files, e.g., in > llvm/test/Transforms/Attributor and clang/test/OpenMP? > > Ah no I did not, I'll do that on Monday. https://github.com/ll

[clang] [clang]get non-injected-class before finding instantiated decl (PR #70886)

2023-11-02 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn commented: LGTM, but I'm not very familiar with the C++ specific parts of clang, so someone else ought to take a look also https://github.com/llvm/llvm-project/pull/70886 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2023-11-02 Thread Henrik G. Olsson via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: hnrklssn wrote: Nice. I realise you're following the convention already established in the test file, but have you considered compiling with `-verify=new,both` and `-verify=ref,both`, respectively, and combining the shared diagnostics into `bo

[clang] [clang][Interp] Handle std::move etc. builtins (PR #70772)

2023-11-01 Thread Henrik G. Olsson via cfe-commits
hnrklssn wrote: Would making a class with custom move and copy constructors with side effects, and moving/copying an instance around a bit to affect the results of static_asserts, work for testing? https://github.com/llvm/llvm-project/pull/70772 ___

[clang] [clang]get non-injected-class before finding instantiated decl (PR #70886)

2023-11-01 Thread Henrik G. Olsson via cfe-commits
@@ -429,3 +429,19 @@ namespace qualified_friend_no_match { friend void Y::f(double); // expected-error {{friend declaration of 'f' does not match any declaration in 'qualified_friend_no_match::Y'}} }; } + +namespace gh21483 { +template +struct B { + struct mixin { +

[clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

2023-11-01 Thread Henrik G. Olsson via cfe-commits
@@ -2537,19 +2555,13 @@ class FieldInitializerValidatorCCC final : public CorrectionCandidateCallback { /// actually be initialized. hnrklssn wrote: The comment above looks like it needs to be updated with `@param`s for `FinishSubobjectInit`, `TopLevelObject`

[clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

2023-11-01 Thread Henrik G. Olsson via cfe-commits
@@ -4,7 +4,7 @@ // RUN: %clang_cc1 -std=c++20 %s -verify=cxx20,expected,reorder -Wno-c99-designator -Werror=reorder-init-list -Wno-initializer-overrides // RUN: %clang_cc1 -std=c++20 %s -verify=cxx20,expected,override -Wno-c99-designator -Wno-reorder-init-list -Werror=initiali

[clang] [clang]get non-injected-class before finding instantiated decl (PR #70886)

2023-11-01 Thread Henrik G. Olsson via cfe-commits
@@ -429,3 +429,19 @@ namespace qualified_friend_no_match { friend void Y::f(double); // expected-error {{friend declaration of 'f' does not match any declaration in 'qualified_friend_no_match::Y'}} }; } + +namespace gh21483 { +template +struct B { + struct mixin { +

[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-20 Thread Henrik G. Olsson via cfe-commits
@@ -139,9 +139,23 @@ std::optional ProfileList::isFileExcluded(StringRef FileName, CodeGenOptions::ProfileInstrKind Kind) const { StringRef Section = getSectionName(Kind); - // Check for "source:=" + + // Convert the input file path to its canoni

[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-04 Thread Henrik G. Olsson via cfe-commits
@@ -139,9 +139,23 @@ std::optional ProfileList::isFileExcluded(StringRef FileName, CodeGenOptions::ProfileInstrKind Kind) const { StringRef Section = getSectionName(Kind); - // Check for "source:=" + + // Convert the input file path to its canoni

[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-04 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn requested changes to this pull request. Please update `clang/test/CodeGen/profile-filter.c` with some cases that exercise the new code path. https://github.com/llvm/llvm-project/pull/67519 ___ cfe-commits mailing list cfe-c

[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-04 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn edited https://github.com/llvm/llvm-project/pull/67519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add missing canonicalization in int literal profile (PR #67822)

2023-10-02 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn closed https://github.com/llvm/llvm-project/pull/67822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add missing canonicalization in int literal profile (PR #67822)

2023-09-29 Thread Henrik G. Olsson via cfe-commits
https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/67822 The addition of the type kind to the profile ID of IntegerLiterals results in e.g. size_t and unsigned long literals mismatch even on platforms where they are canonically the same type. This patch checks the Ca

[clang] [clang] [C23] Fix crash with _BitInt running clang-tidy (PR #65889)

2023-09-29 Thread Henrik G. Olsson via cfe-commits
@@ -1333,7 +1333,13 @@ void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { VisitExpr(S); S->getValue().Profile(ID); - ID.AddInteger(S->getType()->castAs()->getKind()); + + QualType T = S->get

[clang-tools-extra] [clang] [C23] Fix crash with _BitInt running clang-tidy (PR #65889)

2023-09-29 Thread Henrik G. Olsson via cfe-commits
@@ -1333,7 +1333,13 @@ void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { VisitExpr(S); S->getValue().Profile(ID); - ID.AddInteger(S->getType()->castAs()->getKind()); + + QualType T = S->get

[clang] 8a3fdf7 - [UTC] Add fallback support for specific metadata, and check their defs

2023-07-05 Thread Henrik G. Olsson via cfe-commits
Author: Henrik G. Olsson Date: 2023-07-05T14:04:50+02:00 New Revision: 8a3fdf7b908978625e9a7e57fbb443e4e6f98976 URL: https://github.com/llvm/llvm-project/commit/8a3fdf7b908978625e9a7e57fbb443e4e6f98976 DIFF: https://github.com/llvm/llvm-project/commit/8a3fdf7b908978625e9a7e57fbb443e4e6f98976.di

[clang] 8fa2e93 - [clang] Do not merge traps in functions annotated optnone

2022-11-30 Thread Henrik G. Olsson via cfe-commits
Author: Henrik G. Olsson Date: 2022-11-30T15:06:32+01:00 New Revision: 8fa2e93538595e1ff973110cb3f301b65bc9d2eb URL: https://github.com/llvm/llvm-project/commit/8fa2e93538595e1ff973110cb3f301b65bc9d2eb DIFF: https://github.com/llvm/llvm-project/commit/8fa2e93538595e1ff973110cb3f301b65bc9d2eb.di