
When running the test suite with the instrumentation macros, I noticed two lldb-mi tests regressed. The issue was the copy constructor of SBLineEntry. Without the macros the returned value would be elided, but with the macros the copy constructor was called. The latter using ::IsValid to determine whether the underlying opaque pointer should be set. This is likely a remnant of when ::IsValid would only check the validity of the smart pointer. In SBLineEntry however, it actually forwards to LineEntry::IsValid(). So what happened here was that because of the macros the copy constructor was called. The opaque pointer was valid but the LineEntry didn't consider itself valid. So the copied-to object ended up default initialized. This patch replaces all checks for IsValid in copy (assignment) constructors with checks for the opaque pointer itself. Differential revision: https://reviews.llvm.org/D58946 llvm-svn: 355458
31 lines
834 B
C++
31 lines
834 B
C++
//===-- Utils.h -------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_API_UTILS_H
|
|
#define LLDB_API_UTILS_H
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
#include <memory>
|
|
|
|
namespace lldb_private {
|
|
|
|
template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) {
|
|
if (src)
|
|
return llvm::make_unique<T>(*src);
|
|
return nullptr;
|
|
}
|
|
|
|
template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) {
|
|
if (src)
|
|
return std::make_shared<T>(*src);
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace lldb_private
|
|
#endif
|