[clang] fce887b - GlobalModuleIndex - Fix use-after-move clang static analyzer warning.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 08:44:26 PST 2020
Author: Simon Pilgrim
Date: 2020-01-11T16:43:02Z
New Revision: fce887beb79780d0e0b19e8ab6176978a3dce9b8
URL: https://github.com/llvm/llvm-project/commit/fce887beb79780d0e0b19e8ab6176978a3dce9b8
DIFF: https://github.com/llvm/llvm-project/commit/fce887beb79780d0e0b19e8ab6176978a3dce9b8.diff
LOG: GlobalModuleIndex - Fix use-after-move clang static analyzer warning.
Shadow variable names meant we were referencing the Buffer input argument, not the GlobalModuleIndex member that its std::move()'d it.
Added:
Modified:
clang/lib/Serialization/GlobalModuleIndex.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 89a1c6cb8e69..462d29c2a0f1 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -125,11 +125,12 @@ typedef llvm::OnDiskIterableChainedHashTable<IdentifierIndexReaderTrait>
}
-GlobalModuleIndex::GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer,
- llvm::BitstreamCursor Cursor)
- : Buffer(std::move(Buffer)), IdentifierIndex(), NumIdentifierLookups(),
+GlobalModuleIndex::GlobalModuleIndex(
+ std::unique_ptr<llvm::MemoryBuffer> IndexBuffer,
+ llvm::BitstreamCursor Cursor)
+ : Buffer(std::move(IndexBuffer)), IdentifierIndex(), NumIdentifierLookups(),
NumIdentifierLookupHits() {
- auto Fail = [&Buffer](llvm::Error &&Err) {
+ auto Fail = [&](llvm::Error &&Err) {
report_fatal_error("Module index '" + Buffer->getBufferIdentifier() +
"' failed: " + toString(std::move(Err)));
};
More information about the cfe-commits
mailing list