blob: 1de85236a889a38bf116d169f84d36cd5dfca6cb [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"
11#include <string>
12
13struct Global {
14 std::string *Str;
15 Global() : Str(nullptr) {}
16 ~Global() {
17 if (Str)
18 *Str = "Global::~Global";
19 }
20};
21
22struct Local {
23 std::string &Str;
24 Local(std::string &S) : Str(S) { Str = "Local::Local"; }
25 ~Local() { Str = "Local::~Local"; }
26};
27
28static Global Glb;
29
30extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
31 std::string &LStr) {
32 static Local Lcl(LStr);
33 Glb.Str = &GStr;
34}
35
36extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; }