aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/Parser.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-12-13[OPENMP]Fix skipping of functions body.Alexey Bataev1-0/+4
When parsing the code with OpenMP and the function's body must be skipped, need to skip also OpenMP annotation tokens. Otherwise the counters for braces/parens are unbalanced and parsing fails.
2019-10-14PR43080: Do not build context-sensitive expressions during name classification.Richard Smith1-12/+28
Summary: We don't know what context to use until the classification result is consumed by the parser, which could happen in a different semantic context. So don't build the expression that results from name classification until we get to that point and can handle it properly. This covers everything except C++ implicit class member access, which is a little awkward to handle properly in the face of the protected member access check. But it at least fixes all the currently-filed instances of PR43080. Reviewers: efriedma Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68896 llvm-svn: 374826
2019-09-13[NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.Erich Keane1-2/+1
In order to enable future improvements to our attribute diagnostics, this moves info from ParsedAttr into CommonAttributeInfo, then makes this type the base of the *Attr and ParsedAttr types. Quite a bit of refactoring took place, including removing a bunch of redundant Spelling Index propogation. Differential Revision: https://reviews.llvm.org/D67368 llvm-svn: 371875
2019-08-01[Parser] Change parameter type from int to enumSerge Pavlov1-2/+2
Some parser functions accept argument of type unsigned while it is actually of type DeclSpec::TST. No functional changes. Differential Revision: https://reviews.llvm.org/D65406 llvm-svn: 367545
2019-05-17[Lex] Allow to consume tokens while preprocessingIlya Biryukov1-2/+2
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-05-09[c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith1-10/+41
template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
2019-04-15Simplify diagnosis of misplaced attributes in module-declarations.Richard Smith1-4/+3
No functional change intended. llvm-svn: 358463
2019-04-14[c++20] Enable driver and frontend support for building and usingRichard Smith1-1/+1
modules when -std=c++2a is specified. llvm-svn: 358355
2019-04-14[c++20] Parsing support for module-declarations, import-declarations,Richard Smith1-25/+177
and the global and private module fragment. For now, the private module fragment introducer is ignored, but use of the global module fragment introducer should be properly enforced. llvm-svn: 358353
2019-04-11Add support for attributes on @implementations in Objective-CErik Pilkington1-2/+6
We want to make objc_nonlazy_class apply to implementations, but ran into this. There doesn't seem to be any reason that this isn't supported. Differential revision: https://reviews.llvm.org/D60542 llvm-svn: 358200
2019-03-25[Sema][NFCI] Don't allocate storage for the various ↵Bruno Ricci1-4/+4
CorrectionCandidateCallback unless we are going to do some typo correction The various CorrectionCandidateCallbacks are currently heap-allocated unconditionally. This was needed because of delayed typo correction. However these allocations represent currently 15.4% of all allocations (number of allocations) when parsing all of Boost (!), mostly because of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes and isCXXDeclarationSpecifier. Note that all of these callback objects are small. Let's not do this. Instead initially allocate the callback on the stack, and only do a heap allocation if we are going to do some typo correction. Do this by: 1. Adding a clone function to each callback, which will do a polymorphic clone of the callback. This clone function is required to be implemented by every callback (of which there is a fair amount). Make sure this is the case by making it pure virtual. 2. Use this clone function when we are going to try to correct a typo. This additionally cut the time of -fsyntax-only on all of Boost by 0.5% (not that much, but still something). No functional changes intended. Differential Revision: https://reviews.llvm.org/D58827 Reviewed By: rnk llvm-svn: 356925
2019-03-13[Parse] Parse '#pragma clang attribute' as an external-declarationErik Pilkington1-4/+3
Previously, we parsed it only in the top level, which excludes namespaces and extern "C" blocks. rdar://problem/48818890 Differential revision: https://reviews.llvm.org/D59282 llvm-svn: 356075
2019-03-07[OPENMP 5.0]Add initial support for 'allocate' directive.Alexey Bataev1-1/+2
Added parsing/sema analysis/serialization/deserialization support for 'allocate' directive. llvm-svn: 355614
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-10Misc typos fixes in ./lib folderRaphael Isemann1-1/+1
Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned` Reviewers: teemperor Reviewed By: teemperor Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55475 llvm-svn: 348755
2018-11-01Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner1-2/+2
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-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-5/+5
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-09-18[CodeComplete] Add completions for filenames in #include directives.Sam McCall1-0/+4
Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 llvm-svn: 342449
2018-08-14We have in place support for parsing #pragma FENV_ACCESS, but that Kevin P. Neal1-0/+3
information is then discarded with a warning to the user that we don't support it. This patch gets us one step closer by getting the info down into the AST in most cases. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D49865 llvm-svn: 339693
2018-07-30Remove trailing spaceFangrui Song1-34/+34
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-07-13[NFC] Rename clang::AttributeList to clang::ParsedAttrErich Keane1-1/+1
Since The type no longer contains the 'next' item anymore, it isn't a list, so rename it to ParsedAttr to be more accurate. llvm-svn: 337005
2018-07-12AttributeList de-listifying:Erich Keane1-14/+8
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-27[Modules][ObjC] Warn on the use of '@import' in framework headersBruno Cardoso Lopes1-0/+12
Using @import in framework headers inhibit the use of such headers when not using modules, this is specially bad for headers that end up in the SDK (or any other system framework). Add a warning to give users some indication that this is discouraged. rdar://problem/39192894 llvm-svn: 335780
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-8/+8
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
2018-04-27Parse A::template B as an identifier rather than as a template-id with noRichard Smith1-1/+1
template arguments. This fixes some cases where we'd incorrectly accept "A::template B" when B is a kind of template that requires template arguments (in particular, a variable template or a concept). llvm-svn: 331013
2018-04-26Revert rC330794 and some dependent tiny bug fixes Faisal Vali1-3/+3
See Richard's humbling feedback here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html Wish I'd had the patience to solicit the feedback prior to committing :) Sorry for the noise guys. Thank you Richard for being the steward that clang deserves! llvm-svn: 330888
2018-04-25[c++2a] [concepts] Add rudimentary parsing support for template concept ↵Faisal Vali1-3/+3
declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! llvm-svn: 330794
2018-04-10Revert r329684 (and follow-ups 329693, 329714). See discussion on ↵Nico Weber1-43/+1
https://reviews.llvm.org/D43578. llvm-svn: 329739
2018-04-10-ftime-report switch support in Clang.Andrew V. Tischenko1-1/+43
The current support of the feature produces only 2 lines in report: -Some general Code Generation Time; -Total time of Backend Consumer actions. This patch extends Clang time report with new lines related to Preprocessor, Include Filea Search, Parsing, etc. Differential Revision: https://reviews.llvm.org/D43578 llvm-svn: 329684
2018-03-16[Parser] Remove hard-coded bracket depth limitJan Korous1-1/+1
The diagnostics produced if assert fails are using proper limit from language definition already. llvm-svn: 327735
2018-02-28Fix a couple of cases where we would fail to correctly parse deduced class ↵Richard Smith1-2/+2
template specialization types. Specifically, we would not properly parse these types within template arguments (for non-type template parameters), and in tentative parses. Fixing both of these essentially requires that we parse deduced template specialization types as types in all contexts, even in template argument lists -- in particular, tentative parsing may look ahead and annotate a deduced template specialization type before we figure out that we're actually supposed to treat the tokens as a template-name. We deal with this by simply permitting deduced template specialization types when parsing template arguments, and converting them to template template arguments. llvm-svn: 326299
2018-02-12Allow the NS, CF, and ObjC attributes to be used with ↵Aaron Ballman1-1/+1
-fdouble-square-bracket-attributes. The syntactic locations for such attributes on ObjC constructs have been specifically chosen to follow the GNU attribute syntactic locations. llvm-svn: 324890
2018-01-01Again reverting an attempt to convert the DeclSpec enums into scoped enums.Faisal Vali1-1/+1
- reverts r321622, r321625, and r321626. - the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough. The bots still complain of warnings being seen. - to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change. So in short - I give up (for now at least). Sorry about the noise. llvm-svn: 321628
2018-01-01[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali1-1/+1
TypeSpecifierType into scoped enums with underlying types. - Since these enums are used as bit-fields - for the bit-fields to be interpreted as unsigned, the underlying type must be specified as unsigned. Previous failed attempt - wherein I did not specify an underlying type - was the sum of: https://reviews.llvm.org/rC321614 https://reviews.llvm.org/rC321615 llvm-svn: 321622
2018-01-01Revert r321614 and r321615Faisal Vali1-1/+1
- the enum changes to TypeSpecifierType are breaking some tests - and will require a more careful integration. Sorry about rushing these changes - thought I could sneak them in prior to heading out for new years ;) llvm-svn: 321616
2018-01-01[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali1-1/+1
TypeSpecifierType into scoped enums. llvm-svn: 321614
2017-12-31[NFC] Modernize enum DeclSpecContext into a scoped enum.Faisal Vali1-3/+4
llvm-svn: 321590
2017-12-29[NFC] Modernize enum Declarator::TheContext to a type-safe scoped enum.Faisal Vali1-8/+8
Note, we don't do any bitwise manipulations when using them. llvm-svn: 321546
2017-12-25Add a fixit for attributes incorrectly placed prior to 'struct/class/enum' ↵Faisal Vali1-1/+25
keyword. Suggest moving the following erroneous attrib list (based on location) [[]] struct X; to struct [[]] X; Additionally, added a fixme for the current implementation that diagnoses misplaced attributes to consider using the newly introduced diagnostic (that I think is more user-friendly). llvm-svn: 321449
2017-11-21[Modules TS] Added module re-export support.Hamza Sood1-6/+8
This implements [dcl.modules.export] from the C++ Modules TS, which lets a module re-export another module with the "export import" syntax. Differential Revision: https://reviews.llvm.org/D40270 llvm-svn: 318744
2017-10-24[code completion] Complete ObjC methods in @implementation without leadingAlex Lorenz1-3/+9
'-'/'+' prefix rdar://12040840 llvm-svn: 316458
2017-10-10[Modules TS] Diagnose attempts to enter module implementation units without ↵Richard Smith1-2/+2
the module interface being available. llvm-svn: 315381
2017-08-21Fixed a crash on replaying Preamble's PP conditional stack.Ilya Biryukov1-2/+0
Summary: The crash occurs when the first token after a preamble is a macro expansion. Fixed by moving replayPreambleConditionalStack from Parser into Preprocessor. It is now called right after the predefines file is processed. Reviewers: erikjv, bkramer, klimek, yvvan Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36872 llvm-svn: 311330
2017-08-10Place implictly declared functions at block scopeMomchil Velikov1-4/+7
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-05Fix invalid warnings for header guards in preamblesErik Verbruggen1-0/+2
Fixes https://bugs.llvm.org/show_bug.cgi?id=33574 Differential Revision: https://reviews.llvm.org/D34882 llvm-svn: 307134
2017-07-05[modules ts] Declarations from a module interface unit are only visible outsideRichard Smith1-0/+2
the module if declared in an export block. llvm-svn: 307115
2017-06-03Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova1-0/+2
llvm-svn: 304646
2017-05-18Fix the location of "missing ';'" suggestions after annotation tokens.Richard Smith1-15/+7
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-21P0629R0: Switch to latest proposal for distinguishing module interface from ↵Richard Smith1-39/+28
implementation. This switches from the prototype syntax in P0273R0 ('module' and 'module implementation') to the consensus syntax 'export module' and 'module'. In passing, drop the "module declaration must be first" enforcement, since EWG seems to have changed its mind on that. llvm-svn: 301056
2017-04-19Add support for editor placeholders to ClangAlex Lorenz1-0/+6
This commit teaches Clang to recognize editor placeholders that are produced when an IDE like Xcode inserts a code-completion result that includes a placeholder. Now when the lexer sees a placeholder token, it emits an 'editor placeholder in source file' error and creates an identifier token that represents the placeholder. The parser/sema can now recognize the placeholders and can suppress the diagnostics related to the placeholders. This ensures that live issues in an IDE like Xcode won't get spurious diagnostics related to placeholders. This commit also adds a new compiler option named '-fallow-editor-placeholders' that silences the 'editor placeholder in source file' error. This is useful for an IDE like Xcode as we don't want to display those errors in live issues. rdar://31581400 Differential Revision: https://reviews.llvm.org/D32081 llvm-svn: 300667