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 | |
| 12 | #ifdef _WIN32 |
| 13 | // Disable warnings from inclusion of xlocale & exception |
| 14 | #pragma warning(push) |
| 15 | #pragma warning(disable: 4530) |
| 16 | #pragma warning(disable: 4577) |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 17 | #include <string> |
Frederich Munch | d0c0700 | 2017-04-27 17:33:50 +0000 | [diff] [blame^] | 18 | #pragma warning(pop) |
| 19 | #else |
| 20 | #include <string> |
| 21 | #endif |
Frederich Munch | c1db8cf | 2017-04-27 16:55:24 +0000 | [diff] [blame] | 22 | |
| 23 | struct Global { |
| 24 | std::string *Str; |
| 25 | Global() : Str(nullptr) {} |
| 26 | ~Global() { |
| 27 | if (Str) |
| 28 | *Str = "Global::~Global"; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | struct Local { |
| 33 | std::string &Str; |
| 34 | Local(std::string &S) : Str(S) { Str = "Local::Local"; } |
| 35 | ~Local() { Str = "Local::~Local"; } |
| 36 | }; |
| 37 | |
| 38 | static Global Glb; |
| 39 | |
| 40 | extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr, |
| 41 | std::string &LStr) { |
| 42 | static Local Lcl(LStr); |
| 43 | Glb.Str = &GStr; |
| 44 | } |
| 45 | |
| 46 | extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; } |