[clang-tools-extra] [NFC] Fix uninitialized scalar field in constructor. (PR #118324)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 07:56:44 PST 2024
https://github.com/zahiraam updated https://github.com/llvm/llvm-project/pull/118324
>From 4142b5bd36a4f7a554196687e191a09dba9e4dcf Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 2 Dec 2024 09:09:21 -0800
Subject: [PATCH 1/4] [NFC] Fix uninitialized data member in constructor.
---
clang-tools-extra/clangd/index/dex/Dex.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang-tools-extra/clangd/index/dex/Dex.h b/clang-tools-extra/clangd/index/dex/Dex.h
index 69e161d51135b6..f907c9a55b935b 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.h
+++ b/clang-tools-extra/clangd/index/dex/Dex.h
@@ -58,6 +58,7 @@ class Dex : public SymbolIndex {
KeepAlive = std::shared_ptr<void>(
std::make_shared<Payload>(std::move(BackingData)), nullptr);
this->BackingDataSize = BackingDataSize;
+ this->IdxContents = IndexContents::All;
}
template <typename SymbolRange, typename RefsRange, typename RelationsRange,
>From d93be0f1db9eb4cb4691c7b023bf6bccccc046d7 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 2 Dec 2024 10:54:41 -0800
Subject: [PATCH 2/4] Fix uninitialized scalar field in constructor.
---
clang-tools-extra/clangd/index/MemIndex.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang-tools-extra/clangd/index/MemIndex.h b/clang-tools-extra/clangd/index/MemIndex.h
index fba2c1a7120a2b..879d7750ac0480 100644
--- a/clang-tools-extra/clangd/index/MemIndex.h
+++ b/clang-tools-extra/clangd/index/MemIndex.h
@@ -43,6 +43,7 @@ class MemIndex : public SymbolIndex {
KeepAlive = std::shared_ptr<void>(
std::make_shared<Payload>(std::move(BackingData)), nullptr);
this->BackingDataSize = BackingDataSize;
+ this->IdxContents = IndexContents::All;
}
template <typename SymbolRange, typename RefRange, typename RelationRange,
>From 12febcfcb0bbf7d4ec0ee3265076dabfc07f6ba6 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Mon, 2 Dec 2024 14:10:29 -0800
Subject: [PATCH 3/4] Put the initialization in the declaration.
---
clang-tools-extra/clangd/index/MemIndex.h | 1 -
clang-tools-extra/clangd/index/dex/Dex.h | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/clang-tools-extra/clangd/index/MemIndex.h b/clang-tools-extra/clangd/index/MemIndex.h
index 879d7750ac0480..fba2c1a7120a2b 100644
--- a/clang-tools-extra/clangd/index/MemIndex.h
+++ b/clang-tools-extra/clangd/index/MemIndex.h
@@ -43,7 +43,6 @@ class MemIndex : public SymbolIndex {
KeepAlive = std::shared_ptr<void>(
std::make_shared<Payload>(std::move(BackingData)), nullptr);
this->BackingDataSize = BackingDataSize;
- this->IdxContents = IndexContents::All;
}
template <typename SymbolRange, typename RefRange, typename RelationRange,
diff --git a/clang-tools-extra/clangd/index/dex/Dex.h b/clang-tools-extra/clangd/index/dex/Dex.h
index f907c9a55b935b..84397458107de7 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.h
+++ b/clang-tools-extra/clangd/index/dex/Dex.h
@@ -58,7 +58,6 @@ class Dex : public SymbolIndex {
KeepAlive = std::shared_ptr<void>(
std::make_shared<Payload>(std::move(BackingData)), nullptr);
this->BackingDataSize = BackingDataSize;
- this->IdxContents = IndexContents::All;
}
template <typename SymbolRange, typename RefsRange, typename RelationsRange,
@@ -124,7 +123,7 @@ class Dex : public SymbolIndex {
// Set of files which were used during this index build.
llvm::StringSet<> Files;
// Contents of the index (symbols, references, etc.)
- IndexContents IdxContents;
+ IndexContents IdxContents = IndexContents::None;
// Size of memory retained by KeepAlive.
size_t BackingDataSize = 0;
};
>From af9712fd94008868d18c65941abe78e24853ae8b Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Tue, 3 Dec 2024 07:56:01 -0800
Subject: [PATCH 4/4] Added the initialization of IndexContents in MemIndex.
---
clang-tools-extra/clangd/index/MemIndex.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/clangd/index/MemIndex.h b/clang-tools-extra/clangd/index/MemIndex.h
index fba2c1a7120a2b..ff427f65fdf066 100644
--- a/clang-tools-extra/clangd/index/MemIndex.h
+++ b/clang-tools-extra/clangd/index/MemIndex.h
@@ -93,7 +93,7 @@ class MemIndex : public SymbolIndex {
// Set of files which were used during this index build.
llvm::StringSet<> Files;
// Contents of the index (symbols, references, etc.)
- IndexContents IdxContents;
+ IndexContents IdxContents = IndexContents::None;
std::shared_ptr<void> KeepAlive; // poor man's move-only std::any
// Size of memory retained by KeepAlive.
size_t BackingDataSize = 0;
More information about the cfe-commits
mailing list