summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2016-12-09 00:11:53 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2016-12-09 00:11:53 +0000
commit6a643fea5cc7bd7f3bffec675dd62c8e31f4c777 (patch)
treeeda02138676cda0fbef226055573c2729d379002 /include/clang/Basic/SourceManager.h
parent848b4ceee68b918ab674a9db5c1277edcfb1a452 (diff)
[AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h51
1 files changed, 29 insertions, 22 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 3e4ec36627..c8fe2ab90c 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -44,28 +44,34 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
+#include <algorithm>
#include <cassert>
+#include <cstddef>
+#include <cstdint>
#include <map>
#include <memory>
+#include <string>
+#include <utility>
#include <vector>
namespace clang {
+class ASTReader;
+class ASTWriter;
class DiagnosticsEngine;
-class SourceManager;
-class FileManager;
-class FileEntry;
class LineTableInfo;
-class ASTWriter;
-class ASTReader;
+class SourceManager;
/// \brief Public enums and private classes that are part of the
/// SourceManager implementation.
///
namespace SrcMgr {
+
/// \brief Indicates whether a file or directory holds normal user code,
/// system code, or system code which is implicitly 'extern "C"' in C++ mode.
///
@@ -144,8 +150,6 @@ namespace SrcMgr {
SourceLineCache(nullptr), NumLines(0), BufferOverridden(false),
IsSystemFile(false), IsTransient(false) {}
- ~ContentCache();
-
/// The copy ctor does not allow copies where source object has either
/// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory
/// is not transferred, so this is a logical error.
@@ -162,6 +166,10 @@ namespace SrcMgr {
NumLines = RHS.NumLines;
}
+ ContentCache &operator=(const ContentCache& RHS) = delete;
+
+ ~ContentCache();
+
/// \brief Returns the memory buffer for the associated content.
///
/// \param Diag Object through which diagnostics will be emitted if the
@@ -217,10 +225,6 @@ namespace SrcMgr {
bool shouldFreeBuffer() const {
return (Buffer.getInt() & DoNotFreeFlag) == 0;
}
-
- private:
- // Disable assignments.
- ContentCache &operator=(const ContentCache& RHS) = delete;
};
// Assert that the \c ContentCache objects will always be 8-byte aligned so
@@ -257,6 +261,7 @@ namespace SrcMgr {
friend class clang::SourceManager;
friend class clang::ASTWriter;
friend class clang::ASTReader;
+
public:
/// \brief Return a FileInfo object.
static FileInfo get(SourceLocation IL, const ContentCache *Con,
@@ -274,6 +279,7 @@ namespace SrcMgr {
SourceLocation getIncludeLoc() const {
return SourceLocation::getFromRawEncoding(IncludeLoc);
}
+
const ContentCache* getContentCache() const {
return reinterpret_cast<const ContentCache*>(Data & ~uintptr_t(7));
}
@@ -314,9 +320,11 @@ namespace SrcMgr {
SourceLocation getSpellingLoc() const {
return SourceLocation::getFromRawEncoding(SpellingLoc);
}
+
SourceLocation getExpansionLocStart() const {
return SourceLocation::getFromRawEncoding(ExpansionLocStart);
}
+
SourceLocation getExpansionLocEnd() const {
SourceLocation EndLoc =
SourceLocation::getFromRawEncoding(ExpansionLocEnd);
@@ -397,6 +405,7 @@ namespace SrcMgr {
FileInfo File;
ExpansionInfo Expansion;
};
+
public:
unsigned getOffset() const { return Offset; }
@@ -431,6 +440,7 @@ namespace SrcMgr {
return E;
}
};
+
} // end SrcMgr namespace.
/// \brief External source of source location entries.
@@ -451,7 +461,6 @@ public:
virtual std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) = 0;
};
-
/// \brief Holds the cache used by isBeforeInTranslationUnit.
///
/// The cache structure is complex enough to be worth breaking out of
@@ -477,6 +486,7 @@ class InBeforeInTUCacheEntry {
/// if LQueryFID is a parent of RQueryFID (or vice versa) then these can be a
/// random token in the parent.
unsigned LCommonOffset, RCommonOffset;
+
public:
/// \brief Return true if the currently cached values match up with
/// the specified LHS/RHS query.
@@ -524,13 +534,12 @@ public:
LCommonOffset = lCommonOffset;
RCommonOffset = rCommonOffset;
}
-
};
/// \brief The stack used when building modules on demand, which is used
/// to provide a link between the source managers of the different compiler
/// instances.
-typedef ArrayRef<std::pair<std::string, FullSourceLoc> > ModuleBuildStack;
+typedef ArrayRef<std::pair<std::string, FullSourceLoc>> ModuleBuildStack;
/// \brief This class handles loading and caching of source files into memory.
///
@@ -665,7 +674,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
///
/// Used to cache results from and speed-up \c getDecomposedIncludedLoc
/// function.
- mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned> > IncludedLocMap;
+ mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap;
/// The key value into the IsBeforeInTUCache table.
typedef std::pair<FileID, FileID> IsBeforeInTUCacheKey;
@@ -704,12 +713,11 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// we can add a cc1-level option to do so.
SmallVector<std::pair<std::string, FullSourceLoc>, 2> StoredModuleBuildStack;
- // SourceManager doesn't support copy construction.
- explicit SourceManager(const SourceManager&) = delete;
- void operator=(const SourceManager&) = delete;
public:
SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
bool UserFilesAreVolatile = false);
+ explicit SourceManager(const SourceManager &) = delete;
+ SourceManager &operator=(const SourceManager &) = delete;
~SourceManager();
void clearIDTables();
@@ -1712,7 +1720,6 @@ public:
}
};
-} // end namespace clang
-
+} // end namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H