|
1 |
| -//===--- ObjectFilePCHContainerOperations.cpp -----------------------------===// |
| 1 | +//===--- ObjectFilePCHContainerWriter.cpp -----------------------------===// |
2 | 2 | //
|
3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
4 | 4 | // See https://llvm.org/LICENSE.txt for license information.
|
5 | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
6 | 6 | //
|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 |
| -#include "clang/CodeGen/ObjectFilePCHContainerOperations.h" |
| 9 | +#include "clang/CodeGen/ObjectFilePCHContainerWriter.h" |
10 | 10 | #include "CGDebugInfo.h"
|
11 | 11 | #include "CodeGenModule.h"
|
12 | 12 | #include "clang/AST/ASTContext.h"
|
@@ -360,46 +360,3 @@ ObjectFilePCHContainerWriter::CreatePCHContainerGenerator(
|
360 | 360 | return std::make_unique<PCHContainerGenerator>(
|
361 | 361 | CI, MainFileName, OutputFileName, std::move(OS), Buffer);
|
362 | 362 | }
|
363 |
| - |
364 |
| -ArrayRef<StringRef> ObjectFilePCHContainerReader::getFormats() const { |
365 |
| - static StringRef Formats[] = {"obj", "raw"}; |
366 |
| - return Formats; |
367 |
| -} |
368 |
| - |
369 |
| -StringRef |
370 |
| -ObjectFilePCHContainerReader::ExtractPCH(llvm::MemoryBufferRef Buffer) const { |
371 |
| - StringRef PCH; |
372 |
| - auto OFOrErr = llvm::object::ObjectFile::createObjectFile(Buffer); |
373 |
| - if (OFOrErr) { |
374 |
| - auto &OF = OFOrErr.get(); |
375 |
| - bool IsCOFF = isa<llvm::object::COFFObjectFile>(*OF); |
376 |
| - // Find the clang AST section in the container. |
377 |
| - for (auto &Section : OF->sections()) { |
378 |
| - StringRef Name; |
379 |
| - if (Expected<StringRef> NameOrErr = Section.getName()) |
380 |
| - Name = *NameOrErr; |
381 |
| - else |
382 |
| - consumeError(NameOrErr.takeError()); |
383 |
| - |
384 |
| - if ((!IsCOFF && Name == "__clangast") || (IsCOFF && Name == "clangast")) { |
385 |
| - if (Expected<StringRef> E = Section.getContents()) |
386 |
| - return *E; |
387 |
| - else { |
388 |
| - handleAllErrors(E.takeError(), [&](const llvm::ErrorInfoBase &EIB) { |
389 |
| - EIB.log(llvm::errs()); |
390 |
| - }); |
391 |
| - return ""; |
392 |
| - } |
393 |
| - } |
394 |
| - } |
395 |
| - } |
396 |
| - handleAllErrors(OFOrErr.takeError(), [&](const llvm::ErrorInfoBase &EIB) { |
397 |
| - if (EIB.convertToErrorCode() == |
398 |
| - llvm::object::object_error::invalid_file_type) |
399 |
| - // As a fallback, treat the buffer as a raw AST. |
400 |
| - PCH = Buffer.getBuffer(); |
401 |
| - else |
402 |
| - EIB.log(llvm::errs()); |
403 |
| - }); |
404 |
| - return PCH; |
405 |
| -} |
0 commit comments