mirror of
https://github.com/intel/llvm.git
synced 2026-01-30 14:07:28 +08:00
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
40 lines
1.6 KiB
C++
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);
|
|
}
|