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:
https://msdn.microsoft.com/en-us/library/dn636922.aspx
This patch fixes the regression for the support for attribute ((section).
https://github.com/llvm-mirror/clang/commit/746b78de7812bc785fbb5207b788348040b23fa7
The regression was caused by previous MS __declspec(code_seg) support.
Patch by Soumi Manna (Manna)
https://reviews.llvm.org/D43352
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.
If !NewCSA->isImplicit() && is removed, no check-clang test will break.
(This is noticed while I am investigating whether VisibilityAttr can use isImplicit as well https://reviews.llvm.org/D153835)