summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseCXXInlineMethods.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-4/+4
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* AttributeList de-listifying:Erich Keane2018-07-121-6/+4
| | | | | | | | | | | Basically, "AttributeList" loses all list-like mechanisms, ParsedAttributes is switched to use a TinyPtrVector (and a ParsedAttributesView is created to have a non-allocating attributes list). DeclaratorChunk gets the later kind, Declarator/DeclSpec keep ParsedAttributes. Iterators are added to the ParsedAttribute types so that for-loops work. llvm-svn: 336945
* Diagnose missing 'template' keywords in more cases.Richard Smith2018-06-261-0/+8
| | | | | | | | | | | | | | | | | | | | We track when we see a name-shaped expression followed by a '<' token and parse the '<' as a comparison. Then: * if we see a token sequence that cannot possibly be an expression but can be a template argument (in particular, a type-id) that follows either a ',' or the '<', diagnose that the '<' was supposed to start a template argument list, and * if we see '>()', diagnose that the '<' was supposed to start a template argument list. This only changes the diagnostic for error cases, and in practice appears to catch the most common cases where a missing 'template' keyword leads to parse errors within a template. Differential Revision: https://reviews.llvm.org/D48571 llvm-svn: 335687
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-3/+3
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* PR34163: Don't cache an incorrect key function for a class if queried betweenRichard Smith2017-08-121-18/+5
| | | | | | | | | | | the class becoming complete and its inline methods being parsed. This replaces the hack of using the "late parsed template" flag to track member functions with bodies we've not parsed yet; instead we now use the "will have body" flag, which carries the desired implication that the function declaration *is* a definition, and that we've just not parsed its body yet. llvm-svn: 310776
* Place implictly declared functions at block scopeMomchil Velikov2017-08-101-1/+2
| | | | | | | | | | | | Such implicitly declared functions behave as if the enclosing block contained the declaration extern int name() (C90, 6.3.3.2 Function calls), thus their names should have block scope (C90, 6.1.2.1 Scope of identifiers). This patch fixes https://bugs.llvm.org/show_bug.cgi?id=33224 Differential Revision: https://reviews.llvm.org/D33676 llvm-svn: 310616
* fix typos in comments; NFCHiroshi Inoue2017-07-131-1/+1
| | | | llvm-svn: 307886
* Fix the location of "missing ';'" suggestions after annotation tokens.Richard Smith2017-05-181-14/+1
| | | | | | | | | | We were incorrectly setting PrevTokLocation to the first token in the annotation token instead of the last when consuming it. To fix this without adding a complex switch to the hot path through ConsumeToken, we now have a ConsumeAnnotationToken function for consuming annotation tokens in addition to the other Consume*Token special case functions. llvm-svn: 303372
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-3/+3
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* Publish RAIIObjectsForParser.h for external usage.Vassil Vassilev2017-03-231-1/+1
| | | | | | | | | Some clients (eg the cling interpreter) need to recover their parser from errors. Patch by Axel Naumann (D31190)! llvm-svn: 298606
* Use unique_ptr for cached tokens for default arguments in C++.Malcolm Parsons2016-11-171-4/+2
| | | | | | | | | | | | | | | | | Summary: This changes pointers to cached tokens for default arguments in C++ from raw pointers to unique_ptrs. There was a fixme in the code where the cached tokens are created about using a smart pointer. The change is straightforward, though I did have to track down and fix a memory corruption caused by the change. memcpy was being used to copy parameter information. This duplicated the unique_ptr, which led to the cached token buffer being deleted prematurely. Patch by David Tarditi! Reviewers: malcolm.parsons Subscribers: arphaman, malcolm.parsons, cfe-commits Differential Revision: https://reviews.llvm.org/D26435 llvm-svn: 287241
* Fix heuristics skipping invalid ctor-initializers with C++11Olivier Goffart2016-11-031-9/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | Use better heuristics to detect if a '{' might be the start of the constructor body or not. Especially when there is a completion token. Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to c++11 The problem was is how we recover invalid code in the ctor-init part as we skip the function body. In particular, we want to know if a '{' is the begining of the body. In C++03, we always consider it as the beginng of the body. The problem was that in C++11, it may be the start of an initializer, so we skip over it, causing further parse errors later. (It is important that we are able to parse correctly the rest of the class definition, to know what are the class member, for example) This commit is improving the heuristics to decide if the '{' is starting a function body. The rules are the following: If we are not in a template argument, and that the previous tokens are not an identifier, or a >, then it is much more likely to be the function body. We verify that further by checking the token after the matching '}' The commit also fix the behavior when there is a code_completion token in the ctor-initializers. Differential Revision: https://reviews.llvm.org/D21502 llvm-svn: 285883
* Fix a few issues while skipping function bodiesOlivier Goffart2016-06-161-0/+6
| | | | | | | | | | | | | | | | | | | | - In functions with try { } catch { }, only the try block would be skipped, not the catch blocks - The template functions would still be parsed. - The initializers within a constructor would still be parsed. - The inline functions within class would still be stored, only to be discared later. - Invalid code with try would assert (as in "int foo() try assert_here") This attempt to do even less while skipping function bodies. Differential Revision: http://reviews.llvm.org/D20821 llvm-svn: 272963
* [-fms-extensions] Don't crash on explicit class-scope specializations & ↵David Majnemer2016-06-101-1/+1
| | | | | | | | | | | | | | default arguments The code had a typo it was doing: Param->setUninstantiatedDefaultArg(Param->getUninstantiatedDefaultArg()); This is a no-op but may assert, we wanted to do: Param->setUninstantiatedDefaultArg(OldParam->getUninstantiatedDefaultArg()); This fixes PR28082. llvm-svn: 272425
* For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann2016-03-301-2/+4
| | | | | | | | | | | | | | ...as that is apparently what MSVC does. This is an updated version of r263738, which had to be reverted in r263740 due to test failures. The original version had erroneously emitted functions that are defined in class templates, too (see the updated "Handle friend functions" code in EmitDeferredDecls, lib/CodeGen/ModuleBuilder.cpp). (The updated tests needed to be split out into their own dllexport-ms-friend.cpp because of the CHECK-NOTs which would have interfered with subsequent CHECK-DAGs in dllexport.cpp.) Differential Revision: http://reviews.llvm.org/D18430 llvm-svn: 264841
* Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner2016-03-171-4/+2
| | | | | | | | | This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
* For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner2016-03-171-2/+4
| | | | | | | | | | | | Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
* [Sema] PR25181 Fix crash when method declaration with throw spec fails to ↵Reid Kleckner2016-02-191-1/+2
| | | | | | | | | | | | | | | parse correctly Fixes crash referenced in PR25181 where dyn_cast is called on a null instance of LM.Method. Reviewers: majnemer, rnk Patch by Don Hinton Differential Revision: http://reviews.llvm.org/D17072 llvm-svn: 261292
* Simplify EnterTokenStream API to make it more robust for memory managementDavid Blaikie2016-02-091-7/+7
| | | | | | | | | | | | | | | While this won't help fix things like the bug that r260219 addressed, it seems like good tidy up to have anyway. (it might be nice if "makeArrayRef" always produced a MutableArrayRef & let it decay to an ArrayRef when needed - then I'd use that for the MutableArrayRefs in this patch) If we had std::dynarray I'd use that instead of unique_ptr+size_t, ideally (but then it'd have to be threaded down through the Preprocessor all the way - no idea how painful that would be) llvm-svn: 260246
* Merge some similar diagnostics using %select.Craig Topper2015-11-141-4/+6
| | | | llvm-svn: 253136
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Rework parsing of pure-specifiers. Perform the grammar matching andRichard Smith2015-06-301-7/+3
| | | | | | disambiguation in the parser rather than trying to do it in Sema. llvm-svn: 241032
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-5/+4
| | | | | | is(). llvm-svn: 240008
* Cleanup: no need to pass DefinitionKind into ParseCXXInlineMethodDefEli Bendersky2015-03-231-5/+3
| | | | | | | | | | All ParseCXXInlineMethodDef does with it is assign it on the ParsingDeclarator. Since that is passed in as well, the (single) caller may as well set the DefinitionKind, thus simplifying the code. No change in functionality. llvm-svn: 233043
* Record correct source range for defaulted/deleted members.Eli Bendersky2015-03-231-0/+7
| | | | | | | | | | | | | | | | | | | Fixes https://llvm.org/bugs/show_bug.cgi?id=20744 struct A { A() = default; }; Previously the source range of the declaration of A ended at the ')'. It should include the '= default' part as well. The same for '= delete'. Note: this will break one of the clang-tidy fixers, which is going to be addessed in a follow-up patch. Differential Revision: http://reviews.llvm.org/D8465 llvm-svn: 233028
* Parse: Don't assume tokens have a lengthDavid Majnemer2015-03-191-7/+3
| | | | | | | Don't crash if the last token in a bad inline method body is an annotation token. llvm-svn: 232694
* FIX PR 18432, default args, friends & late-parsed members.Nathan Sidwell2015-02-191-1/+12
| | | | | | | | | | | | Sema::MergeCXXFunctionDecl: propagate hasUnparsedDefaultArg to new decl. Parser::HandleMemberFunctionDeclDelays: check hasUnparsedDefaultArg flag. Parser::ParseLexedMethodDeclaration: handle inherited unparsed default arg case. llvm-svn: 229852
* Code cleanupNathan Sidwell2015-01-301-10/+8
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Parse: use the EOF token method to lex inline method bodiesDavid Majnemer2015-01-131-20/+23
| | | | | | | | Mark the end of the method body with an EOF token, collect it once we expect to be done with method body parsing. No functionality change intended. llvm-svn: 225765
* Parse: Further simplify ParseLexedMethodDeclarationDavid Majnemer2015-01-131-30/+33
| | | | | | | No functionality change intended, just moving code around to make it simpler. llvm-svn: 225763
* Parse: Get rid of cxx_exceptspec_end, use EOF insteadDavid Majnemer2015-01-121-2/+5
| | | | | | | | Similar to r225619, use a special EOF token to mark the end of the exception specification instead of cxx_exceptspec_end. Use the current scope as the marker. llvm-svn: 225622
* Parse: Just a small tidy-up in ParseLexedMethodDeclarationDavid Majnemer2015-01-121-5/+7
| | | | | | No functional change intended, just tidy up the parse flow. llvm-svn: 225620
* Parse: Get rid of tok::cxx_defaultarg_end, use EOF insteadDavid Majnemer2015-01-121-3/+7
| | | | | | | I added setEofData/getEofData to solve this sort of problem back in r224505. Use the Param's decl to tell us if this is *our* EOF token. llvm-svn: 225619
* Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directlyDavid Majnemer2015-01-121-0/+1
| | | | llvm-svn: 225616
* Don't crash on surprising tokens in default parameter template lists.Nico Weber2014-12-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixes this snippet from SLi's afl fuzzer output: class { i (x = <, enum This parsed i as a function, x as a paramter, and the stuff after < as a template list. This then called TryConsumeDeclarationSpecifier() which called TryAnnotateCXXScopeToken() without checking the preconditions of this function. Check them before calling, like all other callers of TryAnnotateCXXScopeToken() do. A more readable reproducer that causes the same crash is class { void i(int x = MyTemplateClass<int, union int>::foo()); }; The reduced version used an eof token as surprising token, but kw_int works just as well to repro and is easier to insert into a test file. llvm-svn: 224906
* Fix layering violation, Lex shouldn't know about DeclDavid Majnemer2014-12-191-2/+2
| | | | llvm-svn: 224562
* Parse: Don't parse after the eof has been consumedDavid Majnemer2014-12-181-1/+4
| | | | | | | | | | | | | | ParseCXXNonStaticMemberInitializer stashes away all the tokens for the initializer and an additional EOF token to denote where the initializer ends. However, it is possible for ParseLexedMemberInitializer to get its hands on the "real" EOF token; since the two tokens are indistinguishable, we end up consuming the EOF and descend into madness. Instead, make it possible to tell which EOF token we are looking at. This fixes PR21872. llvm-svn: 224505
* PR21565: Further refine the conditions for enabling eager parsing ofRichard Smith2014-11-201-7/+6
| | | | | | | | std::X::swap exception specifications (allowing parsing of non-conforming code in libstdc++). The old conditions also matched the functions in MSVC's STL, which were relying on deferred parsing here. llvm-svn: 222471
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-0/+1
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). llvm-svn: 222464
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-0/+70
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* PR20760: Don't assert (and produce better diagnostics) if a default initializerRichard Smith2014-08-271-18/+29
| | | | | | contains an unmatched closing bracket token. llvm-svn: 216518
* Fix default argument comma disambiguation bug following the 'template' keyword.Richard Smith2014-07-271-0/+1
| | | | llvm-svn: 214051
* Avoid crash if default argument parsed with errors.Serge Pavlov2014-07-221-1/+2
| | | | | | | | | | | | | | If function parameters have default values, and that of the second parameter is parsed with errors, function declaration would have a parameter without default value that follows a parameter with that. Such declaration breaks logic of selecting overloaded function. As a solution, put opaque object as default value in such case. This patch fixes PR20055. Differential Revision: http://reviews.llvm.org/D4378 llvm-svn: 213594
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-2/+2
| | | | | | takeAs to getAs. llvm-svn: 209800
* Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg2014-05-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR11170) The previous code that was supposed to handle this didn't work since parsing of inline method definitions is delayed to the end of the outer class definition. Thus, when HandleTagDeclDefinition() got called for the inner class, the inline functions in that class had not been parsed yet. Richard suggested that the way to do this is by handling inline method definitions through a new ASTConsumer callback. I really wanted to call ASTContext::DeclMustBeEmitted() instead of checking for attributes, but doing that causes us to compute linkage, and then we fail with "error: unsupported: typedef changes linkage of anonymous type, but linkage was already computed" on tests like this: (from SemaCXX/undefined-internal.cpp) :-/ namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } Differential Revision: http://reviews.llvm.org/D3809 llvm-svn: 209549
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-5/+6
| | | | llvm-svn: 209275
* Replace a fake enum class with the real thing.Richard Smith2014-05-161-6/+6
| | | | llvm-svn: 208943
* Wrap to 80 columns. No behavior change.Nico Weber2014-05-101-8/+12
| | | | llvm-svn: 208475
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-1/+1
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
OpenPOWER on IntegriCloud