summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorOliver Stannard <oliver.stannard@arm.com>2014-06-20 12:43:07 +0000
committerOliver Stannard <oliver.stannard@arm.com>2014-06-20 12:43:07 +0000
commit693a26d234c4ebf6411a50d5b3d50ca8ea2f54c6 (patch)
treeafe782dd8245b4645951b45f77bb68658712369c /lib/CodeGen/CodeGenModule.cpp
parentda3504c90ff68c32eb16b91924ca888d1a5af105 (diff)
downloadclang-693a26d234c4ebf6411a50d5b3d50ca8ea2f54c6.tar.gz
clang-693a26d234c4ebf6411a50d5b3d50ca8ea2f54c6.tar.bz2
clang-693a26d234c4ebf6411a50d5b3d50ca8ea2f54c6.tar.xz
Add module flags metadata to record the settings for enum and wchar width
Add module flags metadata to record the settings for enum and wchar width, to allow correct ARM build attribute generation git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 3c709f21c4..6e02342fbe 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -352,6 +352,23 @@ void CodeGenModule::Release() {
getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
llvm::DEBUG_METADATA_VERSION);
+ // We need to record the widths of enums and wchar_t, so that we can generate
+ // the correct build attributes in the ARM backend.
+ llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
+ if ( Arch == llvm::Triple::arm
+ || Arch == llvm::Triple::armeb
+ || Arch == llvm::Triple::thumb
+ || Arch == llvm::Triple::thumbeb) {
+ // Width of wchar_t in bytes
+ uint64_t WCharWidth =
+ Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
+ getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
+
+ // The minimum width of an enum in bytes
+ uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
+ getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
+ }
+
SimplifyPersonality();
if (getCodeGenOpts().EmitDeclMetadata)