[compiler-rt] 1fbe5fb - scudo/standalone: prepare for enabling format string checking
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 04:45:35 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-13T13:45:30+02:00
New Revision: 1fbe5fb81c80ebd481430cbe0b457d3726329b29
URL: https://github.com/llvm/llvm-project/commit/1fbe5fb81c80ebd481430cbe0b457d3726329b29
DIFF: https://github.com/llvm/llvm-project/commit/1fbe5fb81c80ebd481430cbe0b457d3726329b29.diff
LOG: scudo/standalone: prepare for enabling format string checking
Move __attribute__((format)) to the function declarations in the header file.
It's almost pointless in the source file.
But disable the warning with -Wno-format for now
since there is a number of existing warnings.
Depends on D107984.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108014
Added:
Modified:
compiler-rt/lib/scudo/standalone/CMakeLists.txt
compiler-rt/lib/scudo/standalone/string_utils.cpp
compiler-rt/lib/scudo/standalone/string_utils.h
compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
index 8c3708d3a45f5..17af724541071 100644
--- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -10,6 +10,9 @@ list(APPEND SCUDO_CFLAGS
-g
-nostdinc++)
+# Too many existing bugs, needs cleanup.
+append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SCUDO_CFLAGS)
+
# Remove -stdlib= which is unused when passing -nostdinc++.
string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
diff --git a/compiler-rt/lib/scudo/standalone/string_utils.cpp b/compiler-rt/lib/scudo/standalone/string_utils.cpp
index acf85889fcff8..13fdb9c6ca6cd 100644
--- a/compiler-rt/lib/scudo/standalone/string_utils.cpp
+++ b/compiler-rt/lib/scudo/standalone/string_utils.cpp
@@ -236,7 +236,6 @@ void ScopedString::append(const char *Format, va_list Args) {
va_end(ArgsCopy);
}
-FORMAT(2, 3)
void ScopedString::append(const char *Format, ...) {
va_list Args;
va_start(Args, Format);
@@ -244,7 +243,6 @@ void ScopedString::append(const char *Format, ...) {
va_end(Args);
}
-FORMAT(1, 2)
void Printf(const char *Format, ...) {
va_list Args;
va_start(Args, Format);
diff --git a/compiler-rt/lib/scudo/standalone/string_utils.h b/compiler-rt/lib/scudo/standalone/string_utils.h
index 06d23d42246d0..dd6ff7893b839 100644
--- a/compiler-rt/lib/scudo/standalone/string_utils.h
+++ b/compiler-rt/lib/scudo/standalone/string_utils.h
@@ -26,15 +26,16 @@ class ScopedString {
String.push_back('\0');
}
void append(const char *Format, va_list Args);
- void append(const char *Format, ...);
+ void append(const char *Format, ...) FORMAT(2, 3);
void output() const { outputRaw(String.data()); }
private:
Vector<char> String;
};
-int formatString(char *Buffer, uptr BufferLength, const char *Format, ...);
-void Printf(const char *Format, ...);
+int formatString(char *Buffer, uptr BufferLength, const char *Format, ...)
+ FORMAT(3, 4);
+void Printf(const char *Format, ...) FORMAT(1, 2);
} // namespace scudo
diff --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
index f4186eba16881..def0a20a4348f 100644
--- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
@@ -17,6 +17,9 @@ set(SCUDO_UNITTEST_CFLAGS
# TODO(kostyak): find a way to make -fsized-deallocation work
-Wno-mismatched-new-delete)
+# Too many existing bugs, needs cleanup.
+append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SCUDO_UNITTEST_CFLAGS)
+
if(COMPILER_RT_DEBUG)
list(APPEND SCUDO_UNITTEST_CFLAGS -DSCUDO_DEBUG=1)
endif()
More information about the llvm-commits
mailing list