Disable useless warnings only for the wrapper functions.

We simulate programatically:
void __cling_Unique {
  #pragma push
  #pragma ... ignore ...
  {code}
  #pragma pop
}
This commit is contained in:
Vassil Vassilev 2014-04-01 16:44:59 +02:00 committed by sftnight
parent f9f6c937d3
commit ffc9fe50b5
4 changed files with 26 additions and 16 deletions

View File

@ -465,17 +465,6 @@ namespace cling {
}
void CIFactory::SetClingCustomDiagnosticMappings(DiagnosticsEngine& Diags) {
// Disable warnings which doesn't make sense when using the prompt
// This gets reset with the clang::Diagnostics().Reset(/*soft*/=false)
SourceLocation noLoc;
Diags.setDiagnosticMapping(clang::diag::warn_unused_expr,
clang::diag::MAP_IGNORE, noLoc);
Diags.setDiagnosticMapping(clang::diag::warn_unused_call,
clang::diag::MAP_IGNORE, noLoc);
Diags.setDiagnosticMapping(clang::diag::warn_unused_comparison,
clang::diag::MAP_IGNORE, noLoc);
Diags.setDiagnosticMapping(clang::diag::ext_return_has_expr,
clang::diag::MAP_IGNORE, noLoc);
}
void CIFactory::SetClingCustomLangOpts(LangOptions& Opts) {

View File

@ -143,6 +143,12 @@ namespace cling {
}
SourceLocation IncrementalParser::getLastMemoryBufferEndLoc() const {
const SourceManager& SM = getCI()->getSourceManager();
SourceLocation Result = SM.getLocForStartOfFile(m_VirtualFileID);
return Result.getLocWithOffset(m_MemoryBuffers.size() + 1);
}
IncrementalParser::~IncrementalParser() {
if (hasCodeGenerator()) {
getCodeGenerator()->ReleaseModule();
@ -612,8 +618,7 @@ namespace cling {
// Create SourceLocation, which will allow clang to order the overload
// candidates for example
SourceLocation NewLoc = SM.getLocForStartOfFile(m_VirtualFileID);
NewLoc = NewLoc.getLocWithOffset(m_MemoryBuffers.size() + 1);
SourceLocation NewLoc = getLastMemoryBufferEndLoc().getLocWithOffset(1);
// Create FileID for the current buffer
FileID FID = SM.createFileIDForMemBuffer(m_MemoryBuffers.back(),

View File

@ -108,6 +108,7 @@ namespace cling {
clang::Parser* getParser() const { return m_Parser.get(); }
clang::CodeGenerator* getCodeGenerator() const { return m_CodeGen.get(); }
bool hasCodeGenerator() const { return m_CodeGen.get(); }
clang::SourceLocation getLastMemoryBufferEndLoc() const;
/// \{
/// \name Transaction Support

View File

@ -882,11 +882,25 @@ namespace cling {
std::string Wrapper = input;
WrapInput(Wrapper, WrapperName);
// Disable warnings which doesn't make sense when using the prompt
// This gets reset with the clang::Diagnostics().Reset(/*soft*/=false)
SourceLocation Loc = m_IncrParser->getLastMemoryBufferEndLoc();
DiagnosticsEngine& Diags = getCI()->getDiagnostics();
Diags.pushMappings(Loc);
Loc = Loc.getLocWithOffset(1);
Diags.setDiagnosticMapping(clang::diag::warn_unused_expr,
clang::diag::MAP_IGNORE, Loc);
Diags.setDiagnosticMapping(clang::diag::warn_unused_call,
clang::diag::MAP_IGNORE, Loc);
Diags.setDiagnosticMapping(clang::diag::warn_unused_comparison,
clang::diag::MAP_IGNORE, Loc);
Diags.setDiagnosticMapping(clang::diag::ext_return_has_expr,
clang::diag::MAP_IGNORE, Loc);
Loc = Loc.getLocWithOffset(1);
if (Transaction* lastT = m_IncrParser->Compile(Wrapper, CO)) {
//FIXME: uncomment when the macro support comes in the transaction
//assert((!V || lastT->size()) && "No decls created!?");
Diags.popMappings(Loc);
assert((lastT->getState() == Transaction::kCommitted
|| lastT->getState() == Transaction::kRolledBack)
|| lastT->getState() == Transaction::kRolledBack)
&& "Not committed?");
if (lastT->getIssuedDiags() != Transaction::kErrors) {
if (!lastT->getWrapperFD()) // no wrapper to run
@ -899,6 +913,7 @@ namespace cling {
return Interpreter::kFailure;
}
Diags.popMappings(Loc);
return Interpreter::kSuccess;
}