I don't like that parts of the test here are duplicated in three different
places; can you refactor to improve that? Maybe factor out a
`CanEmitAsAvailableExternally` from `GetOrCreateLLVMGlobal` and
`GetLLVMLinkageVarDefinition`, call `isTypeConstant` in there rather than
asserting it, and remove the assert from `shouldEmitGlobalVariable`?
It also seems weird to me that `shouldEmitGlobalVariable` would return `true`
when `GetLLVMLinkageVarDefinition` returns
`llvm::GlobalVariable::ExternalLinkage` (even though in practice this never
actually happens).
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1908-1909
@@ +1907,4 @@
+ if (D->hasInit() && !D->hasDefinition(Context)) {
+ assert(isTypeConstant(D->getType(), /*ExcludeCtor=*/true) &&
+ "Variable to be emitted as available externally must be constant!");
+ return llvm::GlobalValue::AvailableExternallyLinkage;
----------------
Why is this an assert rather than a test?
http://llvm-reviews.chandlerc.com/D1982
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits