Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MachineFunctionAnalysis
std::unique_ptr<MachineFunction> MF;

public:
Result(std::unique_ptr<MachineFunction> MF) : MF(std::move(MF)) {}
Result(std::unique_ptr<MachineFunction> MF);
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes seem largely related to the addition of constexpr to unique_ptr in C++23, which caused Clang to require type completeness in more cases.

I guess the completeness requirement is somehow superfluous, see #59292. Perhaps we should mention the that issue in the PR description (which will be used for squashed commit message by default).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, clang is a bit eager in instantiating the unique_ptr usage in header files with the constexpr property of c++23.
This is related to #5929 as it is a similar error that was then showing up when constexpr changes with vectors and strings that were added in c+20.
With respect to the errors solved in this PR, the first mention I can find of errors due to the instantiation time of constexpr unique_ptrs is found in #74963.

In particular, this comment describes largest problem addressed in this PR: #74963 (comment)

Referencing the above comment is an example of this issue in another project, which appears to be using MCSV. It looks like these changes with respect to unique_ptr in c++23 have broken a popular paradigm of defining some methods in header files use unique_pointers to hold references to imported classes and methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're working around a clang bug here, can we fix clang instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've found in other issues, it seems that clang isn't wrong to be instantiating the unique_ptrs as early as it is. I'll see what else I can find on the topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is another mention of this issue from a different project. The consensus there is that the other compilers are allowing invalid c++ code according to the standard, and that . So rather I'd say that these errors are the result of a bug-fix.

As commented in the linked issue:

If fact cppreference.com states that:

std::unique_ptr may be constructed for an incomplete type T, such as to facilitate the use as a handle in the pImpl idiom. If the default deleter is used, T must be complete at the point in code where the deleter is invoked, which happens in the destructor, move assignment operator, and reset member function of std::unique_ptr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this comment it also seems like the clang team does not intend on changing their implementation to avoid such errors:

This would seem to require that we instantiate constexpr functions on-demand, when they are actually called during constant evaluation, rather than performing the instantiations in advance of constant evaluation[1]. This has various problems:

  • It breaks layering: constant evaluation needs template instantiation and hence all of Sema. This is a problem for uses of the Clang AST library, which is not allowed to depend on Sema but contains constant evaluation. For example, this is a problem for code generation, which should not assume there's still a Sema instance around but needs to perform constant evaluation. It's probably feasible to handle this, by adding an optional callback from constant evaluation into template instantiation, and only providing it in the cases of language-semantics-required constant evaluations performed from Sema.

  • It breaks instantiation depth: during a deeply-recursive constant evaluation, we would be able to trigger a template instantiation, which could result in a deeply-recursive constant evaluation, that then triggers another template instantiation, and so on. This dramatically increases the potential stack depth per template instantiation "step", which seems likely to run us out of stack in a way that our existing guards against this problem won't catch.

  • It breaks the desirable language property that constant evaluation is free of side-effects. If constant evaluation can trigger template instantiation, then it becomes observable and whether a certain subexpression was evaluated can have effects on the behavior of the program. This is also mitigated to some extent by only triggering template instantiation from constant evaluations that are required by the language semantics, so that speculative evaluations used to drive warnings, and enabling warning flags, don't change the program behavior, but will require significant caution.

This is not to say that we shouldn't do it, but it's not trivial, and these concerns led to the language rules explicitly accommodating implementations that want to eagerly instantiate constexpr functions on first use.

[1]: I think there is actually another strategy that we could take. We could track a call graph of constexpr functions, like we do for CUDA, then when Sema is about to kick off a language-semantics-required constant evaluation, it could quickly scan the expression for function references and instantiate those functions plus anything reachable from them in the call graph that is not yet instantiated. That would avoid the instantiation depth problem and the layering problem, at least, and because it'd be an explicit step taken by Sema it'd be less likely that an implementation of a warning flag would accidentally trigger template instantiation. But it'd come with additional storage costs.

