diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-06-21 23:19:47 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-06-21 23:19:47 +0000 |
commit | dfaebc43c987d4856bea7eae58a47ac82f30a2f5 (patch) | |
tree | 91ab906a5be7c9790a8ba59b4b9b12110dd74279 /lib/Support | |
parent | bb561ec060874d7d34a851d7b0ea248a078fb4c4 (diff) |
[ProfileData, Support] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/GraphWriter.cpp | 19 | ||||
-rw-r--r-- | lib/Support/YAMLParser.cpp | 58 | ||||
-rw-r--r-- | lib/Support/YAMLTraits.cpp | 31 |
3 files changed, 71 insertions, 37 deletions
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index f70b77da8de4..e04bd8bb3b9a 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -1,4 +1,4 @@ -//===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===// +//===- GraphWriter.cpp - Implements GraphWriter support routines ----------===// // // The LLVM Compiler Infrastructure // @@ -12,10 +12,22 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Program.h" +#include "llvm/Support/raw_ostream.h" +#include <cassert> +#include <system_error> +#include <string> +#include <vector> + using namespace llvm; static cl::opt<bool> ViewBackground("view-background", cl::Hidden, @@ -99,8 +111,10 @@ static bool ExecGraphViewer(StringRef ExecPath, std::vector<const char *> &args, } namespace { + struct GraphSession { std::string LogBuffer; + bool TryFindProgram(StringRef Names, std::string &ProgramPath) { raw_string_ostream Log(LogBuffer); SmallVector<StringRef, 8> parts; @@ -115,7 +129,8 @@ struct GraphSession { return false; } }; -} // namespace + +} // end anonymous namespace static const char *getProgramName(GraphProgram::Name program) { switch (program) { diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index 01ae3214453d..e2f21a56a810 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -1,4 +1,4 @@ -//===--- YAMLParser.cpp - Simple YAML parser ------------------------------===// +//===- YAMLParser.cpp - Simple YAML parser --------------------------------===// // // The LLVM Compiler Infrastructure // @@ -13,15 +13,29 @@ #include "llvm/Support/YAMLParser.h" #include "llvm/ADT/AllocatorList.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" +#include <algorithm> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <map> +#include <memory> +#include <string> +#include <system_error> +#include <utility> using namespace llvm; using namespace yaml; @@ -37,7 +51,7 @@ enum UnicodeEncodingForm { /// EncodingInfo - Holds the encoding type and length of the byte order mark if /// it exists. Length is in {0, 2, 3, 4}. -typedef std::pair<UnicodeEncodingForm, unsigned> EncodingInfo; +using EncodingInfo = std::pair<UnicodeEncodingForm, unsigned>; /// getUnicodeEncoding - Reads up to the first 4 bytes to determine the Unicode /// encoding form of \a Input. @@ -46,7 +60,7 @@ typedef std::pair<UnicodeEncodingForm, unsigned> EncodingInfo; /// @returns An EncodingInfo indicating the Unicode encoding form of the input /// and how long the byte order mark is if one exists. static EncodingInfo getUnicodeEncoding(StringRef Input) { - if (Input.size() == 0) + if (Input.empty()) return std::make_pair(UEF_Unknown, 0); switch (uint8_t(Input[0])) { @@ -95,8 +109,6 @@ static EncodingInfo getUnicodeEncoding(StringRef Input) { return std::make_pair(UEF_UTF8, 0); } -namespace llvm { -namespace yaml { /// Pin the vtables to this file. void Node::anchor() {} void NullNode::anchor() {} @@ -107,6 +119,9 @@ void MappingNode::anchor() {} void SequenceNode::anchor() {} void AliasNode::anchor() {} +namespace llvm { +namespace yaml { + /// Token - A single YAML token. struct Token { enum TokenKind { @@ -133,7 +148,7 @@ struct Token { TK_Alias, TK_Anchor, TK_Tag - } Kind; + } Kind = TK_Error; /// A string of length 0 or more whose begin() points to the logical location /// of the token in the input. @@ -142,14 +157,16 @@ struct Token { /// The value of a block scalar node. std::string Value; - Token() : Kind(TK_Error) {} + Token() = default; }; -} -} -typedef llvm::BumpPtrList<Token> TokenQueueT; +} // end namespace yaml +} // end namespace llvm + +using TokenQueueT = BumpPtrList<Token>; namespace { + /// @brief This struct is used to track simple keys. /// /// Simple keys are handled by creating an entry in SimpleKeys for each Token @@ -170,12 +187,13 @@ struct SimpleKey { return Tok == Other.Tok; } }; -} + +} // end anonymous namespace /// @brief The Unicode scalar value of a UTF-8 minimal well-formed code unit /// subsequence and the subsequence's length in code units (uint8_t). /// A length of 0 represents an error. -typedef std::pair<uint32_t, unsigned> UTF8Decoded; +using UTF8Decoded = std::pair<uint32_t, unsigned>; static UTF8Decoded decodeUTF8(StringRef Range) { StringRef::iterator Position= Range.begin(); @@ -229,6 +247,7 @@ static UTF8Decoded decodeUTF8(StringRef Range) { namespace llvm { namespace yaml { + /// @brief Scans YAML tokens from a MemoryBuffer. class Scanner { public: @@ -350,7 +369,8 @@ private: /// ns-char. StringRef::iterator skip_ns_char(StringRef::iterator Position); - typedef StringRef::iterator (Scanner::*SkipWhileFunc)(StringRef::iterator); + using SkipWhileFunc = StringRef::iterator (Scanner::*)(StringRef::iterator); + /// @brief Skip minimal well-formed code unit subsequences until Func /// returns its input. /// @@ -655,10 +675,10 @@ bool yaml::dumpTokens(StringRef Input, raw_ostream &OS) { } bool yaml::scanTokens(StringRef Input) { - llvm::SourceMgr SM; - llvm::yaml::Scanner scanner(Input, SM); - for (;;) { - llvm::yaml::Token T = scanner.getNext(); + SourceMgr SM; + Scanner scanner(Input, SM); + while (true) { + Token T = scanner.getNext(); if (T.Kind == Token::TK_StreamEnd) break; else if (T.Kind == Token::TK_Error) @@ -1744,7 +1764,7 @@ Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM, bool ShowColors, std::error_code *EC) : scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {} -Stream::~Stream() {} +Stream::~Stream() = default; bool Stream::failed() { return scanner->failed(); } @@ -1851,8 +1871,6 @@ bool Node::failed() const { return Doc->failed(); } - - StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const { // TODO: Handle newlines properly. We need to remove leading whitespace. if (Value[0] == '"') { // Double quoted. diff --git a/lib/Support/YAMLTraits.cpp b/lib/Support/YAMLTraits.cpp index c410b1d56086..8684cd950d88 100644 --- a/lib/Support/YAMLTraits.cpp +++ b/lib/Support/YAMLTraits.cpp @@ -8,17 +8,26 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/YAMLTraits.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/LineIterator.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" -#include <cctype> +#include <algorithm> +#include <cassert> +#include <cstdint> +#include <cstdlib> #include <cstring> +#include <string> +#include <vector> + using namespace llvm; using namespace yaml; @@ -26,11 +35,9 @@ using namespace yaml; // IO //===----------------------------------------------------------------------===// -IO::IO(void *Context) : Ctxt(Context) { -} +IO::IO(void *Context) : Ctxt(Context) {} -IO::~IO() { -} +IO::~IO() = default; void *IO::getContext() { return Ctxt; @@ -46,15 +53,13 @@ void IO::setContext(void *Context) { Input::Input(StringRef InputContent, void *Ctxt, SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt) - : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)), - CurrentNode(nullptr) { + : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)) { if (DiagHandler) SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt); DocIterator = Strm->begin(); } -Input::~Input() { -} +Input::~Input() = default; std::error_code Input::error() { return EC; } @@ -398,13 +403,9 @@ bool Input::canElideEmptySequence() { //===----------------------------------------------------------------------===// Output::Output(raw_ostream &yout, void *context, int WrapColumn) - : IO(context), Out(yout), WrapColumn(WrapColumn), Column(0), - ColumnAtFlowStart(0), ColumnAtMapFlowStart(0), NeedBitValueComma(false), - NeedFlowSequenceComma(false), EnumerationMatchFound(false), - NeedsNewLine(false), WriteDefaultValues(false) {} + : IO(context), Out(yout), WrapColumn(WrapColumn) {} -Output::~Output() { -} +Output::~Output() = default; bool Output::outputting() { return true; |