mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Adapt rL364464: clang::FrontendAction::Execute returns llvm::Error instead of bool
This commit is contained in:
		
							parent
							
								
									2d11cc25c1
								
							
						
					
					
						commit
						6d0a096272
					
				@ -1271,14 +1271,21 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
 | 
			
		||||
 | 
			
		||||
  std::unique_ptr<FrontendAction> Action = createIndexingAction(
 | 
			
		||||
      DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
 | 
			
		||||
 | 
			
		||||
  std::string reason;
 | 
			
		||||
  {
 | 
			
		||||
    llvm::CrashRecoveryContext CRC;
 | 
			
		||||
    auto parse = [&]() {
 | 
			
		||||
      if (!Action->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
 | 
			
		||||
        return;
 | 
			
		||||
#if LLVM_VERSION_MAJOR >= 9 // rL364464
 | 
			
		||||
      if (llvm::Error E = Action->Execute()) {
 | 
			
		||||
        reason = llvm::toString(std::move(E));
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
#else
 | 
			
		||||
      if (!Action->Execute())
 | 
			
		||||
        return;
 | 
			
		||||
#endif
 | 
			
		||||
      Action->EndSourceFile();
 | 
			
		||||
      ok = true;
 | 
			
		||||
    };
 | 
			
		||||
@ -1288,7 +1295,8 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (!ok) {
 | 
			
		||||
    LOG_S(ERROR) << "failed to index " << main;
 | 
			
		||||
    LOG_S(ERROR) << "failed to index " << main
 | 
			
		||||
                 << (reason.empty() ? "" : ": " + reason);
 | 
			
		||||
    return {};
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -327,8 +327,15 @@ bool Parse(CompilerInstance &Clang) {
 | 
			
		||||
  SyntaxOnlyAction Action;
 | 
			
		||||
  if (!Action.BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0]))
 | 
			
		||||
    return false;
 | 
			
		||||
#if LLVM_VERSION_MAJOR >= 9 // rL364464
 | 
			
		||||
  if (llvm::Error E = Action.Execute()) {
 | 
			
		||||
    llvm::consumeError(std::move(E));
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
#else
 | 
			
		||||
  if (!Action.Execute())
 | 
			
		||||
    return false;
 | 
			
		||||
#endif
 | 
			
		||||
  Action.EndSourceFile();
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user