blob: c54de6759dc37fe1d8837d6d3d995cb724220edd [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
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 Munchc1db8cf2017-04-27 16:55:24 +000017#include <string>
Frederich Munchd0c07002017-04-27 17:33:50 +000018#pragma warning(pop)
19#else
20#include <string>
21#endif
Frederich Munchc1db8cf2017-04-27 16:55:24 +000022
23struct Global {
24 std::string *Str;
25 Global() : Str(nullptr) {}
26 ~Global() {
27 if (Str)
28 *Str = "Global::~Global";
29 }
30};
31
32struct Local {
33 std::string &Str;
34 Local(std::string &S) : Str(S) { Str = "Local::Local"; }
35 ~Local() { Str = "Local::~Local"; }
36};
37
38static Global Glb;
39
40extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
41 std::string &LStr) {
42 static Local Lcl(LStr);
43 Glb.Str = &GStr;
44}
45
46extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; }