HeaderToModel: emit forward declaration later

We used to emit the forward declaration for the type we were editing
*before* `#pragma once`. This was not good per se, but it also lead to
failures due to the introduction of `_PACKED`, which is not yet defined
at that stage.
This commit is contained in:
Alessandro Di Federico
2023-08-03 14:52:44 +02:00
parent c623e2d9d6
commit 100a27bb1c
@@ -154,12 +154,13 @@ struct ImportModelFromCAnalysis {
if (not isa<model::RawFunctionType>(*TypeToEdit)
and not isa<model::CABIFunctionType>(*TypeToEdit)
and not isa<model::TypedefType>(*TypeToEdit)) {
llvm::raw_string_ostream Stream(Options.PostIncludes);
ptml::PTMLCBuilder ThePTMLCBuilder(true);
ptml::PTMLIndentedOstream ThePTMLStream(Header, 4, true);
Header << ThePTMLCBuilder.getLineComment("The type we are editing.");
ptml::PTMLIndentedOstream ThePTMLStream(Stream, 4, true);
Stream << ThePTMLCBuilder.getLineComment("The type we are editing");
// The definition of this type will be at the end of the file.
printForwardDeclaration(**TypeToEdit, ThePTMLStream, ThePTMLCBuilder);
Header << '\n';
Stream << '\n';
}
// Find all types whose definition depends on the type we are editing.