Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 1 | //===- 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 Munch | d0c0700 | 2017-04-27 17:33:50 +0000 | [diff] [blame] | 11 | |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 12 | struct Global { |
| 13 | std::string *Str; |
Frederich Munch | ad12580 | 2017-06-05 16:26:58 +0000 | [diff] [blame] | 14 | std::vector<std::string> *Vec; |
| 15 | Global() : Str(nullptr), Vec(nullptr) {} |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 16 | ~Global() { |
Frederich Munch | ad12580 | 2017-06-05 16:26:58 +0000 | [diff] [blame] | 17 | if (Str) { |
| 18 | if (Vec) |
| 19 | Vec->push_back(*Str); |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 20 | *Str = "Global::~Global"; |
Frederich Munch | ad12580 | 2017-06-05 16:26:58 +0000 | [diff] [blame] | 21 | } |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 22 | } |
| 23 | }; |
| 24 | |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 25 | static Global Glb; |
| 26 | |
Frederich Munch | ad12580 | 2017-06-05 16:26:58 +0000 | [diff] [blame] | 27 | struct 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 Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 38 | extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr, |
| 39 | std::string &LStr) { |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 40 | Glb.Str = &GStr; |
Frederich Munch | ad12580 | 2017-06-05 16:26:58 +0000 | [diff] [blame] | 41 | static Local Lcl(LStr); |
| 42 | } |
| 43 | |
| 44 | extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) { |
| 45 | Glb.Vec = &V; |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Frederich Munch | 6391c7e | 2017-06-13 19:05:24 +0000 | [diff] [blame] | 48 | #define PIPSQUEAK_TESTA_RETURN "LibCall" |
| 49 | #include "ExportedFuncs.cxx" |