OSDN Git Service

Refactor DynamicLibrary so searching for a symbol will have a defined order and
[android-x86/external-llvm.git] / unittests / Support / DynamicLibrary / PipSqueak.cxx
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"
11 #include <string>
12
13 struct Global {
14   std::string *Str;
15   Global() : Str(nullptr) {}
16   ~Global() {
17     if (Str)
18       *Str = "Global::~Global";
19   }
20 };
21
22 struct Local {
23   std::string &Str;
24   Local(std::string &S) : Str(S) { Str = "Local::Local"; }
25   ~Local() { Str = "Local::~Local"; }
26 };
27
28 static Global Glb;
29
30 extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
31                                             std::string &LStr) {
32   static Local Lcl(LStr);
33   Glb.Str = &GStr;
34 }
35
36 extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; }