Enable most relevant clang-tidy checks and fix uncovered issues. (#220)

Most of these were fixed automatically (including things like adding
`[[nodiscard]]` and such). A number of others required manual edits.
I think all of them were pretty nice improvements.

There were a few places where the issues really stem from external
constraints and I've disabled the checks: GoogleTest macros or the
specific LibFuzzer entry points.

The only other places I disabled are the implicit conversions to
a private `enum` in the classes wrapping those `enum`s. These implicit
conversions are necessarily implicit to serve their only purpose:
enabling their use in `switch` statements and `case` labels. When these
were highlighted, it showed that one of these was actually converting to
an *`int`*. I've switched that to use the private `enum` instead as
doing so is important to enable warnings on non-covering `switch`
statements over than `enum`. And indeed, there is a `switch` that was
was implicitly relying on falling through in this way, so I've added the
explicit documentation of the intentional pattern to address that
warning.

Sorry this is so large, all of this somewhat fell out of enabling the
`clang-tidy` checks. If it is too difficult to review as lump, I can
work on breaking it apart as needed. Just let me know.
This commit is contained in:
Chandler Carruth
2020-12-08 14:43:37 -08:00
committed by GitHub
parent 2efbe1074e
commit d4a2d435b8
15 changed files with 155 additions and 97 deletions
+4 -3
View File
@@ -4,13 +4,13 @@
#include "source/source_buffer.h"
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <cerrno>
#include <cstdint>
#include <system_error>
#include "llvm/ADT/ScopeExit.h"
@@ -84,7 +84,8 @@ SourceBuffer::~SourceBuffer() {
if (!text_.empty()) {
errno = 0;
int result =
munmap(const_cast<void*>((const void*)text_.data()), text_.size());
munmap(const_cast<void*>(static_cast<const void*>(text_.data())),
text_.size());
(void)result;
assert(result != -1 && "Unmapping text failed!");
}