diff options
author | Jordan Rupprecht <[email protected]> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <[email protected]> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /lib/Frontend/PrecompiledPreamble.cpp | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrecompiledPreamble.cpp')
-rw-r--r-- | lib/Frontend/PrecompiledPreamble.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/Frontend/PrecompiledPreamble.cpp b/lib/Frontend/PrecompiledPreamble.cpp index 1930af187e..59467c3c41 100644 --- a/lib/Frontend/PrecompiledPreamble.cpp +++ b/lib/Frontend/PrecompiledPreamble.cpp @@ -1,9 +1,8 @@ //===--- PrecompiledPreamble.cpp - Build precompiled preambles --*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -19,6 +18,7 @@ #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/FrontendOptions.h" #include "clang/Lex/Lexer.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Serialization/ASTWriter.h" #include "llvm/ADT/StringExtras.h" @@ -157,9 +157,12 @@ private: class PrecompilePreambleConsumer : public PCHGenerator { public: PrecompilePreambleConsumer(PrecompilePreambleAction &Action, - const Preprocessor &PP, StringRef isysroot, + const Preprocessor &PP, + InMemoryModuleCache &ModuleCache, + StringRef isysroot, std::unique_ptr<raw_ostream> Out) - : PCHGenerator(PP, "", isysroot, std::make_shared<PCHBuffer>(), + : PCHGenerator(PP, ModuleCache, "", isysroot, + std::make_shared<PCHBuffer>(), ArrayRef<std::shared_ptr<ModuleFileExtension>>(), /*AllowASTWithErrors=*/true), Action(Action), Out(std::move(Out)) {} @@ -211,7 +214,7 @@ PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI, Sysroot.clear(); return llvm::make_unique<PrecompilePreambleConsumer>( - *this, CI.getPreprocessor(), Sysroot, std::move(OS)); + *this, CI.getPreprocessor(), CI.getModuleCache(), Sysroot, std::move(OS)); } template <class T> bool moveOnNoError(llvm::ErrorOr<T> Val, T &Output) { @@ -347,6 +350,8 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build( Callbacks.createPPCallbacks(); if (DelegatedPPCallbacks) Clang->getPreprocessor().addPPCallbacks(std::move(DelegatedPPCallbacks)); + if (auto CommentHandler = Callbacks.getCommentHandler()) + Clang->getPreprocessor().addCommentHandler(CommentHandler); Act->Execute(); @@ -372,7 +377,7 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build( PrecompiledPreamble::PreambleFileHash::createForFile(File->getSize(), ModTime); } else { - llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File); + const llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File); FilesInPreamble[File->getName()] = PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(Buffer); } @@ -743,6 +748,7 @@ void PreambleCallbacks::HandleTopLevelDecl(DeclGroupRef DG) {} std::unique_ptr<PPCallbacks> PreambleCallbacks::createPPCallbacks() { return nullptr; } +CommentHandler *PreambleCallbacks::getCommentHandler() { return nullptr; } static llvm::ManagedStatic<BuildPreambleErrorCategory> BuildPreambleErrCategory; |