aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorYeoul Na <yeoul_na@apple.com>2024-03-20 13:36:56 +0900
committerGitHub <noreply@github.com>2024-03-20 13:36:56 +0900
commit3eb9ff30959a670559bcba03d149d4c51bf7c9c9 (patch)
treef64783446a5463a010e0ed2e39dcd4275e0a09d8 /clang/lib/CodeGen/CodeGenFunction.cpp
parentb2082a98175b0e5356f23bf21d3dc5b76edea390 (diff)
downloadllvm-3eb9ff30959a670559bcba03d149d4c51bf7c9c9.zip
llvm-3eb9ff30959a670559bcba03d149d4c51bf7c9c9.tar.gz
llvm-3eb9ff30959a670559bcba03d149d4c51bf7c9c9.tar.bz2
Turn 'counted_by' into a type attribute and parse it into 'CountAttributedType' (#78000)
In `-fbounds-safety`, bounds annotations are considered type attributes rather than declaration attributes. Constructing them as type attributes allows us to extend the attribute to apply nested pointers, which is essential to annotate functions that involve out parameters: `void foo(int *__counted_by(*out_count) *out_buf, int *out_count)`. We introduce a new sugar type to support bounds annotated types, `CountAttributedType`. In order to maintain extra data (the bounds expression and the dependent declaration information) that is not trackable in `AttributedType` we create a new type dedicate to this functionality. This patch also extends the parsing logic to parse the `counted_by` argument as an expression, which will allow us to extend the model to support arguments beyond an identifier, e.g., `__counted_by(n + m)` in the future as specified by `-fbounds-safety`. This also adjusts `__bdos` and array-bounds sanitizer code that already uses `CountedByAttr` to check `CountAttributedType` instead to get the field referred to by the attribute.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 98bea82..fad26c4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2409,6 +2409,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
case Type::BTFTagAttributed:
case Type::SubstTemplateTypeParm:
case Type::MacroQualified:
+ case Type::CountAttributed:
// Keep walking after single level desugaring.
type = type.getSingleStepDesugaredType(getContext());
break;