From d8d127664d509b7409f9a6f1430eec77be1dceec Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 11 Dec 2012 14:43:40 +0000 Subject: [PATCH] Until we have the full implementation of the preprocessor directives just act on #include. This makes sure that we don't do any extra work causing roottest failures. git-svn-id: http://root.cern.ch/svn/root/trunk@47972 27541ba8-7e3a-0410-8455-c3a389f83636 --- include/cling/Interpreter/Interpreter.h | 2 +- lib/Interpreter/Interpreter.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/cling/Interpreter/Interpreter.h b/include/cling/Interpreter/Interpreter.h index ee8cd8f0..e4e480b8 100644 --- a/include/cling/Interpreter/Interpreter.h +++ b/include/cling/Interpreter/Interpreter.h @@ -297,7 +297,7 @@ namespace cling { /// ///\returns true if the input should be wrapped. /// - bool ShouldWrapInput(llvm::StringRef input); + bool ShouldWrapInput(const std::string& input); ///\brief Wraps a given input. /// diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index afc99357..f3809a1d 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -475,15 +475,15 @@ namespace cling { return Interpreter::kFailure; } - bool Interpreter::ShouldWrapInput(llvm::StringRef input) { + bool Interpreter::ShouldWrapInput(const std::string& input) { llvm::OwningPtr buf; buf.reset(llvm::MemoryBuffer::getMemBuffer(input, "Cling Preparse Buf")); - Lexer WrapLexer(SourceLocation(), getSema().getLangOpts(), input.data(), - input.data(), input.data() + input.size()); + Lexer WrapLexer(SourceLocation(), getSema().getLangOpts(), input.c_str(), + input.c_str(), input.c_str() + input.size()); Token Tok; WrapLexer.Lex(Tok); - tok::TokenKind kind = Tok.getKind(); + const tok::TokenKind kind = Tok.getKind(); if (kind == tok::raw_identifier && !Tok.needsCleaning()) { StringRef keyword(Tok.getRawIdentifierData(), Tok.getLength()); @@ -494,12 +494,16 @@ namespace cling { if (keyword.equals("namespace")) return false; } - - switch (kind) { - case tok::hash : return false; - default: - return true; + else if (kind == tok::hash) { + WrapLexer.Lex(Tok); + if (Tok.is(tok::raw_identifier) && !Tok.needsCleaning()) { + StringRef keyword(Tok.getRawIdentifierData(), Tok.getLength()); + if (keyword.equals("include")) + return false; + } } + + return true; }