[llvm] r303460 - Verifier: Check wchar_size module flag.
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri May 19 15:37:01 PDT 2017
Author: matze
Date: Fri May 19 17:37:01 2017
New Revision: 303460
URL: http://llvm.org/viewvc/llvm-project?rev=303460&view=rev
Log:
Verifier: Check wchar_size module flag.
Differential Revision: https://reviews.llvm.org/D32974
Modified:
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=303460&r1=303459&r2=303460&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri May 19 17:37:01 2017
@@ -1317,6 +1317,15 @@ Verifier::visitModuleFlag(const MDNode *
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<ConstantInt>(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.
More information about the llvm-commits
mailing list