If a redeclaration of a multiversion function is invalid,
it may be in a broken condition (for example, missing an important
attribute). We shouldn't analyze invalid redeclarations.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
How the bug was working on this example:
void foo() {} [[gnu::target("default")]] void foo() {} [[gnu::target("avx2")]] void foo() {}
- Clang parses the definition of the foo function (line 1)
- When parsing the second definition (line 2), Clang will delete TargetAttr in this function
- Eventually Clang will mark both foos as invalid.
- When parsing the third definition (line 3), in the CheckMultiVersionAdditionalDecl method Clang is trying to compare TargetAttr of the 2nd and the 3rd foo: link.
- The CurTA variable is equal to nullptr (because we deleted the attribute in the second step), so there is undefined behaviour.
I suggest to stop looking to invalid declarations.