Create a virtual file entry for each input line.
This is the only way not to confuse the diagnostics engine of upgraded clang. Also, this gives us a few advantages: * We can compare more precisely the source locations of diagnostics; * We can merge the code completion code path which works with file entries; * We can rely better when specifying //expected-note-s in different files.
This commit is contained in:
parent
a1bd767b6b
commit
8f257e74d3
@ -164,8 +164,11 @@ namespace cling {
|
||||
differentContent(m_LookupTablesFile, m_DiffPair->m_LookupTablesFile,
|
||||
"lookup tables", verbose, &builtinNames);
|
||||
|
||||
// We create a virtual file for each input line in the format input_line_N.
|
||||
llvm::SmallVector<llvm::StringRef, 2> input_lines;
|
||||
input_lines.push_back("input_line_[0-9].*");
|
||||
differentContent(m_IncludedFilesFile, m_DiffPair->m_IncludedFilesFile,
|
||||
"included files", verbose);
|
||||
"included files", verbose, &input_lines);
|
||||
|
||||
differentContent(m_ASTFile, m_DiffPair->m_ASTFile, "AST", verbose);
|
||||
|
||||
|
@ -700,20 +700,14 @@ namespace cling {
|
||||
|
||||
// Create FileID for the current buffer.
|
||||
FileID FID;
|
||||
if (CO.CodeCompletionOffset == -1)
|
||||
{
|
||||
FID = SM.createFileID(std::move(MB), SrcMgr::C_User,
|
||||
/*LoadedID*/0,
|
||||
/*LoadedOffset*/0, NewLoc);
|
||||
} else {
|
||||
// Create FileEntry and FileID for the current buffer.
|
||||
// Enabling the completion point only works on FileEntries.
|
||||
const clang::FileEntry* FE
|
||||
= SM.getFileManager().getVirtualFile("vfile for " + source_name.str(),
|
||||
InputSize, 0 /* mod time*/);
|
||||
= SM.getFileManager().getVirtualFile(source_name.str(), InputSize,
|
||||
0 /* mod time*/);
|
||||
SM.overrideFileContents(FE, std::move(MB));
|
||||
FID = SM.createFileID(FE, NewLoc, SrcMgr::C_User);
|
||||
|
||||
if (CO.CodeCompletionOffset != -1) {
|
||||
// The completion point is set one a 1-based line/column numbering.
|
||||
// It relies on the implementation to account for the wrapper extra line.
|
||||
PP.SetCodeCompletionPoint(FE, 1/* start point 1-based line*/,
|
||||
|
@ -10,8 +10,7 @@
|
||||
// Test incompleteType
|
||||
|
||||
.rawInput 1
|
||||
class __attribute__((annotate("Def.h"))) C;
|
||||
//expected-note + {{}}
|
||||
class __attribute__((annotate("Def.h"))) C; //expected-note + {{}}
|
||||
.rawInput 0
|
||||
|
||||
C c; //expected-error {{variable has incomplete type 'C'}} expected-warning@1 0+ {{Note: 'C' can be found in Def.h}}
|
||||
|
@ -18,9 +18,8 @@ int f = 0;
|
||||
int f() {
|
||||
printf("Now f is a function\n");
|
||||
return 0;
|
||||
} int a = f();
|
||||
} int a = f(); //CHECK: Now f is a function
|
||||
.undo
|
||||
//CHECK: Now f is a function
|
||||
.compareState "preUnload"
|
||||
//CHECK-NOT: Differences
|
||||
double f = 3.14
|
||||
|
@ -14,7 +14,7 @@
|
||||
// RUN: cat %s | %cling -nostdinc++ -Xclang -verify 2>&1 | FileCheck %s
|
||||
// Test nobuiltinincTest
|
||||
|
||||
// expected-error@1 {{'new' file not found}}
|
||||
// expected-error@input_line_1:1 {{'new' file not found}}
|
||||
|
||||
// CHECK: Warning in cling::IncrementalParser::CheckABICompatibility():
|
||||
// CHECK: Possible C++ standard library mismatch, compiled with {{.*$}}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
// RUN: cat %s | %cling -nostdinc++ -nobuiltininc -Xclang -verify 2>&1 | FileCheck %s
|
||||
|
||||
// expected-error {{'new' file not found}}
|
||||
// expected-error@input_line_1:1 {{'new' file not found}}
|
||||
|
||||
// CHECK: Warning in cling::IncrementalParser::CheckABICompatibility():
|
||||
// CHECK: Possible C++ standard library mismatch, compiled with
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
.rawInput 1
|
||||
|
||||
BEGIN_NAMESPACE int j; END_NAMESPACE
|
||||
BEGIN_NAMESPACE int j; END_NAMESPACE // expected-note {{previous definition is here}}
|
||||
|
||||
.storeState "testMacroExpansion"
|
||||
BEGIN_NAMESPACE int j; END_NAMESPACE // expected-error {{redefinition of 'j'}} expected-note {{previous definition is here}}
|
||||
BEGIN_NAMESPACE int j; END_NAMESPACE // expected-error {{redefinition of 'j'}}
|
||||
.compareState "testMacroExpansion"
|
||||
.rawInput 0
|
||||
// CHECK-NOT: Differences
|
||||
|
@ -56,10 +56,10 @@ V // CHECK: (cling::Value &) boxes [(int *) 0x12 <invalid memory address>]
|
||||
gCling->evaluate("gCling->declare(\"double sin(double);\"); double one = sin(3.141/2);", V);
|
||||
V // CHECK: (cling::Value &) boxes [(double) 1.000000]
|
||||
|
||||
gCling->process("double one = sin(3.141/2);", &V);
|
||||
gCling->process("double one = sin(3.141/2); // expected-note {{previous definition is here}}", &V);
|
||||
V // CHECK: (cling::Value &) boxes [(double) 1.000000]
|
||||
one // CHECK: (double) 1
|
||||
int one; // expected-error {{redefinition of 'one' with a different type: 'int' vs 'double'}} expected-note {{previous definition is here}}
|
||||
int one; // expected-error {{redefinition of 'one' with a different type: 'int' vs 'double'}}
|
||||
|
||||
// Make sure that PR#98434 doesn't get reintroduced.
|
||||
.rawInput
|
||||
|
@ -9,7 +9,8 @@
|
||||
// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib%shlibext
|
||||
// RUN: cat %s | %cling -L %T -Xclang -verify 2>&1 | FileCheck %s
|
||||
|
||||
#pragma cling load("DoesNotExistPleaseRecover") // expected-error@1{{'DoesNotExistPleaseRecover' file not found}}
|
||||
#pragma cling load("DoesNotExistPleaseRecover")
|
||||
// expected-error@input_line_13:1{{'DoesNotExistPleaseRecover' file not found}}
|
||||
|
||||
#pragma cling load("libcall_lib")
|
||||
extern "C" int cling_testlibrary_function();
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
// RUN: cat %s | %cling -Xclang -verify
|
||||
|
||||
class MyClass{};
|
||||
class MyClass{} // expected-error {{redefinition of 'MyClass'}} expected-note {{previous definition is here}}
|
||||
MyClass s;
|
||||
MyClass s; // expected-error {{redefinition of 's'}} expected-note {{previous definition is here}}
|
||||
class MyClass{}; // expected-note {{previous definition is here}}
|
||||
struct MyClass{} // expected-error {{redefinition of 'MyClass'}}
|
||||
MyClass * s; // expected-note {{previous definition is here}}
|
||||
MyClass s; // expected-error {{redefinition of 's'}}
|
||||
|
||||
const char* a = "test";
|
||||
const char* a = ""; // expected-error {{redefinition of 'a'}} expected-note {{previous definition is here}}
|
||||
const char* a = "test"; // expected-note {{previous definition is here}}
|
||||
const char* a = ""; // expected-error {{redefinition of 'a'}}
|
||||
|
||||
.q
|
||||
|
@ -105,5 +105,5 @@ auto fn_moo = std::bind (bla, _1,_2,10) // CHECK: ERROR in cling::executePrintVa
|
||||
void f(std::string) {}
|
||||
.rawInput 0
|
||||
f // CHECK: (void (*)(std::string)) Function @0x{{[0-9a-f]+}}
|
||||
// CHECK: at :1:
|
||||
// CHECK: at input_line_{{[0-9].*}}:1:
|
||||
// CHECK: void f(std::string) {}
|
||||
|
Loading…
Reference in New Issue
Block a user