aganea created this revision. aganea added reviewers: rsmith, aaron.ballman, rnk. Herald added subscribers: cfe-commits, arphaman. Herald added a project: clang.
As per title: previously, running the test `clang/test/Index/annotate-deep-statements.cpp` used to fail because of stack exhaustion (Debug target on Windows compiled with clang-cl) Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70149 Files: clang/lib/Sema/SemaChecking.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3595,6 +3595,7 @@ const char *const *command_line_args, int num_command_line_args, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options, CXTranslationUnit *out_TU) { + noteBottomOfStack(); SmallVector<const char *, 4> Args; Args.push_back("clang"); Args.append(command_line_args, command_line_args + num_command_line_args); @@ -3619,6 +3620,7 @@ CXErrorCode result = CXError_Failure; auto ParseTranslationUnitImpl = [=, &result] { + noteBottomOfStack(); result = clang_parseTranslationUnit_Impl( CIdx, source_filename, command_line_args, num_command_line_args, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU); @@ -6621,9 +6623,10 @@ void clang_executeOnThread(void (*fn)(void*), void *user_data, unsigned stack_size) { - llvm::llvm_execute_on_thread( - fn, user_data, - stack_size == 0 ? llvm::None : llvm::Optional<unsigned>(stack_size)); + llvm::llvm_execute_on_thread(fn, user_data, + stack_size == 0 + ? clang::DesiredStackSize + : llvm::Optional<unsigned>(stack_size)); } //===----------------------------------------------------------------------===// Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -12930,7 +12930,8 @@ // expression or statement in the body of the function [and thus before // the value computation of its result]. SequencedSubexpression Sequenced(*this); - Base::VisitCallExpr(CE); + SemaRef.runWithSufficientStackSpace(CE->getExprLoc(), + [&] { Base::VisitCallExpr(CE); }); // FIXME: CXXNewExpr and CXXDeleteExpr implicitly call functions. }
Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -3595,6 +3595,7 @@ const char *const *command_line_args, int num_command_line_args, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options, CXTranslationUnit *out_TU) { + noteBottomOfStack(); SmallVector<const char *, 4> Args; Args.push_back("clang"); Args.append(command_line_args, command_line_args + num_command_line_args); @@ -3619,6 +3620,7 @@ CXErrorCode result = CXError_Failure; auto ParseTranslationUnitImpl = [=, &result] { + noteBottomOfStack(); result = clang_parseTranslationUnit_Impl( CIdx, source_filename, command_line_args, num_command_line_args, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU); @@ -6621,9 +6623,10 @@ void clang_executeOnThread(void (*fn)(void*), void *user_data, unsigned stack_size) { - llvm::llvm_execute_on_thread( - fn, user_data, - stack_size == 0 ? llvm::None : llvm::Optional<unsigned>(stack_size)); + llvm::llvm_execute_on_thread(fn, user_data, + stack_size == 0 + ? clang::DesiredStackSize + : llvm::Optional<unsigned>(stack_size)); } //===----------------------------------------------------------------------===// Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -12930,7 +12930,8 @@ // expression or statement in the body of the function [and thus before // the value computation of its result]. SequencedSubexpression Sequenced(*this); - Base::VisitCallExpr(CE); + SemaRef.runWithSufficientStackSpace(CE->getExprLoc(), + [&] { Base::VisitCallExpr(CE); }); // FIXME: CXXNewExpr and CXXDeleteExpr implicitly call functions. }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits