aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex/PTHManager.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-27 00:01:05 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-27 00:01:05 +0000
commit277faca30c9f8f72b79f55695cbe3395ec246e7c (patch)
tree80ed507b156a6d73ba2cf5651e772dd55f7adee0 /include/clang/Lex/PTHManager.h
parent528473335419f072f6eff25a4af07925c1692121 (diff)
PTH: Use Token::setLiteralData() to directly store a pointer to cached spelling data in the PTH file. This removes a ton of code for looking up spellings using sourcelocations in the PTH file. This simplifies both PTH-generation and reading.
Performance impact for -fsyntax-only on Cocoa.h (with Cocoa.h in the PTH file): - PTH generation time improves by 5% - PTH reading improves by 0.3%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/PTHManager.h')
-rw-r--r--include/clang/Lex/PTHManager.h48
1 files changed, 10 insertions, 38 deletions
diff --git a/include/clang/Lex/PTHManager.h b/include/clang/Lex/PTHManager.h
index 31cf78f036..b77cda1f0b 100644
--- a/include/clang/Lex/PTHManager.h
+++ b/include/clang/Lex/PTHManager.h
@@ -29,42 +29,13 @@ namespace clang {
class FileEntry;
class PTHLexer;
-class PTHManager;
-
-class PTHSpellingSearch {
- PTHManager& PTHMgr;
-
- const unsigned char* const TableBeg;
- const unsigned char* const TableEnd;
-
- const unsigned NumSpellings;
- const unsigned char* LinearItr;
-
-public:
- enum { SpellingEntrySize = 4*2 };
-
- unsigned getSpellingBinarySearch(unsigned fpos, const char *&Buffer);
- unsigned getSpellingLinearSearch(unsigned fpos, const char *&Buffer);
-
- PTHSpellingSearch(PTHManager& pm, unsigned numSpellings,
- const unsigned char* tableBeg)
- : PTHMgr(pm),
- TableBeg(tableBeg),
- TableEnd(tableBeg + numSpellings*SpellingEntrySize),
- NumSpellings(numSpellings),
- LinearItr(tableBeg) {}
-};
class PTHManager : public IdentifierInfoLookup {
friend class PTHLexer;
- friend class PTHSpellingSearch;
/// The memory mapped PTH file.
const llvm::MemoryBuffer* Buf;
-
- /// A map from FileIDs to SpellingSearch objects.
- llvm::DenseMap<FileID, PTHSpellingSearch*> SpellingMap;
-
+
/// Alloc - Allocator used for IdentifierInfo objects.
llvm::BumpPtrAllocator Alloc;
@@ -84,7 +55,7 @@ class PTHManager : public IdentifierInfoLookup {
/// SortedIdTable - Array ordering persistent identifier IDs by the lexical
/// order of their corresponding strings. This is used by get().
const unsigned char* const SortedIdTable;
-
+
/// NumIds - The number of identifiers in the PTH file.
const unsigned NumIds;
@@ -92,11 +63,16 @@ class PTHManager : public IdentifierInfoLookup {
/// PTHLexer objects.
Preprocessor* PP;
+ /// SpellingBase - The base offset within the PTH memory buffer that
+ /// contains the cached spellings for literals.
+ const unsigned char* const SpellingBase;
+
/// This constructor is intended to only be called by the static 'Create'
/// method.
PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup,
const unsigned char* idDataTable, IdentifierInfo** perIDCache,
- const unsigned char* sortedIdTable, unsigned numIds);
+ const unsigned char* sortedIdTable, unsigned numIds,
+ const unsigned char* spellingBase);
// Do not implement.
PTHManager();
@@ -119,7 +95,7 @@ class PTHManager : public IdentifierInfoLookup {
public:
// The current PTH version.
- enum { Version = 0 };
+ enum { Version = 1 };
~PTHManager();
@@ -138,11 +114,7 @@ public:
/// CreateLexer - Return a PTHLexer that "lexes" the cached tokens for the
/// specified file. This method returns NULL if no cached tokens exist.
/// It is the responsibility of the caller to 'delete' the returned object.
- PTHLexer *CreateLexer(FileID FID);
-
- unsigned getSpelling(SourceLocation Loc, const char *&Buffer);
-private:
- unsigned getSpelling(FileID FID, unsigned fpos, const char *& Buffer);
+ PTHLexer *CreateLexer(FileID FID);
};
} // end namespace clang