================
@@ -1161,10 +1161,13 @@ class Parser : public CodeCompletionHandler {
     IdentifierInfo *MacroII = nullptr;
     SourceLocation AttrNameLoc;
     SmallVector<Decl *, 2> Decls;
+    unsigned NestedTypeLevel;
----------------
rapidsna wrote:

I discussed the current approach with @AaronBallman and other clang 
contributors clarified why we need to track the type position for late-parsed 
attributes.

**Context**

The question was: why track the index when `DeclaratorChunk` already knows 
where attributes should be attached and `GetFullTypeForDeclarator` can 
construct the type accordingly?

The key issue: These attributes are late-parsed, meaning they won't be parsed 
when `GetFullTypeForDeclarator` is initially called to construct the type from 
`DeclaratorChunk`. The `LateParsedAttribute` information must be passed around, 
and parsing doesn't occur until after the structure definition is complete. We 
agreed that tracking the position of these late-parsed attributes is necessary.

**Updated Approach**

However, a concern was raised about how to indicate the index for templated 
types when we eventually add C++ support, e.g.:

```C++
Foo<T>::Bar<int * __counted_by(yada)>::baz *[12]
```

**New direction:** Instead of using an index, we'll create a placeholder type 
for types attributed with late attributes during initial type construction. 
When late parsing occurs, we'll use TreeTransform to rebuild the whole 
declaration that has the attribute, replacing the placeholder with the concrete 
type (e.g., `CountAttributedType`).

I'll have a draft implementation ready by next week.

https://github.com/llvm/llvm-project/pull/166491
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to