This patch uses CodeSegAttr to represent __declspec(code_seg) rather than building on the existing support for #pragma code_seg.
The code_seg declspec is applied on functions and classes. This attribute enables the placement of code into separate named segments, including compiler-generated codes and template instantiations.
For more information, please see the following:
This patch fixes the regression for the support for attribute ((section).
The regression was caused by previous MS __declspec(code_seg) support.
Patch by Soumi Manna (Manna)
The “declspec(code_seg)” uses CodeSegAttr. The patch is written to handle CodeGen support for the CodeSeg attribute. To prevent code_seg declspec interacting with attribute __((section)) or anything else that creates SectionAttr, the patch is written to check for SectionAttr (to check for #pragma code_seg related attributes) that only comes from #pragma code_seg and not a SectionAttr coming from some other construct that creates SectionAttrs.
Inside getImplicitCodeSegAttrFromClass routine, the patches are written to match with complicated Microsoft Compiler’s behavior (https://reviews.llvm.org/D22931, this is no longer available and it seems like Microsoft has removed this feedback page).
To match with the Microsoft Compiler, diagnostics messages are added for the code-seg
attribute mismatches on base and derived classes, virtual overrides, multiple and virtual inheritance, and function overloading.