diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp | 69 | 
1 files changed, 25 insertions, 44 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp b/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp index ecb09da3c1ef..f66674535423 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp @@ -30,7 +30,6 @@  #include "clang/Frontend/Utils.h"  #include "clang/Frontend/VerifyDiagnosticConsumer.h"  #include "clang/Lex/HeaderSearch.h" -#include "clang/Lex/PTHManager.h"  #include "clang/Lex/Preprocessor.h"  #include "clang/Lex/PreprocessorOptions.h"  #include "clang/Sema/CodeCompleteConsumer.h" @@ -38,6 +37,7 @@  #include "clang/Serialization/ASTReader.h"  #include "clang/Serialization/GlobalModuleIndex.h"  #include "llvm/ADT/Statistic.h" +#include "llvm/Support/BuryPointer.h"  #include "llvm/Support/CrashRecoveryContext.h"  #include "llvm/Support/Errc.h"  #include "llvm/Support/FileSystem.h" @@ -177,18 +177,18 @@ static void collectIncludePCH(CompilerInstance &CI,    std::error_code EC;    SmallString<128> DirNative;    llvm::sys::path::native(PCHDir->getName(), DirNative); -  vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem(); +  llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();    SimpleASTReaderListener Validator(CI.getPreprocessor()); -  for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd; +  for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;         Dir != DirEnd && !EC; Dir.increment(EC)) {      // Check whether this is an AST file. ASTReader::isAcceptableASTFile is not      // used here since we're not interested in validating the PCH at this time,      // but only to check whether this is a file containing an AST.      if (!ASTReader::readASTFileControlBlock( -            Dir->getName(), FileMgr, CI.getPCHContainerReader(), +            Dir->path(), FileMgr, CI.getPCHContainerReader(),              /*FindModuleFileExtensions=*/false, Validator,              /*ValidateDiagnosticOptions=*/false)) -      MDC->addFile(Dir->getName()); +      MDC->addFile(Dir->path());    }  } @@ -198,14 +198,14 @@ static void collectVFSEntries(CompilerInstance &CI,      return;    // Collect all VFS found. -  SmallVector<vfs::YAMLVFSEntry, 16> VFSEntries; +  SmallVector<llvm::vfs::YAMLVFSEntry, 16> VFSEntries;    for (const std::string &VFSFile : CI.getHeaderSearchOpts().VFSOverlayFiles) {      llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =          llvm::MemoryBuffer::getFile(VFSFile);      if (!Buffer)        return; -    vfs::collectVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/ nullptr, -                            VFSFile, VFSEntries); +    llvm::vfs::collectVFSFromYAML(std::move(Buffer.get()), +                                  /*DiagHandler*/ nullptr, VFSFile, VFSEntries);    }    for (auto &E : VFSEntries) @@ -303,7 +303,7 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,  FileManager *CompilerInstance::createFileManager() {    if (!hasVirtualFileSystem()) { -    IntrusiveRefCntPtr<vfs::FileSystem> VFS = +    IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =          createVFSFromCompilerInvocation(getInvocation(), getDiagnostics());      setVirtualFileSystem(VFS);    } @@ -372,10 +372,8 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags,  void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {    const PreprocessorOptions &PPOpts = getPreprocessorOpts(); -  // Create a PTH manager if we are using some form of a token cache. -  PTHManager *PTHMgr = nullptr; -  if (!PPOpts.TokenCache.empty()) -    PTHMgr = PTHManager::Create(PPOpts.TokenCache, getDiagnostics()); +  // The module manager holds a reference to the old preprocessor (if any). +  ModuleManager.reset();    // Create the Preprocessor.    HeaderSearch *HeaderInfo = @@ -383,19 +381,12 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {                         getDiagnostics(), getLangOpts(), &getTarget());    PP = std::make_shared<Preprocessor>(        Invocation->getPreprocessorOptsPtr(), getDiagnostics(), getLangOpts(), -      getSourceManager(), getPCMCache(), *HeaderInfo, *this, PTHMgr, +      getSourceManager(), getPCMCache(), *HeaderInfo, *this, +      /*IdentifierInfoLookup=*/nullptr,        /*OwnsHeaderSearch=*/true, TUKind);    getTarget().adjust(getLangOpts());    PP->Initialize(getTarget(), getAuxTarget()); -  // Note that this is different then passing PTHMgr to Preprocessor's ctor. -  // That argument is used as the IdentifierInfoLookup argument to -  // IdentifierTable's ctor. -  if (PTHMgr) { -    PTHMgr->setPreprocessor(&*PP); -    PP->setPTHManager(PTHMgr); -  } -    if (PPOpts.DetailedRecord)      PP->createPreprocessingRecord(); @@ -911,6 +902,9 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {    // taking it as an input instead of hard-coding llvm::errs.    raw_ostream &OS = llvm::errs(); +  if (!Act.PrepareToExecute(*this)) +    return false; +    // Create the target instance.    setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(),                                           getInvocation().TargetOpts)); @@ -921,7 +915,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {    if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) &&        !getFrontendOpts().AuxTriple.empty()) {      auto TO = std::make_shared<TargetOptions>(); -    TO->Triple = getFrontendOpts().AuxTriple; +    TO->Triple = llvm::Triple::normalize(getFrontendOpts().AuxTriple);      TO->HostTriple = getTarget().getTriple().str();      setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO));    } @@ -1021,7 +1015,7 @@ static InputKind::Language getLanguageFromOptions(const LangOptions &LangOpts) {      return InputKind::OpenCL;    if (LangOpts.CUDA)      return InputKind::CUDA; -  if (LangOpts.ObjC1) +  if (LangOpts.ObjC)      return LangOpts.CPlusPlus ? InputKind::ObjCXX : InputKind::ObjC;    return LangOpts.CPlusPlus ? InputKind::CXX : InputKind::C;  } @@ -1266,7 +1260,7 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,            << Module->Name << Locked.getErrorMessage();        // Clear out any potential leftover.        Locked.unsafeRemoveLockFile(); -      // FALLTHROUGH +      LLVM_FALLTHROUGH;      case llvm::LockFileManager::LFS_Owned:        // We're responsible for building the module ourselves.        if (!compileModuleImpl(ImportingInstance, ModuleNameLoc, Module, @@ -1615,22 +1609,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,                               Module::NameVisibilityKind Visibility,                               bool IsInclusionDirective) {    // Determine what file we're searching from. -  // FIXME: Should we be deciding whether this is a submodule (here and -  // below) based on -fmodules-ts or should we pass a flag and make the -  // caller decide? -  std::string ModuleName; -  if (getLangOpts().ModulesTS) { -    // FIXME: Same code as Sema::ActOnModuleDecl() so there is probably a -    // better place/way to do this. -    for (auto &Piece : Path) { -      if (!ModuleName.empty()) -        ModuleName += "."; -      ModuleName += Piece.first->getName(); -    } -  } -  else -    ModuleName = Path[0].first->getName(); - +  StringRef ModuleName = Path[0].first->getName();    SourceLocation ModuleNameLoc = Path[0].second;    // If we've already handled this import, just return the cached result. @@ -1736,7 +1715,9 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,      // module cache, we don't know how to rebuild modules.      unsigned ARRFlags = Source == ModuleCache ?                          ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing : -                        ASTReader::ARR_ConfigurationMismatch; +                        Source == PrebuiltModulePath ? +                            0 : +                            ASTReader::ARR_ConfigurationMismatch;      switch (ModuleManager->ReadAST(ModuleFileName,                                     Source == PrebuiltModulePath                                         ? serialization::MK_PrebuiltModule @@ -1859,7 +1840,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,    // Verify that the rest of the module path actually corresponds to    // a submodule.    bool MapPrivateSubModToTopLevel = false; -  if (!getLangOpts().ModulesTS && Path.size() > 1) { +  if (Path.size() > 1) {      for (unsigned I = 1, N = Path.size(); I != N; ++I) {        StringRef Name = Path[I].first->getName();        clang::Module *Sub = Module->findSubmodule(Name); @@ -2139,7 +2120,7 @@ CompilerInstance::lookupMissingImports(StringRef Name,    return false;  } -void CompilerInstance::resetAndLeakSema() { BuryPointer(takeSema()); } +void CompilerInstance::resetAndLeakSema() { llvm::BuryPointer(takeSema()); }  void CompilerInstance::setExternalSemaSource(      IntrusiveRefCntPtr<ExternalSemaSource> ESS) {  | 
