//===--- MacroExpansion.cpp - Top level Macro Expansion -------------------===////// 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 top level handling of macro expasion for the// preprocessor.////===----------------------------------------------------------------------===//#include"clang/Lex/Preprocessor.h"#include"MacroArgs.h"#include"clang/Basic/FileManager.h"#include"clang/Basic/SourceManager.h"#include"clang/Basic/TargetInfo.h"#include"clang/Lex/CodeCompletionHandler.h"#include"clang/Lex/ExternalPreprocessorSource.h"#include"clang/Lex/LexDiagnostic.h"#include"clang/Lex/MacroInfo.h"#include"llvm/ADT/STLExtras.h"#include"llvm/ADT/SmallString.h"#include"llvm/ADT/StringSwitch.h"#include"llvm/Config/llvm-config.h"#include"llvm/Support/ErrorHandling.h"#include"llvm/Support/Format.h"#include"llvm/Support/raw_ostream.h"#include<cstdio>#include<ctime>usingnamespaceclang;MacroInfo*Preprocessor::getMacroInfoHistory(IdentifierInfo*II)const{assert(II->hadMacroDefinition()&&"Identifier has not been not a macro!");macro_iteratorPos=Macros.find(II);assert(Pos!=Macros.end()&&"Identifier macro info is missing!");returnPos->second;}/// setMacroInfo - Specify a macro for this identifier.///voidPreprocessor::setMacroInfo(IdentifierInfo*II,MacroInfo*MI){assert(MI&&"MacroInfo should be non-zero!");assert(MI->getUndefLoc().isInvalid()&&"Undefined macros cannot be registered");MacroInfo*&StoredMI=Macros[II];MI->setPreviousDefinition(StoredMI);StoredMI=MI;II->setHasMacroDefinition(MI->getUndefLoc().isInvalid());if(II->isFromAST())II->setChangedSinceDeserialization();}voidPreprocessor::addLoadedMacroInfo(IdentifierInfo*II,MacroInfo*MI,MacroInfo*Hint){assert(MI&&"Missing macro?");assert(MI->isFromAST()&&"Macro is not from an AST?");assert(!MI->getPreviousDefinition()&&"Macro already in chain?");MacroInfo*&StoredMI=Macros[II];// Easy case: this is the first macro definition for this macro.if(!StoredMI){StoredMI=MI;if(MI->isDefined())II<