llvm-project/clang/test/Modules/Inputs/redecl-add-after-load.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
500 B
C
Raw Normal View History

If a declaration is loaded, and then a module import adds a redeclaration, then ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
2014-05-17 07:01:30 +08:00
struct A {};
extern const int variable = 0;
extern constexpr int function() { return 0; }
namespace N {
struct A {};
extern const int variable = 0;
extern constexpr int function() { return 0; }
}
@import redecl_add_after_load_top;
struct C::A {};
const int C::variable = 0;
constexpr int C::function() { return 0; }
struct D {
struct A;
static const int variable;
static constexpr int function();
};
struct D::A {};
const int D::variable = 0;
constexpr int D::function() { return 0; }