blob: 375d72c0b535f4fc785e736e5969c4c4cd1dc1da [file] [log] [blame]
Frederich Munchc1db8cf2017-04-27 16:55:24 +00001//===- llvm/unittest/Support/DynamicLibrary/PipSqueak.cxx -----------------===//
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"
Frederich Munchd0c07002017-04-27 17:33:50 +000011
Frederich Munchc1db8cf2017-04-27 16:55:24 +000012struct Global {
13 std::string *Str;
Frederich Munchad125802017-06-05 16:26:58 +000014 std::vector<std::string> *Vec;
15 Global() : Str(nullptr), Vec(nullptr) {}
Frederich Munchc1db8cf2017-04-27 16:55:24 +000016 ~Global() {
Frederich Munchad125802017-06-05 16:26:58 +000017 if (Str) {
18 if (Vec)
19 Vec->push_back(*Str);
Frederich Munchc1db8cf2017-04-27 16:55:24 +000020 *Str = "Global::~Global";
Frederich Munchad125802017-06-05 16:26:58 +000021 }
Frederich Munchc1db8cf2017-04-27 16:55:24 +000022 }
23};
24
Frederich Munchc1db8cf2017-04-27 16:55:24 +000025static Global Glb;
26
Frederich Munchad125802017-06-05 16:26:58 +000027struct Local {
28 std::string &Str;
29 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 }
34 ~Local() { Str = "Local::~Local"; }
35};
36
37
Frederich Munchc1db8cf2017-04-27 16:55:24 +000038extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
39 std::string &LStr) {
Frederich Munchc1db8cf2017-04-27 16:55:24 +000040 Glb.Str = &GStr;
Frederich Munchad125802017-06-05 16:26:58 +000041 static Local Lcl(LStr);
42}
43
44extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) {
45 Glb.Vec = &V;
Frederich Munchc1db8cf2017-04-27 16:55:24 +000046}
47
Frederich Munch6391c7e2017-06-13 19:05:24 +000048#define PIPSQUEAK_TESTA_RETURN "LibCall"
49#include "ExportedFuncs.cxx"