Author: Balázs Benics Date: 2026-02-17T13:55:58Z New Revision: 7be392e0ea13f96aae8e7082a3c0206e09cd2f03
URL: https://github.com/llvm/llvm-project/commit/7be392e0ea13f96aae8e7082a3c0206e09cd2f03 DIFF: https://github.com/llvm/llvm-project/commit/7be392e0ea13f96aae8e7082a3c0206e09cd2f03.diff LOG: [clang][ssaf] Fix building on gcc-7 and MinGW/Cygwin (#181812) So we had two problems: 1) gcc-7 does not fully support C++17 mandatory NRVO, so we need an explicit std::move in return statements to workaround this. 2) MinGW/Cygwin is picky about extern templates; this actually bit me once, so I'll think about how to mitigate in long term, but for now just add the missing declarations. Reported in: https://github.com/llvm/llvm-project/pull/180021#issuecomment-3912981241 https://github.com/llvm/llvm-project/pull/180021#issuecomment-3914252777 Added: Modified: clang/include/clang/Analysis/Scalable/Serialization/JSONFormat.h clang/lib/Analysis/Scalable/Serialization/JSONFormat.cpp clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.cpp clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.h Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/Scalable/Serialization/JSONFormat.h b/clang/include/clang/Analysis/Scalable/Serialization/JSONFormat.h index c10650c2133e7..052aa2641dbce 100644 --- a/clang/include/clang/Analysis/Scalable/Serialization/JSONFormat.h +++ b/clang/include/clang/Analysis/Scalable/Serialization/JSONFormat.h @@ -14,8 +14,10 @@ #define CLANG_ANALYSIS_SCALABLE_SERIALIZATION_JSONFORMAT_H #include "clang/Analysis/Scalable/Serialization/SerializationFormat.h" +#include "clang/Support/Compiler.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/Support/JSON.h" +#include "llvm/Support/Registry.h" namespace clang::ssaf { @@ -125,4 +127,9 @@ class JSONFormat final : public SerializationFormat { } // namespace clang::ssaf +namespace llvm { +extern template class CLANG_TEMPLATE_ABI + Registry<clang::ssaf::JSONFormat::FormatInfo>; +} // namespace llvm + #endif // CLANG_ANALYSIS_SCALABLE_SERIALIZATION_JSONFORMAT_H diff --git a/clang/lib/Analysis/Scalable/Serialization/JSONFormat.cpp b/clang/lib/Analysis/Scalable/Serialization/JSONFormat.cpp index 6f7de45e863d1..9f13aa1fb7545 100644 --- a/clang/lib/Analysis/Scalable/Serialization/JSONFormat.cpp +++ b/clang/lib/Analysis/Scalable/Serialization/JSONFormat.cpp @@ -15,6 +15,8 @@ using Array = llvm::json::Array; using Object = llvm::json::Object; using Value = llvm::json::Value; +LLVM_INSTANTIATE_REGISTRY(llvm::Registry<JSONFormat::FormatInfo>) + //---------------------------------------------------------------------------- // ErrorBuilder - Fluent API for constructing contextual errors. //---------------------------------------------------------------------------- @@ -705,7 +707,7 @@ JSONFormat::entityDataMapFromJSON(const SummaryName &SN, } } - return EntityDataMap; + return std::move(EntityDataMap); } llvm::Expected<Array> JSONFormat::entityDataMapToJSON( @@ -841,7 +843,7 @@ JSONFormat::summaryDataMapFromJSON(const Array &SummaryDataArray, } } - return SummaryDataMap; + return std::move(SummaryDataMap); } llvm::Expected<Array> JSONFormat::summaryDataMapToJSON( @@ -866,7 +868,7 @@ llvm::Expected<Array> JSONFormat::summaryDataMapToJSON( Result.push_back(std::move(*ExpectedSummaryDataMapObject)); } - return Result; + return std::move(Result); } //---------------------------------------------------------------------------- @@ -956,7 +958,7 @@ llvm::Expected<TUSummary> JSONFormat::readTUSummary(llvm::StringRef Path) { getData(Summary) = std::move(*ExpectedSummaryDataMap); } - return Summary; + return std::move(Summary); } llvm::Error JSONFormat::writeTUSummary(const TUSummary &S, diff --git a/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.cpp b/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.cpp index e42dc2cb4408d..7feb97d72ee2a 100644 --- a/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.cpp +++ b/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.cpp @@ -27,6 +27,8 @@ using namespace clang; using namespace ssaf; +LLVM_INSTANTIATE_REGISTRY(llvm::Registry<MockSerializationFormat::FormatInfo>) + MockSerializationFormat::MockSerializationFormat() { for (const auto &FormatInfoEntry : llvm::Registry<FormatInfo>::entries()) { std::unique_ptr<FormatInfo> Info = FormatInfoEntry.instantiate(); @@ -89,7 +91,7 @@ MockSerializationFormat::readTUSummary(llvm::StringRef Path) { assert(Inserted); } - return Summary; + return std::move(Summary); } llvm::Error MockSerializationFormat::writeTUSummary(const TUSummary &Summary, diff --git a/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.h b/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.h index 31aa8211a2ac3..918406c87afb3 100644 --- a/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.h +++ b/clang/unittests/Analysis/Scalable/Registries/MockSerializationFormat.h @@ -11,7 +11,9 @@ #include "clang/Analysis/Scalable/Model/SummaryName.h" #include "clang/Analysis/Scalable/Serialization/SerializationFormat.h" +#include "clang/Support/Compiler.h" #include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/Support/Registry.h" #include <string> namespace clang::ssaf { @@ -42,4 +44,9 @@ class MockSerializationFormat final : public SerializationFormat { } // namespace clang::ssaf +namespace llvm { +extern template class CLANG_TEMPLATE_ABI + Registry<clang::ssaf::MockSerializationFormat::FormatInfo>; +} // namespace llvm + #endif // LLVM_CLANG_UNITTESTS_ANALYSIS_SCALABLE_REGISTRIES_MOCKSERIALIZATIONFORMAT_H _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
