|
47 | 47 | #define LLVM_SUPPORT_JSON_H
|
48 | 48 |
|
49 | 49 | #include "llvm/ADT/DenseMap.h"
|
| 50 | +#include "llvm/ADT/STLFunctionalExtras.h" |
50 | 51 | #include "llvm/ADT/SmallVector.h"
|
51 | 52 | #include "llvm/ADT/StringRef.h"
|
52 |
| -#include "llvm/ADT/STLFunctionalExtras.h" |
| 53 | +#include "llvm/Support/Compiler.h" |
53 | 54 | #include "llvm/Support/Error.h"
|
54 | 55 | #include "llvm/Support/FormatVariadic.h"
|
55 | 56 | #include "llvm/Support/raw_ostream.h"
|
@@ -482,6 +483,18 @@ class Value {
|
482 | 483 | friend class Object;
|
483 | 484 |
|
484 | 485 | template <typename T, typename... U> void create(U &&... V) {
|
| 486 | +#if LLVM_ADDRESS_SANITIZER_BUILD |
| 487 | + // Unpoisoning to prevent overwriting poisoned object (e.g., annotated short |
| 488 | + // string). Objects that have had their memory poisoned may cause an ASan |
| 489 | + // error if their memory is reused without calling their destructor. |
| 490 | + // Unpoisoning the memory prevents this error from occurring. |
| 491 | + // FIXME: This is a temporary solution to prevent buildbots from failing. |
| 492 | + // The more appropriate approach would be to call the object's destructor |
| 493 | + // to unpoison memory. This would prevent any potential memory leaks (long |
| 494 | + // strings). Read for details: |
| 495 | + // https://github.com/llvm/llvm-project/pull/79065#discussion_r1462621761 |
| 496 | + __asan_unpoison_memory_region(&Union, sizeof(T)); |
| 497 | +#endif |
485 | 498 | new (reinterpret_cast<T *>(&Union)) T(std::forward<U>(V)...);
|
486 | 499 | }
|
487 | 500 | template <typename T> T &as() const {
|
|
0 commit comments