Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Serialization/GeneratePCH.cpp
//===--- GeneratePCH.cpp - Sema Consumer for PCH Generation -----*- C++ -*-===// | //===--- GeneratePCH.cpp - Sema Consumer for PCH Generation -----*- C++ -*-===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// This file defines the PCHGenerator, which as a SemaConsumer that generates | // This file defines the PCHGenerator, which as a SemaConsumer that generates | ||||
// a PCH file. | // a PCH file. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "clang/AST/ASTContext.h" | #include "clang/AST/ASTContext.h" | ||||
#include "clang/Lex/HeaderSearch.h" | #include "clang/Lex/HeaderSearch.h" | ||||
#include "clang/Lex/Preprocessor.h" | #include "clang/Lex/Preprocessor.h" | ||||
#include "clang/Lex/PreprocessorOptions.h" | |||||
#include "clang/Sema/SemaConsumer.h" | #include "clang/Sema/SemaConsumer.h" | ||||
#include "clang/Serialization/ASTWriter.h" | #include "clang/Serialization/ASTWriter.h" | ||||
#include "llvm/Bitstream/BitstreamWriter.h" | #include "llvm/Bitstream/BitstreamWriter.h" | ||||
using namespace clang; | using namespace clang; | ||||
PCHGenerator::PCHGenerator( | PCHGenerator::PCHGenerator( | ||||
const Preprocessor &PP, InMemoryModuleCache &ModuleCache, | const Preprocessor &PP, InMemoryModuleCache &ModuleCache, | ||||
Show All 9 Lines | : PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()), | ||||
ShouldCacheASTInMemory(ShouldCacheASTInMemory) { | ShouldCacheASTInMemory(ShouldCacheASTInMemory) { | ||||
this->Buffer->IsComplete = false; | this->Buffer->IsComplete = false; | ||||
} | } | ||||
PCHGenerator::~PCHGenerator() { | PCHGenerator::~PCHGenerator() { | ||||
} | } | ||||
void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { | void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { | ||||
// Do not attempt to write the AST file. | |||||
if (PP.getPreprocessorOpts().ScanningMode) | |||||
return; | |||||
// Don't create a PCH if there were fatal failures during module loading. | // Don't create a PCH if there were fatal failures during module loading. | ||||
if (PP.getModuleLoader().HadFatalFailure) | if (PP.getModuleLoader().HadFatalFailure) | ||||
return; | return; | ||||
bool hasErrors = PP.getDiagnostics().hasErrorOccurred(); | bool hasErrors = PP.getDiagnostics().hasErrorOccurred(); | ||||
if (hasErrors && !AllowASTWithErrors) | if (hasErrors && !AllowASTWithErrors) | ||||
return; | return; | ||||
Show All 35 Lines |