aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PreprocessingRecord.cpp
blob: 3e0a03b74f823d9444b839b0bc7330715981f98c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===--- PreprocessingRecord.cpp - Record of Preprocessing ------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file implements the PreprocessingRecord class, which maintains a record
//  of what occurred during preprocessing, and its helpers.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Token.h"

using namespace clang;

void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
  PreprocessedEntities.push_back(Entity);
}

void PopulatePreprocessingRecord::MacroExpands(const Token &Id, 
                                               const MacroInfo* MI) {
  Record.addPreprocessedEntity(
                        new (Record) MacroInstantiation(Id.getIdentifierInfo(),
                                                       Id.getLocation(),
                                                        MacroDefinitions[MI]));
}

void PopulatePreprocessingRecord::MacroDefined(const IdentifierInfo *II, 
                                               const MacroInfo *MI) {
  SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc());
  MacroDefinition *Def
    = new (Record) MacroDefinition(II, MI->getDefinitionLoc(), R);
  MacroDefinitions[MI] = Def;
  Record.addPreprocessedEntity(Def);
}