diff options
Diffstat (limited to 'llvm/unittests/Support/DynamicLibrary/PipSqueak.cxx')
-rw-r--r-- | llvm/unittests/Support/DynamicLibrary/PipSqueak.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/unittests/Support/DynamicLibrary/PipSqueak.cxx b/llvm/unittests/Support/DynamicLibrary/PipSqueak.cxx new file mode 100644 index 00000000000..1de85236a88 --- /dev/null +++ b/llvm/unittests/Support/DynamicLibrary/PipSqueak.cxx @@ -0,0 +1,36 @@ +//===- llvm/unittest/Support/DynamicLibrary/PipSqueak.cxx -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "PipSqueak.h" +#include <string> + +struct Global { + std::string *Str; + Global() : Str(nullptr) {} + ~Global() { + if (Str) + *Str = "Global::~Global"; + } +}; + +struct Local { + std::string &Str; + Local(std::string &S) : Str(S) { Str = "Local::Local"; } + ~Local() { Str = "Local::~Local"; } +}; + +static Global Glb; + +extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr, + std::string &LStr) { + static Local Lcl(LStr); + Glb.Str = &GStr; +} + +extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; } |