PipSqueak.cxx 918 B

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