diff options
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/AddressSpaces.h | 12 | ||||
-rw-r--r-- | include/clang/Basic/CommentOptions.h | 16 | ||||
-rw-r--r-- | include/clang/Basic/FileSystemStatCache.h | 53 | ||||
-rw-r--r-- | include/clang/Basic/Linkage.h | 11 | ||||
-rw-r--r-- | include/clang/Basic/ObjCRuntime.h | 24 | ||||
-rw-r--r-- | include/clang/Basic/Sanitizers.h | 16 | ||||
-rw-r--r-- | include/clang/Basic/VirtualFileSystem.h | 42 |
7 files changed, 99 insertions, 75 deletions
diff --git a/include/clang/Basic/AddressSpaces.h b/include/clang/Basic/AddressSpaces.h index 67019f6925..286b0330f4 100644 --- a/include/clang/Basic/AddressSpaces.h +++ b/include/clang/Basic/AddressSpaces.h @@ -1,4 +1,4 @@ -//===--- AddressSpaces.h - Language-specific address spaces -----*- C++ -*-===// +//===- AddressSpaces.h - Language-specific address spaces -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,17 +6,17 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Provides definitions for the various language-specific address /// spaces. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_ADDRESSSPACES_H #define LLVM_CLANG_BASIC_ADDRESSSPACES_H -#include <assert.h> +#include <cassert> namespace clang { @@ -51,7 +51,7 @@ enum class LangAS : unsigned { /// The type of a lookup table which maps from language-specific address spaces /// to target-specific ones. -typedef unsigned LangASMap[(unsigned)LangAS::FirstTargetAddressSpace]; +using LangASMap = unsigned[(unsigned)LangAS::FirstTargetAddressSpace]; /// \return whether \p AS is a target-specific address space rather than a /// clang AST address space @@ -71,4 +71,4 @@ inline LangAS getLangASFromTargetAS(unsigned TargetAS) { } // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_ADDRESSSPACES_H diff --git a/include/clang/Basic/CommentOptions.h b/include/clang/Basic/CommentOptions.h index 92419f91b7..efd94e6e35 100644 --- a/include/clang/Basic/CommentOptions.h +++ b/include/clang/Basic/CommentOptions.h @@ -1,4 +1,4 @@ -//===--- CommentOptions.h - Options for parsing comments -----*- C++ -*-===// +//===- CommentOptions.h - Options for parsing comments ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,10 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the clang::CommentOptions interface. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_COMMENTOPTIONS_H @@ -22,18 +22,18 @@ namespace clang { /// \brief Options for controlling comment parsing. struct CommentOptions { - typedef std::vector<std::string> BlockCommandNamesTy; + using BlockCommandNamesTy = std::vector<std::string>; /// \brief Command names to treat as block commands in comments. /// Should not include the leading backslash. BlockCommandNamesTy BlockCommandNames; /// \brief Treat ordinary comments as documentation comments. - bool ParseAllComments; + bool ParseAllComments = false; - CommentOptions() : ParseAllComments(false) { } + CommentOptions() = default; }; -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_COMMENTOPTIONS_H diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h index 75f986b59b..7bd2267232 100644 --- a/include/clang/Basic/FileSystemStatCache.h +++ b/include/clang/Basic/FileSystemStatCache.h @@ -1,4 +1,4 @@ -//===--- FileSystemStatCache.h - Caching for 'stat' calls -------*- C++ -*-===// +//===- FileSystemStatCache.h - Caching for 'stat' calls ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,10 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the FileSystemStatCache interface. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_FILESYSTEMSTATCACHE_H @@ -17,29 +17,38 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/FileSystem.h" +#include <cstdint> +#include <ctime> #include <memory> +#include <string> +#include <utility> namespace clang { namespace vfs { + class File; class FileSystem; -} + +} // namespace vfs // FIXME: should probably replace this with vfs::Status struct FileData { std::string Name; - uint64_t Size; - time_t ModTime; + uint64_t Size = 0; + time_t ModTime = 0; llvm::sys::fs::UniqueID UniqueID; - bool IsDirectory; - bool IsNamedPipe; - bool InPCH; - bool IsVFSMapped; // FIXME: remove this when files support multiple names - FileData() - : Size(0), ModTime(0), IsDirectory(false), IsNamedPipe(false), - InPCH(false), IsVFSMapped(false) {} + bool IsDirectory = false; + bool IsNamedPipe = false; + bool InPCH = false; + + // FIXME: remove this when files support multiple names + bool IsVFSMapped = false; + + FileData() = default; }; /// \brief Abstract interface for introducing a FileManager cache for 'stat' @@ -47,15 +56,19 @@ struct FileData { /// improve performance. class FileSystemStatCache { virtual void anchor(); + protected: std::unique_ptr<FileSystemStatCache> NextStatCache; public: - virtual ~FileSystemStatCache() {} + virtual ~FileSystemStatCache() = default; enum LookupResult { - CacheExists, ///< We know the file exists and its cached stat data. - CacheMissing ///< We know that the file doesn't exist. + /// We know the file exists and its cached stat data. + CacheExists, + + /// We know that the file doesn't exist. + CacheMissing }; /// \brief Get the 'stat' information for the specified path, using the cache @@ -115,8 +128,8 @@ public: /// \brief The set of stat() calls that have been seen. llvm::StringMap<FileData, llvm::BumpPtrAllocator> StatCalls; - typedef llvm::StringMap<FileData, llvm::BumpPtrAllocator>::const_iterator - iterator; + using iterator = + llvm::StringMap<FileData, llvm::BumpPtrAllocator>::const_iterator; iterator begin() const { return StatCalls.begin(); } iterator end() const { return StatCalls.end(); } @@ -126,6 +139,6 @@ public: vfs::FileSystem &FS) override; }; -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_FILESYSTEMSTATCACHE_H diff --git a/include/clang/Basic/Linkage.h b/include/clang/Basic/Linkage.h index 6ec8763f24..adf1d08954 100644 --- a/include/clang/Basic/Linkage.h +++ b/include/clang/Basic/Linkage.h @@ -1,4 +1,4 @@ -//===--- Linkage.h - Linkage enumeration and utilities ----------*- C++ -*-===// +//===- Linkage.h - Linkage enumeration and utilities ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,16 +6,15 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the Linkage enumeration and various utility functions. -/// +// //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_BASIC_LINKAGE_H #define LLVM_CLANG_BASIC_LINKAGE_H -#include <assert.h> -#include <stdint.h> #include <utility> namespace clang { @@ -125,6 +124,6 @@ inline Linkage minLinkage(Linkage L1, Linkage L2) { return L1 < L2 ? L1 : L2; } -} // end namespace clang +} // namespace clang #endif // LLVM_CLANG_BASIC_LINKAGE_H diff --git a/include/clang/Basic/ObjCRuntime.h b/include/clang/Basic/ObjCRuntime.h index 3926c0c9b7..c41803c3bb 100644 --- a/include/clang/Basic/ObjCRuntime.h +++ b/include/clang/Basic/ObjCRuntime.h @@ -1,4 +1,4 @@ -//===--- ObjCRuntime.h - Objective-C Runtime Configuration ------*- C++ -*-===// +//===- ObjCRuntime.h - Objective-C Runtime Configuration --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,18 +6,21 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines types useful for describing an Objective-C runtime. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_OBJCRUNTIME_H #define LLVM_CLANG_BASIC_OBJCRUNTIME_H +#include "clang/Basic/LLVM.h" #include "clang/Basic/VersionTuple.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/ErrorHandling.h" +#include <string> namespace clang { @@ -57,15 +60,14 @@ public: }; private: - Kind TheKind; + Kind TheKind = MacOSX; VersionTuple Version; public: /// A bogus initialization of the runtime. - ObjCRuntime() : TheKind(MacOSX) {} - + ObjCRuntime() = default; ObjCRuntime(Kind kind, const VersionTuple &version) - : TheKind(kind), Version(version) {} + : TheKind(kind), Version(version) {} void set(Kind kind, VersionTuple version) { TheKind = kind; @@ -182,9 +184,8 @@ public: return true; case GNUstep: return getVersion() >= VersionTuple(1, 7); - default: - return false; + return false; } } @@ -320,7 +321,6 @@ public: return getVersion() >= VersionTuple(2); case GNUstep: return false; - default: return false; } @@ -360,6 +360,6 @@ public: raw_ostream &operator<<(raw_ostream &out, const ObjCRuntime &value); -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_OBJCRUNTIME_H diff --git a/include/clang/Basic/Sanitizers.h b/include/clang/Basic/Sanitizers.h index 1b936c7d11..fad22b2a75 100644 --- a/include/clang/Basic/Sanitizers.h +++ b/include/clang/Basic/Sanitizers.h @@ -1,4 +1,4 @@ -//===--- Sanitizers.h - C Language Family Language Options ------*- C++ -*-===// +//===- Sanitizers.h - C Language Family Language Options --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,10 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the clang::SanitizerKind enum. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_SANITIZERS_H @@ -18,10 +18,12 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MathExtras.h" +#include <cassert> +#include <cstdint> namespace clang { -typedef uint64_t SanitizerMask; +using SanitizerMask = uint64_t; namespace SanitizerKind { @@ -43,7 +45,7 @@ enum SanitizerOrdinal : uint64_t { const SanitizerMask ID##Group = 1ULL << SO_##ID##Group; #include "clang/Basic/Sanitizers.def" -} +} // namespace SanitizerKind struct SanitizerSet { /// \brief Check if a certain (single) sanitizer is enabled. @@ -85,6 +87,6 @@ inline SanitizerMask getPPTransparentSanitizers() { SanitizerKind::Nullability | SanitizerKind::Undefined; } -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_SANITIZERS_H diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index 245452dd12..ec7cd6f5e8 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -6,8 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// /// \file /// \brief Defines the virtual file system interface vfs::FileSystem. +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H @@ -15,6 +17,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -23,8 +26,6 @@ #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/Support/raw_ostream.h" -#include <algorithm> #include <cassert> #include <cstdint> #include <ctime> @@ -39,7 +40,7 @@ namespace llvm { class MemoryBuffer; -} // end namespace llvm +} // namespace llvm namespace clang { namespace vfs { @@ -52,14 +53,14 @@ class Status { uint32_t User; uint32_t Group; uint64_t Size; - llvm::sys::fs::file_type Type; + llvm::sys::fs::file_type Type = llvm::sys::fs::file_type::status_error; llvm::sys::fs::perms Perms; public: - bool IsVFSMapped; // FIXME: remove when files support multiple names + // FIXME: remove when files support multiple names + bool IsVFSMapped = false; -public: - Status() : Type(llvm::sys::fs::file_type::status_error) {} + Status() = default; Status(const llvm::sys::fs::file_status &Status); Status(StringRef Name, llvm::sys::fs::UniqueID UID, llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group, @@ -139,7 +140,7 @@ struct DirIterImpl { Status CurrentEntry; }; -} // end namespace detail +} // namespace detail /// \brief An input iterator over the entries in a virtual path, similar to /// llvm::sys::fs::directory_iterator. @@ -184,8 +185,8 @@ class FileSystem; /// \brief An input iterator over the recursive contents of a virtual path, /// similar to llvm::sys::fs::recursive_directory_iterator. class recursive_directory_iterator { - typedef std::stack<directory_iterator, std::vector<directory_iterator>> - IterState; + using IterState = + std::stack<directory_iterator, std::vector<directory_iterator>>; FileSystem *FS; std::shared_ptr<IterState> State; // Input iterator semantics on copy. @@ -193,6 +194,7 @@ class recursive_directory_iterator { public: recursive_directory_iterator(FileSystem &FS, const Twine &Path, std::error_code &EC); + /// \brief Construct an 'end' iterator. recursive_directory_iterator() = default; @@ -211,7 +213,7 @@ public: /// \brief Gets the current level. Starting path is at level 0. int level() const { - assert(State->size() && "Cannot get level without any iteration state"); + assert(!State->empty() && "Cannot get level without any iteration state"); return State->size()-1; } }; @@ -223,6 +225,7 @@ public: /// \brief Get the status of the entry at \p Path, if one exists. virtual llvm::ErrorOr<Status> status(const Twine &Path) = 0; + /// \brief Get a \p File object for the file at \p Path, if one exists. virtual llvm::ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) = 0; @@ -241,6 +244,7 @@ public: /// Set the working directory. This will affect all following operations on /// this file system and may propagate down for nested file systems. virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) = 0; + /// Get the working directory of this file system. virtual llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const = 0; @@ -276,13 +280,15 @@ IntrusiveRefCntPtr<FileSystem> getRealFileSystem(); /// that exists in more than one file system, the file in the top-most file /// system overrides the other(s). class OverlayFileSystem : public FileSystem { - typedef SmallVector<IntrusiveRefCntPtr<FileSystem>, 1> FileSystemList; + using FileSystemList = SmallVector<IntrusiveRefCntPtr<FileSystem>, 1>; + /// \brief The stack of file systems, implemented as a list in order of /// their addition. FileSystemList FSList; public: OverlayFileSystem(IntrusiveRefCntPtr<FileSystem> Base); + /// \brief Pushes a file system on top of the stack. void pushOverlay(IntrusiveRefCntPtr<FileSystem> FS); @@ -293,7 +299,7 @@ public: llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const override; std::error_code setCurrentWorkingDirectory(const Twine &Path) override; - typedef FileSystemList::reverse_iterator iterator; + using iterator = FileSystemList::reverse_iterator; /// \brief Get an iterator pointing to the most recently added file system. iterator overlays_begin() { return FSList.rbegin(); } @@ -307,7 +313,7 @@ namespace detail { class InMemoryDirectory; -} // end namespace detail +} // namespace detail /// An in-memory file system. class InMemoryFileSystem : public FileSystem { @@ -330,6 +336,7 @@ public: Optional<uint32_t> User = None, Optional<uint32_t> Group = None, Optional<llvm::sys::fs::file_type> Type = None, Optional<llvm::sys::fs::perms> Perms = None); + /// Add a buffer to the VFS with a path. The VFS does not own the buffer. /// If present, User, Group, Type and Perms apply to the newly-created file /// or directory. @@ -344,6 +351,7 @@ public: Optional<llvm::sys::fs::perms> Perms = None); std::string toString() const; + /// Return true if this file system normalizes . and .. in paths. bool useNormalizedPaths() const { return UseNormalizedPaths; } @@ -351,9 +359,11 @@ public: llvm::ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override; directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override; + llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const override { return WorkingDirectory; } + std::error_code setCurrentWorkingDirectory(const Twine &Path) override; }; @@ -419,7 +429,7 @@ public: void write(llvm::raw_ostream &OS); }; -} // end namespace vfs -} // end namespace clang +} // namespace vfs +} // namespace clang #endif // LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H |