Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
//===-- ASTMerge.cpp - AST Merging Frontent Action --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/ASTUnit.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTImporter.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
using namespace clang;
std::unique_ptr<ASTConsumer>
ASTMergeAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return AdaptedAction->CreateASTConsumer(CI, InFile);
}
bool ASTMergeAction::BeginSourceFileAction(CompilerInstance &CI) {
// FIXME: This is a hack. We need a better way to communicate the
// AST file, compiler instance, and file name than member variables
// of FrontendAction.
AdaptedAction->setCurrentInput(getCurrentInput(), takeCurrentASTUnit());
AdaptedAction->setCompilerInstance(&CI);
return AdaptedAction->BeginSourceFileAction(CI);
}
void ASTMergeAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
CI.getDiagnostics().getClient()->BeginSourceFile(
CI.getASTContext().getLangOpts());
CI.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
&CI.getASTContext());
IntrusiveRefCntPtr<DiagnosticIDs>
DiagIDs(CI.getDiagnostics().getDiagnosticIDs());
for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) {
IntrusiveRefCntPtr<DiagnosticsEngine>
Diags(new DiagnosticsEngine(DiagIDs, &CI.getDiagnosticOpts(),
new ForwardingDiagnosticConsumer(
*CI.getDiagnostics().getClient()),
/*ShouldOwnClient=*/true));
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
CI.getFileSystemOpts(), false);
if (!Unit)
continue;
ASTImporter Importer(CI.getASTContext(),
CI.getFileManager(),
Unit->getASTContext(),
Unit->getFileManager(),
/*MinimalImport=*/false);
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
for (auto *D : TU->decls()) {
// Don't re-import __va_list_tag, __builtin_va_list.
if (const auto *ND = dyn_cast<NamedDecl>(D))
if (IdentifierInfo *II = ND->getIdentifier())
if (II->isStr("__va_list_tag") || II->isStr("__builtin_va_list"))
continue;
Decl *ToD = Importer.Import(D);
if (ToD) {
DeclGroupRef DGR(ToD);
CI.getASTConsumer().HandleTopLevelDecl(DGR);
}
}
}
AdaptedAction->ExecuteAction();
CI.getDiagnostics().getClient()->EndSourceFile();
}
void ASTMergeAction::EndSourceFileAction() {
return AdaptedAction->EndSourceFileAction();
}
ASTMergeAction::ASTMergeAction(std::unique_ptr<FrontendAction> adaptedAction,
ArrayRef<std::string> ASTFiles)
: AdaptedAction(std::move(adaptedAction)), ASTFiles(ASTFiles.begin(), ASTFiles.end()) {
assert(AdaptedAction && "ASTMergeAction needs an action to adapt");
}
ASTMergeAction::~ASTMergeAction() {
}
bool ASTMergeAction::usesPreprocessorOnly() const {
return AdaptedAction->usesPreprocessorOnly();
}
TranslationUnitKind ASTMergeAction::getTranslationUnitKind() {
return AdaptedAction->getTranslationUnitKind();
}
bool ASTMergeAction::hasPCHSupport() const {
return AdaptedAction->hasPCHSupport();
}
bool ASTMergeAction::hasASTFileSupport() const {
return AdaptedAction->hasASTFileSupport();
}
bool ASTMergeAction::hasCodeCompletionSupport() const {
return AdaptedAction->hasCodeCompletionSupport();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
add_subdirectory(Rewrite)
set(LLVM_LINK_COMPONENTS
BitReader
Option
ProfileData
Support
)
set(optional_deps intrinsics_gen)
if (CLANG_BUILT_STANDALONE)
set(optional_deps)
endif()
add_clang_library(clangFrontend
ASTConsumers.cpp
ASTMerge.cpp
ASTUnit.cpp
CacheTokens.cpp
ChainedDiagnosticConsumer.cpp
ChainedIncludesSource.cpp
CodeGenOptions.cpp
CompilerInstance.cpp
CompilerInvocation.cpp
CreateInvocationFromCommandLine.cpp
DependencyFile.cpp
DependencyGraph.cpp
DiagnosticRenderer.cpp
FrontendAction.cpp
FrontendActions.cpp
FrontendOptions.cpp
HeaderIncludeGen.cpp
InitHeaderSearch.cpp
InitPreprocessor.cpp
LangStandards.cpp
LayoutOverrideSource.cpp
LogDiagnosticPrinter.cpp
ModuleDependencyCollector.cpp
MultiplexConsumer.cpp
PCHContainerOperations.cpp
PrecompiledPreamble.cpp
PrintPreprocessedOutput.cpp
SerializedDiagnosticPrinter.cpp
SerializedDiagnosticReader.cpp
TestModuleFileExtension.cpp
TextDiagnostic.cpp
TextDiagnosticBuffer.cpp
TextDiagnosticPrinter.cpp
VerifyDiagnosticConsumer.cpp
DEPENDS
ClangDriverOptions
${optional_deps}
LINK_LIBS
clangAST
clangBasic
clangDriver
clangEdit
clangLex
clangParse
clangSema
clangSerialization
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
//===- ChainedDiagnosticConsumer.cpp - Chain Diagnostic Clients -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/ChainedDiagnosticConsumer.h"
using namespace clang;
void ChainedDiagnosticConsumer::anchor() { }

View File

@ -0,0 +1,219 @@
//===- ChainedIncludesSource.cpp - Chained PCHs in Memory -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the ChainedIncludesSource class, which converts headers
// to chained PCHs in memory, mainly used for testing.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Sema/MultiplexExternalSemaSource.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ASTWriter.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace clang;
namespace {
class ChainedIncludesSourceImpl : public ExternalSemaSource {
public:
ChainedIncludesSourceImpl(std::vector<std::unique_ptr<CompilerInstance>> CIs)
: CIs(std::move(CIs)) {}
protected:
//===----------------------------------------------------------------------===//
// ExternalASTSource interface.
//===----------------------------------------------------------------------===//
/// Return the amount of memory used by memory buffers, breaking down
/// by heap-backed versus mmap'ed memory.
void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override {
for (unsigned i = 0, e = CIs.size(); i != e; ++i) {
if (const ExternalASTSource *eSrc =
CIs[i]->getASTContext().getExternalSource()) {
eSrc->getMemoryBufferSizes(sizes);
}
}
}
private:
std::vector<std::unique_ptr<CompilerInstance>> CIs;
};
/// Members of ChainedIncludesSource, factored out so we can initialize
/// them before we initialize the ExternalSemaSource base class.
struct ChainedIncludesSourceMembers {
ChainedIncludesSourceMembers(
std::vector<std::unique_ptr<CompilerInstance>> CIs,
IntrusiveRefCntPtr<ExternalSemaSource> FinalReader)
: Impl(std::move(CIs)), FinalReader(std::move(FinalReader)) {}
ChainedIncludesSourceImpl Impl;
IntrusiveRefCntPtr<ExternalSemaSource> FinalReader;
};
/// Use MultiplexExternalSemaSource to dispatch all ExternalSemaSource
/// calls to the final reader.
class ChainedIncludesSource
: private ChainedIncludesSourceMembers,
public MultiplexExternalSemaSource {
public:
ChainedIncludesSource(std::vector<std::unique_ptr<CompilerInstance>> CIs,
IntrusiveRefCntPtr<ExternalSemaSource> FinalReader)
: ChainedIncludesSourceMembers(std::move(CIs), std::move(FinalReader)),
MultiplexExternalSemaSource(Impl, *this->FinalReader) {}
};
}
static ASTReader *
createASTReader(CompilerInstance &CI, StringRef pchFile,
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> &MemBufs,
SmallVectorImpl<std::string> &bufNames,
ASTDeserializationListener *deserialListener = nullptr) {
Preprocessor &PP = CI.getPreprocessor();
std::unique_ptr<ASTReader> Reader;
Reader.reset(new ASTReader(PP, &CI.getASTContext(),
CI.getPCHContainerReader(),
/*Extensions=*/{ },
/*isysroot=*/"", /*DisableValidation=*/true));
for (unsigned ti = 0; ti < bufNames.size(); ++ti) {
StringRef sr(bufNames[ti]);
Reader->addInMemoryBuffer(sr, std::move(MemBufs[ti]));
}
Reader->setDeserializationListener(deserialListener);
switch (Reader->ReadAST(pchFile, serialization::MK_PCH, SourceLocation(),
ASTReader::ARR_None)) {
case ASTReader::Success:
// Set the predefines buffer as suggested by the PCH reader.
PP.setPredefines(Reader->getSuggestedPredefines());
return Reader.release();
case ASTReader::Failure:
case ASTReader::Missing:
case ASTReader::OutOfDate:
case ASTReader::VersionMismatch:
case ASTReader::ConfigurationMismatch:
case ASTReader::HadErrors:
break;
}
return nullptr;
}
IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
CompilerInstance &CI, IntrusiveRefCntPtr<ExternalSemaSource> &Reader) {
std::vector<std::string> &includes = CI.getPreprocessorOpts().ChainedIncludes;
assert(!includes.empty() && "No '-chain-include' in options!");
std::vector<std::unique_ptr<CompilerInstance>> CIs;
InputKind IK = CI.getFrontendOpts().Inputs[0].getKind();
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> SerialBufs;
SmallVector<std::string, 4> serialBufNames;
for (unsigned i = 0, e = includes.size(); i != e; ++i) {
bool firstInclude = (i == 0);
std::unique_ptr<CompilerInvocation> CInvok;
CInvok.reset(new CompilerInvocation(CI.getInvocation()));
CInvok->getPreprocessorOpts().ChainedIncludes.clear();
CInvok->getPreprocessorOpts().ImplicitPCHInclude.clear();
CInvok->getPreprocessorOpts().ImplicitPTHInclude.clear();
CInvok->getPreprocessorOpts().DisablePCHValidation = true;
CInvok->getPreprocessorOpts().Includes.clear();
CInvok->getPreprocessorOpts().MacroIncludes.clear();
CInvok->getPreprocessorOpts().Macros.clear();
CInvok->getFrontendOpts().Inputs.clear();
FrontendInputFile InputFile(includes[i], IK);
CInvok->getFrontendOpts().Inputs.push_back(InputFile);
TextDiagnosticPrinter *DiagClient =
new TextDiagnosticPrinter(llvm::errs(), new DiagnosticOptions());
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient));
std::unique_ptr<CompilerInstance> Clang(
new CompilerInstance(CI.getPCHContainerOperations()));
Clang->setInvocation(std::move(CInvok));
Clang->setDiagnostics(Diags.get());
Clang->setTarget(TargetInfo::CreateTargetInfo(
Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
Clang->createFileManager();
Clang->createSourceManager(Clang->getFileManager());
Clang->createPreprocessor(TU_Prefix);
Clang->getDiagnosticClient().BeginSourceFile(Clang->getLangOpts(),
&Clang->getPreprocessor());
Clang->createASTContext();
auto Buffer = std::make_shared<PCHBuffer>();
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions;
auto consumer = llvm::make_unique<PCHGenerator>(
Clang->getPreprocessor(), "-", /*isysroot=*/"", Buffer,
Extensions, /*AllowASTWithErrors=*/true);
Clang->getASTContext().setASTMutationListener(
consumer->GetASTMutationListener());
Clang->setASTConsumer(std::move(consumer));
Clang->createSema(TU_Prefix, nullptr);
if (firstInclude) {
Preprocessor &PP = Clang->getPreprocessor();
PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
PP.getLangOpts());
} else {
assert(!SerialBufs.empty());
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> Bufs;
// TODO: Pass through the existing MemoryBuffer instances instead of
// allocating new ones.
for (auto &SB : SerialBufs)
Bufs.push_back(llvm::MemoryBuffer::getMemBuffer(SB->getBuffer()));
std::string pchName = includes[i-1];
llvm::raw_string_ostream os(pchName);
os << ".pch" << i-1;
serialBufNames.push_back(os.str());
IntrusiveRefCntPtr<ASTReader> Reader;
Reader = createASTReader(
*Clang, pchName, Bufs, serialBufNames,
Clang->getASTConsumer().GetASTDeserializationListener());
if (!Reader)
return nullptr;
Clang->setModuleManager(Reader);
Clang->getASTContext().setExternalSource(Reader);
}
if (!Clang->InitializeSourceManager(InputFile))
return nullptr;
ParseAST(Clang->getSema());
Clang->getDiagnosticClient().EndSourceFile();
assert(Buffer->IsComplete && "serialization did not complete");
auto &serialAST = Buffer->Data;
SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(
StringRef(serialAST.data(), serialAST.size())));
serialAST.clear();
CIs.push_back(std::move(Clang));
}
assert(!SerialBufs.empty());
std::string pchName = includes.back() + ".pch-final";
serialBufNames.push_back(pchName);
Reader = createASTReader(CI, pchName, SerialBufs, serialBufNames);
if (!Reader)
return nullptr;
return IntrusiveRefCntPtr<ChainedIncludesSource>(
new ChainedIncludesSource(std::move(CIs), Reader));
}

