[PATCH] D149854: [llvm][ADT] Fix compilation of headers under C++23
Adrian Vogelsgesang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 15:21:55 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG687bd77e2c26: [ADT][NFC] Fix compilation of headers under C++23 (authored by avogelsgesang).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149854/new/
https://reviews.llvm.org/D149854
Files:
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/IR/ModuleSummaryIndex.h
Index: llvm/include/llvm/IR/ModuleSummaryIndex.h
===================================================================
--- llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -147,7 +147,7 @@
StringRef Name;
} U;
- GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
+ inline GlobalValueSummaryInfo(bool HaveGVs);
/// List of global value summary structures for a particular value held
/// in the GlobalValueMap. Requires a vector in the case of multiple
@@ -575,6 +575,8 @@
friend class ModuleSummaryIndex;
};
+GlobalValueSummaryInfo::GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
+
/// Alias summary information.
class AliasSummary : public GlobalValueSummary {
ValueInfo AliaseeValueInfo;
Index: llvm/include/llvm/ADT/APFloat.h
===================================================================
--- llvm/include/llvm/ADT/APFloat.h
+++ llvm/include/llvm/ADT/APFloat.h
@@ -679,21 +679,14 @@
DoubleAPFloat(DoubleAPFloat &&RHS);
DoubleAPFloat &operator=(const DoubleAPFloat &RHS);
-
- DoubleAPFloat &operator=(DoubleAPFloat &&RHS) {
- if (this != &RHS) {
- this->~DoubleAPFloat();
- new (this) DoubleAPFloat(std::move(RHS));
- }
- return *this;
- }
+ inline DoubleAPFloat &operator=(DoubleAPFloat &&RHS);
bool needsCleanup() const { return Floats != nullptr; }
- APFloat &getFirst() { return Floats[0]; }
- const APFloat &getFirst() const { return Floats[0]; }
- APFloat &getSecond() { return Floats[1]; }
- const APFloat &getSecond() const { return Floats[1]; }
+ inline APFloat &getFirst();
+ inline const APFloat &getFirst() const;
+ inline APFloat &getSecond();
+ inline const APFloat &getSecond() const;
opStatus add(const DoubleAPFloat &RHS, roundingMode RM);
opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM);
@@ -1408,6 +1401,27 @@
return A < B ? B : A;
}
+// We want the following functions to be available in the header for inlining.
+// We cannot define them inline in the class definition of `DoubleAPFloat`
+// because doing so would instantiate `std::unique_ptr<APFloat[]>` before
+// `APFloat` is defined, and that would be undefined behavior.
+namespace detail {
+
+DoubleAPFloat &DoubleAPFloat::operator=(DoubleAPFloat &&RHS) {
+ if (this != &RHS) {
+ this->~DoubleAPFloat();
+ new (this) DoubleAPFloat(std::move(RHS));
+ }
+ return *this;
+}
+
+APFloat &DoubleAPFloat::getFirst() { return Floats[0]; }
+const APFloat &DoubleAPFloat::getFirst() const { return Floats[0]; }
+APFloat &DoubleAPFloat::getSecond() { return Floats[1]; }
+const APFloat &DoubleAPFloat::getSecond() const { return Floats[1]; }
+
+} // namespace detail
+
} // namespace llvm
#undef APFLOAT_DISPATCH_ON_SEMANTICS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149854.521469.patch
Type: text/x-patch
Size: 2763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/514fd47b/attachment.bin>
More information about the llvm-commits
mailing list