[compiler-rt] r367493 - compiler-rt: Try to appease lint script.
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 16:34:07 PDT 2019
Author: nico
Date: Wed Jul 31 16:34:07 2019
New Revision: 367493
URL: http://llvm.org/viewvc/llvm-project?rev=367493&view=rev
Log:
compiler-rt: Try to appease lint script.
A bot complains:
/b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp:2: Streams are highly discouraged. [readability/streams] [3]
/b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp:11: Streams are highly discouraged. [readability/streams] [3]
lib/CMakeFiles/SanitizerLintCheck.dir/build.make:57: recipe for target 'lib/CMakeFiles/SanitizerLintCheck' failed
I do not know why this apparently wasn't a problem when the files
had extension .cc.
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cpp
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp?rev=367493&r1=367492&r2=367493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp Wed Jul 31 16:34:07 2019
@@ -1,5 +1,4 @@
#include <thread>
-#include <iostream>
const size_t kAllocSize = 16;
const size_t kInitialNumAllocs = 1 << 10;
@@ -8,8 +7,6 @@ const size_t kNumIterations = 1 << 7;
const size_t kNumThreads = 16;
void Thread() {
- // int sp;
- // std::cerr << "Thread starting, sp = " << &sp << std::endl;
char *InitialAllocations[kInitialNumAllocs];
char *PeriodicaAllocations[kPeriodicNumAllocs];
for (auto &p : InitialAllocations) p = new char[kAllocSize];
@@ -26,8 +23,6 @@ void Thread() {
}
int main() {
-// Thread();
-// return 0;
std::thread *Threads[kNumThreads];
for (auto &T : Threads) T = new std::thread(&Thread);
for (auto T : Threads) {
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cpp?rev=367493&r1=367492&r2=367493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cpp (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cpp Wed Jul 31 16:34:07 2019
@@ -8,7 +8,8 @@
// Tests for sanitizer_libc.h.
//===----------------------------------------------------------------------===//
#include <algorithm>
-#include <fstream>
+#include <vector>
+#include <stdio.h>
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_file.h"
@@ -173,9 +174,11 @@ class SanitizerCommonFileTest : public :
temp_file_name(file_name_, sizeof(file_name_),
"sanitizer_common.ReadFile.tmp.");
- std::ofstream f(file_name_, std::ios::out | std::ios::binary);
- if (!data_.empty())
- f.write(data_.data(), data_.size());
+ if (FILE *f = fopen(file_name_, "wb")) {
+ if (!data_.empty())
+ fwrite(data_.data(), data_.size(), 1, f);
+ fclose(f);
+ }
}
void TearDown() override { Unlink(file_name_); }
More information about the llvm-commits
mailing list