Files
llvm/clang/lib/Lex/PreprocessingRecord.cpp
Douglas Gregor 78ae2481b6 Explicitly link macro instantiations to macro definitions in the
preprocessing record. Use that link with clang_getCursorReferenced()
and clang_getCursorDefinition() to match instantiations of a macro to
the definition of the macro.

llvm-svn: 98842
2010-03-18 18:23:03 +00:00

40 lines
1.6 KiB
C++

//===--- 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);
}