Douglas Gregor | 065f8d1 | 2010-03-18 17:52:52 +0000 | [diff] [blame^] | 1 | //===--- PreprocessingRecord.cpp - Record of Preprocessing ------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the PreprocessingRecord class, which maintains a record |
| 11 | // of what occurred during preprocessing, and its helpers. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #include "clang/Lex/PreprocessingRecord.h" |
| 15 | #include "clang/Lex/MacroInfo.h" |
| 16 | #include "clang/Lex/Token.h" |
| 17 | |
| 18 | using namespace clang; |
| 19 | |
| 20 | void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) { |
| 21 | PreprocessedEntities.push_back(Entity); |
| 22 | } |
| 23 | |
| 24 | void PopulatePreprocessingRecord::MacroExpands(const Token &Id, |
| 25 | const MacroInfo* MI) { |
| 26 | Record.addPreprocessedEntity( |
| 27 | new (Record) MacroInstantiation(Id.getIdentifierInfo(), |
| 28 | Id.getLocation(), |
| 29 | MI->getDefinitionLoc())); |
| 30 | } |
| 31 | |
| 32 | void PopulatePreprocessingRecord::MacroDefined(const IdentifierInfo *II, |
| 33 | const MacroInfo *MI) { |
| 34 | SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); |
| 35 | Record.addPreprocessedEntity( |
| 36 | new (Record) MacroDefinition(II, MI->getDefinitionLoc(), R)); |
| 37 | } |