[clang] nolock/noalloc attributes (PR #84983)

2024-03-19 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-19 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-19 Thread Doug Wyatt via cfe-commits
@@ -2380,6 +2382,1239 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +// Temporary debugging option +#define FX_ANALYZER_VERIFY_DECL_LIST 1 +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-19 Thread Doug Wyatt via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-18 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-18 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-18 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-18 Thread Doug Wyatt via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-18 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-16 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-16 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-16 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-16 Thread Doug Wyatt via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-15 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-15 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-15 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > I would maybe try going with that then for now (and maybe add a comment about > that too); I’m not sure my function pointer example is really the same > situation, but I remember finding an example that was analogous but for > `noreturn` _somwhere_ in the test cases, but I

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > Just tried. In C mode, it works to do nothing about effect changes in > isFunctionConversion (!). I would maybe try going with that then for now (and maybe add a comment about that too); I’m not sure my function pointer example is really the same situation, but I remember

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > have you tried maybe simply not setting `Changed` to `true` (perhaps only > > in C mode)? Just tried. In C mode, it works to do nothing about effect changes in isFunctionConversion (!). https://github.com/llvm/llvm-project/pull/84983

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > Adapted from `test/Sema/initialize-noreturn.c` Seeing as that test does check that we’re issuing an error for this, and seeing that this seems to be handled in `isFunctionConversion()`, it really just seems like that function is supposed to error if there is a conversion

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > > I was testing with `noreturn` earlier. It's hard to compare, because (at > least in C23): > > ``` > ../clang/test/Sema/attr-nolock-wip.cpp:15:19: error: 'noreturn' attribute > cannot be applied to types >15 | void noret(int) [[noreturn]]; > | ^

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > have you tried maybe simply not setting `Changed` to `true` (perhaps only > > in C mode)? > > It’s worth pointing out that C also warns (and C23 straight-up _errors_) if > you replace `nolock` w/ `noreturn` iirc, so either that’s also a bug or > that’s intended; I think

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > swapping the two didn’t seem to change anything In one specific place where this is called in C mode, that is. From what I could see, the ordering seems to be correct for other calls to this function. https://github.com/llvm/llvm-project/pull/84983

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > have you tried maybe simply not setting `Changed` to `true` (perhaps only in > C mode)? It’s worth pointing out that C also warns (and C23 straight-up *errors*) if you replace `nolock` w/ `noreturn` iirc, so either that’s also a bug or that’s intended; I think I was going

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > the naming of "From" and "To" seems backwards. I noticed that as well; as I recall, swapping the two didn’t seem to change anything. I might open a pr or issue about this to either fix this or at least get some clarification as to whether that was really intended. I got a

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
Sirraide wrote: > I've probably been staring at this way too long, but here's what's going on. > My test is: My bad, I remember looking into this yesterday or the day before; from what I could tell, it seems I may have forgotten to share what I found here: I think the problem is that the

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > * Conversions between functions / function pointers with and without the > > attribute work in C++ but not in C and I'm a bit lost (there's a bunch of > > debug logging around this e.g. Sema::IsFunctionConversion and > > Sema::ImpCastExprToType) I've probably been

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
@@ -3922,6 +3922,42 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *, Scope *S, return true; } + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + if (OldFX != NewFX) { +const auto Diffs =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-14 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Shafik Yaghmour via cfe-commits
@@ -4181,6 +4185,127 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +class FunctionEffect; +class FunctionEffectSet; + +// It is the user's responsibility to keep this in set form: elements are +// ordered and unique. +// We could

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Quick drive by comment https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Shafik Yaghmour via cfe-commits
@@ -4181,6 +4185,127 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +class FunctionEffect; +class FunctionEffectSet; + +// It is the user's responsibility to keep this in set form: elements are +// ordered and unique. +// We could

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > * the bug where `AttributedType` sugar gets lost on lambdas (when the > > "inferred" return type gets converted to a concrete one) happens here and > > the `nolock(false)` attribute is lost from `h`. > > Opened an issue for this (#85120) because it really does seem like a

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -11100,6 +11136,48 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, return nullptr; } +// Should only be called when getFunctionEffects() returns a non-empty set. +// Decl should be a FunctionDecl or BlockDecl. +void

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -11100,6 +11136,48 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, return nullptr; } +// Should only be called when getFunctionEffects() returns a non-empty set. +// Decl should be a FunctionDecl or BlockDecl. +void

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
Sirraide wrote: > * the bug where `AttributedType` sugar gets lost on lambdas (when the > "inferred" return type gets converted to a concrete one) happens here and the > `nolock(false)` attribute is lost from `h`. Opened an issue for this (#85120) because it really does seem like a bug to me.

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > Since you mention it is attached to the type, is it mangled then differently. > e.g.: > Does the above f calls to 2 different functions? This example is problematic because in this construct, `g` and `h` degenerate into function pointers, and inference doesn't work across

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Andrew Pinski via cfe-commits
pinskia wrote: One question since the attribute is applied to types is there a way to get the nolock/noalloc from type?. e.g. ``` template [[nolock(T)]] void f(T a) { a(); } ``` Will the above work or is there no way to implement that currently? Since you mention it is attached to the type,

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s dougsonos wrote: OK, maybe "syntax" then... https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -11100,6 +11136,48 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, return nullptr; } +// Should only be called when getFunctionEffects() returns a non-empty set. +// Decl should be a FunctionDecl or BlockDecl. +void

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s Sirraide wrote: It’s usually not required to separate code that errors and code that is supposed to compile without errors, but if it is required for something like this, then sure, go

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s dougsonos wrote: Hm, the standard diagnostic for diagnosing incompatible attributes produces an error, and the last-pass constraint analysis is skipped when there are errors. I'm going to

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos deleted https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-13 Thread Doug Wyatt via cfe-commits
@@ -395,6 +395,33 @@ bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr , unsigned ArgNum, return checkStringLiteralArgumentAttr(AL, ArgExpr, Str, ArgLocation); } +/// Check if the argument \p ArgNum of \p Attr is a compile-time constant +/// integer (boolean)

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s +// R UN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(clang_nolock) +#error "the 'nolock' attribute is not available" +#endif + +void unannotated(void); +void

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s dougsonos wrote: Thanks, yes, I will merge them (other than the one that is checking the AST dump). https://github.com/llvm/llvm-project/pull/84983

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s +// R UN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(clang_nolock) +#error "the 'nolock' attribute is not available" +#endif + +void unannotated(void); +void

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -395,6 +395,33 @@ bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr , unsigned ArgNum, return checkStringLiteralArgumentAttr(AL, ArgExpr, Str, ArgLocation); } +/// Check if the argument \p ArgNum of \p Attr is a compile-time constant +/// integer (boolean)

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -339,6 +349,11 @@ namespace { bool didParseNoDeref() const { return parsedNoDeref; } +void setParsedNolock(unsigned char v) { parsedNolock = v; } +unsigned char getParsedNolock() const { return parsedNolock; } +void setParsedNoalloc(unsigned char v) {

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -395,6 +395,33 @@ bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr , unsigned ArgNum, return checkStringLiteralArgumentAttr(AL, ArgExpr, Str, ArgLocation); } +/// Check if the argument \p ArgNum of \p Attr is a compile-time constant +/// integer (boolean)

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -2380,6 +2382,1239 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +// Temporary debugging option +#define FX_ANALYZER_VERIFY_DECL_LIST 1 +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -4912,3 +4922,279 @@ void AutoType::Profile(llvm::FoldingSetNodeID , const ASTContext ) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::~FunctionEffect() =

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -3666,11 +3673,14 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID , QualType Result, // Finally we have a trailing return type flag (bool) // combined with AArch64 SME Attributes, to save space: // int + // Then add the FunctionEffects // //

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -3666,11 +3673,14 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID , QualType Result, // Finally we have a trailing return type flag (bool) // combined with AArch64 SME Attributes, to save space: // int + // Then add the FunctionEffects // //

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -1402,6 +1402,29 @@ def CXX11NoReturn : InheritableAttr { let Documentation = [CXX11NoReturnDocs]; } +def NoLock : DeclOrTypeAttr { + let Spellings = [CXX11<"clang", "nolock">, + C23<"clang", "nolock">, + GNU<"clang_nolock">]; + + //

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -10778,6 +10778,101 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function '%1' must not allocate or deallocate memory">, + InGroup; +

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
@@ -1402,6 +1402,29 @@ def CXX11NoReturn : InheritableAttr { let Documentation = [CXX11NoReturnDocs]; } +def NoLock : DeclOrTypeAttr { + let Spellings = [CXX11<"clang", "nolock">, + C23<"clang", "nolock">, + GNU<"clang_nolock">]; + + //

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos reopened https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > * Does the FunctionEffect / FunctionEffectSet abstraction make sense > > (Type.h)? The idea is that an abstract effect system for functions could > > easily support things like "TCB with types" or adding "nowait" to the > > "nolock/noalloc" group of effects. > > Hmm,

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos closed https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
Sirraide wrote: > * Conversions between functions / function pointers with and without the > attribute work in C++ but not in C and I'm a bit lost (there's a bunch of > debug logging around this e.g. Sema::IsFunctionConversion and > Sema::ImpCastExprToType) Er, I’ll see if I can find some

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
Sirraide wrote: > - Does the FunctionEffect / FunctionEffectSet abstraction make sense > (Type.h)? The idea is that an abstract effect system for functions could > easily support things like "TCB with types" or adding "nowait" to the > "nolock/noalloc" group of effects. Hmm, this is a

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
Sirraide wrote: > * FunctionEffect/FunctionEffectSet need to be serialized as part of > FunctionProtoType That’s in `TypeProperties.td` from what I recall. You might be able to pack this into an integer or something similar perhaps. https://github.com/llvm/llvm-project/pull/84983

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread Andrew Pinski via cfe-commits
pinskia wrote: Does it make sense to have some C testcases too? Likewise some testcases testing the __attribute__ style attribute? I would say more testcases the better really. https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -1402,6 +1402,29 @@ def CXX11NoReturn : InheritableAttr { let Documentation = [CXX11NoReturnDocs]; } +def NoLock : DeclOrTypeAttr { + let Spellings = [CXX11<"clang", "nolock">, + C23<"clang", "nolock">, + GNU<"clang_nolock">]; + + //

[clang] nolock/noalloc attributes (PR #84983)

2024-03-12 Thread via cfe-commits
@@ -18321,6 +18321,28 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New, return true; } + // Virtual overrides: check for matching effects. Sirraide wrote: Just a remark: Despite what I said wrt function declaration merging, I

  1   2   >