View File

@ -0,0 +1,32 @@
//===--- CodeGenOptions.cpp -----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/CodeGenOptions.h"
#include <string.h>
namespace clang {
CodeGenOptions::CodeGenOptions() {
#define CODEGENOPT(Name, Bits, Default) Name = Default;
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
#include "clang/Frontend/CodeGenOptions.def"
RelocationModel = "pic";
memcpy(CoverageVersion, "402*", 4);
}
bool CodeGenOptions::isNoBuiltinFunc(const char *Name) const {
StringRef FuncName(Name);
for (unsigned i = 0, e = NoBuiltinFuncs.size(); i != e; ++i)
if (FuncName.equals(NoBuiltinFuncs[i]))
return true;
return false;
}
} // end namespace clang

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
438a48083ef616e85a67cef871235da058a7080f

View File

@ -0,0 +1,106 @@
//===--- CreateInvocationFromCommandLine.cpp - CompilerInvocation from Args ==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Construct a compiler invocation object for command line driver arguments
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/Utils.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Host.h"
using namespace clang;
using namespace llvm::opt;
/// createInvocationFromCommandLine - Construct a compiler invocation object for
/// a command line argument vector.
///
/// \return A CompilerInvocation, or 0 if none was built for the given
/// argument vector.
std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
ArrayRef<const char *> ArgList, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
if (!Diags.get()) {
// No diagnostics engine was provided, so create our own diagnostics object
// with the default options.
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions);
}
SmallVector<const char *, 16> Args(ArgList.begin(), ArgList.end());
// FIXME: Find a cleaner way to force the driver into restricted modes.
Args.push_back("-fsyntax-only");
// FIXME: We shouldn't have to pass in the path info.
driver::Driver TheDriver(Args[0], llvm::sys::getDefaultTargetTriple(),
*Diags, VFS);
// Don't check that inputs exist, they may have been remapped.
TheDriver.setCheckInputsExist(false);
std::unique_ptr<driver::Compilation> C(TheDriver.BuildCompilation(Args));
if (!C)
return nullptr;
// Just print the cc1 options if -### was present.
if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {
C->getJobs().Print(llvm::errs(), "\n", true);
return nullptr;
}
// We expect to get back exactly one command job, if we didn't something
// failed. Offload compilation is an exception as it creates multiple jobs. If
// that's the case, we proceed with the first job. If caller needs a
// particular job, it should be controlled via options (e.g.
// --cuda-{host|device}-only for CUDA) passed to the driver.
const driver::JobList &Jobs = C->getJobs();
bool OffloadCompilation = false;
if (Jobs.size() > 1) {
for (auto &A : C->getActions()){
// On MacOSX real actions may end up being wrapped in BindArchAction
if (isa<driver::BindArchAction>(A))
A = *A->input_begin();
if (isa<driver::OffloadAction>(A)) {
OffloadCompilation = true;
break;
}
}
}
if (Jobs.size() == 0 || !isa<driver::Command>(*Jobs.begin()) ||
(Jobs.size() > 1 && !OffloadCompilation)) {
SmallString<256> Msg;
llvm::raw_svector_ostream OS(Msg);
Jobs.Print(OS, "; ", true);
Diags->Report(diag::err_fe_expected_compiler_job) << OS.str();
return nullptr;
}
const driver::Command &Cmd = cast<driver::Command>(*Jobs.begin());
if (StringRef(Cmd.getCreator().getName()) != "clang") {
Diags->Report(diag::err_fe_expected_clang_command);
return nullptr;
}
const ArgStringList &CCArgs = Cmd.getArguments();
auto CI = llvm::make_unique<CompilerInvocation>();
if (!CompilerInvocation::CreateFromArgs(*CI,
const_cast<const char **>(CCArgs.data()),
const_cast<const char **>(CCArgs.data()) +
CCArgs.size(),
*Diags))
return nullptr;
return CI;
}

