diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-03-07 07:47:58 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-03-07 07:47:58 +0000 |
commit | e1974dcd92b0f27e4a8ba54887640b2a93993b40 (patch) | |
tree | bbd8e20e8b482ec5577257f8ceda44a2eaab0f1a /clang/lib | |
parent | 648250a2e50c00eb5c56182a7d2f2b41f74ab16e (diff) | |
download | llvm-e1974dcd92b0f27e4a8ba54887640b2a93993b40.zip llvm-e1974dcd92b0f27e4a8ba54887640b2a93993b40.tar.gz llvm-e1974dcd92b0f27e4a8ba54887640b2a93993b40.tar.bz2 |
[Preprocessor] Pass TranslationUnitKind to the preprocessor and if it is TU_Prefix
avoid warning for unused macros.
rdar://15034698
llvm-svn: 203213
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/ChainedIncludesSource.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 4 |
5 files changed, 19 insertions, 10 deletions
diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp index ab5c81f..1bdd48e 100644 --- a/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -104,7 +104,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { &Clang->getTargetOpts())); Clang->createFileManager(); Clang->createSourceManager(Clang->getFileManager()); - Clang->createPreprocessor(); + Clang->createPreprocessor(TU_Prefix); Clang->getDiagnosticClient().BeginSourceFile(Clang->getLangOpts(), &Clang->getPreprocessor()); Clang->createASTContext(); diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f10311a..be1a540 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -223,7 +223,7 @@ void CompilerInstance::createSourceManager(FileManager &FileMgr) { // Preprocessor -void CompilerInstance::createPreprocessor() { +void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { const PreprocessorOptions &PPOpts = getPreprocessorOpts(); // Create a PTH manager if we are using some form of a token cache. @@ -240,7 +240,10 @@ void CompilerInstance::createPreprocessor() { PP = new Preprocessor(&getPreprocessorOpts(), getDiagnostics(), getLangOpts(), &getTarget(), getSourceManager(), *HeaderInfo, *this, PTHMgr, - /*OwnsHeaderSearch=*/true); + /*OwnsHeaderSearch=*/true, + /*DelayInitialization=*/false, + /*IncrProcessing=*/false, + TUKind); // Note that this is different then passing PTHMgr to Preprocessor's ctor. // That argument is used as the IdentifierInfoLookup argument to diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index f028a56..6cebead 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -291,7 +291,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, } // Set up the preprocessor. - CI.createPreprocessor(); + CI.createPreprocessor(getTranslationUnitKind()); // Inform the diagnostic client we are processing a source file. CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 4170fc3..218c5d4 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -427,11 +427,15 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { if (!isIncrementalProcessingEnabled()) CurPPLexer = 0; - // This is the end of the top-level file. 'WarnUnusedMacroLocs' has collected - // all macro locations that we need to warn because they are not used. - for (WarnUnusedMacroLocsTy::iterator - I=WarnUnusedMacroLocs.begin(), E=WarnUnusedMacroLocs.end(); I!=E; ++I) - Diag(*I, diag::pp_macro_not_used); + if (TUKind != TU_Prefix) { + // This is the end of the top-level file. 'WarnUnusedMacroLocs' has + // collected all macro locations that we need to warn because they are not + // used. + for (WarnUnusedMacroLocsTy::iterator + I=WarnUnusedMacroLocs.begin(), E=WarnUnusedMacroLocs.end(); + I!=E; ++I) + Diag(*I, diag::pp_macro_not_used); + } // If we are building a module that has an umbrella header, make sure that // each of the headers within the directory covered by the umbrella header diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index e7d8440..2125d18 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -59,11 +59,13 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, const TargetInfo *target, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup, bool OwnsHeaders, - bool DelayInitialization, bool IncrProcessing) + bool DelayInitialization, bool IncrProcessing, + TranslationUnitKind TUKind) : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(target), FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(0), Identifiers(opts, IILookup), IncrementalProcessing(IncrProcessing), + TUKind(TUKind), CodeComplete(0), CodeCompletionFile(0), CodeCompletionOffset(0), LastTokenWasAt(false), ModuleImportExpectsIdentifier(false), CodeCompletionReached(0), SkipMainFilePreamble(0, true), CurPPLexer(0), |