Until now, it was possible to set an initilizer for e.g. a struct that
contained a global constant from some other module. The verifier would
complain, but the verifier's complaint doesn't point very accurately at
the problem.
Details
- Reviewers
efriedma pete arichardson
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 35563 Build 35562: arc lint + arc unit
Event Timeline
I picked reviewers by taking the last two people who changed the file, hope you don't mind.
pete: I took the liberty of adding you as reviewer since you made the most recent change to that function. 2015-06-02. Not exactly yesterday.
llvm/lib/IR/Globals.cpp | ||
---|---|---|
386 | Please clang-format this. Can you check for ConstantAggregate here, instead of checking ConstantStruct and ConstantArray separately? Would it also make sense to check for ConstantExpr? Can you use a for-range loop here? (for (auto *Op : V->operands())) |
I like colon-for.
llvm/lib/IR/Globals.cpp | ||
---|---|---|
386 | Oooh, I can call constants() now. Someone has added that. (Might be a while ago, this isn't exactly new code. ;-) I changed it to test ConstantAggregate, and added a passing unit test involving ConstantExpr. |
llvm/unittests/IR/VerifierTest.cpp | ||
---|---|---|
228 | Are you sure this actually does what you want? ConstantExpr::get() does basic constant folding. |
I don't think you actually need a recursion guard; you only recurse on ConstantAggregates, and they can't refer to themselves circularly. But maybe it's a good idea anyway to avoid exponential compile-time in certain edge cases.
llvm/unittests/IR/VerifierTest.cpp | ||
---|---|---|
237 | This test *still* isn't testing what you want; verification fails due to the other global variable. |
Please clang-format this.
Can you check for ConstantAggregate here, instead of checking ConstantStruct and ConstantArray separately? Would it also make sense to check for ConstantExpr?
Can you use a for-range loop here? (for (auto *Op : V->operands()))