r174190 - Introduce SourceManager::PredefinesFileID, to allow each checking of whether
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Feb 1 08:36:07 PST 2013
Author: akirtzidis
Date: Fri Feb 1 10:36:07 2013
New Revision: 174190
URL: http://llvm.org/viewvc/llvm-project?rev=174190&view=rev
Log:
Introduce SourceManager::PredefinesFileID, to allow each checking of whether
a source location came from the predefines buffer.
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=174190&r1=174189&r2=174190&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Feb 1 10:36:07 2013
@@ -348,6 +348,9 @@ class Preprocessor : public RefCountedBa
/// should use from the command line etc.
std::string Predefines;
+ /// \brief The file ID for the preprocessor predefines.
+ FileID PredefinesFileID;
+
/// TokenLexerCache - Cache macro expanders to reduce malloc traffic.
enum { TokenLexerCacheSize = 8 };
unsigned NumCachedTokenLexers;
@@ -503,6 +506,9 @@ public:
/// expansions going on at the time.
PreprocessorLexer *getCurrentFileLexer() const;
+ /// \brief Returns the file ID for the preprocessor predefines.
+ FileID getPredefinesFileID() { return PredefinesFileID; }
+
/// getPPCallbacks/addPPCallbacks - Accessors for preprocessor callbacks.
/// Note that this class takes ownership of any PPCallbacks object given to
/// it.
@@ -1357,6 +1363,12 @@ private:
/// start getting tokens from it using the PTH cache.
void EnterSourceFileWithPTH(PTHLexer *PL, const DirectoryLookup *Dir);
+ /// \brief Set the file ID for the preprocessor predefines.
+ void setPredefinesFileID(FileID FID) {
+ assert(PredefinesFileID.isInvalid() && "PredefinesFileID already set!");
+ PredefinesFileID = FID;
+ }
+
/// IsFileLexer - Returns true if we are lexing from a file and not a
/// pragma or a macro.
static bool IsFileLexer(const Lexer* L, const PreprocessorLexer* P) {
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=174190&r1=174189&r2=174190&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Feb 1 10:36:07 2013
@@ -483,6 +483,7 @@ void Preprocessor::EnterMainSourceFile()
assert(SB && "Cannot create predefined source buffer");
FileID FID = SourceMgr.createFileIDForMemBuffer(SB);
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
+ setPredefinesFileID(FID);
// Start parsing the predefines.
EnterSourceFile(FID, 0, SourceLocation());
More information about the cfe-commits
mailing list