diff options
author | Oliver Stannard <oliver.stannard@arm.com> | 2014-06-20 12:43:07 +0000 |
---|---|---|
committer | Oliver Stannard <oliver.stannard@arm.com> | 2014-06-20 12:43:07 +0000 |
commit | e3a4fb6512552a8de67097703b99997ceab2064a (patch) | |
tree | 5891ad89357ea10909d0dd1cc8af52fb376e55e9 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | c2a363aa3359a79ec657aab7bc82043988be6ea7 (diff) | |
download | llvm-e3a4fb6512552a8de67097703b99997ceab2064a.zip llvm-e3a4fb6512552a8de67097703b99997ceab2064a.tar.gz llvm-e3a4fb6512552a8de67097703b99997ceab2064a.tar.bz2 |
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
llvm-svn: 211354
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3c709f2..6e02342 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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) |