[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,27 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static void CheckBoundsSafetyLang(InputKind IK, DiagnosticsEngine &Diags) { rapidsn

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,27 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static void CheckBoundsSafetyLang(InputKind IK, DiagnosticsEngine &Diags) { rapidsn

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/8] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
@@ -1412,6 +1412,9 @@ def FunctionMultiVersioning def NoDeref : DiagGroup<"noderef">; +// Bounds safety specific warnings +def IgnoredBoundsSafety : DiagGroup<"ignored-bounds-safety">; rapidsna wrote: Removed it! https://github.com/llvm/llvm-project/pull/70

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-07 Thread Yeoul Na via cfe-commits
rapidsna wrote: > > [Driver][BoundsSafety] Add -fbounds-safety-experimental flag #70480 > > The patch implements `-fexperimental-bounds-safety` I just updated the title. I'll make sure I update the text when I squash the commits. https://github.com/llvm/llvm-project/pull/70480 __

[llvm] [clang-tools-extra] [clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[llvm] [clang-tools-extra] [clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[clang-tools-extra] [llvm] [clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[clang] [clang-tools-extra] [llvm] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[llvm] [clang-tools-extra] [clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[clang] [clang-tools-extra] [llvm] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[clang-tools-extra] [llvm] [clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-08 Thread Yeoul Na via cfe-commits
@@ -859,53 +860,93 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); +// The code generated here calculates

[llvm] [clang] [clang-tools-extra] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-09 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna approved this pull request. Thank you! LGTM. https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-09 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/9] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-09 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,27 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static void CheckBoundsSafetyLang(InputKind IK, DiagnosticsEngine &Diags) { rapidsn

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-09 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 01/10] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-09 Thread Yeoul Na via cfe-commits
rapidsna wrote: > However, implementing the checking in clang/lib/Driver is much more common. > clang/lib/Frontend/CompilerInvocation.cpp has some checking, but the majority > is in clang/lib/Driver. @MaskRay To be clear, the check is now in Driver as you suggested. It's just that the fronten

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-09 Thread Yeoul Na via cfe-commits
rapidsna wrote: > Sometimes, it is actually useful to expose some experimental features that we > don't feel comfortable surfacing as driver options as cc1 options. The cc1 > options give the users to experiment with the feature. It's the users's > responsibility to adapt when the feature chan

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna commented: Thanks @AaronBallman for your feedback! I left inlined comments to answer these and updated documents. https://github.com/llvm/llvm-project/pull/70749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-12-11 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,362 @@ +== +``-fbounds-safety``: Enforcing bounds safety for C +== + +.. contents:: + :local: + +Overview + + +``-fbounds-safety`` is a C extension to enforce bound

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-14 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-14 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 01/11] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-14 Thread Yeoul Na via cfe-commits
rapidsna wrote: > > -fbounds-safety-experimental is an experimental flag for -fbounds-safety, > > -fexperimental-bounds-safety Changed the description in the PR! I'll adjust the commit message too when I squash all the changes once I get your approval. https://github.com/llvm/llvm-project/pul

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-14 Thread Yeoul Na via cfe-commits
rapidsna wrote: > > @MaskRay To be clear, the check is now in Driver as you suggested. It's > > just that the frontend also has some extra checks too. So, you want me to > > remove the extra checks in the frontend? > > Yes, otherwise it's duplicated check. I just removed the check in the fron

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2023-11-14 Thread Yeoul Na via cfe-commits
rapidsna wrote: > In addition, I think our convention is to add the option when the feature is > ready, rather than add a no-op option, than build functional patches on top > of it. @MaskRay This feature will involve a lot of incremental patches. And we will still need an experimental flag t

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/2] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,9 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +def error_bounds_safety_lang_not_supported : Error< rapidsna wrote: Done! https://github.com/llvm/llvm-project/pull/70480 _

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,9 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +def error_bounds_safety_lang_not_supported : Error< rapidsna wrote: Done! https://github.com/llvm/llvm-project/pull/70480 _

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,23 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static bool SupportsBoundsSafety(Language Lang) { + // Currently, bounds safety is only supported f

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,23 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static bool SupportsBoundsSafety(Language Lang) { + // Currently, bounds safety is only supported f

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -3835,6 +3852,12 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.Trigraphs = Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs); + Opts.BoundsSafety = Args.hasFlag(OPT_fbounds_safety, OPT_fno_bounds_safety, ---

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang -c %s -### 2>&1 | not grep fbounds-safety-experimental rapidsna wrote: Done! https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/2] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-30 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,5 @@ + +// RUN: %clang -fbounds-safety-experimental -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fbounds-safety-experimental -fsyntax-only %s 2>&1 | FileCheck %s + +// CHECK: warning: '-fbounds-safety' is ignored for assembly rapidsna wro

[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-10-30 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna created https://github.com/llvm/llvm-project/pull/70749 The document is mostly the exact copy of RFC: Enforcing Bounds Safety in C, except some minor adjustments in the tone to make it more suitable for documentation: https://discourse.llvm.org/t/rfc-enforcing-bound

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-30 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
rapidsna wrote: > The other experimental flags I see start with experimental, this one ends > with it. Why isn't this called `-fexerimental-bounds-safety`? Oh, I can see most of them start with `-fexperimental`, not everything though. I can fix this. Is there a formal convention? https://gith

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang -c %s -### 2>&1 | FileCheck -check-prefix T0 %s rapidsna wrote: @nickdesaulniers I was hoping that we could keep -fbounds-safety tests under a separate folder clang/test/BoundsSafety in order to avoid them from getting mixed up

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,25 @@ +// RUN: not %clang -fbounds-safety-experimental -x c++ %s 2>&1 | FileCheck -check-prefix ERR %s + +// RUN: not %clang -fbounds-safety-experimental -x objective-c %s 2>&1 | FileCheck -check-prefix ERR %s + +// RUN: not %clang -fbounds-safety-experimental -x obje

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -3618,6 +3618,30 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts, GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed); } +static void CheckBoundsSafetyLang(InputKind IK, DiagnosticsEngine &Diags) { + // Currently, bounds

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-01 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/5] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang -c %s -### 2>&1 | FileCheck -check-prefix T0 %s rapidsna wrote: @nickdesaulniers @MaskRay Thank you! I removed the new directory and moved the tests to conform to the existing layout. https://github.com/llvm/llvm-project/pull/70

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
rapidsna wrote: > The other experimental flags I see start with experimental, this one ends > with it. Why isn't this called `-fexerimental-bounds-safety`? @tbaederr Thank you! I just renamed the flag to `-fexperimental-bounds-safety`. https://github.com/llvm/llvm-project/pull/70480 __

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,25 @@ +// RUN: not %clang -fbounds-safety-experimental -x c++ %s 2>&1 | FileCheck -check-prefix ERR %s + rapidsna wrote: @MaskRay Thank you! I removed the blank lines. https://github.com/llvm/llvm-project/pull/70480 __

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning< "as the %select{aliasee|resolver}2">, InGroup; +let CategoryName = "Bounds Safety Issue" in { +def err_bounds_safety_lang_not_supported : Error< + "bounds safety is only supported for C">; +def warn_bounds_safety

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,5 @@ +; RUN: %clang -fbounds-safety-experimental -x ir -S %s -o /dev/null 2>&1 | FileCheck %s +; RUN: %clang_cc1 -fbounds-safety-experimental -x ir -S %s -o /dev/null 2>&1 | FileCheck %s + rapidsna wrote: @MaskRay fixed! https://github.com/llvm/llvm

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,12 @@ +// This reports a warning to follow the default behavior of ClangAs. +// RUN: %clang -fexperimental-bounds-safety -x assembler -c %s -o /dev/null 2>&1 | FileCheck -check-prefix WARN %s + + +// WARN: warning: argument unused during compilation: '-fexperimental-b

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna updated https://github.com/llvm/llvm-project/pull/70480 >From 99ec6e055dd32a86bf6d589a6895658dcbe1d7bd Mon Sep 17 00:00:00 2001 From: Yeoul Na Date: Fri, 27 Oct 2023 08:34:37 -0700 Subject: [PATCH 1/6] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag -f

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-02 Thread Yeoul Na via cfe-commits
rapidsna wrote: > @kees, @nickdesaulniers, @rapidsna, and @apple-fcloutier Should this feature > support a `__bdos` to an address inside the FAM? > > ``` > #include > #include > > struct flex { > double dummy; > char count; > char fam[] __attribute__((counted_by(count

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
@@ -0,0 +1,12 @@ +// This reports a warning to follow the default behavior of ClangAs. +// RUN: %clang -fexperimental-bounds-safety -x assembler -c %s -o /dev/null 2>&1 | FileCheck -check-prefix WARN %s rapidsna wrote: I think `-x assembler` and `-x assembler-wi

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

2023-11-02 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-02 Thread Yeoul Na via cfe-commits
rapidsna wrote: ``` #include #include struct flex { int c; int fam[] __attribute__((counted_by(c))); }; int main() { struct flex *p = (struct flex *)malloc(sizeof(struct flex) + sizeof(int) * 10); p->c = 100; printf("%lu\n", __builtin_dynamic_object_size(&p->fam[0], 0)); /

  1   2   3   >