Originally posted by @zygoloid in #59966

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronBallman Could you please take a look at this? Is this being "Won't Fix" still the current stance of Clang? This seems like a bad footgun for adoption of future C++ standards :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not necessarily arguing against this but I suspect if we do look into this, it won't be a quick fix and we will likely run into a lot of core issues along the way. I don't see this being resolved quickly.

One also has to consider, we eventually need someone to implement reflection and that is likely going to be a large set of refactoring and a core issue generator galore. Likely the refactoring and core issues will kind of all be around the same areas. So we may be pretty resource constrained once this work starts.

BTW Aaron is out for the next month.

MachineFunction &getMF() { return *MF; };
LLVM_ABI bool invalidate(Function &, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &);
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/CodeGen/ResourcePriorityQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace llvm {

public:
ResourcePriorityQueue(SelectionDAGISel *IS);
~ResourcePriorityQueue();

bool isBottomUp() const override { return false; }

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/DebugInfo/GSYM/GsymContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class GsymReader;
class GsymContext : public DIContext {
public:
GsymContext(std::unique_ptr<GsymReader> Reader);
~GsymContext();

GsymContext(GsymContext &) = delete;
GsymContext &operator=(GsymContext &) = delete;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H

#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/Casting.h"
#include <algorithm>
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/Support/Compiler.h"
#include <memory>

Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class InputFile {
getOrCreateTypeCollection(TypeCollectionKind Kind);

public:
InputFile(PDBFile *Pdb) { PdbOrObj = Pdb; }
InputFile(object::COFFObjectFile *Obj) { PdbOrObj = Obj; }
InputFile(MemoryBuffer *Buffer) { PdbOrObj = Buffer; }
InputFile(PDBFile *Pdb);
InputFile(object::COFFObjectFile *Obj);
InputFile(MemoryBuffer *Buffer);
LLVM_ABI ~InputFile();
InputFile(InputFile &&Other) = default;

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H

#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAILED: [code=1] lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDBSymbol.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/kykrueger/repos/llvm-project/build/lib/DebugInfo/PDB -I/Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/PDB -I/Users/kykrueger/repos/llvm-project/build/include -I/Users/kykrueger/repos/llvm-project/llvm/include -isystem /opt/homebrew/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -std=c++2b -arch arm64  -fno-exceptions -funwind-tables -fno-rtti -MD -MT lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDBSymbol.cpp.o -MF lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDBSymbol.cpp.o.d -o lib/DebugInfo/PDB/CMakeFiles/LLVMDebugInfoPDB.dir/PDBSymbol.cpp.o -c /Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp
In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp:9:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/APFloat.h:19:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/Hashing.h:53:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1846:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:79:19: error: invalid application of 'sizeof' to an incomplete type 'llvm::pdb::PDBSymbolTypeFunctionSig'
   79 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:293:7: note: in instantiation of member function 'std::default_delete<llvm::pdb::PDBSymbolTypeFunctionSig>::operator()' requested here
  293 |       __ptr_.second()(__tmp);
      |       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:262:71: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::PDBSymbolTypeFunctionSig>::reset' requested here
  262 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
      |                                                                       ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h:73:3: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::PDBSymbolTypeFunctionSig>::~unique_ptr' requested here
   73 |   FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType,
      |   ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:28:12: note: expanded from macro 'FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME'
   28 |     return getConcreteSymbolByIdHelper<ConcreteType>(Id);                      \
      |            ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:49:7: note: forward declaration of 'llvm::pdb::PDBSymbolTypeFunctionSig'
   49 | class PDBSymbolTypeFunctionSig;
      |       ^
1 error generated.

The code generated by the macro at line 73:

  FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType,
                                              getSignature)

Results in a unique_ptr to PDBSymbolTypeFunctionSig which is now a constexpr in c++23.
This constexpr requires that PDBSymbolTypeFunctionSig is a complete type, which was not the case with the forward declaration.

Instead of importing the header here, it should also be possible to move the definition of the methods defined by the macro to the PDBSymbolFunc.cpp file where the complete type is known. Since there are so many methods defined with these macros in PDB, I didn't want to break the paradigm by moving the methods and only declaring them here in the header.

#include "llvm/Support/Compiler.h"

#include "PDBSymbol.h"
Expand All @@ -21,7 +22,6 @@ namespace pdb {

class PDBSymDumper;
class PDBSymbolData;
class PDBSymbolTypeFunctionSig;
template <typename ChildType> class IPDBEnumChildren;

class LLVM_ABI PDBSymbolFunc : public PDBSymbol {
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace pdb {
class LLVM_ABI PDBSymbolTypeBuiltin : public PDBSymbol {
DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType)
public:
~PDBSymbolTypeBuiltin();
void dump(PDBSymDumper &Dumper) const override;

FORWARD_SYMBOL_METHOD(getBuiltinType)
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

#include "PDBSymbol.h"
#include "PDBTypes.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h:12:                                                                                                      
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:12:                                                                                                              
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h:12:                                                                                                          
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:12:                                                                                                               
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/APFloat.h:19:                                                                                                                          
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:                                                                                                                         
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/Hashing.h:53:                                                                                                                          
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1846:                                                                                                           
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:                                                                                           
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:79:19: error: invalid application of 'sizeof' to an incomplete type 'llvm::pdb::IPDBLineNumber'                           
   79 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");                                                                                                                                       
      |                   ^~~~~~~~~~~                                                                                                                                                                                  
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:293:7: note: in instantiation of member function 'std::default_delete<llvm::pdb::IPDBLineNumber>::operator()' requested he
re                                                                                                                                                                                                                     
  293 |       __ptr_.second()(__tmp);                                                                                                                                                                                  
      |       ^                                                                                                                                                                                                        
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:262:71: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::IPDBLineNumber>::reset' requested here      
  262 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }                                                                                                                               
      |                                                                       ^                                                                                                                                        
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h:41:25: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::IPDBLineNumber>::~unique_ptr' requested here      
   41 |   FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn)                                                                                                                                                                  
      |                         ^                                                                                                                                                                                      
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:30:7: note: forward declaration of 'llvm::pdb::IPDBLineNumber'                                                                          
   30 | class IPDBLineNumber;  

This include solves the above error when compiling against the c++23 standard.

Similar to the case of #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h", I didn't want to break the paradigm of declaring all of the methods with the macros in this header file. It may be possible to fix this by removing the use of this macro FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn), and instead only declaring the method while defining it in a place where the full definition of IPDBLineNumber is known.

#include "llvm/Support/Compiler.h"

#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In file included from /Users/kykrueger/repos/llvm-project/llvm/lib/DebugInfo/PDB/PDBSymbolTypeEnum.cpp:9:                                                                                                              
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h:12:                                                                                                      
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:12:                                                                                                              
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/APFloat.h:19:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12:
In file included from /Users/kykrueger/repos/llvm-project/llvm/include/llvm/ADT/Hashing.h:53:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/algorithm:1846:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:79:19: error: invalid application of 'sizeof' to an incomplete type 'llvm::pdb::PDBSymbolTypeBuiltin'
   79 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:293:7: note: in instantiation of member function 'std::default_delete<llvm::pdb::PDBSymbolTypeBuiltin>::operator()' reques
ted here
  293 |       __ptr_.second()(__tmp);
      |       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:262:71: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::PDBSymbolTypeBuiltin>::reset' requested here
  262 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
      |                                                                       ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h:46:3: note: in instantiation of member function 'std::unique_ptr<llvm::pdb::PDBSymbolTypeBuiltin>::~unique_ptr' requested here
   46 |   FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeBuiltin, getType,
      |   ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:28:12: note: expanded from macro 'FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME'
   28 |     return getConcreteSymbolByIdHelper<ConcreteType>(Id);                      \
      |            ^
/Users/kykrueger/repos/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h:52:7: note: forward declaration of 'llvm::pdb::PDBSymbolTypeBuiltin'
   52 | class PDBSymbolTypeBuiltin;

Similar to the case of #include "llvm/DebugInfo/PDB/IPDBLineNumber.h" above, this include also provides a complete type which is required in the expanded version of a below macro:

  FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeBuiltin, getType,
                                              getUnderlyingType)


namespace llvm {

Expand Down
4 changes: 1 addition & 3 deletions llvm/include/llvm/MC/MCGOFFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class MCGOFFStreamer : public MCObjectStreamer {
public:
MCGOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> OW,
std::unique_ptr<MCCodeEmitter> Emitter)
: MCObjectStreamer(Context, std::move(MAB), std::move(OW),
std::move(Emitter)) {}
std::unique_ptr<MCCodeEmitter> Emitter);

~MCGOFFStreamer() override;

Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/CodeGen/LiveDebugVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,6 @@ class UserLabel {

namespace llvm {

/// Implementation of the LiveDebugVariables pass.

LiveDebugVariables::LiveDebugVariables() = default;
LiveDebugVariables::~LiveDebugVariables() = default;
LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) = default;

class LiveDebugVariables::LDVImpl {
LocMap::Allocator allocator;
MachineFunction *MF = nullptr;
Expand Down Expand Up @@ -683,6 +677,12 @@ class LiveDebugVariables::LDVImpl {
void print(raw_ostream&);
};

/// Implementation of the LiveDebugVariables pass.

LiveDebugVariables::LiveDebugVariables() = default;
LiveDebugVariables::~LiveDebugVariables() = default;
LiveDebugVariables::LiveDebugVariables(LiveDebugVariables &&) = default;

} // namespace llvm

static void printDebugLoc(const DebugLoc &DL, raw_ostream &CommentOS,
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/CodeGen/MachineFunctionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ using namespace llvm;

AnalysisKey MachineFunctionAnalysis::Key;

llvm::MachineFunctionAnalysis::Result::Result(
std::unique_ptr<MachineFunction> MF)
: MF(std::move(MF)) {}

bool MachineFunctionAnalysis::Result::invalidate(
Function &, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/ResourcePriorityQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ ResourcePriorityQueue::ResourcePriorityQueue(SelectionDAGISel *IS)
HorizontalVerticalBalance = 0;
}

ResourcePriorityQueue::~ResourcePriorityQueue() = default;

unsigned
ResourcePriorityQueue::numberRCValPredInSU(SUnit *SU, unsigned RCId) {
unsigned NumberDeps = 0;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/DebugInfo/GSYM/GsymContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using namespace llvm;
using namespace llvm::gsym;

GsymContext::~GsymContext() = default;
GsymContext::GsymContext(std::unique_ptr<GsymReader> Reader)
: DIContext(CK_GSYM), Reader(std::move(Reader)) {}

Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,8 @@ bool llvm::pdb::shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group,
// Otherwise, only dump if this is the same module specified.
return (Filters.DumpModi == Idx);
}
llvm::pdb::InputFile::InputFile(PDBFile *Pdb) { PdbOrObj = Pdb; }

llvm::pdb::InputFile::InputFile(object::COFFObjectFile *Obj) { PdbOrObj = Obj; }

llvm::pdb::InputFile::InputFile(MemoryBuffer *Buffer) { PdbOrObj = Buffer; }
6 changes: 6 additions & 0 deletions llvm/lib/DebugInfo/PDB/PDBSymbolTypeBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

#include "llvm/DebugInfo/PDB/PDBSymDumper.h"

namespace llvm {
namespace pdb {
PDBSymbolTypeBuiltin::~PDBSymbolTypeBuiltin() = default;
} // namespace pdb
} // namespace llvm

using namespace llvm;
using namespace llvm::pdb;

Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/MC/MCGOFFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ MCStreamer *llvm::createGOFFStreamer(MCContext &Context,
new MCGOFFStreamer(Context, std::move(MAB), std::move(OW), std::move(CE));
return S;
}
llvm::MCGOFFStreamer::MCGOFFStreamer(MCContext &Context,
std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> OW,
std::unique_ptr<MCCodeEmitter> Emitter)
: MCObjectStreamer(Context, std::move(MAB), std::move(OW),
std::move(Emitter)) {}
3 changes: 3 additions & 0 deletions llvm/lib/ObjCopy/ELF/ELFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,9 @@ Error BasicELFBuilder::initSections() {
return Error::success();
}

BasicELFBuilder::BasicELFBuilder() : Obj(std::make_unique<Object>()) {}
BasicELFBuilder::~BasicELFBuilder() = default;

void BinaryELFBuilder::addData(SymbolTableSection *SymTab) {
auto Data = ArrayRef<uint8_t>(
reinterpret_cast<const uint8_t *>(MemBuf->getBufferStart()),
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/ObjCopy/ELF/ELFObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ class BasicELFBuilder {
Error initSections();

public:
BasicELFBuilder() : Obj(std::make_unique<Object>()) {}
BasicELFBuilder();
~BasicELFBuilder();
};

class BinaryELFBuilder : public BasicELFBuilder {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Remarks/BitstreamRemarkParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,5 @@ BitstreamRemarkParser::processRemark(BitstreamRemarkParserHelper &Helper) {

return std::move(Result);
}
llvm::remarks::BitstreamRemarkParser::BitstreamRemarkParser(StringRef Buf)
: RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
3 changes: 1 addition & 2 deletions llvm/lib/Remarks/BitstreamRemarkParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ struct BitstreamRemarkParser : public RemarkParser {

/// Create a parser that expects to find a string table embedded in the
/// stream.
explicit BitstreamRemarkParser(StringRef Buf)
: RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
explicit BitstreamRemarkParser(StringRef Buf);

Expected<std::unique_ptr<Remark>> next() override;

Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/TableGen/TGParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ using namespace llvm;

namespace llvm {

RecordsEntry::RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
RecordsEntry::RecordsEntry(std::unique_ptr<ForeachLoop> Loop)
: Loop(std::move(Loop)) {}
RecordsEntry::RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion)
: Assertion(std::move(Assertion)) {}
RecordsEntry::RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump)
: Dump(std::move(Dump)) {}

struct SubClassReference {
SMRange RefRange;
const Record *Rec = nullptr;
Expand Down
10 changes: 4 additions & 6 deletions llvm/lib/TableGen/TGParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ struct RecordsEntry {
void dump() const;

RecordsEntry() = default;
RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
RecordsEntry(std::unique_ptr<ForeachLoop> Loop) : Loop(std::move(Loop)) {}
RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion)
: Assertion(std::move(Assertion)) {}
RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump)
: Dump(std::move(Dump)) {}
RecordsEntry(std::unique_ptr<Record> Rec);
RecordsEntry(std::unique_ptr<ForeachLoop> Loop);
RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion);
RecordsEntry(std::unique_ptr<Record::DumpInfo> Dump);
};

/// ForeachLoop - Record the iteration state associated with a for loop.
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ RISCVTargetELFStreamer::RISCVTargetELFStreamer(MCStreamer &S,
setFlagsFromFeatures(STI);
}

RISCVELFStreamer::RISCVELFStreamer(MCContext &C,
std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> MOW,
std::unique_ptr<MCCodeEmitter> MCE)
: MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}

RISCVELFStreamer &RISCVTargetELFStreamer::getStreamer() {
return static_cast<RISCVELFStreamer &>(Streamer);
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class RISCVELFStreamer : public MCELFStreamer {
public:
RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> MOW,
std::unique_ptr<MCCodeEmitter> MCE)
: MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
std::unique_ptr<MCCodeEmitter> MCE);

void changeSection(MCSection *Section, uint32_t Subsection) override;
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
Expand Down
5 changes: 5 additions & 0 deletions llvm/tools/dsymutil/DebugMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ struct YAMLContext {

} // end anonymous namespace

DebugMap::DebugMap(const Triple &BinaryTriple, StringRef BinaryPath,
ArrayRef<uint8_t> BinaryUUID)
: BinaryTriple(BinaryTriple), BinaryPath(std::string(BinaryPath)),
BinaryUUID(BinaryUUID.begin(), BinaryUUID.end()) {}

ErrorOr<std::vector<std::unique_ptr<DebugMap>>>
DebugMap::parseYAMLDebugMap(BinaryHolder &BinHolder, StringRef InputFile,
StringRef PrependPath, bool Verbose) {
Expand Down
4 changes: 1 addition & 3 deletions llvm/tools/dsymutil/DebugMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ class DebugMap {

public:
DebugMap(const Triple &BinaryTriple, StringRef BinaryPath,
ArrayRef<uint8_t> BinaryUUID = ArrayRef<uint8_t>())
: BinaryTriple(BinaryTriple), BinaryPath(std::string(BinaryPath)),
BinaryUUID(BinaryUUID.begin(), BinaryUUID.end()) {}
ArrayRef<uint8_t> BinaryUUID = ArrayRef<uint8_t>());

using const_iterator = ObjectContainer::const_iterator;

Expand Down
17 changes: 17 additions & 0 deletions llvm/tools/llvm-cov/SourceCoverageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@

using namespace llvm;

ExpansionView::ExpansionView(const CounterMappingRegion &Region,
std::unique_ptr<SourceCoverageView> View)
: Region(Region), View(std::move(View)) {}

ExpansionView::ExpansionView(ExpansionView &&RHS)
: Region(std::move(RHS.Region)), View(std::move(RHS.View)) {}

ExpansionView &ExpansionView::operator=(ExpansionView &&RHS) {
Region = std::move(RHS.Region);
View = std::move(RHS.View);
return *this;
}

InstantiationView::InstantiationView(StringRef FunctionName, unsigned Line,
std::unique_ptr<SourceCoverageView> View)
: FunctionName(FunctionName), Line(Line), View(std::move(View)) {}

void CoveragePrinter::StreamDestructor::operator()(raw_ostream *OS) const {
if (OS == &outs())
return;
Expand Down
15 changes: 4 additions & 11 deletions llvm/tools/llvm-cov/SourceCoverageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,9 @@ struct ExpansionView {
std::unique_ptr<SourceCoverageView> View;

ExpansionView(const CounterMappingRegion &Region,
std::unique_ptr<SourceCoverageView> View)
: Region(Region), View(std::move(View)) {}
ExpansionView(ExpansionView &&RHS)
: Region(std::move(RHS.Region)), View(std::move(RHS.View)) {}
ExpansionView &operator=(ExpansionView &&RHS) {
Region = std::move(RHS.Region);
View = std::move(RHS.View);
return *this;
}
std::unique_ptr<SourceCoverageView> View);
ExpansionView(ExpansionView &&RHS);
ExpansionView &operator=(ExpansionView &&RHS);

unsigned getLine() const { return Region.LineStart; }
unsigned getStartCol() const { return Region.ColumnStart; }
Expand All @@ -58,8 +52,7 @@ struct InstantiationView {
std::unique_ptr<SourceCoverageView> View;

InstantiationView(StringRef FunctionName, unsigned Line,
std::unique_ptr<SourceCoverageView> View)
: FunctionName(FunctionName), Line(Line), View(std::move(View)) {}
std::unique_ptr<SourceCoverageView> View);

friend bool operator<(const InstantiationView &LHS,
const InstantiationView &RHS) {
Expand Down
Loading