[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

[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 &

[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 , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , 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 , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , 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

[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 , 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 , 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

[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 , 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 , FieldDecl *FD, Expr *E, - llvm::SmallVectorImpl ) { +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

[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 >

[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

[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 ___

[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 ___

[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

[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.

[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

[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

[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

[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

[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

[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

[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

[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 =

[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 =

[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:

[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: