https://bugs.llvm.org/show_bug.cgi?id=48434

            Bug ID: 48434
           Summary: attribute instantiation for class template
                    specializations can lead to deserialization cycles
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Modules
          Assignee: unassignedclangb...@nondot.org
          Reporter: richard-l...@metafoo.co.uk
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Consider:

```
template<typename T> struct A;
using X = A<int>;
template<typename T> struct [[attr(X)]] A {};
X x;
```

Now, deserializing `x` crashes, because it hits a cycle:

* Deserializing `x` reads the TypedefNameDecl `X`
* Deserializing `X` reads its RecordType `A<int>`
* Deserializing `A<int>` reads its attributes
* Deserializing `attr(X)` finds we already have an `X`, so tries to use it
* Using the `X` to form a `TypedefType` crashes, because `X` is not
sufficiently initialized

This is broken because we violated the deserialization invariant by emitting
bitcode for `X` that (indirectly) refers to a lexically-later part of the
program, specifically the attributes for `A<int>`.

To fix this, I think we need to lazily load attributes, at least for template
specializations.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to