diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-29 23:20:19 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-29 23:20:19 +0000 |
commit | 20e883e59b4dc30d70552f14af40987db9338bb7 (patch) | |
tree | 9d2b93090e92a4da4b0158d8ed4ac246d83a3d86 /clang/lib/Lex/Preprocessor.cpp | |
parent | bf0a42ac09f45b05345f4f1eba0bd20500681575 (diff) | |
download | llvm-20e883e59b4dc30d70552f14af40987db9338bb7.zip llvm-20e883e59b4dc30d70552f14af40987db9338bb7.tar.gz llvm-20e883e59b4dc30d70552f14af40987db9338bb7.tar.bz2 |
[modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest
of better source fidelity, represent the macro definition information
faithfully: we have a linear macro directive history within each module, and at
any point we have a unique "latest" local macro directive and a collection of
visible imported directives. This also removes the attendent complexity of
attempting to create a correct MacroDirective history (which we got wrong
in the general case).
No functionality change intended.
llvm-svn: 236176
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 92ab2af..cd00be8 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -73,8 +73,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, ModuleImportExpectsIdentifier(false), CodeCompletionReached(0), MainFileDir(nullptr), SkipMainFilePreamble(0, true), CurPPLexer(nullptr), CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), - Callbacks(nullptr), MacroVisibilityGeneration(0), - MacroArgCache(nullptr), Record(nullptr), + Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr), MIChainHead(nullptr), DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; @@ -108,6 +107,9 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, // We haven't read anything from the external source. ReadMacrosFromExternalSource = false; + // We might already have some macros from an imported module (via a PCH or + // preamble) if modules is enabled. + MacroVisibilityGeneration = LangOpts.Modules ? 1 : 0; // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro. // This gets unpoisoned where it is allowed. @@ -623,8 +625,8 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) { } // If this is a macro to be expanded, do it. - if (MacroDirective *MD = getMacroDirective(&II)) { - MacroInfo *MI = MD->getMacroInfo(); + if (MacroDefinition MD = getMacroDefinition(&II)) { + auto *MI = MD.getMacroInfo(); if (!DisableMacroExpansion) { if (!Identifier.isExpandDisabled() && MI->isEnabled()) { // C99 6.10.3p10: If the preprocessing token immediately after the |