[PATCH] D118755: [clangd] Crash in __memcmp_avx2_movbe
Ivan Murashko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 10 09:41:28 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d7c8d870db: [clangd] Crash in __memcmp_avx2_movbe (authored by ivanmurashko).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118755/new/
https://reviews.llvm.org/D118755
Files:
clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
clang/unittests/Tooling/HeaderIncludesTest.cpp
Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===================================================================
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -51,6 +51,15 @@
EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
}
+TEST_F(HeaderIncludesTest, RepeatedIncludes) {
+ std::string Code;
+ for (int i = 0; i < 100; ++i) {
+ Code += "#include \"a.h\"\n";
+ }
+ std::string Expected = Code + "#include \"a2.h\"\n";
+ EXPECT_EQ(Expected, insert(Code, "\"a2.h\""));
+}
+
TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
std::string Code = "#ifndef A_H\n"
"#define A_H\n"
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===================================================================
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -14,6 +14,7 @@
#include "clang/Tooling/Inclusions/IncludeStyle.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
+#include <list>
#include <unordered_map>
namespace clang {
@@ -97,7 +98,8 @@
// Map from include name (quotation trimmed) to a list of existing includes
// (in case there are more than one) with the name in the current file. <x>
// and "x" will be treated as the same header when deleting #includes.
- llvm::StringMap<llvm::SmallVector<Include, 1>> ExistingIncludes;
+ // std::list is used for pointers stability (see IncludesByPriority)
+ llvm::StringMap<std::list<Include>> ExistingIncludes;
/// Map from priorities of #include categories to all #includes in the same
/// category. This is used to find #includes of the same category when
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118755.407583.patch
Type: text/x-patch
Size: 1739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220210/3e7f78e5/attachment-0001.bin>
More information about the cfe-commits
mailing list