aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseCXXInlineMethods.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-1/+1
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-06-14[C++20] add Basic consteval specifierGauthier Harnisch1-1/+1
Summary: this revision adds Lexing, Parsing and Basic Semantic for the consteval specifier as specified by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html with this patch, the consteval specifier is treated as constexpr but can only be applied to function declaration. Changes: - add the consteval keyword. - add parsing of consteval specifier for normal declarations and lambdas expressions. - add the whether a declaration is constexpr is now represented by and enum everywhere except for variable because they can't be consteval. - adapt diagnostic about constexpr to print constexpr or consteval depending on the case. - add tests for basic semantic. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: eraman, efriedma, rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61790 llvm-svn: 363362
2019-05-17[Lex] Allow to consume tokens while preprocessingIlya Biryukov1-5/+6
Summary: By adding a hook to consume all tokens produced by the preprocessor. The intention of this change is to make it possible to consume the expanded tokens without re-runnig the preprocessor with minimal changes to the preprocessor and minimal performance penalty when preprocessing without recording the tokens. The added hook is very low-level and reconstructing the expanded token stream requires more work in the client code, the actual algorithm to collect the tokens using this hook can be found in the follow-up change. Reviewers: rsmith Reviewed By: rsmith Subscribers: eraman, nemanjai, kbarton, jsji, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59885 llvm-svn: 361007
2019-01-28Rename getTypeQualifiers to getMethodQualifiers.Anastasia Stulova1-1/+1
Use more descriptive name for the method qualifiers getter. Differential Revision: https://reviews.llvm.org/D56792 llvm-svn: 352349
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-13[OpenCL] Add generic AS to 'this' pointerMikael Nilsson1-1/+1
Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 349019
2018-12-12Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson1-1/+1
Reverting because the patch broke lldb. llvm-svn: 348931
2018-12-12[OpenCL] Add generic AS to 'this' pointerMikael Nilsson1-1/+1
Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 348927
2018-11-01Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner1-4/+4
This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
2018-07-30Remove trailing spaceFangrui Song1-4/+4
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-07-12AttributeList de-listifying:Erich Keane1-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
2018-06-26Diagnose missing 'template' keywords in more cases.Richard Smith1-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
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-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
2017-08-12PR34163: Don't cache an incorrect key function for a class if queried betweenRichard Smith1-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
2017-08-10Place implictly declared functions at block scopeMomchil Velikov1-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
2017-07-13fix typos in comments; NFCHiroshi Inoue1-1/+1
llvm-svn: 307886
2017-05-18Fix the location of "missing ';'" suggestions after annotation tokens.Richard Smith1-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
2017-04-01[NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali1-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
2017-03-23Publish RAIIObjectsForParser.h for external usage.Vassil Vassilev1-1/+1
Some clients (eg the cling interpreter) need to recover their parser from errors. Patch by Axel Naumann (D31190)! llvm-svn: 298606
2016-11-17Use unique_ptr for cached tokens for default arguments in C++.Malcolm Parsons1-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
2016-11-03Fix heuristics skipping invalid ctor-initializers with C++11Olivier Goffart1-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
2016-06-16Fix a few issues while skipping function bodiesOlivier Goffart1-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
2016-06-10[-fms-extensions] Don't crash on explicit class-scope specializations & ↵David Majnemer1-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
2016-03-30For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann1-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
2016-03-17Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner1-4/+2
This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
2016-03-17For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner1-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
2016-02-19[Sema] PR25181 Fix crash when method declaration with throw spec fails to ↵Reid Kleckner1-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
2016-02-09Simplify EnterTokenStream API to make it more robust for memory managementDavid Blaikie1-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
2015-11-14Merge some similar diagnostics using %select.Craig Topper1-4/+6
llvm-svn: 253136
2015-10-20Roll-back r250822.Angel Garcia Gomez1-1/+1
Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
2015-10-20Apply modernize-use-default to clang.Angel Garcia Gomez1-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
2015-06-30Rework parsing of pure-specifiers. Perform the grammar matching andRichard Smith1-7/+3
disambiguation in the parser rather than trying to do it in Sema. llvm-svn: 241032
2015-06-18[clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki1-5/+4
is(). llvm-svn: 240008
2015-03-23Cleanup: no need to pass DefinitionKind into ParseCXXInlineMethodDefEli Bendersky1-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
2015-03-23Record correct source range for defaulted/deleted members.Eli Bendersky1-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
2015-03-19Parse: Don't assume tokens have a lengthDavid Majnemer1-7/+3
Don't crash if the last token in a bad inline method body is an annotation token. llvm-svn: 232694
2015-02-19FIX PR 18432, default args, friends & late-parsed members.Nathan Sidwell1-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
2015-01-30Code cleanupNathan Sidwell1-10/+8
Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
2015-01-13Parse: use the EOF token method to lex inline method bodiesDavid Majnemer1-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
2015-01-13Parse: Further simplify ParseLexedMethodDeclarationDavid Majnemer1-30/+33
No functionality change intended, just moving code around to make it simpler. llvm-svn: 225763
2015-01-12Parse: Get rid of cxx_exceptspec_end, use EOF insteadDavid Majnemer1-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
2015-01-12Parse: Just a small tidy-up in ParseLexedMethodDeclarationDavid Majnemer1-5/+7
No functional change intended, just tidy up the parse flow. llvm-svn: 225620
2015-01-12Parse: Get rid of tok::cxx_defaultarg_end, use EOF insteadDavid Majnemer1-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
2015-01-12Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directlyDavid Majnemer1-0/+1
llvm-svn: 225616
2014-12-28Don't crash on surprising tokens in default parameter template lists.Nico Weber1-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
2014-12-19Fix layering violation, Lex shouldn't know about DeclDavid Majnemer1-2/+2
llvm-svn: 224562
2014-12-18Parse: Don't parse after the eof has been consumedDavid Majnemer1-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
2014-11-20PR21565: Further refine the conditions for enabling eager parsing ofRichard Smith1-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
2014-11-20Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata1-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
2014-11-13PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith1-0/+70
is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918