[llvm] ef459de - BinaryStream - fix static analyzer warnings. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 8 05:20:49 PST 2019
Author: Simon Pilgrim
Date: 2019-11-08T13:20:24Z
New Revision: ef459dedcafbdfda630c884f788a6b53ee9ee30c
URL: https://github.com/llvm/llvm-project/commit/ef459dedcafbdfda630c884f788a6b53ee9ee30c
DIFF: https://github.com/llvm/llvm-project/commit/ef459dedcafbdfda630c884f788a6b53ee9ee30c.diff
LOG: BinaryStream - fix static analyzer warnings. NFCI.
- uninitialized variables
- documention warnings
- shadow variable names
Added:
Modified:
llvm/include/llvm/Support/BinaryStreamArray.h
llvm/include/llvm/Support/BinaryStreamReader.h
llvm/include/llvm/Support/BinaryStreamRef.h
llvm/lib/Support/BinaryStreamReader.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/BinaryStreamArray.h b/llvm/include/llvm/Support/BinaryStreamArray.h
index 67ba2e4189be..e490389c8ec4 100644
--- a/llvm/include/llvm/Support/BinaryStreamArray.h
+++ b/llvm/include/llvm/Support/BinaryStreamArray.h
@@ -133,9 +133,9 @@ class VarStreamArray {
Extractor &getExtractor() { return E; }
BinaryStreamRef getUnderlyingStream() const { return Stream; }
- void setUnderlyingStream(BinaryStreamRef S, uint32_t Skew = 0) {
- Stream = S;
- this->Skew = Skew;
+ void setUnderlyingStream(BinaryStreamRef NewStream, uint32_t NewSkew = 0) {
+ Stream = NewStream;
+ Skew = NewSkew;
}
void drop_front() { Skew += begin()->length(); }
@@ -143,7 +143,7 @@ class VarStreamArray {
private:
BinaryStreamRef Stream;
Extractor E;
- uint32_t Skew;
+ uint32_t Skew = 0;
};
template <typename ValueType, typename Extractor>
diff --git a/llvm/include/llvm/Support/BinaryStreamReader.h b/llvm/include/llvm/Support/BinaryStreamReader.h
index 9e16ce227ff8..b7d61c02667b 100644
--- a/llvm/include/llvm/Support/BinaryStreamReader.h
+++ b/llvm/include/llvm/Support/BinaryStreamReader.h
@@ -148,14 +148,14 @@ class BinaryStreamReader {
/// returns an appropriate error code.
Error readStreamRef(BinaryStreamRef &Ref, uint32_t Length);
- /// Read \p Length bytes from the underlying stream into \p Stream. This is
+ /// Read \p Length bytes from the underlying stream into \p Ref. This is
/// equivalent to calling getUnderlyingStream().slice(Offset, Length).
/// Updates the stream's offset to point after the newly read object. Never
/// causes a copy.
///
/// \returns a success error code if the data was successfully read, otherwise
/// returns an appropriate error code.
- Error readSubstream(BinarySubstreamRef &Stream, uint32_t Size);
+ Error readSubstream(BinarySubstreamRef &Ref, uint32_t Length);
/// Get a pointer to an object of type T from the underlying stream, as if by
/// memcpy, and store the result into \p Dest. It is up to the caller to
diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h
index 7427b8da5b43..5375d6a3a761 100644
--- a/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -198,7 +198,7 @@ class BinaryStreamRef
};
struct BinarySubstreamRef {
- uint32_t Offset; // Offset in the parent stream
+ uint32_t Offset = 0; // Offset in the parent stream
BinaryStreamRef StreamData; // Stream Data
BinarySubstreamRef slice(uint32_t Off, uint32_t Size) const {
@@ -211,8 +211,8 @@ struct BinarySubstreamRef {
BinarySubstreamRef keep_front(uint32_t N) const { return slice(0, N); }
std::pair<BinarySubstreamRef, BinarySubstreamRef>
- split(uint32_t Offset) const {
- return std::make_pair(keep_front(Offset), drop_front(Offset));
+ split(uint32_t Off) const {
+ return std::make_pair(keep_front(Off), drop_front(Off));
}
uint32_t size() const { return StreamData.getLength(); }
diff --git a/llvm/lib/Support/BinaryStreamReader.cpp b/llvm/lib/Support/BinaryStreamReader.cpp
index b17786593bde..a0434bdc6115 100644
--- a/llvm/lib/Support/BinaryStreamReader.cpp
+++ b/llvm/lib/Support/BinaryStreamReader.cpp
@@ -139,10 +139,10 @@ Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref, uint32_t Length) {
return Error::success();
}
-Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Stream,
- uint32_t Size) {
- Stream.Offset = getOffset();
- return readStreamRef(Stream.StreamData, Size);
+Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Ref,
+ uint32_t Length) {
+ Ref.Offset = getOffset();
+ return readStreamRef(Ref.StreamData, Length);
}
Error BinaryStreamReader::skip(uint32_t Amount) {
More information about the llvm-commits
mailing list