llvm-project/clang/test/Parser
Matt Beaumont-Gay d0457924e3 Fix a crash-on-invalid.
The token stream was not getting properly reset when leaving
ParseLexedMethodDef in some error cases. In the testcase, that caused later
accesses to the token stream to touch memory which had been freed as we
finished parsing the class definition. Major hat-tip to AddressSanitizer for
helping pinpoint the use-after-free, including the allocation and deallocation
points:

==21510== ERROR: AddressSanitizer heap-use-after-free on address 0x7feb3de87848 at pc 0x249f4e2 bp 0x7fff15a89df0 sp 0x7fff15a89ce0
READ of size 1 at 0x7feb3de87848 thread T0
  #0 0x249f4e2 clang::TokenLexer::Lex()
  #1 0x1c834a0 clang::Parser::ConsumeToken()
  #2 0x1c7dc0f clang::Parser::ParseDeclarationOrFunctionDefinition()
  #3 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>
0x7feb3de87848 is located 1992 bytes inside of 3816-byte region [0x7feb3de87080,0x7feb3de87f68)
freed by thread T0 here:
  #0 0x3a22c19 free
  #1 0x1d136a1 clang::Parser::LexedMethod::~LexedMethod()
  #2 0x1cef528 clang::Parser::DeallocateParsedClasses()
  #3 0x1cef676 clang::Parser::PopParsingClass()
  #4 0x1cea094 clang::Parser::ParseCXXMemberSpecification()
  #5 0x1ce7ae5 clang::Parser::ParseClassSpecifier()
  #6 0x1cfe588 clang::Parser::ParseDeclarationSpecifiers()
  #7 0x1c7dbe8 clang::Parser::ParseDeclarationOrFunctionDefinition()
  #8 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>
previously allocated by thread T0 here:
  #0 0x3a2302d realloc
  #1 0x39d7c97 llvm::SmallVectorBase::grow_pod()
  #2 0x1ac588e llvm::SmallVectorImpl<>::push_back()
  #3 0x1d12d8b clang::Parser::ConsumeAndStoreUntil()
  #4 0x1c9c24d clang::Parser::ConsumeAndStoreUntil()
  #5 0x1d12c1e clang::Parser::ConsumeAndStoreUntil()
  #6 0x1c9c24d clang::Parser::ConsumeAndStoreUntil()
  #7 0x1d10042 clang::Parser::ParseCXXInlineMethodDef()
  #8 0x1cec51a clang::Parser::ParseCXXClassMemberDeclaration()
  #9 0x1ce9de5 clang::Parser::ParseCXXMemberSpecification()
  #10 0x1ce7ae5 clang::Parser::ParseClassSpecifier()
  #11 0x1cfe588 clang::Parser::ParseDeclarationSpecifiers()
  #12 0x1c7dbe8 clang::Parser::ParseDeclarationOrFunctionDefinition()
  #13 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>

