[docs] Fix build-docs.sh
[llvm-project.git] / llvm / unittests / Support / DynamicLibrary / PipSqueak.cpp
blob8ff2c30f4925a71fc443b97cb504e969cf5ddaee
1 //===- llvm/unittest/Support/DynamicLibrary/PipSqueak.cpp -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "PipSqueak.h"
11 struct Global {
12 std::string *Str;
13 std::vector<std::string> *Vec;
14 Global() : Str(nullptr), Vec(nullptr) {}
15 ~Global() {
16 if (Str) {
17 if (Vec)
18 Vec->push_back(*Str);
19 *Str = "Global::~Global";
24 static Global Glb;
26 struct Local {
27 std::string &Str;
28 Local(std::string &S) : Str(S) {
29 Str = "Local::Local";
30 if (Glb.Str && !Glb.Str->empty())
31 Str += std::string("(") + *Glb.Str + std::string(")");
33 ~Local() { Str = "Local::~Local"; }
37 extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
38 std::string &LStr) {
39 Glb.Str = &GStr;
40 static Local Lcl(LStr);
43 extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) {
44 Glb.Vec = &V;
47 #define PIPSQUEAK_TESTA_RETURN "LibCall"
48 #include "ExportedFuncs.cpp"