svf-tools 1.0.970 → 1.0.971

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.970",
3
+ "version": "1.0.971",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -53,6 +53,9 @@ struct DemangledName
53
53
 
54
54
  struct DemangledName demangle(const std::string& name);
55
55
 
56
+
57
+ Set<std::string> getClsNamesInBrackets(const std::string& name);
58
+
56
59
  std::string getBeforeBrackets(const std::string& name);
57
60
  std::string getClassNameFromVtblObj(const std::string& vtblName);
58
61
 
@@ -236,6 +236,71 @@ struct cppUtil::DemangledName cppUtil::demangle(const std::string& name)
236
236
 
237
237
  return dname;
238
238
  }
239
+
240
+ // Extract class name in parameters
241
+ // e.g., given "WithSemaphore::WithSemaphore(AP_HAL::Semaphore&)", return "AP_HAL::Semaphore"
242
+ Set<std::string> cppUtil::getClsNamesInBrackets(const std::string& name)
243
+ {
244
+ Set<std::string> res;
245
+ // Lambda to trim whitespace from both ends of a string
246
+ auto trim = [](std::string& s)
247
+ {
248
+ size_t first = s.find_first_not_of(' ');
249
+ size_t last = s.find_last_not_of(' ');
250
+ if (first != std::string::npos && last != std::string::npos)
251
+ {
252
+ s = s.substr(first, (last - first + 1));
253
+ }
254
+ else
255
+ {
256
+ s.clear();
257
+ }
258
+ };
259
+
260
+ // Lambda to remove trailing '*' and '&' characters
261
+ auto removePointerAndReference = [](std::string& s)
262
+ {
263
+ while (!s.empty() && (s.back() == '*' || s.back() == '&'))
264
+ {
265
+ s.pop_back();
266
+ }
267
+ };
268
+
269
+ s32_t status;
270
+ char* realname = abi::__cxa_demangle(name.c_str(), 0, 0, &status);
271
+ if (realname == nullptr)
272
+ {
273
+ // do nothing
274
+ }
275
+ else
276
+ {
277
+ std::string realnameStr = std::string(realname);
278
+
279
+ // Find the start and end of the parameter list
280
+ size_t start = realnameStr.find('(');
281
+ size_t end = realnameStr.find(')');
282
+ if (start == std::string::npos || end == std::string::npos || start >= end)
283
+ {
284
+ return res; // Return empty set if the format is incorrect
285
+ }
286
+
287
+ // Extract the parameter list
288
+ std::string paramList = realnameStr.substr(start + 1, end - start - 1);
289
+
290
+ // Split the parameter list by commas
291
+ std::istringstream ss(paramList);
292
+ std::string param;
293
+ while (std::getline(ss, param, ','))
294
+ {
295
+ trim(param);
296
+ removePointerAndReference(param);
297
+ res.insert(param);
298
+ }
299
+ std::free(realname);
300
+ }
301
+ return res;
302
+ }
303
+
239
304
  std::string cppUtil::getClassNameFromVtblObj(const std::string& vtblName)
240
305
  {
241
306
  std::string className = "";
@@ -646,7 +711,10 @@ Set<std::string> cppUtil::extractClsNamesFromFunc(const Function *foo)
646
711
  {
647
712
  // c++ constructor or destructor
648
713
  DemangledName demangledName = cppUtil::demangle(name);
649
- return {demangledName.className};
714
+ Set<std::string> clsNameInBrackets =
715
+ cppUtil::getClsNamesInBrackets(name);
716
+ clsNameInBrackets.insert(demangledName.className);
717
+ return clsNameInBrackets;
650
718
  }
651
719
  else if (isTemplateFunc(foo))
652
720
  {