[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2024-01-27 Thread Pavel Kalugin via cfe-commits
p4vook wrote: I converted the PR to draft, as this seems to be a part of a bigger problem with inserting statements into wrong nodes of the syntax tree (this seems to only show up when namespaces are present). I believe it shouldn't be fixed just by a simple check for `nullptr`. https://githu

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2024-01-27 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook converted_to_draft https://github.com/llvm/llvm-project/pull/75629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-16 Thread Pavel Kalugin via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;" p4vook wrote: Yep, we can, I'll try to do it this evening. I couldn't figure out why this test failed though, I probably need to fix it somehow. https://github.com/llvm/llvm-

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-16 Thread Vassil Vassilev via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;" vgvassilev wrote: @p4vook ping. https://github.com/llvm/llvm-project/pull/75629 ___ cfe-commits mailing list cfe-commits@lists.llvm

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;" vgvassilev wrote: Then we can put it in a new file called `error-recovery.cpp`. https://github.com/llvm/llvm-project/pull/75629 ___

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook edited https://github.com/llvm/llvm-project/pull/75629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook edited https://github.com/llvm/llvm-project/pull/75629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;" p4vook wrote: I don't quite understand, the `code-undo.cpp` doesn't seem to have anything that produces an error, but this test does. If we define a::b(t), clang-repl stops se

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook updated https://github.com/llvm/llvm-project/pull/75629 >From 2c4ab0990b55be21ca820d84eebb46b1814bb0aa Mon Sep 17 00:00:00 2001 From: Pavel Kalugin Date: Fri, 15 Dec 2023 15:05:45 +0300 Subject: [PATCH 1/3] [clang-repl] fix segfault in CleanUpPTU() Check if the last t

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook updated https://github.com/llvm/llvm-project/pull/75629 >From 2c4ab0990b55be21ca820d84eebb46b1814bb0aa Mon Sep 17 00:00:00 2001 From: Pavel Kalugin Date: Fri, 15 Dec 2023 15:05:45 +0300 Subject: [PATCH 1/2] [clang-repl] fix segfault in CleanUpPTU() Check if the last t

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits
@@ -373,7 +373,15 @@ std::unique_ptr IncrementalParser::GenModule() { void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) { TranslationUnitDecl *MostRecentTU = PTU.TUPart; + if (!MostRecentTU) { +return; + } + TranslationUnitDecl *FirstTU = MostRecentTU

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits
@@ -373,7 +373,15 @@ std::unique_ptr IncrementalParser::GenModule() { void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) { TranslationUnitDecl *MostRecentTU = PTU.TUPart; + if (!MostRecentTU) { +return; + } vgvassilev wrote: ```suggestio

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;" vgvassilev wrote: Can you move this in the `code-undo.cpp` test? https://github.com/llvm/llvm-project/pull/75629 ___ cfe-commits ma

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Pavel Kalugin (p4vook) Changes Check if the last translation unit or its first declaration are actually empty and do not nead cleanup. Previously this caused segmentation fault on empty PTUs. Add a regression test. Fixes: #72980 --- Fu

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it i

[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Pavel Kalugin via cfe-commits
https://github.com/p4vook created https://github.com/llvm/llvm-project/pull/75629 Check if the last translation unit or its first declaration are actually empty and do not nead cleanup. Previously this caused segmentation fault on empty PTUs. Add a regression test. Fixes: #72980 >From 2c4ab