]> granicus.if.org Git - clang/commit
[modules] Fix handling of initializers for templated global variables.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Feb 2019 23:37:13 +0000 (23:37 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Feb 2019 23:37:13 +0000 (23:37 +0000)
commit26e77b4d957d6eb9983421365f7456cca056f7ed
tree6afd25bd4fc46e7a7ee6d3e4c3e7b703afcab44d
parent799a65b8b6de83772790861fdc396b391431b812
[modules] Fix handling of initializers for templated global variables.

For global variables with unordered initialization that are instantiated
within a module, we previously did not emit the global (or its
initializer) at all unless it was used in the importing translation unit
(and sometimes not even then!), leading to misbehavior and link errors.

We now emit the initializer for an instantiated global variable with
unordered initialization with side-effects in a module into every
translation unit that imports the module. This is unfortunate, but
mostly matches the behavior of a non-modular compilation and seems to be
the best that we can reasonably do.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353240 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/TextNodeDumper.cpp
lib/Serialization/ASTCommon.h
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/Modules/initializers.cpp [new file with mode: 0644]