Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Parse/Parser.h"
Expand Down Expand Up @@ -550,12 +551,17 @@ namespace cling {
}

const MacroInfo* Interpreter::getMacro(llvm::StringRef Macro) const {
const clang::Preprocessor& PP = getCI()->getPreprocessor();
if (const IdentifierInfo* II = PP.getIdentifierInfo(Macro)) {
if (const DefMacroDirective* MD = llvm::dyn_cast_or_null
<DefMacroDirective>(PP.getLocalMacroDirective(II))) {
return MD->getMacroInfo();
}
clang::Preprocessor& PP = getCI()->getPreprocessor();
if (IdentifierInfo* II = PP.getIdentifierInfo(Macro)) {
// If the information about this identifier is out of date, update it from
// the external source.
// FIXME: getIdentifierInfo will probably do this for us once we update
// clang. If so, please remove this manual update.
if (II->isOutOfDate())
PP.getExternalSource()->updateOutOfDateIdentifier(*II);
MacroDefinition MDef = PP.getMacroDefinition(II);
MacroInfo* MI = MDef.getMacroInfo();
return MI;
}
return nullptr;
}
Expand Down