View File

@ -0,0 +1,473 @@
//===--- DependencyFile.cpp - Generate dependency file --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This code generates dependency files.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Lex/DirectoryLookup.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Serialization/ASTReader.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
namespace {
struct DepCollectorPPCallbacks : public PPCallbacks {
DependencyCollector &DepCollector;
SourceManager &SM;
DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM)
: DepCollector(L), SM(SM) { }
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override {
if (Reason != PPCallbacks::EnterFile)
return;
// Dependency generation really does want to go all the way to the
// file entry for a source location to find out what is depended on.
// We do not want #line markers to affect dependency generation!
const FileEntry *FE =
SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc)));
if (!FE)
return;
StringRef Filename =
llvm::sys::path::remove_leading_dotslash(FE->getName());
DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
isSystem(FileType),
/*IsModuleFile*/false, /*IsMissing*/false);
}
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported) override {
if (!File)
DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
/*IsSystem*/false, /*IsModuleFile*/false,
/*IsMissing*/true);
// Files that actually exist are handled by FileChanged.
}
void EndOfMainFile() override {
DepCollector.finishedMainFile();
}
};
struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
DependencyCollector &DepCollector;
DepCollectorMMCallbacks(DependencyCollector &DC) : DepCollector(DC) {}
void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,
bool IsSystem) override {
StringRef Filename = Entry.getName();
DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
/*IsSystem*/IsSystem,
/*IsModuleFile*/false,
/*IsMissing*/false);
}
};
struct DepCollectorASTListener : public ASTReaderListener {
DependencyCollector &DepCollector;
DepCollectorASTListener(DependencyCollector &L) : DepCollector(L) { }
bool needsInputFileVisitation() override { return true; }
bool needsSystemInputFileVisitation() override {
return DepCollector.needSystemDependencies();
}
void visitModuleFile(StringRef Filename,
serialization::ModuleKind Kind) override {
DepCollector.maybeAddDependency(Filename, /*FromModule*/true,
/*IsSystem*/false, /*IsModuleFile*/true,
/*IsMissing*/false);
}
bool visitInputFile(StringRef Filename, bool IsSystem,
bool IsOverridden, bool IsExplicitModule) override {
if (IsOverridden || IsExplicitModule)
return true;
DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem,
/*IsModuleFile*/false, /*IsMissing*/false);
return true;
}
};
} // end anonymous namespace
void DependencyCollector::maybeAddDependency(StringRef Filename, bool FromModule,
bool IsSystem, bool IsModuleFile,
bool IsMissing) {
if (Seen.insert(Filename).second &&
sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing))
Dependencies.push_back(Filename);
}
static bool isSpecialFilename(StringRef Filename) {
return llvm::StringSwitch<bool>(Filename)
.Case("<built-in>", true)
.Case("<stdin>", true)
.Default(false);
}
bool DependencyCollector::sawDependency(StringRef Filename, bool FromModule,
bool IsSystem, bool IsModuleFile,
bool IsMissing) {
return !isSpecialFilename(Filename) &&
(needSystemDependencies() || !IsSystem);
}
DependencyCollector::~DependencyCollector() { }
void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
PP.addPPCallbacks(
llvm::make_unique<DepCollectorPPCallbacks>(*this, PP.getSourceManager()));
PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(
llvm::make_unique<DepCollectorMMCallbacks>(*this));
}
void DependencyCollector::attachToASTReader(ASTReader &R) {
R.addListener(llvm::make_unique<DepCollectorASTListener>(*this));
}
namespace {
/// Private implementation for DependencyFileGenerator
class DFGImpl : public PPCallbacks {
std::vector<std::string> Files;
llvm::StringSet<> FilesSet;
const Preprocessor *PP;
std::string OutputFile;
std::vector<std::string> Targets;
bool IncludeSystemHeaders;
bool PhonyTarget;
bool AddMissingHeaderDeps;
bool SeenMissingHeader;
bool IncludeModuleFiles;
DependencyOutputFormat OutputFormat;
private:
bool FileMatchesDepCriteria(const char *Filename,
SrcMgr::CharacteristicKind FileType);
void OutputDependencyFile();
public:
DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions &Opts)
: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
IncludeSystemHeaders(Opts.IncludeSystemHeaders),
PhonyTarget(Opts.UsePhonyTargets),
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
SeenMissingHeader(false),
IncludeModuleFiles(Opts.IncludeModuleFiles),
OutputFormat(Opts.OutputFormat) {
for (const auto &ExtraDep : Opts.ExtraDeps) {
AddFilename(ExtraDep);
}
}
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported) override;
void EndOfMainFile() override {
OutputDependencyFile();
}
void AddFilename(StringRef Filename);
bool includeSystemHeaders() const { return IncludeSystemHeaders; }
bool includeModuleFiles() const { return IncludeModuleFiles; }
};
class DFGMMCallback : public ModuleMapCallbacks {
DFGImpl &Parent;
public:
DFGMMCallback(DFGImpl &Parent) : Parent(Parent) {}
void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,
bool IsSystem) override {
if (!IsSystem || Parent.includeSystemHeaders())
Parent.AddFilename(Entry.getName());
}
};
class DFGASTReaderListener : public ASTReaderListener {
DFGImpl &Parent;
public:
DFGASTReaderListener(DFGImpl &Parent)
: Parent(Parent) { }
bool needsInputFileVisitation() override { return true; }
bool needsSystemInputFileVisitation() override {
return Parent.includeSystemHeaders();
}
void visitModuleFile(StringRef Filename,
serialization::ModuleKind Kind) override;
bool visitInputFile(StringRef Filename, bool isSystem,
bool isOverridden, bool isExplicitModule) override;
};
}
DependencyFileGenerator::DependencyFileGenerator(void *Impl)
: Impl(Impl) { }
DependencyFileGenerator *DependencyFileGenerator::CreateAndAttachToPreprocessor(
clang::Preprocessor &PP, const clang::DependencyOutputOptions &Opts) {
if (Opts.Targets.empty()) {
PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT);
return nullptr;
}
// Disable the "file not found" diagnostic if the -MG option was given.
if (Opts.AddMissingHeaderDeps)
PP.SetSuppressIncludeNotFoundError(true);
DFGImpl *Callback = new DFGImpl(&PP, Opts);
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(Callback));
PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(
llvm::make_unique<DFGMMCallback>(*Callback));
return new DependencyFileGenerator(Callback);
}
void DependencyFileGenerator::AttachToASTReader(ASTReader &R) {
DFGImpl *I = reinterpret_cast<DFGImpl *>(Impl);
assert(I && "missing implementation");
R.addListener(llvm::make_unique<DFGASTReaderListener>(*I));
}
/// FileMatchesDepCriteria - Determine whether the given Filename should be
/// considered as a dependency.
bool DFGImpl::FileMatchesDepCriteria(const char *Filename,
SrcMgr::CharacteristicKind FileType) {
if (isSpecialFilename(Filename))
return false;
if (IncludeSystemHeaders)
return true;
return !isSystem(FileType);
}
void DFGImpl::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) {
if (Reason != PPCallbacks::EnterFile)
return;
// Dependency generation really does want to go all the way to the
// file entry for a source location to find out what is depended on.
// We do not want #line markers to affect dependency generation!
SourceManager &SM = PP->getSourceManager();
const FileEntry *FE =
SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc)));
if (!FE) return;
StringRef Filename = FE->getName();
if (!FileMatchesDepCriteria(Filename.data(), FileType))
return;
AddFilename(llvm::sys::path::remove_leading_dotslash(Filename));
}
void DFGImpl::InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
StringRef FileName,
bool IsAngled,
CharSourceRange FilenameRange,
const FileEntry *File,
StringRef SearchPath,
StringRef RelativePath,
const Module *Imported) {
if (!File) {
if (AddMissingHeaderDeps)
AddFilename(FileName);
else
SeenMissingHeader = true;
}
}
void DFGImpl::AddFilename(StringRef Filename) {
if (FilesSet.insert(Filename).second)
Files.push_back(Filename);
}
/// Print the filename, with escaping or quoting that accommodates the three
/// most likely tools that use dependency files: GNU Make, BSD Make, and
/// NMake/Jom.
///
/// BSD Make is the simplest case: It does no escaping at all. This means
/// characters that are normally delimiters, i.e. space and # (the comment
/// character) simply aren't supported in filenames.
///
/// GNU Make does allow space and # in filenames, but to avoid being treated
/// as a delimiter or comment, these must be escaped with a backslash. Because
/// backslash is itself the escape character, if a backslash appears in a
/// filename, it should be escaped as well. (As a special case, $ is escaped
/// as $$, which is the normal Make way to handle the $ character.)
/// For compatibility with BSD Make and historical practice, if GNU Make
/// un-escapes characters in a filename but doesn't find a match, it will
/// retry with the unmodified original string.
///
/// GCC tries to accommodate both Make formats by escaping any space or #
/// characters in the original filename, but not escaping backslashes. The
/// apparent intent is so that filenames with backslashes will be handled
/// correctly by BSD Make, and by GNU Make in its fallback mode of using the
/// unmodified original string; filenames with # or space characters aren't
/// supported by BSD Make at all, but will be handled correctly by GNU Make
/// due to the escaping.
///
/// A corner case that GCC gets only partly right is when the original filename
/// has a backslash immediately followed by space or #. GNU Make would expect
/// this backslash to be escaped; however GCC escapes the original backslash
/// only when followed by space, not #. It will therefore take a dependency
/// from a directive such as
/// #include "a\ b\#c.h"
/// and emit it as
/// a\\\ b\\#c.h
/// which GNU Make will interpret as
/// a\ b\
/// followed by a comment. Failing to find this file, it will fall back to the
/// original string, which probably doesn't exist either; in any case it won't
/// find
/// a\ b\#c.h
/// which is the actual filename specified by the include directive.
///
/// Clang does what GCC does, rather than what GNU Make expects.
///
/// NMake/Jom has a different set of scary characters, but wraps filespecs in
/// double-quotes to avoid misinterpreting them; see
/// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info,
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
/// for Windows file-naming info.
static void PrintFilename(raw_ostream &OS, StringRef Filename,
DependencyOutputFormat OutputFormat) {
if (OutputFormat == DependencyOutputFormat::NMake) {
// Add quotes if needed. These are the characters listed as "special" to
// NMake, that are legal in a Windows filespec, and that could cause
// misinterpretation of the dependency string.
if (Filename.find_first_of(" #${}^!") != StringRef::npos)
OS << '\"' << Filename << '\"';
else
OS << Filename;
return;
}
assert(OutputFormat == DependencyOutputFormat::Make);
for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
if (Filename[i] == '#') // Handle '#' the broken gcc way.
OS << '\\';
else if (Filename[i] == ' ') { // Handle space correctly.
OS << '\\';
unsigned j = i;
while (j > 0 && Filename[--j] == '\\')
OS << '\\';
} else if (Filename[i] == '$') // $ is escaped by $$.
OS << '$';
OS << Filename[i];
}
}
void DFGImpl::OutputDependencyFile() {
if (SeenMissingHeader) {
llvm::sys::fs::remove(OutputFile);
return;
}
std::error_code EC;
llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_Text);
if (EC) {
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
<< EC.message();
return;
}
// Write out the dependency targets, trying to avoid overly long
// lines when possible. We try our best to emit exactly the same
// dependency file as GCC (4.2), assuming the included files are the
// same.
const unsigned MaxColumns = 75;
unsigned Columns = 0;
for (StringRef Target : Targets) {
unsigned N = Target.size();
if (Columns == 0) {
Columns += N;
} else if (Columns + N + 2 > MaxColumns) {
Columns = N + 2;
OS << " \\\n ";
} else {
Columns += N + 1;
OS << ' ';
}
// Targets already quoted as needed.
OS << Target;
}
OS << ':';
Columns += 1;
// Now add each dependency in the order it was seen, but avoiding
// duplicates.
for (StringRef File : Files) {
// Start a new line if this would exceed the column limit. Make
// sure to leave space for a trailing " \" in case we need to
// break the line on the next iteration.
unsigned N = File.size();
if (Columns + (N + 1) + 2 > MaxColumns) {
OS << " \\\n ";
Columns = 2;
}
OS << ' ';
PrintFilename(OS, File, OutputFormat);
Columns += N + 1;
}
OS << '\n';
// Create phony targets if requested.
if (PhonyTarget && !Files.empty()) {
// Skip the first entry, this is always the input file itself.
for (auto I = Files.begin() + 1, E = Files.end(); I != E; ++I) {
OS << '\n';
PrintFilename(OS, *I, OutputFormat);
OS << ":\n";
}
}
}
bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename,
bool IsSystem, bool IsOverridden,
bool IsExplicitModule) {
assert(!IsSystem || needsSystemInputFileVisitation());
if (IsOverridden || IsExplicitModule)
return true;
Parent.AddFilename(Filename);
return true;
}
void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename,
serialization::ModuleKind Kind) {
if (Parent.includeModuleFiles())
Parent.AddFilename(Filename);
}

