diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-19 20:49:38 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-19 20:49:38 +0000 |
commit | 7747ce226051791be0a03ec106d9502e3564c1af (patch) | |
tree | aee95454826c294c66952e75676eecd939ea4226 /clang/lib/AST/ASTContext.cpp | |
parent | 39259ffc65556b2e848ff691f6611f896c0ed6aa (diff) | |
download | bcm5719-llvm-7747ce226051791be0a03ec106d9502e3564c1af.tar.gz bcm5719-llvm-7747ce226051791be0a03ec106d9502e3564c1af.zip |
Internal-linkage variables with constant-evaluatable initializers do not need to be emitted. (Also reduces the set of variables that need to be eagerly deserialized when using PCH / modules.)
llvm-svn: 245497
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 192120abf1b..f679377b845 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8311,6 +8311,9 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { // Global named register variables (GNU extension) are never emitted. if (VD->getStorageClass() == SC_Register) return false; + if (VD->getDescribedVarTemplate() || + isa<VarTemplatePartialSpecializationDecl>(VD)) + return false; } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // We never need to emit an uninstantiated function template. if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate) @@ -8383,7 +8386,8 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { return true; // Variables that have initialization with side-effects are required. - if (VD->getInit() && VD->getInit()->HasSideEffects(*this)) + if (VD->getInit() && VD->getInit()->HasSideEffects(*this) && + !VD->evaluateValue()) return true; return false; |