From: Matthias Braun Date: Fri, 19 May 2017 22:37:01 +0000 (+0000) Subject: Verifier: Check wchar_size module flag. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60ecb7fde81665fe54e2ef278eed9fb25e9d8693;p=llvm Verifier: Check wchar_size module flag. Differential Revision: https://reviews.llvm.org/D32974 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303460 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 3b68d636587..4b9bdcf81a3 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -1317,6 +1317,15 @@ Verifier::visitModuleFlag(const MDNode *Op, Assert(Inserted, "module flag identifiers must be unique (or of 'require' type)", ID); } + + if (ID->getString() == "wchar_size") { + ConstantInt *Value + = mdconst::dyn_extract_or_null(Op->getOperand(2)); + Assert(Value, "wchar_size metadata requires constant integer argument"); + uint64_t WCharSize = Value->getZExtValue(); + Assert(WCharSize == 0 || WCharSize == 2 || WCharSize == 4, + "wchar_size should be 0, 2 or 4"); + } } /// Return true if this attribute kind only applies to functions.