aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-19 17:12:43 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-19 17:12:43 +0000
commitb9e1b75772db2c7db566c6034ba90a07f22e35eb (patch)
tree614317b4cd29d2480d014468c34ecbd12b35428b /include/clang
parent94dc8f640ebea52241412512ed48601626edbc58 (diff)
Make the preprocessing record a PPCallbacks subclass itself,
eliminating the extra PopulatePreprocessingRecord object. This will become useful once we start writing the preprocessing record to precompiled headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/Lex/PreprocessingRecord.h14
-rw-r--r--include/clang/Lex/Preprocessor.h4
2 files changed, 15 insertions, 3 deletions
diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h
index c00da563a1..30e5a5a4b0 100644
--- a/include/clang/Lex/PreprocessingRecord.h
+++ b/include/clang/Lex/PreprocessingRecord.h
@@ -14,7 +14,9 @@
#ifndef LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
#define LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
+#include "clang/Lex/PPCallbacks.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Allocator.h"
#include <vector>
@@ -175,7 +177,7 @@ namespace clang {
/// \brief A record of the steps taken while preprocessing a source file,
/// including the various preprocessing directives processed, macros
/// instantiated, etc.
- class PreprocessingRecord {
+ class PreprocessingRecord : public PPCallbacks {
/// \brief Allocator used to store preprocessing objects.
llvm::BumpPtrAllocator BumpAlloc;
@@ -183,6 +185,9 @@ namespace clang {
/// were seen.
std::vector<PreprocessedEntity *> PreprocessedEntities;
+ /// \brief Mapping from MacroInfo structures to their definitions.
+ llvm::DenseMap<const MacroInfo *, MacroDefinition *> MacroDefinitions;
+
public:
/// \brief Allocate memory in the preprocessing record.
void *Allocate(unsigned Size, unsigned Align = 8) {
@@ -202,6 +207,13 @@ namespace clang {
/// \brief Add a new preprocessed entity to this record.
void addPreprocessedEntity(PreprocessedEntity *Entity);
+
+ /// \brief Retrieve the macro definition that corresponds to the given
+ /// \c MacroInfo.
+ MacroDefinition *findMacroDefinition(MacroInfo *MI);
+
+ virtual void MacroExpands(const Token &Id, const MacroInfo* MI);
+ virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
};
} // end namespace clang
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 81fbedcfed..23c118d1fc 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -215,7 +215,7 @@ class Preprocessor {
///
/// This is an optional side structure that can be enabled with
/// \c createPreprocessingRecord() prior to preprocessing.
- llvm::OwningPtr<PreprocessingRecord> Record;
+ PreprocessingRecord *Record;
private: // Cached tokens state.
typedef llvm::SmallVector<Token, 1> CachedTokensTy;
@@ -358,7 +358,7 @@ public:
/// \brief Retrieve the preprocessing record, or NULL if there is no
/// preprocessing record.
- PreprocessingRecord *getPreprocessingRecord() const { return Record.get(); }
+ PreprocessingRecord *getPreprocessingRecord() const { return Record; }
/// \brief Create a new preprocessing record, which will keep track of
/// all macro expansions, macro definitions, etc.