[PATCH] D135906: Fix llvm/lib/ObjCopy, llvm/llvm-ifs: c++20 compatibility
Angelo Matni via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 12:08:03 PDT 2022
angelomatnigoogle created this revision.
angelomatnigoogle added a reviewer: saugustine.
Herald added subscribers: jhenderson, abrachet, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: All.
angelomatnigoogle requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Cleanup: avoid referring to `std::vector<T>` members when `T` is incomplete.
This is not legal <https://timsong-cpp.github.io/cppwp/n4868/vector#overview-4>
according to the C++ standard, and causes build errors in particular in C++20
mode (i.e. using the `--config=cpp20` flag to blaze). Fix it by defining the
vector's type before using the vector.
This CL is part of a
Busy Beavers <https://g3doc.corp.google.com/company/teams/busy-beavers/index.md>
project to remove such build failures from google3 ahead of turning on C++20 for
all targets.
BUSY_BEAVER_PROJECT=go/bb-cpp20-vector-incomplete-types
MARKDOWN=true
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135906
Files:
llvm/lib/ObjCopy/MachO/MachOObject.cpp
llvm/lib/ObjCopy/MachO/MachOObject.h
llvm/tools/llvm-ifs/ErrorCollector.h
Index: llvm/tools/llvm-ifs/ErrorCollector.h
===================================================================
--- llvm/tools/llvm-ifs/ErrorCollector.h
+++ llvm/tools/llvm-ifs/ErrorCollector.h
@@ -21,13 +21,12 @@
#ifndef LLVM_TOOLS_LLVM_IFS_ERRORCOLLECTOR_H
#define LLVM_TOOLS_LLVM_IFS_ERRORCOLLECTOR_H
+#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>
namespace llvm {
-class Error;
-
namespace ifs {
class ErrorCollector {
Index: llvm/lib/ObjCopy/MachO/MachOObject.h
===================================================================
--- llvm/lib/ObjCopy/MachO/MachOObject.h
+++ llvm/lib/ObjCopy/MachO/MachOObject.h
@@ -57,14 +57,9 @@
StringRef Content;
std::vector<RelocationInfo> Relocations;
- Section(StringRef SegName, StringRef SectName)
- : Segname(std::string(SegName)), Sectname(std::string(SectName)),
- CanonicalName((Twine(SegName) + Twine(',') + SectName).str()) {}
-
- Section(StringRef SegName, StringRef SectName, StringRef Content)
- : Segname(std::string(SegName)), Sectname(std::string(SectName)),
- CanonicalName((Twine(SegName) + Twine(',') + SectName).str()),
- Content(Content) {}
+ Section(StringRef SegName, StringRef SectName);
+
+ Section(StringRef SegName, StringRef SectName, StringRef Content);
MachO::SectionType getType() const {
return static_cast<MachO::SectionType>(Flags & MachO::SECTION_TYPE);
Index: llvm/lib/ObjCopy/MachO/MachOObject.cpp
===================================================================
--- llvm/lib/ObjCopy/MachO/MachOObject.cpp
+++ llvm/lib/ObjCopy/MachO/MachOObject.cpp
@@ -13,6 +13,15 @@
using namespace llvm;
using namespace llvm::objcopy::macho;
+Section::Section(StringRef SegName, StringRef SectName)
+ : Segname(std::string(SegName)), Sectname(std::string(SectName)),
+ CanonicalName((Twine(SegName) + Twine(',') + SectName).str()) {}
+
+Section::Section(StringRef SegName, StringRef SectName, StringRef Content)
+ : Segname(std::string(SegName)), Sectname(std::string(SectName)),
+ CanonicalName((Twine(SegName) + Twine(',') + SectName).str()),
+ Content(Content) {}
+
const SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) const {
assert(Index < Symbols.size() && "invalid symbol index");
return Symbols[Index].get();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135906.467562.patch
Type: text/x-patch
Size: 2340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221013/3156f940/attachment.bin>
More information about the llvm-commits
mailing list