diff options
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/CMakeLists.txt | 1 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/normalize_class_name.cpp | 31 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/normalize_class_name.h | 15 |
3 files changed, 47 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/CMakeLists.txt b/vespalib/src/vespa/vespalib/util/CMakeLists.txt index 518cbe337fa..79000a89f5f 100644 --- a/vespalib/src/vespa/vespalib/util/CMakeLists.txt +++ b/vespalib/src/vespa/vespalib/util/CMakeLists.txt @@ -57,6 +57,7 @@ vespa_add_library(vespalib_vespalib_util OBJECT mmap_file_allocator.cpp mmap_file_allocator_factory.cpp monitored_refcount.cpp + normalize_class_name.cpp nice.cpp printable.cpp priority_queue.cpp diff --git a/vespalib/src/vespa/vespalib/util/normalize_class_name.cpp b/vespalib/src/vespa/vespalib/util/normalize_class_name.cpp new file mode 100644 index 00000000000..f0ae498a1a9 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/normalize_class_name.cpp @@ -0,0 +1,31 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "normalize_class_name.h" + +namespace vespalib { + +namespace { + +void +normalize_class_name_helper(vespalib::string& class_name, const vespalib::string& old, const vespalib::string& replacement) +{ + for (;;) { + auto pos = class_name.find(old); + if (pos == vespalib::string::npos) { + break; + } + class_name.replace(pos, old.size(), replacement); + } +} + +} + +vespalib::string +normalize_class_name(vespalib::string class_name) +{ + normalize_class_name_helper(class_name, "long long", "long"); + normalize_class_name_helper(class_name, ">>", "> >"); + return class_name; +} + +} diff --git a/vespalib/src/vespa/vespalib/util/normalize_class_name.h b/vespalib/src/vespa/vespalib/util/normalize_class_name.h new file mode 100644 index 00000000000..597243bd091 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/normalize_class_name.h @@ -0,0 +1,15 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/vespalib/stllike/string.h> + +namespace vespalib { + +/* + * Normalize a demangled class name to compensate for different demangling + * with g++ / libstdc++ / binutils and clang++ / libc++ / llvm toolchains. + */ +vespalib::string normalize_class_name(vespalib::string class_name); + +} |