Implement Interpreter's InclusionDirective() callback

InclusionDirective() callback tells us that an inclusion directive has been processed, allowing us to try to autoload classes using their header file name.
For example try to autoload TGClient (libGui) when seeing #include "TGClient.h"
This should prevent potential crash when executing macros using globals (e.g. gClient), with the following error:
ExecutionContext: use of undefined symbol 'gClient'!
This commit is contained in:
Bertrand Bellenot 2014-01-28 14:52:22 +01:00 committed by sftnight
parent 8efd17d0e6
commit 8ca703c272
2 changed files with 27 additions and 0 deletions

View File

@ -26,6 +26,9 @@ namespace clang {
class Scope;
class TagDecl;
class Type;
class Token;
class FileEntry;
class Module;
}
namespace cling {
@ -105,6 +108,16 @@ namespace cling {
clang::ASTDeserializationListener*
getInterpreterDeserializationListener() const;
virtual void InclusionDirective(clang::SourceLocation /*HashLoc*/,
const clang::Token &/*IncludeTok*/,
llvm::StringRef FileName,
bool /*IsAngled*/,
clang::CharSourceRange /*FilenameRange*/,
const clang::FileEntry */*File*/,
llvm::StringRef /*SearchPath*/,
llvm::StringRef /*RelativePath*/,
const clang::Module */*Imported*/) {}
virtual bool FileNotFound(llvm::StringRef FileName,
llvm::SmallVectorImpl<char>& RecoveryPath);

View File

@ -32,6 +32,20 @@ namespace cling {
InterpreterPPCallbacks(InterpreterCallbacks* C) : m_Callbacks(C) { }
~InterpreterPPCallbacks() { }
virtual void InclusionDirective(clang::SourceLocation HashLoc,
const clang::Token &IncludeTok,
llvm::StringRef FileName,
bool IsAngled,
clang::CharSourceRange FilenameRange,
const clang::FileEntry *File,
llvm::StringRef SearchPath,
llvm::StringRef RelativePath,
const clang::Module *Imported) {
if (m_Callbacks)
m_Callbacks->InclusionDirective(HashLoc, IncludeTok, FileName,
IsAngled, FilenameRange, File,
SearchPath, RelativePath, Imported);
}
virtual bool FileNotFound(llvm::StringRef FileName,
llvm::SmallVectorImpl<char>& RecoveryPath) {
if (m_Callbacks)