llvm-svn: 140427
2011-09-23 22:39:23 +00:00
..
CompoundStmtScope.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
DelayedTemplateParsing.cpp [microsoft] Fix a bug in -fdelayed-template-parsing mode where we were not reentering the delayed function context correctly. The problem was that all template params were reintroduced inside the same scope. So if we had a situation where we had 2 template params with the same name at different scope then clang would generate an error about ambiguous name. 2011-09-22 22:14:56 +00:00
MicrosoftExtensions.c Add support for Microsoft __ptr32 keyword. 2011-08-25 00:36:46 +00:00
MicrosoftExtensions.cpp Add support for Microsoft __if_exists, __if_not_exists extension at class scope. 2011-05-25 10:19:49 +00:00
altivec.c Remove some more hard CR-LF lines. These were particularly weird as they were 2011-04-25 07:09:43 +00:00
argument_qualified.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
argument_redef.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
argument_scope.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
asm-constraints-pr7869.c Added '|' delimiter to separate inline asm multiple alternative constraints for Clang side of support. 2010-09-18 01:15:13 +00:00
asm.c Fix PR7673 by allowing an empty clobbers section in an ASM statement. 2010-07-22 07:11:21 +00:00
attr-availability.c Add a __has_feature check for the 'availability' attribute 2011-03-26 12:16:15 +00:00
attributes.c fix PR6287 by accepting and ignoring the returns_twice attribute. 2010-04-12 02:18:38 +00:00
backtrack-crash.cpp we do in fact have to cache the EOF token returned by the preprocessor. 2010-07-12 04:25:32 +00:00
bad-control.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
block-block-storageclass.c Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00
block-pointer-decl.c Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00
bracket-crash.cpp revert a hunk of code that Argiris added in r106213, which is the 2010-07-12 01:48:28 +00:00
builtin_classify_type.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
builtin_types_compatible.c Improve diagnostics when we fail to convert from a source type to a 2010-04-09 00:35:39 +00:00
c-namespace.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
c1x-generic-selection.c C1X: implement generic selections 2011-04-15 00:35:48 +00:00
char-literal-printing.c This patch makes the string/character literal tests run in C, 2011-07-29 01:08:54 +00:00
check-objc2-syntax-1.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
check-syntax-1.m Cleanup error recovery for a missing '-'|'+' 2010-04-26 21:18:08 +00:00
check_cast.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
compound_literal.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
control-scope.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cuda-kernel-call.cu Parse: add support for parsing CUDA kernel calls 2011-02-09 21:12:02 +00:00
cxx-altivec.cpp comparison of AltiVec vectors now gives bool result (fix for 7533) 2010-11-18 03:19:30 +00:00
cxx-ambig-decl-expr-xfail.cpp When we're performing tentative parsing to determine whether the 2010-07-15 21:05:01 +00:00
cxx-ambig-decl-expr.cpp When we're performing tentative parsing to determine whether the 2010-07-15 21:05:01 +00:00
cxx-ambig-paren-expr.cpp Teach TryAnnotateTypeOrScopeToken to deal with already-annotated 2009-12-19 00:35:18 +00:00
cxx-attributes.cpp Convert this file to not have Windows line endings -- likely committed from 2010-08-05 03:16:33 +00:00
cxx-bool.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-casting.cpp Fix a problem in digraph handling where "[:" might be treated as "<::" and 2011-09-20 20:03:50 +00:00
cxx-class.cpp Parse the optional semicolon after a C++ in-class member function 2011-01-19 16:41:58 +00:00
cxx-condition.cpp Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00
cxx-decl.cpp Avoid superfluous warning after an error is detcted and reported. 2011-04-19 21:42:37 +00:00
cxx-default-args.cpp Change warning about incomplete parsing of C++ default arg to error and provide a test case; thanks Doug! 2010-08-09 21:08:13 +00:00
cxx-default-delete.cpp Implement a few basic tests for defaulted and deleted functions. 2011-05-13 01:01:05 +00:00
cxx-ext-delete-default.cpp Implement a few basic tests for defaulted and deleted functions. 2011-05-13 01:01:05 +00:00
cxx-extern-c-array.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-friend.cpp Tweak the diagnostics for the C++0x extensions to friend types to note 2011-05-10 21:23:31 +00:00
cxx-in-c.c Fix test for previous commit 2011-02-04 11:59:47 +00:00
cxx-member-crash.cpp If the declaration of a C++ member function with an inline definition 2011-04-14 23:19:27 +00:00
cxx-member-init-missing-paren-crash.cpp Fix a crash-on-invalid. 2011-09-23 22:39:23 +00:00
cxx-member-initializers.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-namespace-alias.cpp Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00
cxx-reference.cpp Downgrade the error about rvalue references to an extension warning 2011-01-25 02:17:32 +00:00
cxx-stmt.cpp Add -fcxx-exceptions to all tests that use C++ exceptions. 2011-02-28 00:40:07 +00:00
cxx-template-argument.cpp When we're inside a functional cast, '>' is an operator. Fixes PR8912. 2011-01-11 00:33:19 +00:00
cxx-template-decl.cpp When we are missing the ',' or '>' to terminate a template parameter 2010-10-15 01:15:58 +00:00
cxx-throw.cpp Add -fcxx-exceptions to all tests that use C++ exceptions. 2011-02-28 00:40:07 +00:00
cxx-typeid.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-typeof.cpp Preserve invalidity of typeof operands in C++. 2010-08-24 23:41:43 +00:00
cxx-undeclared-identifier.cpp Fix PR7180. 2010-06-22 11:30:04 +00:00
cxx-using-declaration.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-using-directive.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx-variadic-func.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
cxx0x-attributes.cpp Parsing of C++0x lambda expressions, from John Freeman with help from 2011-08-04 15:30:47 +00:00
cxx0x-in-cxx98.cpp Improve the extension warning for the use of ref-qualifiers, to 2011-01-26 20:35:32 +00:00
cxx0x-lambda-expressions.cpp Parsing of C++0x lambda expressions, from John Freeman with help from 2011-08-04 15:30:47 +00:00
cxx0x-literal-operators.cpp Allow C99 hexfloats in C++0x mode. This change resolves the standards 2011-08-30 22:40:35 +00:00
cxx0x-member-initializers.cpp Implement support for C++11 in-class initialization of non-static data members. 2011-06-11 17:19:42 +00:00
cxx0x-override-control-keywords.cpp Remove 'new' from virt-specifier since it's going to be removed in the next C++0x draft 2011-03-25 11:19:41 +00:00
cxx0x-rvalue-reference.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
declarators.c ...I forgot to check my new test after adding it, and lo, there's slightly different 2010-08-26 17:42:30 +00:00
designator.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
encode.m Enhance the array bounds checking to work for several other constructs, 2011-02-17 21:10:52 +00:00
enhanced-proto-1.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
expressions.c Diagnose a missing ')' on what looks like a statement expression. 2011-04-06 02:35:25 +00:00
expressions.m Revert r114316, -Wunused-value enabled by default was intended. 2010-09-19 23:03:35 +00:00
extension.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
for.cpp Improve parser recovery in "for" statements, from Richard Smith! 2011-02-17 03:38:46 +00:00
function-decls.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
goto.c implement basic support for __label__. I wouldn't be shocked if there are 2011-02-18 02:08:43 +00:00
if-scope-c90.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
if-scope-c99.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
implicit-casts.c Improve diagnostics when we fail to convert from a source type to a 2010-04-09 00:35:39 +00:00
knr_parameter_attributes.c Retain attributes for K&R style parameter declarations. 2010-02-23 12:22:13 +00:00
method-def-in-class.m Better parser recovery when method is 2011-02-23 00:11:21 +00:00
method-prototype-1.m Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00
missing-end-2.m Diagnose a coherant message when @interface 2010-11-02 00:44:43 +00:00
missing-end-3.m Issues good diagnostic when @end is missing. 2010-11-09 20:38:00 +00:00
missing-end.m Don't consume tokens past the end-of-file in an @interface. Fixes 2010-03-16 06:04:47 +00:00
namelookup-bug-1.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
namelookup-bug-2.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
namespace-alias-attr.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
namespaces.cpp Namespaces can only be defined at global or namespace scope. Fixes PR6596. 2010-05-14 05:08:22 +00:00
nested-namespaces-recovery.cpp Add a fix-it and better error recovery for improperly nested namespaces. This will give a better error message for cases such as "namespace foo::bar::baz {}" and a suggested fix-it of "namespace foo { namespace bar { namespace baz {} } }" 2011-05-26 20:11:09 +00:00
objc-alias-printing.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
objc-category-neg-1.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
objc-forcollection-1.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
objc-forcollection-neg-2.m Fix scoping of method declarations and issue 2011-02-09 22:20:01 +00:00
objc-forcollection-neg.m Fix scoping of method declarations and issue 2011-02-09 22:20:01 +00:00
objc-foreach-syntax.m Fix scoping of method declarations and issue 2011-02-09 22:20:01 +00:00
objc-init.m Implement parsing for message sends in Objective-C++. Message sends in 2010-04-21 22:36:40 +00:00
objc-interfaces.m Improve error recovery when we see ':' and expect a ';'. 2010-09-07 18:31:03 +00:00
objc-messaging-1.m Revert r114316, -Wunused-value enabled by default was intended. 2010-09-19 23:03:35 +00:00
objc-messaging-neg-1.m Parsing of C++0x lambda expressions, from John Freeman with help from 2011-08-04 15:30:47 +00:00
objc-missing-impl.m Fixes an instance method meta-data generation bug in 2011-04-22 22:02:28 +00:00
objc-property-syntax.m Use Parser::ExpectAndConsume() uniformly to eat semicolons after 2011-01-05 01:10:06 +00:00
objc-quirks.m Use Parser::ExpectAndConsume() uniformly to eat semicolons after 2011-01-05 01:10:06 +00:00
objc-synthesized-recover.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
objc-try-catch-1.m Make clang -cc1 disable Objective-C exceptions by default, and add a -fobjc-exceptions flag to turn them on. 2011-02-22 01:52:06 +00:00
objc-type-printing.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
objcxx-at.mm Parse an '@' in an Objective-C++ class member specification, 2011-04-14 17:21:19 +00:00
objcxx-lambda-expressions-neg.mm Parsing of C++0x lambda expressions, from John Freeman with help from 2011-08-04 15:30:47 +00:00
objcxx0x-lambda-expressions.mm Parsing of C++0x lambda expressions, from John Freeman with help from 2011-08-04 15:30:47 +00:00
offsetof.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
opencl-astype.cl Modify a diagnostic introduced in r132612 to emit QualTypes directly 2011-06-08 15:15:17 +00:00
opencl-image-access.cl Add support for language-specific address spaces. On top of that, 2011-03-18 22:38:29 +00:00
opencl-kernel.cl OpenCL: add support for __kernel, kernel keywords and EXTENSION, 2011-02-14 01:42:53 +00:00
opencl-pragma.cl OpenCL: add support for __kernel, kernel keywords and EXTENSION, 2011-02-14 01:42:53 +00:00
opencl-storage-class.cl OpenCL: standardise naming of test cases 2011-02-15 19:46:41 +00:00
parenthesis-balance.cpp For code such as: 2011-07-01 20:54:02 +00:00
parmvardecl_conversion.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
placeholder-recovery.m When parsing something that looks like an ill-formed 2010-11-19 17:10:50 +00:00
pointer-arithmetic.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
pointer_promotion.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
pragma-options.c Parser: Add support for #pragma align, which is just another spelling of #pragma 2010-07-31 19:17:07 +00:00
pragma-pack.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
pragma-visibility.c Tests for #pragma GCC visibility. 2010-08-05 07:00:53 +00:00
pragma-visibility2.c PR10392: "#pragma GCC visibility" must not expand macros in its 2011-07-20 01:03:50 +00:00
pragma-weak.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
prefix-attributes.m Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
promote_types_in_proto.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
recovery.c Make the Preprocessor more memory efficient and improve macro instantiation diagnostics. 2011-07-07 03:40:34 +00:00
recovery.m Fix the recovery from missing semis on @property declarations to not consume 2011-03-26 01:53:26 +00:00
selector-1.m fix the second part of rdar://8366474 - clang fails to parse ObjC selectors with '::', when :: isn't the first part of the selector. 2011-03-26 18:11:38 +00:00
statements.c Don't skip past the '}' if an expression has error and is not followed by ';'. 2010-03-31 00:37:59 +00:00
struct-recursion.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
switch-recovery.cpp Remove the last FIXMEs on -Wunused-comparison since it got moved to 2011-08-18 02:04:29 +00:00
top-level-semi-cxx0x.cpp Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
traditional_arg_scope.c Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. 2009-12-15 20:14:24 +00:00
typeof.c The grammar for GNU typeof in C requires an expression to be 2010-07-28 18:22:12 +00:00
types.c Eliminate the "minimal" and printing parser actions, which only ever 2010-07-26 04:08:02 +00:00