1 //===- llvm/unittest/Support/DynamicLibrary/PipSqueak.cpp -----------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "PipSqueak.h" 11 12 struct Global { 13 std::string *Str; 14 std::vector<std::string> *Vec; GlobalGlobal15 Global() : Str(nullptr), Vec(nullptr) {} ~GlobalGlobal16 ~Global() { 17 if (Str) { 18 if (Vec) 19 Vec->push_back(*Str); 20 *Str = "Global::~Global"; 21 } 22 } 23 }; 24 25 static Global Glb; 26 27 struct Local { 28 std::string &Str; LocalLocal29 Local(std::string &S) : Str(S) { 30 Str = "Local::Local"; 31 if (Glb.Str && !Glb.Str->empty()) 32 Str += std::string("(") + *Glb.Str + std::string(")"); 33 } ~LocalLocal34 ~Local() { Str = "Local::~Local"; } 35 }; 36 37 SetStrings(std::string & GStr,std::string & LStr)38extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr, 39 std::string &LStr) { 40 Glb.Str = &GStr; 41 static Local Lcl(LStr); 42 } 43 TestOrder(std::vector<std::string> & V)44extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) { 45 Glb.Vec = &V; 46 } 47 48 #define PIPSQUEAK_TESTA_RETURN "LibCall" 49 #include "ExportedFuncs.cpp" 50