Files
llvm-project/lldb/test/Shell/Expr/TestExprLanguageNote.test
Raul Tambre 21041c9292 [NFCI][lldb][test] Fix mismatched C/C++ substitutions (#165773)
Most of the cases were where a C++ file was being compiled with the C substitution.
There were a few cases of the opposite though.

LLDB seems to be the only real culprit in the LLVM codebase for these mismatches.
Rest of the LLVM presumably sticks at least language-specific options in the common substitutions
making the mistakes immediately apparent.

I found these by using Clang frontend configuration files containing language-specific options for
both C and C++ (e.g. `-std=c2y` and `-std=c++26`).
2025-10-30 23:18:32 +02:00

89 lines
2.1 KiB
Plaintext

# RUN: split-file %s %t
# RUN: %clangxx_host -g %t/main.cpp -o %t.out
#
# RUN: %lldb -x -b -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/no-target.input 2>&1 | FileCheck %s --check-prefix=CHECK-NO-TARGET
#
# RUN: %lldb %t.out -x -b -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/with-target.input 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
#--- main.cpp
int main() {
int x = 10;
return x;
}
#--- with-target.input
expr blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Falling back to default language. Ran expression as 'Objective C++'.
b 4
run
expr blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Ran expression as '{{(ISO )?}}C++{{.*}}'
expr -l objc -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Expression evaluation in pure Objective-C not supported. Ran expression as 'Objective C++'.
expr -l c -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Expression evaluation in pure C not supported. Ran expression as 'ISO C++'.
expr -l c++14 -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Ran expression as 'C++14'
expr -l c++20 -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Ran expression as 'C++20'
expr -l objective-c++ -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Ran expression as 'Objective C++'
# D uses TypeSystemClang but running expressions in it isn't supported. Test that we warn about this.
expr -l D -- blah
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET: note: Expression evaluation in D not supported. Falling back to default language. Ran expression as 'Objective C++'.
expr -l c++17 -- x = 5
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET-NOT: note:
expr x = 5
# CHECK-TARGET: (lldb) expr
# CHECK-TARGET-NOT: note:
#--- no-target.input
expr blah
# CHECK-NO-TARGET: (lldb) expr
# CHECK-NO-TARGET: note: Falling back to default language. Ran expression as 'Objective C++'.
expr -l c++ -- 1 + 1
# CHECK-NO-TARGET: (lldb) expr
# CHECK-NO-TARGET-NOT: note:
expr 1 + 1
# CHECK-NO-TARGET: (lldb) expr
# CHECK-NO-TARGET-NOT: note: