diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index c6b11437d315..795023cfa4f5 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -110,7 +110,10 @@ public: return llvm::None; std::unique_ptr V = std::move(Existing->second); LRU.erase(Existing); - return V; + // GCC 4.8 fails to compile `return V;`, as it tries to call the copy + // constructor of unique_ptr, so we call the move ctor explicitly to avoid + // this miscompile. + return llvm::Optional>(std::move(V)); } private: