
All deserialized VarDecl initializers are EvaluatedStmt, but not all EvaluatedStmt initializers are from a PCH. Calling `VarDecl::hasInitWithSideEffects` can trigger constant evaluation, but it's hard to know ahead of time whether that will trigger deserialization - even if the initializer is fully deserialized, it may contain a call to a constructor whose body is not deserialized. By caching the result of `VarDecl::hasInitWithSideEffects` and populating that cache during deserialization we can guarantee that calling it won't trigger deserialization regardless of the state of the initializer. This also reduces memory usage by removing the `InitSideEffectVars` set in `ASTReader`. rdar://154717930
52 lines
644 B
C++
52 lines
644 B
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodules-cache-path=%t -fmodule-map-file=%t/module.modulemap %t/test.cppm -I%t
|
|
//
|
|
|
|
//--- test.cppm
|
|
#pragma clang module import Baz
|
|
|
|
//--- Foo.h
|
|
#pragma once
|
|
class foo {
|
|
char dummy = 1;
|
|
|
|
public:
|
|
static foo var;
|
|
|
|
};
|
|
|
|
inline foo foo::var;
|
|
|
|
//--- Bar.h
|
|
#pragma once
|
|
#include <Foo.h>
|
|
|
|
void bar() {
|
|
(void) foo::var;
|
|
}
|
|
|
|
//--- Baz.h
|
|
#pragma once
|
|
#include <Foo.h>
|
|
|
|
void baz() {
|
|
(void) foo::var;
|
|
}
|
|
|
|
#include <Bar.h>
|
|
|
|
//--- module.modulemap
|
|
module Foo {
|
|
header "Foo.h"
|
|
}
|
|
module Bar {
|
|
header "Bar.h"
|
|
}
|
|
module Baz {
|
|
header "Baz.h"
|
|
}
|
|
|