18a953299SNico Weber //===- llvm/unittest/Support/DynamicLibrary/PipSqueak.cpp -----------------===// 28a953299SNico Weber // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 68a953299SNico Weber // 78a953299SNico Weber //===----------------------------------------------------------------------===// 88a953299SNico Weber 98a953299SNico Weber #include "PipSqueak.h" 108a953299SNico Weber 118a953299SNico Weber struct Global { 128a953299SNico Weber std::string *Str; 138a953299SNico Weber std::vector<std::string> *Vec; GlobalGlobal148a953299SNico Weber Global() : Str(nullptr), Vec(nullptr) {} ~GlobalGlobal158a953299SNico Weber ~Global() { 168a953299SNico Weber if (Str) { 178a953299SNico Weber if (Vec) 188a953299SNico Weber Vec->push_back(*Str); 198a953299SNico Weber *Str = "Global::~Global"; 208a953299SNico Weber } 218a953299SNico Weber } 228a953299SNico Weber }; 238a953299SNico Weber 248a953299SNico Weber static Global Glb; 258a953299SNico Weber 268a953299SNico Weber struct Local { 278a953299SNico Weber std::string &Str; LocalLocal288a953299SNico Weber Local(std::string &S) : Str(S) { 298a953299SNico Weber Str = "Local::Local"; 308a953299SNico Weber if (Glb.Str && !Glb.Str->empty()) 318a953299SNico Weber Str += std::string("(") + *Glb.Str + std::string(")"); 328a953299SNico Weber } ~LocalLocal338a953299SNico Weber ~Local() { Str = "Local::~Local"; } 348a953299SNico Weber }; 358a953299SNico Weber 368a953299SNico Weber SetStrings(std::string & GStr,std::string & LStr)378a953299SNico Weberextern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr, 388a953299SNico Weber std::string &LStr) { 398a953299SNico Weber Glb.Str = &GStr; 408a953299SNico Weber static Local Lcl(LStr); 418a953299SNico Weber } 428a953299SNico Weber TestOrder(std::vector<std::string> & V)438a953299SNico Weberextern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) { 448a953299SNico Weber Glb.Vec = &V; 458a953299SNico Weber } 468a953299SNico Weber 478a953299SNico Weber #define PIPSQUEAK_TESTA_RETURN "LibCall" 488a953299SNico Weber #include "ExportedFuncs.cpp" 49