| 2721 | static char const hexDigits[] = "0123456789abcdef"; |
| 2722 | |
| 2723 | std::string cmGlobalGenerator::IndexGeneratorTargetUniquely( |
| 2724 | cmGeneratorTarget const* gt) |
| 2725 | { |
| 2726 | // Use the pointer value to uniquely identify the target instance. |
| 2727 | // Use a ":" prefix to avoid conflict with project-defined targets. |
| 2728 | // We must satisfy cmGeneratorExpression::IsValidTargetName so use no |
| 2729 | // other special characters. |
| 2730 | constexpr size_t sizeof_ptr = |
| 2731 | sizeof(gt); // NOLINT(bugprone-sizeof-expression) |
| 2732 | char buf[1 + sizeof_ptr * 2]; |
| 2733 | char* b = buf; |
| 2734 | *b++ = ':'; |
| 2735 | for (size_t i = 0; i < sizeof_ptr; ++i) { |
| 2736 | unsigned char const c = reinterpret_cast<unsigned char const*>(>)[i]; |
| 2737 | *b++ = hexDigits[(c & 0xf0) >> 4]; |
| 2738 | *b++ = hexDigits[(c & 0x0f)]; |
| 2739 | } |
| 2740 | std::string id(buf, sizeof(buf)); |
| 2741 | // We internally index pointers to non-const generator targets |
| 2742 | // but our callers only have pointers to const generator targets. |
| 2743 | // They will give up non-const privileges when looking up anyway. |
| 2744 | this->GeneratorTargetSearchIndex[id] = const_cast<cmGeneratorTarget*>(gt); |
| 2745 | return id; |
| 2746 | } |
| 2747 | |
| 2748 | void cmGlobalGenerator::IndexMakefile(cmMakefile* mf) |
| 2749 | { |