diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-21 01:20:10 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-21 01:20:10 +0000 |
commit | 04765ae01e936a3f2bc980ebd8fc7ea8a4760636 (patch) | |
tree | b5a150687a94b1b7cf20fbad6067172a2013e341 /clang/lib/Lex/Preprocessor.cpp | |
parent | de0aff3e9109ac9444b4408aa7619204344f54ed (diff) | |
download | bcm5719-llvm-04765ae01e936a3f2bc980ebd8fc7ea8a4760636.tar.gz bcm5719-llvm-04765ae01e936a3f2bc980ebd8fc7ea8a4760636.zip |
[modules] If we re-enter a submodule from within itself (when submodule
visibility is enabled) or leave and re-enter it, restore the macro and module
visibility state from last time we were in that submodule.
This allows mutually-#including header files to stand a chance at being
modularized with local visibility enabled.
llvm-svn: 237871
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 9e89497597e..7e33f1ccb48 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -73,7 +73,8 @@ 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), MacroArgCache(nullptr), Record(nullptr), + Callbacks(nullptr), CurSubmoduleState(&NullSubmoduleState), + MacroArgCache(nullptr), Record(nullptr), MIChainHead(nullptr), DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; @@ -266,7 +267,9 @@ void Preprocessor::PrintStats() { llvm::errs() << "\n Macro Expanded Tokens: " << llvm::capacity_in_bytes(MacroExpandedTokens); llvm::errs() << "\n Predefines Buffer: " << Predefines.capacity(); - llvm::errs() << "\n Macros: " << llvm::capacity_in_bytes(Macros); + // FIXME: List information for all submodules. + llvm::errs() << "\n Macros: " + << llvm::capacity_in_bytes(CurSubmoduleState->Macros); llvm::errs() << "\n #pragma push_macro Info: " << llvm::capacity_in_bytes(PragmaPushMacroInfo); llvm::errs() << "\n Poison Reasons: " @@ -283,14 +286,16 @@ Preprocessor::macro_begin(bool IncludeExternalMacros) const { ExternalSource->ReadDefinedMacros(); } - return Macros.begin(); + return CurSubmoduleState->Macros.begin(); } size_t Preprocessor::getTotalMemory() const { return BP.getTotalMemory() + llvm::capacity_in_bytes(MacroExpandedTokens) + Predefines.capacity() /* Predefines buffer. */ - + llvm::capacity_in_bytes(Macros) + // FIXME: Include sizes from all submodules, and include MacroInfo sizes, + // and ModuleMacros. + + llvm::capacity_in_bytes(CurSubmoduleState->Macros) + llvm::capacity_in_bytes(PragmaPushMacroInfo) + llvm::capacity_in_bytes(PoisonReasons) + llvm::capacity_in_bytes(CommentHandlers); @@ -304,7 +309,7 @@ Preprocessor::macro_end(bool IncludeExternalMacros) const { ExternalSource->ReadDefinedMacros(); } - return Macros.end(); + return CurSubmoduleState->Macros.end(); } /// \brief Compares macro tokens with a specified token value sequence. @@ -781,7 +786,7 @@ void Preprocessor::LexAfterModuleImport(Token &Result) { } void Preprocessor::makeModuleVisible(Module *M, SourceLocation Loc) { - VisibleModules.setVisible( + CurSubmoduleState->VisibleModules.setVisible( M, Loc, [](Module *) {}, [&](ArrayRef<Module *> Path, Module *Conflict, StringRef Message) { // FIXME: Include the path in the diagnostic. |