llvm-project/clang/lib
Reid Kleckner c2fd352963 [Sema] Make getCurFunction() return null outside function parsing
Summary:
Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in
the first, always present element of the FunctionScopes stack. This
meant that Sema::getCurFunction would return a pointer to this
pre-allocated object when parsing code outside a function body. This is
pretty much always a bug, so this patch moves the pre-allocated object
into a separate unique_ptr. This should make bugs like PR36536 a lot
more obvious.

As you can see from this patch, there were a number of places that
unconditionally assumed they were always called inside a function.
However, there are also many places that null checked the result of
getCurFunction(), so I think this is a reasonable direction.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 326965
2018-03-08 00:14:34 +00:00
..
ARCMigrate Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:19 +00:00
AST Reland r326766 (with a slightly modified test) 2018-03-07 04:52:34 +00:00
ASTMatchers PR36581: Support data recursion over Stmts in AST matchers. 2018-03-02 21:55:03 +00:00
Analysis Fix an unused variable warning; NFC 2018-03-06 07:45:11 +00:00
Basic Correct the alignment for the PS4 target 2018-03-07 20:48:16 +00:00
CodeGen Set dso_local on tls init functions. 2018-03-07 23:18:06 +00:00
CrossTU [CrossTU] Fix handling of Cross Translation Unit directory path 2017-10-27 12:53:37 +00:00
Driver [Driver] Enable SafeStack by default on Fuchsia 2018-03-07 02:49:58 +00:00
Edit [NFC] Extract method to SourceManager for traversing the macro "stack" 2018-02-09 23:30:07 +00:00
Format [clang-format] Break consecutive string literals in text protos 2018-03-07 21:30:38 +00:00
Frontend [FrontEnd] Allow overriding the default C/C++ -std via CMake vars 2018-03-06 21:26:28 +00:00
FrontendTool Make a build bot happy. 2018-02-10 14:26:53 +00:00
Headers [X86] Fix typo in cpuid.h, bit_AVX51SER->bit_AVX512ER. 2018-03-06 16:06:44 +00:00
Index [Index] fix USR generation for namespace{extern{X}} 2018-02-02 14:13:37 +00:00
Lex [ObjC] Allow declaring __strong pointer fields in structs in Objective-C 2018-02-28 07:15:55 +00:00
Parse [MS] Accept __unaligned as a qualifier on member function pointers 2018-03-07 23:26:02 +00:00
Rewrite [analyzer] Show full analyzer invocation for reproducibility in HTML reports 2018-01-23 19:28:52 +00:00
Sema [Sema] Make getCurFunction() return null outside function parsing 2018-03-08 00:14:34 +00:00
Serialization [NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.) 2018-03-02 00:07:45 +00:00
StaticAnalyzer [analyzer] [PointerArithChecker] do not warn on indexes into vector types 2018-03-07 22:20:39 +00:00
Tooling Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>" 2018-02-27 15:54:55 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00