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:
parent
f9f6c937d3
commit
ffc9fe50b5
@ -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) {
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user