[llvm] 1f9e18b - [llvm] Remove (some) LLVMDemangle header dependencies
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 21 02:47:12 PST 2022
Hi Serge,
I believe that your change is causing the build to fail on Visual Studio:
https://lab.llvm.org/buildbot/#/builders/119/builds/7327/steps/7/logs/stdio
FAILED: lib/Demangle/CMakeFiles/LLVMDemangle.dir/DLangDemangle.cpp.obj
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Demangle -IC:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\lib\Demangle -Iinclude -IC:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\include -D__OPTIMIZE__ /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 /EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes /Folib\Demangle\CMakeFiles\LLVMDemangle.dir\DLangDemangle.cpp.obj /Fdlib\Demangle\CMakeFiles\LLVMDemangle.dir\LLVMDemangle.pdb /FS -c C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\lib\Demangle\DLangDemangle.cpp
C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\include\llvm/Demangle/Utility.h(53): error C2440: 'initializing': cannot convert from 'std::_Array_iterator<_Ty,21>' to 'char *'
with
[
_Ty=char
]
C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\include\llvm/Demangle/Utility.h(53): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\include\llvm/Demangle/Utility.h(63): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'llvm::itanium_demangle::StringView'
C:\buildbot\as-builder-2\x-aarch64\llvm-project\llvm\include\llvm/Demangle/Utility.h(63): note: No constructor could take the source type, or constructor overload resolution was ambiguous
Can you take a look?
Douglas Yung
-----Original Message-----
From: llvm-commits <llvm-commits-bounces at lists.llvm.org> On Behalf Of via llvm-commits
Sent: Friday, January 21, 2022 1:49
To: llvm-commits at lists.llvm.org
Subject: [llvm] 1f9e18b - [llvm] Remove (some) LLVMDemangle header dependencies
Author: serge-sans-paille
Date: 2022-01-21T10:48:09+01:00
New Revision: 1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d
URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-project/commit/1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d__;!!JmoZiZGBv3RvKRSx!ueA2_e1vkaEeRnUp596NhPrMdNXOCjvLIIa13IPsSg3ap95MHZPO-PYmKZZSAafnsg$
DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-project/commit/1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d.diff__;!!JmoZiZGBv3RvKRSx!ueA2_e1vkaEeRnUp596NhPrMdNXOCjvLIIa13IPsSg3ap95MHZPO-PYmKZb64Hd4JQ$
LOG: [llvm] Remove (some) LLVMDemangle header dependencies
- Avoid using <iterator> for std::end on a plain array (using <array> instead)
- Avoid using <algorithm> for std::min and std::equal (using alternate logic and std::strcmp instead)
As an hint to the impact of the cleanup, running
clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Demangle/*.cpp
clang++ -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 203965 lines
after: 169704 lines
Added:
Modified:
llvm/include/llvm/Demangle/ItaniumDemangle.h
llvm/include/llvm/Demangle/StringView.h
llvm/include/llvm/Demangle/Utility.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index b25139d8a72b..01f414a7257b 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -21,12 +21,13 @@
#include "DemangleConfig.h"
#include "StringView.h"
#include "Utility.h"
+#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <numeric>
+#include <limits>
#include <utility>
#define FOR_EACH_NODE_KIND(X) \
diff --git a/llvm/include/llvm/Demangle/StringView.h b/llvm/include/llvm/Demangle/StringView.h
index 1e4d3803f06c..7c8cb482ae1c 100644
--- a/llvm/include/llvm/Demangle/StringView.h
+++ b/llvm/include/llvm/Demangle/StringView.h
@@ -14,7 +14,6 @@
#define DEMANGLE_STRINGVIEW_H
#include "DemangleConfig.h"
-#include <algorithm>
#include <cassert>
#include <cstring>
@@ -38,15 +37,16 @@ class StringView {
StringView substr(size_t Pos, size_t Len = npos) const {
assert(Pos <= size());
- return StringView(begin() + Pos, std::min(Len, size() - Pos));
+ if (Len > size() - Pos)
+ Len = size() - Pos;
+ return StringView(begin() + Pos, Len);
}
size_t find(char C, size_t From = 0) const {
- size_t FindBegin = std::min(From, size());
// Avoid calling memchr with nullptr.
- if (FindBegin < size()) {
+ if (From < size()) {
// Just forward to memchr, which is faster than a hand-rolled loop.
- if (const void *P = ::memchr(First + FindBegin, C, size() - FindBegin))
+ if (const void *P = ::memchr(First + From, C, size() - From))
return size_t(static_cast<const char *>(P) - First);
}
return npos;
@@ -98,7 +98,7 @@ class StringView {
bool startsWith(StringView Str) const {
if (Str.size() > size())
return false;
- return std::equal(Str.begin(), Str.end(), begin());
+ return std::strncmp(Str.begin(), begin(), Str.size()) == 0;
}
const char &operator[](size_t Idx) const { return *(begin() + Idx); } @@ -111,7 +111,7 @@ class StringView {
inline bool operator==(const StringView &LHS, const StringView &RHS) {
return LHS.size() == RHS.size() &&
- std::equal(LHS.begin(), LHS.end(), RHS.begin());
+ std::strncmp(LHS.begin(), RHS.begin(), LHS.size()) == 0;
}
DEMANGLE_NAMESPACE_END
diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h
index 733d83ad1b6b..b816aa22c24e 100644
--- a/llvm/include/llvm/Demangle/Utility.h
+++ b/llvm/include/llvm/Demangle/Utility.h
@@ -14,10 +14,11 @@
#define DEMANGLE_UTILITY_H
#include "StringView.h"
+#include <array>
#include <cstdint>
#include <cstdlib>
#include <cstring>
-#include <iterator>
+#include <exception>
#include <limits>
DEMANGLE_NAMESPACE_BEGIN
@@ -48,8 +49,8 @@ class OutputBuffer {
return;
}
- char Temp[21];
- char *TempPtr = std::end(Temp);
+ std::array<char, 21> Temp;
+ char *TempPtr = Temp.end();
while (N) {
*--TempPtr = char('0' + N % 10);
@@ -59,7 +60,7 @@ class OutputBuffer {
// Add negative sign...
if (isNeg)
*--TempPtr = '-';
- this->operator<<(StringView(TempPtr, std::end(Temp)));
+ this->operator<<(StringView(TempPtr, Temp.end()));
}
public:
_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org
https://urldefense.com/v3/__https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits__;!!JmoZiZGBv3RvKRSx!ueA2_e1vkaEeRnUp596NhPrMdNXOCjvLIIa13IPsSg3ap95MHZPO-PYmKZY7ZXDBNg$
More information about the llvm-commits
mailing list