llvm-project/clang/test
Reid Kleckner b2da086103 Push a function scope when parsing function bodies without a declaration
Summary:
This is PR36536.

There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null
Decl. Currently, the parser continues on to attempt to parse the
statements in the function body without pushing a function scope or
declaration context. However, lots of statement parsing logic relies on
getCurFunction() returning something reasonable. It turns out that
getCurFunction() will never return null today because of an optimization
where Sema pre-allocates one FunctionScopeInfo and reuses it when
possible. This goes wrong when something inside the function body causes
us to push another function scope, such as requiring an implicit
definition of a special member function. Reusing the state clears it
out, which will lead to bugs. In PR36536, we found that the SwitchStack
gets unbalanced, because we push a switch, clear out the stack, and then
try to pop a switch that isn't there.

As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out
of the FunctionScopes stack. This means the FunctionScopes stack will
often be empty, and callers of getCurFunction() will need to check for
null.

Reviewers: thakis

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D43980

llvm-svn: 326926
2018-03-07 18:55:10 +00:00
..
ARCMT [ObjC] Allow declaring __strong pointer fields in structs in Objective-C 2018-02-28 07:15:55 +00:00
ASTMerge [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl 2018-02-14 11:18:00 +00:00
Analysis [analyzer] Fix the checker for the performance anti-pattern to accept messages 2018-03-07 02:54:01 +00:00
CXX [Sema] Improve test coverage of narrowing conversion diagnostics 2018-03-02 10:03:02 +00:00
CodeCompletion [CodeComplete] Omit templated constructors from member list too. 2018-01-22 20:44:47 +00:00
CodeGen Fix a typo from r326844; NFC 2018-03-06 23:09:01 +00:00
CodeGenCUDA Really fix test on windows. 2018-02-23 19:38:41 +00:00
CodeGenCXX Remove a placeholder 2018-03-07 05:02:27 +00:00
CodeGenCoroutines Bring r325915 back. 2018-02-23 19:30:48 +00:00
CodeGenObjC Add an option to disable tail-call optimization for escaping blocks. 2018-03-02 01:53:15 +00:00
CodeGenObjCXX CodeGenObjCXX: handle inalloca appropriately for msgSend variant 2018-02-28 20:16:12 +00:00
CodeGenOpenCL Bring r325915 back. 2018-02-23 19:30:48 +00:00
Coverage
CoverageMapping [Coverage] Handle break/continue outside of loop bodies 2018-02-16 07:59:43 +00:00
Driver [Driver] Enable SafeStack by default on Fuchsia 2018-03-07 02:49:58 +00:00
FixIt [Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo 2018-02-08 14:37:58 +00:00
Format [clang-format] Fix bug where -dump-config failed on ObjC header 2018-01-29 17:36:43 +00:00
Frontend Recommit r324107 again. 2018-02-07 22:15:33 +00:00
Headers In stdbool.h, define bool, false, true only in gnu++98 2017-12-08 08:28:08 +00:00
Import [ASTImporter] Support LambdaExprs and improve template support 2018-01-26 11:36:54 +00:00
Index Clean up AMDGCN tests 2018-02-15 19:12:41 +00:00
Integration Fix the test fix from r312181 2017-08-30 23:26:38 +00:00
Layout
Lexer [ObjC] Allow declaring __strong pointer fields in structs in Objective-C 2018-02-28 07:15:55 +00:00
Misc Revert r326602, it caused PR36620. 2018-03-07 02:22:41 +00:00
Modules [modules] Don't diagnose "redefinition" of a friend with a pending definition 2018-03-01 22:20:13 +00:00
OpenMP [OPENMP] Fix lifetime of the loop counters. 2018-03-07 18:17:06 +00:00
PCH Start setting dllimport/dllexport in setGVProperties. 2018-03-01 00:35:47 +00:00
Parser Fix a couple of cases where we would fail to correctly parse deduced class template specialization types. 2018-02-28 03:02:23 +00:00
Preprocessor [RISCV] Enable __int128_t and __uint128_t through clang flag 2018-02-25 03:58:23 +00:00
Profile [PGO] Detect more structural changes with the stable hash 2017-11-14 23:56:53 +00:00
Refactor [refactor][extract] avoid extracting expressions from types in functions 2017-11-14 18:59:01 +00:00
Rewriter [clang] Remove unit test which uses reverse-iterate flag 2017-08-24 22:40:32 +00:00
Sema Revert r326602, it caused PR36620. 2018-03-07 02:22:41 +00:00
SemaCUDA [CUDA] Allow external variables in separate compilation 2018-02-14 16:04:03 +00:00
SemaCXX Push a function scope when parsing function bodies without a declaration 2018-03-07 18:55:10 +00:00
SemaObjC [ObjC] Allow declaring __strong pointer fields in structs in Objective-C 2018-02-28 07:15:55 +00:00
SemaObjCXX Add support for attribute 'trivial_abi'. 2018-02-05 20:23:22 +00:00
SemaOpenCL [OpenCL] Add "cles_khr_int64" extension. 2018-01-26 11:48:46 +00:00
SemaTemplate Fix assert when template argument deduction's original call arg checking triggers class template instantiation. 2018-02-20 23:47:12 +00:00
TableGen TableGen: Give up on exact fixits for diagnostic groups 2018-03-06 17:55:00 +00:00
Templight [Templight] Template Instantiation Observer 2018-02-10 14:04:45 +00:00
Tooling Fix test clang-diff-json.cpp 2018-02-10 21:28:55 +00:00
Unit [lit] Set shlibpath_var on Solaris 2017-11-27 13:33:19 +00:00
VFS Avoid assumption that lit tests are writable. NFC 2018-01-08 15:05:01 +00:00
clang-rename [clang-rename] Fix and enable the failing TemplatedClassFunction test. 2017-10-25 08:25:25 +00:00
.clang-format
CMakeLists.txt [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK 2018-02-14 22:41:15 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg.py [debuginfo] Remove temporary FIXME. 2017-12-14 22:12:46 +00:00
lit.site.cfg.py.in [lit] Add host_cxx to lit config 2017-10-10 17:53:45 +00:00
make_test_dirs.pl