View File

@ -0,0 +1,138 @@
//===--- DependencyGraph.cpp - Generate dependency file -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This code generates a header dependency graph in DOT format, for use
// with, e.g., GraphViz.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
namespace DOT = llvm::DOT;
namespace {
class DependencyGraphCallback : public PPCallbacks {
const Preprocessor *PP;
std::string OutputFile;
std::string SysRoot;
llvm::SetVector<const FileEntry *> AllFiles;
typedef llvm::DenseMap<const FileEntry *,
SmallVector<const FileEntry *, 2> > DependencyMap;
DependencyMap Dependencies;
private:
raw_ostream &writeNodeReference(raw_ostream &OS,
const FileEntry *Node);
void OutputGraphFile();
public:
DependencyGraphCallback(const Preprocessor *_PP, StringRef OutputFile,
StringRef SysRoot)
: PP(_PP), OutputFile(OutputFile.str()), SysRoot(SysRoot.str()) { }
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported) override;
void EndOfMainFile() override {
OutputGraphFile();
}
};
}
void clang::AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile,
StringRef SysRoot) {
PP.addPPCallbacks(llvm::make_unique<DependencyGraphCallback>(&PP, OutputFile,
SysRoot));
}
void DependencyGraphCallback::InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
StringRef FileName,
bool IsAngled,
CharSourceRange FilenameRange,
const FileEntry *File,
StringRef SearchPath,
StringRef RelativePath,
const Module *Imported) {
if (!File)
return;
SourceManager &SM = PP->getSourceManager();
const FileEntry *FromFile
= SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(HashLoc)));
if (!FromFile)
return;
Dependencies[FromFile].push_back(File);
AllFiles.insert(File);
AllFiles.insert(FromFile);
}
raw_ostream &
DependencyGraphCallback::writeNodeReference(raw_ostream &OS,
const FileEntry *Node) {
OS << "header_" << Node->getUID();
return OS;
}
void DependencyGraphCallback::OutputGraphFile() {
std::error_code EC;
llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_Text);
if (EC) {
PP->getDiagnostics().Report(diag::err_fe_error_opening) << OutputFile
<< EC.message();
return;
}
OS << "digraph \"dependencies\" {\n";
// Write the nodes
for (unsigned I = 0, N = AllFiles.size(); I != N; ++I) {
// Write the node itself.
OS.indent(2);
writeNodeReference(OS, AllFiles[I]);
OS << " [ shape=\"box\", label=\"";
StringRef FileName = AllFiles[I]->getName();
if (FileName.startswith(SysRoot))
FileName = FileName.substr(SysRoot.size());
OS << DOT::EscapeString(FileName)
<< "\"];\n";
}
// Write the edges
for (DependencyMap::iterator F = Dependencies.begin(),
FEnd = Dependencies.end();
F != FEnd; ++F) {
for (unsigned I = 0, N = F->second.size(); I != N; ++I) {
OS.indent(2);
writeNodeReference(OS, F->first);
OS << " -> ";
writeNodeReference(OS, F->second[I]);
OS << ";\n";
}
}
OS << "}\n";
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
//===--- FrontendOptions.cpp ----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/FrontendOptions.h"
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
InputKind FrontendOptions::getInputKindForExtension(StringRef Extension) {
return llvm::StringSwitch<InputKind>(Extension)
.Cases("ast", "pcm", InputKind(InputKind::Unknown, InputKind::Precompiled))
.Case("c", InputKind::C)
.Cases("S", "s", InputKind::Asm)
.Case("i", InputKind(InputKind::C).getPreprocessed())
.Case("ii", InputKind(InputKind::CXX).getPreprocessed())
.Case("cui", InputKind(InputKind::CUDA).getPreprocessed())
.Case("m", InputKind::ObjC)
.Case("mi", InputKind(InputKind::ObjC).getPreprocessed())
.Cases("mm", "M", InputKind::ObjCXX)
.Case("mii", InputKind(InputKind::ObjCXX).getPreprocessed())
.Cases("C", "cc", "cp", InputKind::CXX)
.Cases("cpp", "CPP", "c++", "cxx", "hpp", InputKind::CXX)
.Case("cppm", InputKind::CXX)
.Case("iim", InputKind(InputKind::CXX).getPreprocessed())
.Case("cl", InputKind::OpenCL)
.Case("cu", InputKind::CUDA)
.Cases("ll", "bc", InputKind::LLVM_IR)
.Default(InputKind::Unknown);
}

View File

@ -0,0 +1,166 @@
//===--- HeaderIncludes.cpp - Generate Header Includes --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/Utils.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
namespace {
class HeaderIncludesCallback : public PPCallbacks {
SourceManager &SM;
raw_ostream *OutputFile;
const DependencyOutputOptions &DepOpts;
unsigned CurrentIncludeDepth;
bool HasProcessedPredefines;
bool OwnsOutputFile;
bool ShowAllHeaders;
bool ShowDepth;
bool MSStyle;
public:
HeaderIncludesCallback(const Preprocessor *PP, bool ShowAllHeaders_,
raw_ostream *OutputFile_,
const DependencyOutputOptions &DepOpts,
bool OwnsOutputFile_, bool ShowDepth_, bool MSStyle_)
: SM(PP->getSourceManager()), OutputFile(OutputFile_), DepOpts(DepOpts),
CurrentIncludeDepth(0), HasProcessedPredefines(false),
OwnsOutputFile(OwnsOutputFile_), ShowAllHeaders(ShowAllHeaders_),
ShowDepth(ShowDepth_), MSStyle(MSStyle_) {}
~HeaderIncludesCallback() override {
if (OwnsOutputFile)
delete OutputFile;
}
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
};
}
static void PrintHeaderInfo(raw_ostream *OutputFile, StringRef Filename,
bool ShowDepth, unsigned CurrentIncludeDepth,
bool MSStyle) {
// Write to a temporary string to avoid unnecessary flushing on errs().
SmallString<512> Pathname(Filename);
if (!MSStyle)
Lexer::Stringify(Pathname);
SmallString<256> Msg;
if (MSStyle)
Msg += "Note: including file:";
if (ShowDepth) {
// The main source file is at depth 1, so skip one dot.
for (unsigned i = 1; i != CurrentIncludeDepth; ++i)
Msg += MSStyle ? ' ' : '.';
if (!MSStyle)
Msg += ' ';
}
Msg += Pathname;
Msg += '\n';
*OutputFile << Msg;
OutputFile->flush();
}
void clang::AttachHeaderIncludeGen(Preprocessor &PP,
const DependencyOutputOptions &DepOpts,
bool ShowAllHeaders, StringRef OutputPath,
bool ShowDepth, bool MSStyle) {
raw_ostream *OutputFile = MSStyle ? &llvm::outs() : &llvm::errs();
bool OwnsOutputFile = false;
// Open the output file, if used.
if (!OutputPath.empty()) {
std::error_code EC;
llvm::raw_fd_ostream *OS = new llvm::raw_fd_ostream(
OutputPath.str(), EC, llvm::sys::fs::F_Append | llvm::sys::fs::F_Text);
if (EC) {
PP.getDiagnostics().Report(clang::diag::warn_fe_cc_print_header_failure)
<< EC.message();
delete OS;
} else {
OS->SetUnbuffered();
OutputFile = OS;
OwnsOutputFile = true;
}
}
// Print header info for extra headers, pretending they were discovered by
// the regular preprocessor. The primary use case is to support proper
// generation of Make / Ninja file dependencies for implicit includes, such
// as sanitizer blacklists. It's only important for cl.exe compatibility,
// the GNU way to generate rules is -M / -MM / -MD / -MMD.
for (const auto &Header : DepOpts.ExtraDeps)
PrintHeaderInfo(OutputFile, Header, ShowDepth, 2, MSStyle);
PP.addPPCallbacks(llvm::make_unique<HeaderIncludesCallback>(
&PP, ShowAllHeaders, OutputFile, DepOpts, OwnsOutputFile, ShowDepth,
MSStyle));
}
void HeaderIncludesCallback::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
SrcMgr::CharacteristicKind NewFileType,
FileID PrevFID) {
// Unless we are exiting a #include, make sure to skip ahead to the line the
// #include directive was at.
PresumedLoc UserLoc = SM.getPresumedLoc(Loc);
if (UserLoc.isInvalid())
return;
// Adjust the current include depth.
if (Reason == PPCallbacks::EnterFile) {
++CurrentIncludeDepth;
} else if (Reason == PPCallbacks::ExitFile) {
if (CurrentIncludeDepth)
--CurrentIncludeDepth;
// We track when we are done with the predefines by watching for the first
// place where we drop back to a nesting depth of 1.
if (CurrentIncludeDepth == 1 && !HasProcessedPredefines) {
if (!DepOpts.ShowIncludesPretendHeader.empty()) {
PrintHeaderInfo(OutputFile, DepOpts.ShowIncludesPretendHeader,
ShowDepth, 2, MSStyle);
}
HasProcessedPredefines = true;
}
return;
} else
return;
// Show the header if we are (a) past the predefines, or (b) showing all
// headers and in the predefines at a depth past the initial file and command
// line buffers.
bool ShowHeader = (HasProcessedPredefines ||
(ShowAllHeaders && CurrentIncludeDepth > 2));
unsigned IncludeDepth = CurrentIncludeDepth;
if (!HasProcessedPredefines)
--IncludeDepth; // Ignore indent from <built-in>.
else if (!DepOpts.ShowIncludesPretendHeader.empty())
++IncludeDepth; // Pretend inclusion by ShowIncludesPretendHeader.
// Dump the header include information we are past the predefines buffer or
// are showing all headers and this isn't the magic implicit <command line>
// header.
// FIXME: Identify headers in a more robust way than comparing their name to
// "<command line>" and "<built-in>" in a bunch of places.
if (ShowHeader && Reason == PPCallbacks::EnterFile &&
UserLoc.getFilename() != StringRef("<command line>")) {
PrintHeaderInfo(OutputFile, UserLoc.getFilename(), ShowDepth, IncludeDepth,
MSStyle);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More