Skip to content

Commit 0140bbd

Browse files
committed
suppress redecl notes coming from interactive line includer
This follows the same behaviour as clang-repl, maybe this should be fixed upstream.
1 parent be377ed commit 0140bbd

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

interpreter/cling/lib/Interpreter/IncrementalParser.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@ namespace {
183183
}
184184
}
185185

186+
// FIXME:
187+
// Suppress meaningless "note: '' included multiple times, additional
188+
// include site here" from virtual Cling buffers.
189+
// Also happens with clang-repl.
190+
if (Info.getID() == diag::note_redefinition_include_same_file) {
191+
if (!Info.hasSourceManager() || !Info.getLocation().isValid())
192+
return;
193+
194+
const PresumedLoc PLoc =
195+
Info.getSourceManager().getPresumedLoc(Info.getLocation());
196+
if (!PLoc.isValid())
197+
return;
198+
199+
StringRef Filename = PLoc.getFilename();
200+
if (Filename.empty() ||
201+
Filename.contains("cling interactive line includer"))
202+
return;
203+
}
204+
186205
// In principle, for simplicity, we preserve the old behavior of
187206
// delivering diagnostics to just one consumer (that is why we don't emit
188207
// to both), but we allow the "sink" to be changed.
@@ -888,7 +907,7 @@ namespace cling {
888907

889908
// Create SourceLocation, which will allow clang to order the overload
890909
// candidates for example
891-
SourceLocation NewLoc = getNextAvailableUniqueSourceLoc();
910+
SourceLocation NewLoc = SM.getLocForStartOfFile(SM.getMainFileID());
892911

893912
// Create FileID for the current buffer.
894913
FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, /*LoadedID=*/0,

interpreter/cling/test/ErrorRecovery/MacroExpansion.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
.rawInput 1
1515

16-
BEGIN_NAMESPACE int j; END_NAMESPACE // expected-note {{previous definition is here}}
16+
BEGIN_NAMESPACE int j; END_NAMESPACE
1717

1818
.storeState "testMacroExpansion"
1919
BEGIN_NAMESPACE int j; END_NAMESPACE // expected-error {{redefinition of 'j'}}

interpreter/cling/test/ErrorRecovery/SubsequentDecls.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TemplatedF((double)3.14)
4646

4747
// ROOT-7295
4848
#include <vector>
49-
std::vector<float> a; // expected-note {{previous definition is here}}
49+
std::vector<float> a;
5050
std::vector<float> a; // expected-error {{redefinition of 'a'}}
5151

5252
.q

interpreter/cling/test/Prompt/Redeclarations.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct MyClass{} // expected-error {{redefinition of 'MyClass'}}
1313
MyClass * s; // expected-note {{previous definition is here}}
1414
MyClass s; // expected-error {{redefinition of 's'}}
1515

16-
const char* a = "test"; // expected-note {{previous definition is here}}
16+
const char* a = "test";
1717
const char* a = ""; // expected-error {{redefinition of 'a'}}
1818

1919
.q

0 commit comments

Comments
 (0)