Parser.h revision 62c9258f4a71569a66d805fc7776526a2c76b34e
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- Parser.h - C Language Parser ---------------------------*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the Parser interface. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_PARSE_PARSER_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_PARSE_PARSER_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 17ad2b804faf29042e6c4e331d0987f103f1e2fd31John McCall#include "clang/Basic/Specifiers.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/Lex/Preprocessor.h" 19f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor#include "clang/Lex/CodeCompletionHandler.h" 20f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall#include "clang/Sema/Sema.h" 2119510856727e0e14a3696b2a72c35163bff2a71fJohn McCall#include "clang/Sema/DeclSpec.h" 22f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall#include "llvm/Support/PrettyStackTrace.h" 234726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek#include "llvm/ADT/OwningPtr.h" 244cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis#include <stack> 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 27fcdd8fe26de3eee44927600bf1853e21bd90dd84Daniel Dunbar class PragmaHandler; 285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Scope; 292b5289b6fd7e3d9899868410a498c081c9595662John McCall class DeclGroupRef; 303cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner class DiagnosticBuilder; 310102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner class Parser; 324726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek class PragmaUnusedHandler; 3308d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner class ColonProtectionRAIIObject; 340fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor class InMessageExpressionRAIIObject; 350a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor class VersionTuple; 360a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 370102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// PrettyStackTraceParserEntry - If a crash happens while the parser is active, 380102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// an entry is printed for it. 390102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerclass PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry { 400102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner const Parser &P; 410102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerpublic: 420102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner PrettyStackTraceParserEntry(const Parser &p) : P(p) {} 430102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner virtual void print(llvm::raw_ostream &OS) const; 440102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner}; 451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 466aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// PrecedenceLevels - These are precedences for the binary/ternary 476aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// operators in the C99 grammar. These have been named to relate 486aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// with the C99 grammar productions. Low precedences numbers bind 496aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// more weakly than high numbers. 506aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregornamespace prec { 516aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor enum Level { 526aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Unknown = 0, // Not binary operator. 536aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Comma = 1, // , 546aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= 556aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Conditional = 3, // ? 566aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor LogicalOr = 4, // || 576aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor LogicalAnd = 5, // && 586aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor InclusiveOr = 6, // | 596aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor ExclusiveOr = 7, // ^ 606aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor And = 8, // & 616aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Equality = 9, // ==, != 626aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Relational = 10, // >=, <=, >, < 636aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Shift = 11, // <<, >> 646aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Additive = 12, // -, + 656aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Multiplicative = 13, // *, /, % 666aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor PointerToMember = 14 // .*, ->* 676aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor }; 686aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor} 691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Parser - This implements a parser for the C family of languages. After 715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// parsing units of the grammar, productions are invoked to handle whatever has 725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// been read. 735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 74f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregorclass Parser : public CodeCompletionHandler { 754726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek friend class PragmaUnusedHandler; 7608d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner friend class ColonProtectionRAIIObject; 770fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor friend class InMessageExpressionRAIIObject; 7836d36806f1972f7ec1d2a3f59155187278c56508Argyrios Kyrtzidis friend class ParenBraceBracketBalancer; 791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Preprocessor &PP; 811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8297d0205d16fef2a783e785459b5f30f6a9dfbcb9Eric Christopher /// Tok - The current token we are peeking ahead. All parsing methods assume 835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// that this is valid. 84d217773f106856a11879ec79dc468efefaf2ee75Chris Lattner Token Tok; 851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 864b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // PrevTokLocation - The location of the token we previously 874b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // consumed. This token is used for diagnostics where we expected to 884b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // see a token following another token (e.g., the ';' at the end of 894b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // a statement). 904b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor SourceLocation PrevTokLocation; 914b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor 925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned short ParenCount, BracketCount, BraceCount; 935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Actions - These are the callbacks we invoke as we parse various constructs 9587c300738174924453648c3b2d6f366c8284fac4Douglas Gregor /// in the file. 96f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema &Actions; 971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Diagnostic &Diags; 991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1009e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner /// ScopeCache - Cache scopes to reduce malloc traffic. 1019e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner enum { ScopeCacheSize = 16 }; 1029e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner unsigned NumCachedScopes; 1039e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner Scope *ScopeCache[ScopeCacheSize]; 104662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar 105662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar /// Ident_super - IdentifierInfo for "super", to support fast 106662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar /// comparison. 107662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar IdentifierInfo *Ident_super; 10882287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// Ident_vector and Ident_pixel - cached IdentifierInfo's for 10982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// "vector" and "pixel" fast comparison. Only present if 11082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// AltiVec enabled. 11182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson IdentifierInfo *Ident_vector; 11282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson IdentifierInfo *Ident_pixel; 113662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar 1140a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "introduced". 1150a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_introduced; 1160a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1170a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "deprecated". 1180a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_deprecated; 1190a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1200a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "obsoleted". 1210a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_obsoleted; 1220a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 123b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor /// \brief Identifier for "unavailable". 124b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor IdentifierInfo *Ident_unavailable; 125b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor 1261f3b6fdabbb10779a473d6315154d7325ce20aeaAnders Carlsson /// C++0x contextual keywords. 1277eeb4ec11043d4860361348f2b19299d957d47a9Anders Carlsson mutable IdentifierInfo *Ident_final; 1287eeb4ec11043d4860361348f2b19299d957d47a9Anders Carlsson mutable IdentifierInfo *Ident_override; 1291f3b6fdabbb10779a473d6315154d7325ce20aeaAnders Carlsson 130cbb98edd530787c2ac019e437e7c599df8004ba7Daniel Dunbar llvm::OwningPtr<PragmaHandler> AlignHandler; 131aa8b0d19244a6e7e8e5798fcc6aef003c274d3e0Eli Friedman llvm::OwningPtr<PragmaHandler> GCCVisibilityHandler; 132861800c676004eabed5927f0552620d06c80a40aDaniel Dunbar llvm::OwningPtr<PragmaHandler> OptionsHandler; 1334726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek llvm::OwningPtr<PragmaHandler> PackHandler; 13462c9258f4a71569a66d805fc7776526a2c76b34eFariborz Jahanian llvm::OwningPtr<PragmaHandler> MSStructHandler; 1354726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek llvm::OwningPtr<PragmaHandler> UnusedHandler; 1369991479ad5dde617168cc1e4b18425cdbbfd9fa9Eli Friedman llvm::OwningPtr<PragmaHandler> WeakHandler; 137321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne llvm::OwningPtr<PragmaHandler> FPContractHandler; 138f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne llvm::OwningPtr<PragmaHandler> OpenCLExtensionHandler; 1391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// Whether the '>' token acts as an operator or not. This will be 14155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// true except when we are parsing an expression within a C++ 14255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// template argument list, where the '>' closes the template 14355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// argument list. 14455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor bool GreaterThanIsOperator; 14508d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner 14608d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// ColonIsSacred - When this is false, we aggressively try to recover from 14708d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// code like "foo : bar" as if it were a typo for "foo :: bar". This is not 14808d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// safe in case statements and a few other things. This is managed by the 14908d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// ColonProtectionRAIIObject RAII object. 15008d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner bool ColonIsSacred; 15155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 1520fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// \brief When true, we are directly inside an Ojective-C messsage 1530fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// send expression. 1540fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// 1550fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// This is managed by the \c InMessageExpressionRAIIObject class, and 1560fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// should not be set directly. 1570fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor bool InMessageExpression; 1580fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor 159c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor /// The "depth" of the template parameters currently being parsed. 160c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor unsigned TemplateParameterDepth; 1618113ecfa4e41e2c888b1794389dfe3bce6386493Ted Kremenek 1628113ecfa4e41e2c888b1794389dfe3bce6386493Ted Kremenek /// Factory object for creating AttributeList objects. 1630b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall AttributeFactory AttrFactory; 1641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 166f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Parser(Preprocessor &PP, Sema &Actions); 1675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ~Parser(); 1685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const LangOptions &getLang() const { return PP.getLangOptions(); } 170444be7366d0a1e172c0290a1ea54c1cb16b5947cDaniel Dunbar const TargetInfo &getTargetInfo() const { return PP.getTargetInfo(); } 1710102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner Preprocessor &getPreprocessor() const { return PP; } 172f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema &getActions() const { return Actions; } 1731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1740102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner const Token &getCurToken() const { return Tok; } 17523c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor Scope *getCurScope() const { return Actions.getCurScope(); } 17623c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor 1775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Type forwarding. All of these are statically 'void*', but they may all be 1785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // different actual classes based on the actions in place. 179ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef Expr ExprTy; 180ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef Stmt StmtTy; 1812b5289b6fd7e3d9899868410a498c081c9595662John McCall typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy; 182ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef CXXBaseSpecifier BaseTy; 183cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt typedef CXXCtorInitializer MemInitTy; 184ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef NestedNameSpecifier CXXScopeTy; 185ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef TemplateParameterList TemplateParamsTy; 1862b5289b6fd7e3d9899868410a498c081c9595662John McCall typedef OpaquePtr<TemplateName> TemplateTy; 1877ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor 188ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef llvm::SmallVector<TemplateParameterList *, 4> TemplateParameterLists; 189c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor 1909ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::ExprResult ExprResult; 1919ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::StmtResult StmtResult; 1929ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::BaseResult BaseResult; 1939ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::MemInitResult MemInitResult; 1949ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::TypeResult TypeResult; 19515faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 1969ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef Expr *ExprArg; 1979ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef ASTMultiPtr<Stmt*> MultiStmtArg; 198f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall typedef Sema::FullExprArg FullExprArg; 1991d922960e083906a586609ac6978678147250177Sebastian Redl 20060d7b3a319d84d688752be3870615ac0f111fb16John McCall /// Adorns a ExprResult with Actions to make it an ExprResult 20160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Owned(ExprResult res) { 20260d7b3a319d84d688752be3870615ac0f111fb16John McCall return ExprResult(res); 20361364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 20460d7b3a319d84d688752be3870615ac0f111fb16John McCall /// Adorns a StmtResult with Actions to make it an StmtResult 20560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Owned(StmtResult res) { 20660d7b3a319d84d688752be3870615ac0f111fb16John McCall return StmtResult(res); 20761364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 20861364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 20960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprError() { return ExprResult(true); } 21060d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult StmtError() { return StmtResult(true); } 211d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor 21260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); } 21360d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); } 21461364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 21560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprEmpty() { return ExprResult(false); } 2165ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis 2175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Parsing methods. 2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParseTranslationUnit - All in one method that initializes parses, and 2205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// shuts down the parser. 2215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseTranslationUnit(); 2221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Initialize - Warm up the parser. 2245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 2255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Initialize(); 2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if 2281f6443255894429fba384de0d5b6389ef578a5e9Steve Naroff /// the EOF was encountered. 229682bf92db408a6cbc3d37b5496a99b6ef85041ecChris Lattner bool ParseTopLevelDecl(DeclGroupPtrTy &Result); 2301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2313fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian DeclGroupPtrTy FinishPendingObjCActions(); 23263e963cdffca9530f920dbab58b9b4eecb2a582cFariborz Jahanian 2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 2345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 2355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Low-Level token peeking and consumption methods. 2365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // 2371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenParen - Return true if the cur token is '(' or ')'. 2395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenParen() const { 2405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_paren || Tok.getKind() == tok::r_paren; 2415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenBracket - Return true if the cur token is '[' or ']'. 2435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenBracket() const { 2445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_square || Tok.getKind() == tok::r_square; 2455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenBrace - Return true if the cur token is '{' or '}'. 2475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenBrace() const { 2485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_brace || Tok.getKind() == tok::r_brace; 2495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenStringLiteral - True if this token is a string-literal. 2525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 2535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenStringLiteral() const { 2545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::string_literal || 2555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Tok.getKind() == tok::wide_string_literal; 2565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 257eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 258a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis /// \brief Returns true if the current token is a '=' or '==' and 259a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis /// false otherwise. If it's '==', we assume that it's a typo and we emit 260a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis /// DiagID and a fixit hint to turn '==' -> '='. 261a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis bool isTokenEqualOrMistypedEqualEqual(unsigned DiagID); 262a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis 2635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeToken - Consume the current 'peek token' and lex the next one. 264d6ecc5cf945ccdf2b931137e364a69cde59ab18bZhongxing Xu /// This does not work with all kinds of tokens: strings and specific other 2655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// tokens must be consumed with custom methods below. This returns the 2665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// location of the consumed token. 2675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeToken() { 2685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(!isTokenStringLiteral() && !isTokenParen() && !isTokenBracket() && 2695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer !isTokenBrace() && 2705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer "Should consume special tokens with Consume*Token"); 271dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor if (Tok.is(tok::code_completion)) { 272dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor CodeCompletionRecovery(); 273dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor return ConsumeCodeCompletionToken(); 274dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor } 275dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor 2764b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 2775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 2784b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 2795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeAnyToken - Dispatch to the right Consume* method based on the 2825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// current token type. This should only be used in cases where the type of 2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// the token really isn't known, e.g. in error recovery. 2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeAnyToken() { 2855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (isTokenParen()) 2865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeParen(); 2875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (isTokenBracket()) 2885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeBracket(); 2895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (isTokenBrace()) 2905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeBrace(); 291d62701bc5321049353017e9abf1963edd57646aaSteve Naroff else if (isTokenStringLiteral()) 292d62701bc5321049353017e9abf1963edd57646aaSteve Naroff return ConsumeStringToken(); 2935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else 2945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeToken(); 2955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeParen - This consume method keeps the paren count up-to-date. 2985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 2995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeParen() { 3005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenParen() && "wrong consume method"); 3015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_paren) 3025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++ParenCount; 3035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (ParenCount) 3045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --ParenCount; // Don't let unbalanced )'s drive the count negative. 3054b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3074b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeBracket - This consume method keeps the bracket count up-to-date. 3115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeBracket() { 3135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenBracket() && "wrong consume method"); 3145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_square) 3155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++BracketCount; 3165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (BracketCount) 3175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --BracketCount; // Don't let unbalanced ]'s drive the count negative. 3181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3194b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3214b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeBrace - This consume method keeps the brace count up-to-date. 3255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeBrace() { 3275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenBrace() && "wrong consume method"); 3285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_brace) 3295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++BraceCount; 3305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (BraceCount) 3315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --BraceCount; // Don't let unbalanced }'s drive the count negative. 3321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3334b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3354b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeStringToken - Consume the current 'peek token', lexing a new one 3395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// and returning the token kind. This method is specific to strings, as it 3405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// handles string literal concatenation, as per C99 5.1.1.2, translation 3415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// phase #6. 3425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeStringToken() { 3435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenStringLiteral() && 3445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer "Should only consume string literals with this method"); 3454b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3474b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 350dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// \brief Consume the current code-completion token. 351dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// 352dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// This routine should be called to consume the code-completion token once 353dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// a code-completion action has already been invoked. 354dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor SourceLocation ConsumeCodeCompletionToken() { 355dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor assert(Tok.is(tok::code_completion)); 356dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor PrevTokLocation = Tok.getLocation(); 357dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor PP.Lex(Tok); 358dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor return PrevTokLocation; 359dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor } 360dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor 361dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor ///\ brief When we are consuming a code-completion token within having 362dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// matched specific position in the grammar, provide code-completion results 363dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// based on context. 364dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor void CodeCompletionRecovery(); 365dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor 366b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis /// \brief Handle the annotation token produced for #pragma unused(...) 367b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis void HandlePragmaUnused(); 368b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis 3696b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// GetLookAheadToken - This peeks ahead N tokens and returns that token 3706b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// without consuming any tokens. LookAhead(0) returns 'Tok', LookAhead(1) 3716b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// returns the token after Tok, etc. 3726b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// 3736b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// Note that this differs from the Preprocessor's LookAhead method, because 3746b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// the Parser always has one token lexed that the preprocessor doesn't. 3756b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// 37603db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis const Token &GetLookAheadToken(unsigned N) { 3776b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner if (N == 0 || Tok.is(tok::eof)) return Tok; 3786b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner return PP.LookAhead(N-1); 3796b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner } 380f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis 381f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis /// NextToken - This peeks ahead one token and returns it without 382f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis /// consuming it. 383f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis const Token &NextToken() { 38403db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis return PP.LookAhead(0); 385f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis } 3865404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 387b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall /// getTypeAnnotation - Read a parsed type out of an annotation token. 388b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall static ParsedType getTypeAnnotation(Token &Tok) { 389b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue()); 390b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall } 391b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall 392b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall static void setTypeAnnotation(Token &Tok, ParsedType T) { 393b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall Tok.setAnnotationValue(T.getAsOpaquePtr()); 394b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall } 395b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall 396eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// TryAnnotateTypeOrScopeToken - If the current token position is on a 397eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// typename (possibly qualified in C++) or a C++ scope specifier not followed 398eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// by a typename, TryAnnotateTypeOrScopeToken will replace one or more tokens 399eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// with a single annotation token representing the typename or C++ scope 400eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// respectively. 401eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// This simplifies handling of C++ scope specifiers and allows efficient 402eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// backtracking without the need to re-parse and resolve nested-names and 403eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// typenames. 40444802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis /// It will mainly be called when we expect to treat identifiers as typenames 40544802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis /// (if they are typenames). For example, in C we do not expect identifiers 40644802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis /// inside expressions to be treated as typenames so it will not be called 40744802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis /// for expressions in C. 408a7bc7c880f86bc180684ef032d06df51bcae7a23Chris Lattner /// 409a7bc7c880f86bc180684ef032d06df51bcae7a23Chris Lattner /// This returns true if the token was annotated. 410495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor bool TryAnnotateTypeOrScopeToken(bool EnteringContext = false); 411eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 4129ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall /// TryAnnotateCXXScopeToken - Like TryAnnotateTypeOrScopeToken but 4139ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall /// only annotates C++ scope specifiers. This returns true if there 4149ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall /// was an unrecoverable error. 415495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor bool TryAnnotateCXXScopeToken(bool EnteringContext = false); 416eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 41782287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// TryAltiVecToken - Check for context-sensitive AltiVec identifier tokens, 41882287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// replacing them with the non-context-sensitive keywords. This returns 41982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// true if the token was replaced. 42082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc, 421b3a4e432c90be98c6d918087750397e86d030368Chris Lattner const char *&PrevSpec, unsigned &DiagID, 422b3a4e432c90be98c6d918087750397e86d030368Chris Lattner bool &isInvalid) { 4231b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner if (!getLang().AltiVec || 4241b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner (Tok.getIdentifierInfo() != Ident_vector && 4251b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner Tok.getIdentifierInfo() != Ident_pixel)) 4261b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return false; 4271b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner 4281b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid); 42982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson } 43082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson 43182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// TryAltiVecVectorToken - Check for context-sensitive AltiVec vector 43282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// identifier token, replacing it with the non-context-sensitive __vector. 43382287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// This returns true if the token was replaced. 43482287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson bool TryAltiVecVectorToken() { 435b3a4e432c90be98c6d918087750397e86d030368Chris Lattner if (!getLang().AltiVec || 436b3a4e432c90be98c6d918087750397e86d030368Chris Lattner Tok.getIdentifierInfo() != Ident_vector) return false; 4371b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return TryAltiVecVectorTokenOutOfLine(); 43882287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson } 4391b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner 4401b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool TryAltiVecVectorTokenOutOfLine(); 4411b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc, 4421b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner const char *&PrevSpec, unsigned &DiagID, 4431b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool &isInvalid); 4441b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner 4455404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// TentativeParsingAction - An object that is used as a kind of "tentative 4465404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// parsing transaction". It gets instantiated to mark the token position and 4475404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// after the token consumption is done, Commit() or Revert() is called to 4485404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// either "commit the consumed tokens" or revert to the previously marked 4495404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// token position. Example: 4505404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// 451314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor /// TentativeParsingAction TPA(*this); 4525404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// ConsumeToken(); 4535404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// .... 4545404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// TPA.Revert(); 4555404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// 4565404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis class TentativeParsingAction { 4575404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis Parser &P; 4585404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis Token PrevTok; 4595404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isActive; 4605404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 4615404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis public: 4625404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis explicit TentativeParsingAction(Parser& p) : P(p) { 4635404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis PrevTok = P.Tok; 4645404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.EnableBacktrackAtThisPos(); 4655404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = true; 4665404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 4675404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis void Commit() { 4685404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(isActive && "Parsing action was finished!"); 4695404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.CommitBacktrackedTokens(); 4705404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = false; 4715404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 4725404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis void Revert() { 4735404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(isActive && "Parsing action was finished!"); 4745404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.Backtrack(); 4755404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.Tok = PrevTok; 4765404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = false; 4775404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 4785404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis ~TentativeParsingAction() { 4795404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(!isActive && "Forgot to call Commit or Revert!"); 4805404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 4815404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis }; 4821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'), 4855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// this helper function matches and consumes the specified RHS token if 4865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// present. If not present, it emits the specified diagnostic indicating 4875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// that the parser failed to match the RHS of the token at LHSLoc. LHSName 4885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// should be the name of the unmatched LHS token. This returns the location 4895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// of the consumed token. 4905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation MatchRHSPunctuation(tok::TokenKind RHSTok, 4915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation LHSLoc); 4921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ExpectAndConsume - The parser expects that 'ExpectedTok' is next in the 4945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// input. If so, it is consumed and false is returned. 4955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 4965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// If the input is malformed, this emits the specified diagnostic. Next, if 4975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SkipToTok is specified, it calls SkipUntil(SkipToTok). Finally, true is 4985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// returned. 4995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned Diag, 5005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *DiagMsg = "", 5015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer tok::TokenKind SkipToTok = tok::unknown); 5025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5039ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// \brief The parser expects a semicolon and, if present, will consume it. 5049ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// 5059ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// If the next token is not a semicolon, this emits the specified diagnostic, 5069ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// or, if there's just some closing-delimiter noise (e.g., ')' or ']') prior 5079ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// to the semicolon, consumes that extra token. 5089ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor bool ExpectAndConsumeSemi(unsigned DiagID); 5099ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor 5105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 5115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Scope manipulation 5121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5138935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// ParseScope - Introduces a new scope for parsing. The kind of 5148935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// scope is determined by ScopeFlags. Objects of this type should 5158935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// be created on the stack to coincide with the position where the 5168935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// parser enters the new scope, and this object's constructor will 5178935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// create that new scope. Similarly, once the object is destroyed 5188935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// the parser will exit the scope. 5198935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor class ParseScope { 5208935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Parser *Self; 5218935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor ParseScope(const ParseScope&); // do not implement 5228935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor ParseScope& operator=(const ParseScope&); // do not implement 5238935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 5248935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor public: 5258935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ParseScope - Construct a new object to manage a scope in the 5268935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // parser Self where the new Scope is created with the flags 5278935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ScopeFlags, but only when ManageScope is true (the default). If 5288935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ManageScope is false, this object does nothing. 5291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ParseScope(Parser *Self, unsigned ScopeFlags, bool ManageScope = true) 5308935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor : Self(Self) { 5318935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor if (ManageScope) 5328935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self->EnterScope(ScopeFlags); 5338935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor else 5348935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor this->Self = 0; 5358935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 5368935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 5378935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // Exit - Exit the scope associated with this object now, rather 5388935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // than waiting until the object is destroyed. 5398935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor void Exit() { 5408935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor if (Self) { 5418935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self->ExitScope(); 5428935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self = 0; 5438935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 5448935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 5458935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 5468935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor ~ParseScope() { 5478935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Exit(); 5488935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 5498935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor }; 5508935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 5515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// EnterScope - Start a new scope. 5525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void EnterScope(unsigned ScopeFlags); 5531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ExitScope - Pop a scope off the scope stack. 5555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ExitScope(); 5565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 5585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Diagnostic Emission and Error recovery. 55915faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 5606aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorpublic: 5613cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 5623cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID); 56315faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 5646aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorprivate: 5651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void SuggestParentheses(SourceLocation Loc, unsigned DK, 5664b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor SourceRange ParenRange); 5674b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor 5685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SkipUntil - Read tokens until we get to the specified token, then consume 56982c7e6d8215567935d3d52741ccca9876a8ea461Steve Naroff /// it (unless DontConsume is true). Because we cannot guarantee that the 5705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// token will ever occur, this skips to the next token, or to some likely 5715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// good stopping point. If StopAtSemi is true, skipping will stop at a ';' 5725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// character. 5731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 5745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// If SkipUntil finds the specified token, it returns true, otherwise it 5751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returns false. 5765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true, 5773437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool DontConsume = false, bool StopAtCodeCompletion = false) { 5783437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis return SkipUntil(&T, 1, StopAtSemi, DontConsume, StopAtCodeCompletion); 5795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true, 5813437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool DontConsume = false, bool StopAtCodeCompletion = false) { 5825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer tok::TokenKind TokArray[] = {T1, T2}; 5833437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis return SkipUntil(TokArray, 2, StopAtSemi, DontConsume,StopAtCodeCompletion); 5845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SkipUntil(const tok::TokenKind *Toks, unsigned NumToks, 5863437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool StopAtSemi = true, bool DontConsume = false, 5873437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool StopAtCodeCompletion = false); 5887ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor 5895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 5904cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis // Lexing and parsing of C++ inline methods. 5914cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 592d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct ParsingClass; 593d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 594d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// [class.mem]p1: "... the class is regarded as complete within 595d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - function bodies 596d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - default arguments 597d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - exception-specifications (TODO: C++0x) 598d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - and brace-or-equal-initializers (TODO: C++0x) 599d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// for non-static data members (including such things in nested classes)." 600d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarations build the tree of those elements so they can 601d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// be parsed after parsing the top-level class. 602d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor class LateParsedDeclaration { 603d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor public: 604d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual ~LateParsedDeclaration(); 605d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 606d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 607d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 608d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor }; 609d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 610d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// Inner node of the LateParsedDeclaration tree that parses 611d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// all its members recursively. 612d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor class LateParsedClass : public LateParsedDeclaration { 613d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor public: 614d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor LateParsedClass(Parser *P, ParsingClass *C); 615d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual ~LateParsedClass(); 616d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 617d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 618d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 619d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 620d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor private: 621d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser *Self; 622d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor ParsingClass *Class; 623d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor }; 624d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 625d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// Contains the lexed tokens of a member function definition 626d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// which needs to be parsed at the end of the class declaration 627d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// after parsing all other member declarations. 628d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct LexedMethod : public LateParsedDeclaration { 629d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser *Self; 630d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *D; 63172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens Toks; 632d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor 633d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// \brief Whether this member function had an associated template 634d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// scope. When true, D is a template declaration. 635d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// othewise, it is a member function declaration. 636d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor bool TemplateScope; 637d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor 638d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor explicit LexedMethod(Parser* P, Decl *MD) 639d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor : Self(P), D(MD), TemplateScope(false) {} 640d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 641d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 6424cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis }; 6434cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 64472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// LateParsedDefaultArgument - Keeps track of a parameter that may 64572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// have a default argument that cannot be parsed yet because it 64672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// occurs within a member function declaration inside the class 64772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// (C++ [class.mem]p2). 64872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor struct LateParsedDefaultArgument { 649d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall explicit LateParsedDefaultArgument(Decl *P, 65072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens *Toks = 0) 65172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor : Param(P), Toks(Toks) { } 65272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 65372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Param - The parameter declaration for this parameter. 654d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *Param; 65572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 65672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Toks - The sequence of tokens that comprises the default 65772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// argument expression, not including the '=' or the terminating 65872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// ')' or ','. This will be NULL for parameters that have no 65972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// default argument. 66072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens *Toks; 66172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 6621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 66372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// LateParsedMethodDeclaration - A method declaration inside a class that 66472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// contains at least one entity whose parsing needs to be delayed 66572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// until the class itself is completely-defined, such as a default 66672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// argument (C++ [class.mem]p2). 667d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct LateParsedMethodDeclaration : public LateParsedDeclaration { 668d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor explicit LateParsedMethodDeclaration(Parser *P, Decl *M) 669d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor : Self(P), Method(M), TemplateScope(false) { } 670d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 671d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 672d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 673d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser* Self; 67472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 67572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Method - The method declaration. 676d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *Method; 67772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 678d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// \brief Whether this member function had an associated template 679d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// scope. When true, D is a template declaration. 680d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// othewise, it is a member function declaration. 681d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor bool TemplateScope; 6821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 68372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// DefaultArgs - Contains the parameters of the function and 68472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// their default arguments. At least one of the parameters will 68572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// have a default argument, but all of the parameters of the 68672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// method will be stored so that they can be reintroduced into 6871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// scope at the appropriate times. 68872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor llvm::SmallVector<LateParsedDefaultArgument, 8> DefaultArgs; 68972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 69072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 691d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarationsContainer - During parsing of a top (non-nested) 692d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// C++ class, its method declarations that contain parts that won't be 693fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// parsed until after the definition is completed (C++ [class.mem]p2), 694d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// the method declarations and possibly attached inline definitions 695d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// will be stored here with the tokens that will be parsed to create those entities. 696d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor typedef llvm::SmallVector<LateParsedDeclaration*, 2> LateParsedDeclarationsContainer; 69772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 6986569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Representation of a class that has been parsed, including 6996569d68745c8213709740337d2be52b031384f58Douglas Gregor /// any member function declarations or definitions that need to be 7006569d68745c8213709740337d2be52b031384f58Douglas Gregor /// parsed after the corresponding top-level class is complete. 7016569d68745c8213709740337d2be52b031384f58Douglas Gregor struct ParsingClass { 702d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall ParsingClass(Decl *TagOrTemplate, bool TopLevelClass) 7031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : TopLevelClass(TopLevelClass), TemplateScope(false), 7046569d68745c8213709740337d2be52b031384f58Douglas Gregor TagOrTemplate(TagOrTemplate) { } 7056569d68745c8213709740337d2be52b031384f58Douglas Gregor 7066569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Whether this is a "top-level" class, meaning that it is 7076569d68745c8213709740337d2be52b031384f58Douglas Gregor /// not nested within another class. 7086569d68745c8213709740337d2be52b031384f58Douglas Gregor bool TopLevelClass : 1; 7096569d68745c8213709740337d2be52b031384f58Douglas Gregor 7106569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Whether this class had an associated template 7116569d68745c8213709740337d2be52b031384f58Douglas Gregor /// scope. When true, TagOrTemplate is a template declaration; 7126569d68745c8213709740337d2be52b031384f58Douglas Gregor /// othewise, it is a tag declaration. 7136569d68745c8213709740337d2be52b031384f58Douglas Gregor bool TemplateScope : 1; 7146569d68745c8213709740337d2be52b031384f58Douglas Gregor 7156569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief The class or class template whose definition we are parsing. 716d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagOrTemplate; 71772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 718d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarations - Method declarations, inline definitions and 719d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// nested classes that contain pieces whose parsing will be delayed until 720d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// the top-level class is fully defined. 721d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor LateParsedDeclarationsContainer LateParsedDeclarations; 72272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 7234cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 7246569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief The stack of classes that is currently being 7256569d68745c8213709740337d2be52b031384f58Douglas Gregor /// parsed. Nested and local classes will be pushed onto this stack 7266569d68745c8213709740337d2be52b031384f58Douglas Gregor /// when they are parsed, and removed afterward. 7276569d68745c8213709740337d2be52b031384f58Douglas Gregor std::stack<ParsingClass *> ClassStack; 7284cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 7296569d68745c8213709740337d2be52b031384f58Douglas Gregor ParsingClass &getCurrentClass() { 7306569d68745c8213709740337d2be52b031384f58Douglas Gregor assert(!ClassStack.empty() && "No lexed method stacks!"); 7316569d68745c8213709740337d2be52b031384f58Douglas Gregor return *ClassStack.top(); 7324cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis } 7334cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 73454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// \brief RAII object used to inform the actions that we're 73554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// currently parsing a declaration. This is active when parsing a 73654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// variable's initializer, but not when parsing the body of a 73754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// class or function definition. 73854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall class ParsingDeclRAIIObject { 739f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema &Actions; 740eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Sema::ParsingDeclState State; 74154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall bool Popped; 742c9068d7dd94d439cec66c421115d15303e481025John McCall 74354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall public: 74454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingDeclRAIIObject(Parser &P) : Actions(P.Actions) { 74554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall push(); 74654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 74754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 748c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject(Parser &P, ParsingDeclRAIIObject *Other) 749c9068d7dd94d439cec66c421115d15303e481025John McCall : Actions(P.Actions) { 750c9068d7dd94d439cec66c421115d15303e481025John McCall if (Other) steal(*Other); 751c9068d7dd94d439cec66c421115d15303e481025John McCall else push(); 752c9068d7dd94d439cec66c421115d15303e481025John McCall } 753c9068d7dd94d439cec66c421115d15303e481025John McCall 754c9068d7dd94d439cec66c421115d15303e481025John McCall /// Creates a RAII object which steals the state from a different 755c9068d7dd94d439cec66c421115d15303e481025John McCall /// object instead of pushing. 756c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject(ParsingDeclRAIIObject &Other) 757c9068d7dd94d439cec66c421115d15303e481025John McCall : Actions(Other.Actions) { 758c9068d7dd94d439cec66c421115d15303e481025John McCall steal(Other); 759c9068d7dd94d439cec66c421115d15303e481025John McCall } 760c9068d7dd94d439cec66c421115d15303e481025John McCall 76154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ~ParsingDeclRAIIObject() { 76254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall abort(); 76354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 76454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 76554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// Resets the RAII object for a new declaration. 76654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall void reset() { 76754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall abort(); 76854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall push(); 76954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 77054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 77154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// Signals that the context was completed without an appropriate 77254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// declaration being parsed. 77354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall void abort() { 774d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall pop(0); 77554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 77654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 777d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void complete(Decl *D) { 77854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall assert(!Popped && "ParsingDeclaration has already been popped!"); 77954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall pop(D); 78054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 78154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 78254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall private: 783c9068d7dd94d439cec66c421115d15303e481025John McCall void steal(ParsingDeclRAIIObject &Other) { 784c9068d7dd94d439cec66c421115d15303e481025John McCall State = Other.State; 785c9068d7dd94d439cec66c421115d15303e481025John McCall Popped = Other.Popped; 786c9068d7dd94d439cec66c421115d15303e481025John McCall Other.Popped = true; 787c9068d7dd94d439cec66c421115d15303e481025John McCall } 788c9068d7dd94d439cec66c421115d15303e481025John McCall 78954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall void push() { 79054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall State = Actions.PushParsingDeclaration(); 79154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall Popped = false; 79254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 79354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 794d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void pop(Decl *D) { 79554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall if (!Popped) { 79654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall Actions.PopParsingDeclaration(State, D); 79754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall Popped = true; 79854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 79954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 80054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall }; 80154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 80254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// A class for parsing a DeclSpec. 80354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall class ParsingDeclSpec : public DeclSpec { 80454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingDeclRAIIObject ParsingRAII; 80554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 80654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall public: 8070b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsingDeclSpec(Parser &P) : DeclSpec(P.AttrFactory), ParsingRAII(P) {} 808c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclSpec(Parser &P, ParsingDeclRAIIObject *RAII) 8090b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall : DeclSpec(P.AttrFactory), ParsingRAII(P, RAII) {} 81054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 811d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void complete(Decl *D) { 81254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingRAII.complete(D); 81354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 81454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 81554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall void abort() { 81654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingRAII.abort(); 81754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 81854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall }; 81954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 82054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall /// A class for parsing a declarator. 82154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall class ParsingDeclarator : public Declarator { 82254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingDeclRAIIObject ParsingRAII; 82354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 82454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall public: 82554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, TheContext C) 82654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall : Declarator(DS, C), ParsingRAII(P) { 82754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 82854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 82954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall const ParsingDeclSpec &getDeclSpec() const { 83054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall return static_cast<const ParsingDeclSpec&>(Declarator::getDeclSpec()); 83154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 83254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 83354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingDeclSpec &getMutableDeclSpec() const { 83454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall return const_cast<ParsingDeclSpec&>(getDeclSpec()); 83554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 83654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 83754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall void clear() { 83854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall Declarator::clear(); 83954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingRAII.reset(); 84054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 84154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 842d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void complete(Decl *D) { 84354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall ParsingRAII.complete(D); 84454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall } 84554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall }; 84654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall 8471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief RAII object used to 8486569d68745c8213709740337d2be52b031384f58Douglas Gregor class ParsingClassDefinition { 8496569d68745c8213709740337d2be52b031384f58Douglas Gregor Parser &P; 8506569d68745c8213709740337d2be52b031384f58Douglas Gregor bool Popped; 851eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Sema::ParsingClassState State; 8526569d68745c8213709740337d2be52b031384f58Douglas Gregor 8536569d68745c8213709740337d2be52b031384f58Douglas Gregor public: 854d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall ParsingClassDefinition(Parser &P, Decl *TagOrTemplate, bool TopLevelClass) 855eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall : P(P), Popped(false), 856eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall State(P.PushParsingClass(TagOrTemplate, TopLevelClass)) { 8576569d68745c8213709740337d2be52b031384f58Douglas Gregor } 8586569d68745c8213709740337d2be52b031384f58Douglas Gregor 8596569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Pop this class of the stack. 8601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void Pop() { 8616569d68745c8213709740337d2be52b031384f58Douglas Gregor assert(!Popped && "Nested class has already been popped"); 8626569d68745c8213709740337d2be52b031384f58Douglas Gregor Popped = true; 863eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall P.PopParsingClass(State); 8646569d68745c8213709740337d2be52b031384f58Douglas Gregor } 8656569d68745c8213709740337d2be52b031384f58Douglas Gregor 8661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~ParsingClassDefinition() { 8676569d68745c8213709740337d2be52b031384f58Douglas Gregor if (!Popped) 868eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall P.PopParsingClass(State); 8696569d68745c8213709740337d2be52b031384f58Douglas Gregor } 8706569d68745c8213709740337d2be52b031384f58Douglas Gregor }; 8716569d68745c8213709740337d2be52b031384f58Douglas Gregor 8724d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief Contains information about any template-specific 8734d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// information that has been parsed prior to parsing declaration 8744d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// specifiers. 8754d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor struct ParsedTemplateInfo { 8761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ParsedTemplateInfo() 8774d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor : Kind(NonTemplate), TemplateParams(0), TemplateLoc() { } 8784d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 8794d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ParsedTemplateInfo(TemplateParameterLists *TemplateParams, 880c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool isSpecialization, 881c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool lastParameterListWasEmpty = false) 8824d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor : Kind(isSpecialization? ExplicitSpecialization : Template), 883c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor TemplateParams(TemplateParams), 884c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor LastParameterListWasEmpty(lastParameterListWasEmpty) { } 8854d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 88645f965581935791a018df829a14dff53c1dd8f47Douglas Gregor explicit ParsedTemplateInfo(SourceLocation ExternLoc, 88745f965581935791a018df829a14dff53c1dd8f47Douglas Gregor SourceLocation TemplateLoc) 8881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Kind(ExplicitInstantiation), TemplateParams(0), 889c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor ExternLoc(ExternLoc), TemplateLoc(TemplateLoc), 890c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor LastParameterListWasEmpty(false){ } 8914d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 8924d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The kind of template we are parsing. 8934d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor enum { 8944d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are not parsing a template at all. 8954d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor NonTemplate = 0, 8964d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing a template declaration. 8974d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor Template, 8984d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing an explicit specialization. 8994d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ExplicitSpecialization, 9004d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing an explicit instantiation. 9014d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ExplicitInstantiation 9024d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor } Kind; 9034d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 9044d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The template parameter lists, for template declarations 9054d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// and explicit specializations. 9064d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor TemplateParameterLists *TemplateParams; 9074d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 90845f965581935791a018df829a14dff53c1dd8f47Douglas Gregor /// \brief The location of the 'extern' keyword, if any, for an explicit 90945f965581935791a018df829a14dff53c1dd8f47Douglas Gregor /// instantiation 91045f965581935791a018df829a14dff53c1dd8f47Douglas Gregor SourceLocation ExternLoc; 9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9124d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The location of the 'template' keyword, for an explicit 9134d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// instantiation. 9144d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor SourceLocation TemplateLoc; 915c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor 916c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor /// \brief Whether the last template parameter list was empty. 917c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool LastParameterListWasEmpty; 91878b810559d89e996e00684335407443936ce34a1John McCall 91978b810559d89e996e00684335407443936ce34a1John McCall SourceRange getSourceRange() const; 9204d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor }; 9211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9228387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// \brief Contains a late templated function. 9238387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// Will be parsed at the end of the translation unit. 9248387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet struct LateParsedTemplatedFunction { 9258387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet explicit LateParsedTemplatedFunction(Parser* P, Decl *MD) 9268387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet : D(MD) {} 9278387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 9288387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet CachedTokens Toks; 9298387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 9308387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// \brief The template function declaration to be late parsed. 9318387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet Decl *D; 9328387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet }; 9338387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 9348387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet void LexTemplateFunctionForLateParsing(CachedTokens &Toks); 9358387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet void ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT); 9368387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet typedef llvm::DenseMap<const FunctionDecl*, LateParsedTemplatedFunction*> 9378387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet LateParsedTemplateMapT; 9388387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet LateParsedTemplateMapT LateParsedTemplateMap; 9398387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 9404a47e8d35dc1778ef7e428d9edd7676be67e725fFrancois Pichet static void LateTemplateParserCallback(void *P, const FunctionDecl *FD); 9414a47e8d35dc1778ef7e428d9edd7676be67e725fFrancois Pichet void LateTemplateParser(const FunctionDecl *FD); 9428387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 943eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Sema::ParsingClassState 944eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall PushParsingClass(Decl *TagOrTemplate, bool TopLevelClass); 94537b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void DeallocateParsedClasses(ParsingClass *Class); 946eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall void PopParsingClass(Sema::ParsingClassState); 94737b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor 948eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Decl *ParseCXXInlineMethodDef(AccessSpecifier AS, ParsingDeclarator &D, 9494867347e82648d3baf09524b98b09c297a5a198fNico Weber const ParsedTemplateInfo &TemplateInfo, 9504867347e82648d3baf09524b98b09c297a5a198fNico Weber const VirtSpecifiers& VS); 95137b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void ParseLexedMethodDeclarations(ParsingClass &Class); 952d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM); 95337b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void ParseLexedMethodDefs(ParsingClass &Class); 954d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor void ParseLexedMethodDef(LexedMethod &LM); 95514b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool ConsumeAndStoreUntil(tok::TokenKind T1, 95614b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis CachedTokens &Toks, 95714b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool StopAtSemi = true, 95814b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool ConsumeFinalToken = true) { 95914b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis return ConsumeAndStoreUntil(T1, T1, Toks, StopAtSemi, ConsumeFinalToken); 96014b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis } 9611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, 96237b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor CachedTokens &Toks, 96314b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool StopAtSemi = true, 96437b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor bool ConsumeFinalToken = true); 9654d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 9664cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 9675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.9: External Definitions. 9687f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall struct ParsedAttributesWithRange : ParsedAttributes { 9690b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange(AttributeFactory &factory) 9700b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall : ParsedAttributes(factory) {} 9710b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall 9727f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceRange Range; 9737f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall }; 9747f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 9757f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs, 97609a63c97b95eb4dc6fd6b2323929e8cf12af03ffDouglas Gregor ParsingDeclSpec *DS = 0); 977c82daefa3062721e98947e08193cd81b4e9df915Chris Lattner bool isDeclarationAfterDeclarator() const; 978004659a56916f2f81ede507c12516c146d6c0df3Chris Lattner bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator); 9797f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(ParsedAttributes &attrs, 9807f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall AccessSpecifier AS = AS_none); 9813acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(ParsingDeclSpec &DS, 9823acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian AccessSpecifier AS = AS_none); 9833acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian 984d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseFunctionDefinition(ParsingDeclarator &D, 98552591bf224b2c43e2b00e265bb8599a620081925Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo()); 9865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseKNRParamDeclarations(Declarator &D); 987ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // EndLoc, if non-NULL, is filled with the location of the last token of 988ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // the simple-asm. 98960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseSimpleAsm(SourceLocation *EndLoc = 0); 99060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseAsmStringLiteral(); 9915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9923536b443bc50d58a79f14fca9b6842541a434854Steve Naroff // Objective-C External Declarations 993d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtDirectives(); 994d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtClassDeclaration(SourceLocation atLoc); 995d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtInterfaceDeclaration(SourceLocation atLoc, 9967f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &prefixAttrs); 997d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseObjCClassInstanceVariables(Decl *interfaceDecl, 99883c481ade785a919ba21a33f9a8b1b21c1212fb3Fariborz Jahanian tok::ObjCKeywordKind visibility, 99960fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff SourceLocation atLoc); 1000d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Decl *> &P, 100171b0addffbdeed29cc062c962e236c34107755d6Argyrios Kyrtzidis llvm::SmallVectorImpl<SourceLocation> &PLocs, 10021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool WarnOnDeclarations, 100371b0addffbdeed29cc062c962e236c34107755d6Argyrios Kyrtzidis SourceLocation &LAngleLoc, 1004e13b9595dc1e2f4288bec34f3412359f648e84a5Chris Lattner SourceLocation &EndProtoLoc); 100546f936e055d763437accd1e5a1bc49e7e5dbc0a3Douglas Gregor bool ParseObjCProtocolQualifiers(DeclSpec &DS); 1006d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseObjCInterfaceDeclList(Decl *interfaceDecl, 1007c81c8144a661a49d7b9dae8d2080dee2e43186ecChris Lattner tok::ObjCKeywordKind contextKey); 1008d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtProtocolDeclaration(SourceLocation atLoc, 10097f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &prefixAttrs); 10101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1011d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ObjCImpDecl; 1012d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall llvm::SmallVector<Decl *, 4> PendingObjCImpDecl; 10130416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff 1014d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtImplementationDeclaration(SourceLocation atLoc); 1015d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtEndDeclaration(SourceRange atEnd); 1016d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc); 1017d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCPropertySynthesize(SourceLocation atLoc); 1018d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCPropertyDynamic(SourceLocation atLoc); 10191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10202fc5c2428ecb450a3256c8316b93b8655cb76a0fChris Lattner IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation); 102134870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner // Definitions for Objective-c context sensitive keywords recognition. 102234870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner enum ObjCTypeQual { 102334870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref, 102434870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner objc_NumQuals 102534870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner }; 1026a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek IdentifierInfo *ObjCTypeQuals[objc_NumQuals]; 10271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1028335a2d4122e41343fe11a775889b8bec5b14be60Fariborz Jahanian bool isTokIdentifier_in() const; 1029d0f97d1716a138a8d9e0df8e5af77334663723d8Fariborz Jahanian 1030b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor /// \brief The context in which we are parsing an Objective-C type name. 1031b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor enum ObjCTypeNameContext { 1032b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor OTN_ResultType, 1033b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor OTN_ParameterType 1034b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor }; 1035b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor 1036b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, ObjCTypeNameContext Context); 1037294494e1cce92043562b4680c613df7fd028c02eSteve Naroff void ParseObjCMethodRequirement(); 1038d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCMethodPrototype(Decl *classOrCat, 103990ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword, 104090ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian bool MethodDefinition = true); 1041d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCMethodDecl(SourceLocation mLoc, tok::TokenKind mType, 1042d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *classDecl, 104390ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword, 104490ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian bool MethodDefinition=true); 1045bdb2d5056fd675c27307b34efd371bbba6839e92Douglas Gregor void ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl); 10461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1047d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCMethodDefinition(); 10481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 10505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.5: Expressions. 10516aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor 1052312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor ExprResult ParseExpression(ExprResult Primary = ExprResult()); 105360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseConstantExpression(); 10542f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl // Expr that doesn't include commas. 1055312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor ExprResult ParseAssignmentExpression(ExprResult Primary = ExprResult()); 10562f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl 105760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseExpressionWithLeadingAt(SourceLocation AtLoc); 10585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 105960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseExpressionWithLeadingExtension(SourceLocation ExtLoc); 1060adf077f46ba5cddcd801a647a5e9a3eb97060df4Eli Friedman 106160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseRHSOfBinaryExpression(ExprResult LHS, 1062312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor prec::Level MinPrec); 106360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCastExpression(bool isUnaryExpression, 1064312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool isAddressOfOperand, 1065312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool &NotCastExpr, 1066312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor ParsedType TypeOfCast); 106760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCastExpression(bool isUnaryExpression, 1068312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool isAddressOfOperand = false, 1069312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor ParsedType TypeOfCast = ParsedType()); 10709c72c6088d591ace8503b842d39448c2040f3033John McCall 10719c72c6088d591ace8503b842d39448c2040f3033John McCall /// Returns true if the next token would start a postfix-expression 10729c72c6088d591ace8503b842d39448c2040f3033John McCall /// suffix. 10739c72c6088d591ace8503b842d39448c2040f3033John McCall bool isPostfixExpressionSuffixStart() { 10749c72c6088d591ace8503b842d39448c2040f3033John McCall tok::TokenKind K = Tok.getKind(); 10759c72c6088d591ace8503b842d39448c2040f3033John McCall return (K == tok::l_square || K == tok::l_paren || 10769c72c6088d591ace8503b842d39448c2040f3033John McCall K == tok::period || K == tok::arrow || 10779c72c6088d591ace8503b842d39448c2040f3033John McCall K == tok::plusplus || K == tok::minusminus); 10789c72c6088d591ace8503b842d39448c2040f3033John McCall } 10799c72c6088d591ace8503b842d39448c2040f3033John McCall 108060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParsePostfixExpressionSuffix(ExprResult LHS); 1081f4e3cfbe8abd124be6341ef5d714819b4fbd9082Peter Collingbourne ExprResult ParseUnaryExprOrTypeTraitExpression(); 108260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBuiltinPrimaryExpression(); 10831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1084f4e3cfbe8abd124be6341ef5d714819b4fbd9082Peter Collingbourne ExprResult ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, 10855ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis bool &isCastExpr, 1086b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType &CastTy, 10875ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis SourceRange &CastRange); 10880cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis 1089ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef llvm::SmallVector<Expr*, 20> ExprListTy; 1090ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall typedef llvm::SmallVector<SourceLocation, 20> CommaLocsTy; 10910cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis 10920cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis /// ParseExpressionList - Used for C/C++ (argument-)expression-list. 1093ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall bool ParseExpressionList(llvm::SmallVectorImpl<Expr*> &Exprs, 1094ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall llvm::SmallVectorImpl<SourceLocation> &CommaLocs, 1095f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall void (Sema::*Completer)(Scope *S, 1096f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Expr *Data, 1097f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Expr **Args, 1098f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall unsigned NumArgs) = 0, 1099ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall Expr *Data = 0); 1100d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl 11015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParenParseOption - Control what ParseParenExpression will parse. 11025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum ParenParseOption { 11035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SimpleExpr, // Only parse '(' expression ')' 11045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CompoundStmt, // Also allow '(' compound-statement ')' 11055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' 11065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CastExpr // Also allow '(' type-name ')' <anything> 11075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 110860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseParenExpression(ParenParseOption &ExprType, 11090350ca519405051e8d45d12ee7d09569a6a9c4c9Argyrios Kyrtzidis bool stopIfCastExpr, 1110b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType TypeOfCast, 1111b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType &CastTy, 1112d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl SourceLocation &RParenLoc); 11131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 111460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, 1115b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType &CastTy, 1116f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis SourceLocation LParenLoc, 1117f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis SourceLocation &RParenLoc); 11181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 111960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCompoundLiteralExpression(ParsedType Ty, 1120d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis SourceLocation LParenLoc, 1121d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis SourceLocation RParenLoc); 11221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 112360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseStringLiteralExpression(); 1124eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1125f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne ExprResult ParseGenericSelectionExpression(); 1126f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne 1127eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis //===--------------------------------------------------------------------===// 1128eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis // C++ Expressions 112960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXIdExpression(bool isAddressOfOperand = false); 11304bdd91c09fd59e0c154d759288beff300e31e1d0Argyrios Kyrtzidis 11311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, 1132b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 1133b10cd04880672103660e5844e51ee91af7361a20Douglas Gregor bool EnteringContext, 11344147d307086cf024a40a080e2bf379e9725f6f41Francois Pichet bool *MayBePseudoDestructor = 0, 11354147d307086cf024a40a080e2bf379e9725f6f41Francois Pichet bool IsTypename = false); 11361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 11385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C++ 5.2p1: C++ Casts 113960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXCasts(); 11405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1142c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // C++ 5.2p1: C++ Type Identification 114360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXTypeid(); 1144c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 1145c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl //===--------------------------------------------------------------------===// 114601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // C++ : Microsoft __uuidof Expression 114701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet ExprResult ParseCXXUuidof(); 114801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 114901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet //===--------------------------------------------------------------------===// 1150d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor // C++ 5.2.4: C++ Pseudo-Destructor Expressions 115160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc, 1152d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor tok::TokenKind OpKind, 1153d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor CXXScopeSpec &SS, 1154b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType); 1155d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor 1156d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor //===--------------------------------------------------------------------===// 11574cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis // C++ 9.3.2: C++ 'this' pointer 115860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXThis(); 11594cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 11604cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 116150dd289f45738ed22b7583d52ed2525b927042ffChris Lattner // C++ 15: C++ Throw Expression 116260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseThrowExpression(); 11637acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl 11647acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl ExceptionSpecificationType MaybeParseExceptionSpecification( 11657acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl SourceRange &SpecificationRange, 11667acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl llvm::SmallVectorImpl<ParsedType> &DynamicExceptions, 11677acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl llvm::SmallVectorImpl<SourceRange> &DynamicExceptionRanges, 11687acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl ExprResult &NoexceptExpr); 11697acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl 1170ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // EndLoc is filled with the location of the last token of the specification. 11717acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl ExceptionSpecificationType ParseDynamicExceptionSpecification( 11727acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl SourceRange &SpecificationRange, 11737acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl llvm::SmallVectorImpl<ParsedType> &Exceptions, 11747acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl llvm::SmallVectorImpl<SourceRange> &Ranges); 117550dd289f45738ed22b7583d52ed2525b927042ffChris Lattner 117650dd289f45738ed22b7583d52ed2525b927042ffChris Lattner //===--------------------------------------------------------------------===// 1177dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // C++0x 8: Function declaration trailing-return-type 1178dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor TypeResult ParseTrailingReturnType(); 1179dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 1180dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor //===--------------------------------------------------------------------===// 11815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C++ 2.13.5: C++ Boolean Literals 118260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXBoolLiteral(); 11835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1185987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // C++ 5.2.3: Explicit type conversion (functional notation) 118660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS); 1187987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 11886aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor bool isCXXSimpleTypeSpecifier() const; 11896aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor 1190987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers. 1191987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// This should only be called when the current token is known to be part of 1192987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// simple-type-specifier. 1193987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis void ParseCXXSimpleTypeSpecifier(DeclSpec &DS); 1194987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 11952f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor bool ParseCXXTypeSpecifierSeq(DeclSpec &DS); 11962f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor 1197987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 11984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // C++ 5.3.4 and 5.3.5: C++ new and delete 1199ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall bool ParseExpressionListOrTypeId(llvm::SmallVectorImpl<Expr*> &Exprs, 1200ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall Declarator &D); 12014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl void ParseDirectNewDeclarator(Declarator &D); 120260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start); 120360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXDeleteExpression(bool UseGlobal, 120459232d35f5820e334b6c8b007ae8006f4390055dChris Lattner SourceLocation Start); 12054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl //===--------------------------------------------------------------------===// 120799e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor // C++ if/switch/while condition expression. 120860d7b3a319d84d688752be3870615ac0f111fb16John McCall bool ParseCXXCondition(ExprResult &ExprResult, Decl *&DeclResult, 1209586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor SourceLocation Loc, bool ConvertToBoolean); 121071b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis 121171b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis //===--------------------------------------------------------------------===// 121212e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor // C++ types 121312e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor 121412e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor //===--------------------------------------------------------------------===// 12155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.7.8: Initialization. 12161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12170eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// ParseInitializer 12180eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// initializer: [C99 6.7.8] 12190eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// assignment-expression 12200eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// '{' ... 122160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseInitializer() { 12220eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner if (Tok.isNot(tok::l_brace)) 122320df9b7ab9388b2a488c5b1293cd196b1e073b4eSebastian Redl return ParseAssignmentExpression(); 12240eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner return ParseBraceInitializer(); 12250eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner } 122660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBraceInitializer(); 122760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseInitializerWithPotentialDesignator(); 12281d922960e083906a586609ac6978678147250177Sebastian Redl 12295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1230296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff // clang Expressions 12311d922960e083906a586609ac6978678147250177Sebastian Redl 123260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBlockLiteralExpression(); // ^{...} 1233296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff 1234296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff //===--------------------------------------------------------------------===// 12355508518a2702b00be3b15a26d772bde968972f54Anders Carlsson // Objective-C Expressions 123660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCAtExpression(SourceLocation AtLocation); 123760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCStringLiteral(SourceLocation AtLoc); 123860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc); 123960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc); 124060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc); 12411b730e847ded503f2e615154035c083c4f94a067Douglas Gregor bool isSimpleObjCMessageExpression(); 124260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCMessageExpression(); 124360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc, 12442725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor SourceLocation SuperLoc, 1245b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ReceiverType, 12461d922960e083906a586609ac6978678147250177Sebastian Redl ExprArg ReceiverExpr); 124760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseAssignmentExprWithObjCMessageExprStart( 12482725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor SourceLocation LBracloc, SourceLocation SuperLoc, 1249b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ReceiverType, ExprArg ReceiverExpr); 12506aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr); 125161364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 12525508518a2702b00be3b15a26d772bde968972f54Anders Carlsson //===--------------------------------------------------------------------===// 12535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.8: Statements and Blocks. 125461364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 125560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseStatement() { 1256c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian StmtVector Stmts(Actions); 1257c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian return ParseStatementOrDeclaration(Stmts, true); 125861364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 1259c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian StmtResult ParseStatementOrDeclaration(StmtVector& Stmts, 1260c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian bool OnlyStatement = false); 1261312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor StmtResult ParseExprStatement(ParsedAttributes &Attrs, ExprResult Primary); 12627f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseLabeledStatement(ParsedAttributes &Attr); 1263bb9b80c308d7d3f758886243c7145404a50c66cfRichard Trieu StmtResult ParseCaseStatement(ParsedAttributes &Attr, 1264bb9b80c308d7d3f758886243c7145404a50c66cfRichard Trieu bool MissingCase = false, 1265bb9b80c308d7d3f758886243c7145404a50c66cfRichard Trieu ExprResult Expr = ExprResult()); 12667f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseDefaultStatement(ParsedAttributes &Attr); 12677f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseCompoundStatement(ParsedAttributes &Attr, 1268312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool isStmtExpr = false); 126960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); 127060d7b3a319d84d688752be3870615ac0f111fb16John McCall bool ParseParenExprOrCondition(ExprResult &ExprResult, 1271d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *&DeclResult, 1272586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor SourceLocation Loc, 127344aa1f397855f130e88e62ffc1029f7f83bb5d2eArgyrios Kyrtzidis bool ConvertToBoolean); 12747f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseIfStatement(ParsedAttributes &Attr); 12757f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseSwitchStatement(ParsedAttributes &Attr); 12767f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseWhileStatement(ParsedAttributes &Attr); 12777f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseDoStatement(ParsedAttributes &Attr); 12787f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseForStatement(ParsedAttributes &Attr); 12797f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseGotoStatement(ParsedAttributes &Attr); 12807f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseContinueStatement(ParsedAttributes &Attr); 12817f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseBreakStatement(ParsedAttributes &Attr); 12827f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseReturnStatement(ParsedAttributes &Attr); 128360d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseAsmStatement(bool &msAsm); 1284a44724d0d6d03568ec9acadc0781d612163008e1Abramo Bagnara StmtResult FuzzyParseMicrosoftAsmStatement(SourceLocation AsmLoc); 1285ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names, 1286ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson llvm::SmallVectorImpl<ExprTy *> &Constraints, 1287ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson llvm::SmallVectorImpl<ExprTy *> &Exprs); 1288a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 1289a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl //===--------------------------------------------------------------------===// 1290a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl // C++ 6: Statements and Blocks 1291a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 12927f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall StmtResult ParseCXXTryBlock(ParsedAttributes &Attr); 129360d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc); 129460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCXXCatchBlock(); 1295a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 1296a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl //===--------------------------------------------------------------------===// 1297a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl // Objective-C Statements 1298a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 129960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCAtStatement(SourceLocation atLoc); 130060d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCTryStmt(SourceLocation atLoc); 130160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCThrowStmt(SourceLocation atLoc); 130260d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc); 1303b235fc2cf37621c7fc6511bb2b8788c95f9fb9fcAnders Carlsson 13045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 13055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 13065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.7: Declarations. 130767d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall 130867d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// A context for parsing declaration specifiers. TODO: flesh this 130967d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// out, there are other significant restrictions on specifiers than 131067d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// would be best implemented in the parser. 131167d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall enum DeclSpecContext { 131267d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall DSC_normal, // normal context 13130efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DSC_class, // class context, enables 'friend' 13140efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DSC_top_level // top-level/namespace declaration context 131567d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall }; 13161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1317ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// Information on a C++0x for-range-initializer found while parsing a 1318ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// declaration which turns out to be a for-range-declaration. 1319ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith struct ForRangeInit { 1320ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith SourceLocation ColonLoc; 1321ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ExprResult RangeExpr; 1322ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 1323ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool ParsedForRangeDecl() { return !ColonLoc.isInvalid(); } 1324ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith }; 1325ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 1326c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian DeclGroupPtrTy ParseDeclaration(StmtVector &Stmts, 1327c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian unsigned Context, SourceLocation &DeclEnd, 13287f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributesWithRange &attrs); 1329c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian DeclGroupPtrTy ParseSimpleDeclaration(StmtVector &Stmts, 1330c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian unsigned Context, 1331bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt SourceLocation &DeclEnd, 13327f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &attrs, 1333ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool RequireSemi, 1334ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ForRangeInit *FRI = 0); 1335312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor DeclGroupPtrTy ParseSimpleDeclaration(ParsingDeclSpec &DS, 1336312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor StmtVector &Stmts, 1337312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor unsigned Context, 1338312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor SourceLocation &DeclEnd, 1339312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool RequireSemi, 1340312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor ForRangeInit *FRI = 0); 134154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context, 1342d8ac05753dc4506224d445ff98399c01da3136e5John McCall bool AllowFunctionDefinitions, 1343ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith SourceLocation *DeclEnd = 0, 1344ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ForRangeInit *FRI = 0); 1345d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseDeclarationAfterDeclarator(Declarator &D, 1346e542c862bdf9a9bcb4f468be8fa6561372430611Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo()); 1347ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool ParseAttributesAfterDeclarator(Declarator &D); 1348ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith Decl *ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D, 1349ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo()); 1350c9977d09a2de7f7d2245973413d4caf86c736640Douglas Gregor Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope); 1351c9977d09a2de7f7d2245973413d4caf86c736640Douglas Gregor Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope); 1352d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl 13530fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// \brief When in code-completion, skip parsing of the function/method body 13540fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// unless the body contains the code-completion point. 13550fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// 13560fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// \returns true if the function body was skipped. 1357b162054ba8f5b64fe87fbc4837933ab23eebd52bArgyrios Kyrtzidis bool trySkippingFunctionBodyForCodeCompletion(); 13580fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis 1359f4382f50b7ab9f445c3f5b3ddaa59e6da25ea3bbChris Lattner bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, 13604d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo, 1361e40c295d017a8f75a945fe9ed2aa9d8bb7a7341aChris Lattner AccessSpecifier AS); 13620efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DeclSpecContext getDeclSpecContextFromDeclaratorContext(unsigned Context); 13631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void ParseDeclarationSpecifiers(DeclSpec &DS, 13644d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 136567d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall AccessSpecifier AS = AS_none, 136667d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall DeclSpecContext DSC = DSC_normal); 13671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ParseOptionalTypeSpecifier(DeclSpec &DS, bool &isInvalid, 13687a0ab5f387722c83e19c7133b46b16988eb19e45Chris Lattner const char *&PrevSpec, 1369fec54013fcd0eb72642741584ca04c1bc292bef8John McCall unsigned &DiagID, 1370d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 1371d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl bool SuppressDeclarations = false); 13724d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 13735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseSpecifierQualifierList(DeclSpec &DS); 13741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1375b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, 1376b77cab97f17f946744c920629ca17271308d8ebfDouglas Gregor ObjCTypeNameContext Context); 13775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 13784c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS, 13791b21391b3b1b7dd829c35f9b69199ed2a67da25aArgyrios Kyrtzidis const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 13801b21391b3b1b7dd829c35f9b69199ed2a67da25aArgyrios Kyrtzidis AccessSpecifier AS = AS_none); 1381d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl); 13825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType, 1383d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagDecl); 1384bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall 1385bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall struct FieldCallback { 1386d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall virtual Decl *invoke(FieldDeclarator &Field) = 0; 13876c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall virtual ~FieldCallback() {} 13886c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall 13896c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall private: 13906c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall virtual void _anchor(); 1391bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall }; 1392d0014540005f2a5ab837365db6bd40f479406758John McCall struct ObjCPropertyCallback; 1393bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall 1394bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall void ParseStructDeclaration(DeclSpec &DS, FieldCallback &Callback); 13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13969497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false); 1397eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis bool isTypeSpecifierQualifier(); 13985f8aa696619e32bf307232841fedb704ba733b4dSteve Naroff bool isTypeQualifier() const; 1399b3a4e432c90be98c6d918087750397e86d030368Chris Lattner 1400b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// isKnownToBeTypeSpecifier - Return true if we know that the specified token 1401b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// is definitely a type-specifier. Return false if it isn't part of a type 1402b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// specifier or if we're not sure. 1403b3a4e432c90be98c6d918087750397e86d030368Chris Lattner bool isKnownToBeTypeSpecifier(const Token &Tok) const; 14045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 14055404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isDeclarationStatement - Disambiguates between a declaration or an 14065404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// expression statement, when parsing function bodies. 14075404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns true for declaration, false for expression. 14085404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isDeclarationStatement() { 14095404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis if (getLang().CPlusPlus) 14105404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis return isCXXDeclarationStatement(); 14119497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor return isDeclarationSpecifier(true); 14125404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 14135404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 1414bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis /// isSimpleDeclaration - Disambiguates between a declaration or an 1415bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis /// expression, mainly used for the C 'clause-1' or the C++ 1416bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis // 'for-init-statement' part of a 'for' statement. 1417bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis /// Returns true for declaration, false for expression. 1418bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis bool isSimpleDeclaration() { 1419bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis if (getLang().CPlusPlus) 1420bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis return isCXXSimpleDeclaration(); 14219497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor return isDeclarationSpecifier(true); 1422bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis } 1423bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis 14249497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor /// \brief Determine whether we are currently at the start of an Objective-C 14259497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor /// class message that appears to be missing the open bracket '['. 14269497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor bool isStartOfObjCClassMessageMissingOpenBracket(); 14279497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor 14280efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// \brief Starting with a scope specifier, identifier, or 14290efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// template-id that refers to the current class, determine whether 14300efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// this is a constructor declarator. 14310efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor bool isConstructorDeclarator(); 14320efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor 14338b642592a35167a3780074e78674e0bece87c40cDouglas Gregor /// \brief Specifies the context in which type-id/expression 14348b642592a35167a3780074e78674e0bece87c40cDouglas Gregor /// disambiguation will occur. 14358b642592a35167a3780074e78674e0bece87c40cDouglas Gregor enum TentativeCXXTypeIdContext { 14368b642592a35167a3780074e78674e0bece87c40cDouglas Gregor TypeIdInParens, 14378b642592a35167a3780074e78674e0bece87c40cDouglas Gregor TypeIdAsTemplateArgument 14388b642592a35167a3780074e78674e0bece87c40cDouglas Gregor }; 14398b642592a35167a3780074e78674e0bece87c40cDouglas Gregor 14408b642592a35167a3780074e78674e0bece87c40cDouglas Gregor 144178c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// isTypeIdInParens - Assumes that a '(' was parsed and now we want to know 144278c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// whether the parens contain an expression or a type-id. 144378c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// Returns true for a type-id and false for an expression. 1444f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isTypeIdInParens(bool &isAmbiguous) { 144578c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis if (getLang().CPlusPlus) 1446f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isCXXTypeId(TypeIdInParens, isAmbiguous); 1447f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis isAmbiguous = false; 144878c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis return isTypeSpecifierQualifier(); 144978c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis } 1450f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isTypeIdInParens() { 1451f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isAmbiguous; 1452f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isTypeIdInParens(isAmbiguous); 1453f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis } 145478c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis 14555404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXDeclarationStatement - C++-specialized function that disambiguates 14565404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// between a declaration or an expression statement, when parsing function 14575404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// bodies. Returns true for declaration, false for expression. 14585404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isCXXDeclarationStatement(); 14595404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 14605404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXSimpleDeclaration - C++-specialized function that disambiguates 14615404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// between a simple-declaration or an expression-statement. 14625404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 14635404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 14645404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns false if the statement is disambiguated as expression. 14655404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isCXXSimpleDeclaration(); 14665404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 14675404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXFunctionDeclarator - Disambiguates between a function declarator or 14685404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// a constructor-style initializer, when parsing declaration statements. 14695404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns true for function declarator and false for constructor-style 1470e75d849d9141d8e47d05a91b7b5c04194854e47aArgyrios Kyrtzidis /// initializer. If 'warnIfAmbiguous' is true a warning will be emitted to 1471259b0d91f2ff90d8daf39221fe133bf1596c5ffbArgyrios Kyrtzidis /// indicate that the parens were disambiguated as function declarator. 14725404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 14735404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 1474e75d849d9141d8e47d05a91b7b5c04194854e47aArgyrios Kyrtzidis bool isCXXFunctionDeclarator(bool warnIfAmbiguous); 14755404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 1476a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// isCXXConditionDeclaration - Disambiguates between a declaration or an 1477a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// expression for a condition of a if/switch/while/for statement. 1478a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 1479a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 1480a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis bool isCXXConditionDeclaration(); 1481a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis 1482f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous); 1483f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isCXXTypeId(TentativeCXXTypeIdContext Context) { 1484f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isAmbiguous; 1485f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isCXXTypeId(Context, isAmbiguous); 1486f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis } 148778c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis 1488b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// TPResult - Used as the result value for functions whose purpose is to 1489b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// disambiguate C++ constructs by "tentatively parsing" them. 1490b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// This is a class instead of a simple enum because the implicit enum-to-bool 1491b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// conversions may cause subtle bugs. 1492b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis class TPResult { 1493b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis enum Result { 1494b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_true, 1495b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_false, 1496b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_ambiguous, 1497b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_error 1498b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis }; 1499b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis Result Res; 1500b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult(Result result) : Res(result) {} 1501b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis public: 1502b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult True() { return TPR_true; } 1503b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult False() { return TPR_false; } 1504b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult Ambiguous() { return TPR_ambiguous; } 1505b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult Error() { return TPR_error; } 1506b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis 1507b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis bool operator==(const TPResult &RHS) const { return Res == RHS.Res; } 1508b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis bool operator!=(const TPResult &RHS) const { return Res != RHS.Res; } 1509b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis }; 1510b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis 1511a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// \brief Based only on the given token kind, determine whether we know that 1512a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// we're at the start of an expression or a type-specifier-seq (which may 1513a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// be an expression, in C++). 1514a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// 1515a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// This routine does not attempt to resolve any of the trick cases, e.g., 1516a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// those involving lookup of identifiers. 1517a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// 1518a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// \returns \c TPR_true if this token starts an expression, \c TPR_false if 1519a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// this token starts a type-specifier-seq, or \c TPR_ambiguous if it cannot 1520a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// tell. 1521a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor TPResult isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind); 1522a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor 1523b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// isCXXDeclarationSpecifier - Returns TPResult::True() if it is a 1524b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// declaration specifier, TPResult::False() if it is not, 1525b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// TPResult::Ambiguous() if it could be either a decl-specifier or a 1526b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// function-style cast, and TPResult::Error() if a parsing error was 1527b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// encountered. 15285404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Doesn't consume tokens. 1529b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult isCXXDeclarationSpecifier(); 1530a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor 15315404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis // "Tentative parsing" functions, used for disambiguation. If a parsing error 1532b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // is encountered they will return TPResult::Error(). 1533b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // Returning TPResult::True()/False() indicates that the ambiguity was 1534b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // resolved and tentative parsing may stop. TPResult::Ambiguous() indicates 1535b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // that more tentative parsing is necessary for disambiguation. 15365404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis // They all consume tokens, so backtracking should be used after calling them. 15375404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 1538b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseDeclarationSpecifier(); 1539b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseSimpleDeclaration(); 1540b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseTypeofSpecifier(); 15419bd1d8d174a9d15ae343246c8322299248b9e92aDouglas Gregor TPResult TryParseProtocolQualifiers(); 1542b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseInitDeclaratorList(); 154378c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis TPResult TryParseDeclarator(bool mayBeAbstract, bool mayHaveIdentifier=true); 1544b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseParameterDeclarationClause(); 1545b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseFunctionDeclarator(); 1546b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseBracketDeclarator(); 15475404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 1548683a81f4373cf1fa9d41a751dca6f7c36125b058Douglas Gregor TypeResult ParseTypeName(SourceRange *Range = 0, 1549683a81f4373cf1fa9d41a751dca6f7c36125b058Douglas Gregor Declarator::TheContext Context 1550c05a94b7accd4035bf5d5897c434c445b22da855John McCall = Declarator::TypeNameContext); 155198eb8a7a702b95183ed015706b1f1c66f5cb27a4Mike Stump void ParseBlockId(); 15527f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 15537f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ProhibitAttributes(ParsedAttributesWithRange &attrs) { 15547f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (!attrs.Range.isValid()) return; 15557f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall DiagnoseProhibitedAttributes(attrs); 15567f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15577f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs); 15587f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 15597f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseGNUAttributes(Declarator &D) { 15607f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (Tok.is(tok::kw___attribute)) { 15610b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributes attrs(AttrFactory); 15627f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation endLoc; 15637f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseGNUAttributes(attrs, &endLoc); 15640b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall D.takeAttributes(attrs, endLoc); 15657f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15667f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15677f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseGNUAttributes(ParsedAttributes &attrs, 15687f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 15697f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (Tok.is(tok::kw___attribute)) 15707f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseGNUAttributes(attrs, endLoc); 15717f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15727f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseGNUAttributes(ParsedAttributes &attrs, 15737f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0); 15747f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 15757f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(Declarator &D) { 15767f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) { 15770b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange attrs(AttrFactory); 15787f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation endLoc; 15797f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseCXX0XAttributes(attrs, &endLoc); 15800b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall D.takeAttributes(attrs, endLoc); 15817f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15827f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15837f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(ParsedAttributes &attrs, 15847f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 15857f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) { 15860b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange attrsWithRange(AttrFactory); 15877f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseCXX0XAttributes(attrsWithRange, endLoc); 15880b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall attrs.takeAllFrom(attrsWithRange); 15897f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15907f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15917f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(ParsedAttributesWithRange &attrs, 15927f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 15937f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) 15947f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseCXX0XAttributes(attrs, endLoc); 15957f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 15967f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseCXX0XAttributes(ParsedAttributesWithRange &attrs, 15977f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *EndLoc = 0); 15987f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 15997f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseMicrosoftAttributes(ParsedAttributes &attrs, 16007f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 16017f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (getLang().Microsoft && Tok.is(tok::l_square)) 16027f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseMicrosoftAttributes(attrs, endLoc); 16037f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 16047f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseMicrosoftAttributes(ParsedAttributes &attrs, 16057f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0); 16067f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseMicrosoftDeclSpec(ParsedAttributes &attrs); 16077f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs); 16087f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseBorlandTypeAttributes(ParsedAttributes &attrs); 1609f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne void ParseOpenCLAttributes(ParsedAttributes &attrs); 1610207f4d8543529221932af82836016a2ef066c917Peter Collingbourne void ParseOpenCLQualifiers(DeclSpec &DS); 16117f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 16120a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor VersionTuple ParseVersionTuple(SourceRange &Range); 16130a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor void ParseAvailabilityAttribute(IdentifierInfo &Availability, 16140a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor SourceLocation AvailabilityLoc, 16150a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor ParsedAttributes &attrs, 16160a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor SourceLocation *endLoc); 16170a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1618d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff void ParseTypeofSpecifier(DeclSpec &DS); 16196fd634f4ac59f5923cffadadb99d19f23c18707aAnders Carlsson void ParseDecltypeSpecifier(DeclSpec &DS); 1620bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt 162160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXX0XAlignArgument(SourceLocation Start); 1622eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1623cc54d594d4f6509c0e3a8e349e481d9b5d899df6Anders Carlsson VirtSpecifiers::Specifier isCXX0XVirtSpecifier() const; 1624b971dbdb65149a7cf0c046380186d0204e5b411eAnders Carlsson void ParseOptionalCXX0XVirtSpecifierSeq(VirtSpecifiers &VS); 16251f3b6fdabbb10779a473d6315154d7325ce20aeaAnders Carlsson 16268a29ba0d66bce99014651f1e3351aef6c3361d3fAnders Carlsson bool isCXX0XFinalKeyword() const; 1627cc54d594d4f6509c0e3a8e349e481d9b5d899df6Anders Carlsson 1628eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to 1629eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// enter a new C++ declarator scope and exit it when the function is 1630eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// finished. 1631eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis class DeclaratorScopeObj { 1632eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis Parser &P; 1633751810234ffb45327f23c5f9fda0b944e480bd2bArgyrios Kyrtzidis CXXScopeSpec &SS; 1634f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis bool EnteredScope; 1635f7f3d0db754db0500b56d49ac19f795f13965912John McCall bool CreatedScope; 1636eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis public: 1637f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss) 1638f7f3d0db754db0500b56d49ac19f795f13965912John McCall : P(p), SS(ss), EnteredScope(false), CreatedScope(false) {} 1639eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1640eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis void EnterDeclaratorScope() { 16412bcb3439b50c7f227a21d7118a2a76904ec60331Argyrios Kyrtzidis assert(!EnteredScope && "Already entered the scope!"); 1642f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis assert(SS.isSet() && "C++ scope was not set!"); 1643f7f3d0db754db0500b56d49ac19f795f13965912John McCall 1644f7f3d0db754db0500b56d49ac19f795f13965912John McCall CreatedScope = true; 1645f7f3d0db754db0500b56d49ac19f795f13965912John McCall P.EnterScope(0); // Not a decl scope. 1646f7f3d0db754db0500b56d49ac19f795f13965912John McCall 164723c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS)) 16483fdbed594f4cb238fe37cad2ec3fefa3b6f67125Douglas Gregor EnteredScope = true; 1649eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis } 1650eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1651eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis ~DeclaratorScopeObj() { 1652f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis if (EnteredScope) { 1653f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis assert(SS.isSet() && "C++ scope was cleared ?"); 165423c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS); 1655f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis } 1656f7f3d0db754db0500b56d49ac19f795f13965912John McCall if (CreatedScope) 1657f7f3d0db754db0500b56d49ac19f795f13965912John McCall P.ExitScope(); 1658eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis } 1659eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis }; 16601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParseDeclarator - Parse and verify a newly-initialized declarator. 16625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseDeclarator(Declarator &D); 16634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl /// A function that parses a variant of direct-declarator. 16644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef void (Parser::*DirectDeclParseFunction)(Declarator&); 16654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl void ParseDeclaratorInternal(Declarator &D, 16664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl DirectDeclParseFunction DirectDeclParser); 16677f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 1668bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt void ParseTypeQualifierListOpt(DeclSpec &DS, bool GNUAttributesAllowed = true, 1669bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt bool CXX0XAttributesAllowed = true); 16705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseDirectDeclarator(Declarator &D); 16715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseParenDeclarator(Declarator &D); 16727399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner void ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, 16737f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &attrs, 16747399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner bool RequiresArg = false); 167566d28650752eeac0b02802a1d8cea425cb6b1c0fChris Lattner void ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc, 167683a944763b0948c608eb48f101ec10a1ae5da46aChris Lattner IdentifierInfo *FirstIdent, 167783a944763b0948c608eb48f101ec10a1ae5da46aChris Lattner SourceLocation FirstIdentLoc, 167866d28650752eeac0b02802a1d8cea425cb6b1c0fChris Lattner Declarator &D); 16795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseBracketDeclarator(Declarator &D); 16801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16818f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner //===--------------------------------------------------------------------===// 16828f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner // C++ 7: Declarations [dcl.dcl] 16831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1684bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt bool isCXX0XAttributeSpecifier(bool FullLookahead = false, 1685bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt tok::TokenKind *After = 0); 1686bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt 1687d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd, 1688d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation InlineLoc = SourceLocation()); 1689d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseLinkage(ParsingDeclSpec &DS, unsigned Context); 1690d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseUsingDirectiveOrDeclaration(unsigned Context, 169178b810559d89e996e00684335407443936ce34a1John McCall const ParsedTemplateInfo &TemplateInfo, 1692d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd, 16937f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributesWithRange &attrs); 169478b810559d89e996e00684335407443936ce34a1John McCall Decl *ParseUsingDirective(unsigned Context, 169578b810559d89e996e00684335407443936ce34a1John McCall SourceLocation UsingLoc, 16967f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation &DeclEnd, 16977f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &attrs); 169878b810559d89e996e00684335407443936ce34a1John McCall Decl *ParseUsingDeclaration(unsigned Context, 169978b810559d89e996e00684335407443936ce34a1John McCall const ParsedTemplateInfo &TemplateInfo, 170078b810559d89e996e00684335407443936ce34a1John McCall SourceLocation UsingLoc, 1701d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd, 1702d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl AccessSpecifier AS = AS_none); 1703d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd); 1704d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc, 1705d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation AliasLoc, IdentifierInfo *Alias, 1706d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd); 17071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1708e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor //===--------------------------------------------------------------------===// 1709e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor // C++ 9: classes [class] and C structs/unions. 1710059101f922de6eb765601459925f4c8914420b23Douglas Gregor TypeResult ParseClassName(SourceLocation &EndLocation, CXXScopeSpec &SS); 17114c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc, 17121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump DeclSpec &DS, 17134d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 1714d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl AccessSpecifier AS = AS_none, 1715d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl bool SuppressDeclarations = false); 17164cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType, 1717d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagDecl); 171837b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void ParseCXXClassMemberDeclaration(AccessSpecifier AS, 1719c9068d7dd94d439cec66c421115d15303e481025John McCall const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 1720c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject *DiagsFromTParams = 0); 1721d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseConstructorInitializer(Decl *ConstructorDecl); 1722d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall MemInitResult ParseMemInitializer(Decl *ConstructorDecl); 1723d33133cdc1af466f9c276249b2621be03867888bEli Friedman void HandleMemberFunctionDefaultArgs(Declarator& DeclaratorInfo, 1724d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ThisDecl); 1725e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor 1726e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor //===--------------------------------------------------------------------===// 1727e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor // C++ 10: Derived classes [class.derived] 1728d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseBaseClause(Decl *ClassDecl); 1729d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall BaseResult ParseBaseSpecifier(Decl *ClassDecl); 17301b7f89846f10681ce3cbe89ef5d60691d55bd918Douglas Gregor AccessSpecifier getAccessSpecifierIfPresent() const; 17311cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor 17323f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, 17333f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor IdentifierInfo *Name, 17343f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor SourceLocation NameLoc, 17353f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor bool EnteringContext, 1736b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 1737d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor UnqualifiedId &Id, 17380278e123b4606ea15dbfa717e9c5a76a5ef2bc7dDouglas Gregor bool AssumeTemplateId, 17390278e123b4606ea15dbfa717e9c5a76a5ef2bc7dDouglas Gregor SourceLocation TemplateKWLoc); 1740ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, 1741b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 1742ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor UnqualifiedId &Result); 17433f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, 174402a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor bool AllowDestructorName, 174502a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor bool AllowConstructorName, 1746b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 17473f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor UnqualifiedId &Result); 17483f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor 17491cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor //===--------------------------------------------------------------------===// 1750adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor // C++ 14: Templates [temp] 1751c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor 1752adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor // C++ 14.1: Template Parameters [temp.param] 1753d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseDeclarationStartingWithTemplate(unsigned Context, 17544d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor SourceLocation &DeclEnd, 17554d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor AccessSpecifier AS = AS_none); 1756d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateDeclarationOrSpecialization(unsigned Context, 175797144fc41a9419bf6d74fc9450e8ef3f6e11f7e0Chris Lattner SourceLocation &DeclEnd, 17584d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor AccessSpecifier AS); 1759d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseSingleDeclarationAfterTemplate( 17601426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor unsigned Context, 17614d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo, 1762c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject &DiagsFromParams, 17631426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor SourceLocation &DeclEnd, 17641426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor AccessSpecifier AS=AS_none); 17651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ParseTemplateParameters(unsigned Depth, 17661f58816e6589ef15d1509c6c99bb8fabf2a4cda9John McCall llvm::SmallVectorImpl<Decl*> &TemplateParams, 17671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation &LAngleLoc, 1768c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor SourceLocation &RAngleLoc); 1769c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor bool ParseTemplateParameterList(unsigned Depth, 17701f58816e6589ef15d1509c6c99bb8fabf2a4cda9John McCall llvm::SmallVectorImpl<Decl*> &TemplateParams); 177198440b4ac17dc5f85ea3db683c1c1785449c17e1Douglas Gregor bool isStartOfTemplateTypeParameter(); 1772d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateParameter(unsigned Depth, unsigned Position); 1773d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTypeParameter(unsigned Depth, unsigned Position); 1774d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position); 1775d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position); 1776d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor // C++ 14.3: Template arguments [temp.arg] 1777314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor typedef llvm::SmallVector<ParsedTemplateArgument, 16> TemplateArgList; 1778cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor 17797532dc66648cfe7432c9fe66dec5225f0ab301c6Douglas Gregor bool ParseTemplateIdAfterTemplateName(TemplateTy Template, 17801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation TemplateNameLoc, 1781059101f922de6eb765601459925f4c8914420b23Douglas Gregor const CXXScopeSpec &SS, 1782cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor bool ConsumeLastToken, 1783cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor SourceLocation &LAngleLoc, 1784cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor TemplateArgList &TemplateArgs, 1785cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor SourceLocation &RAngleLoc); 1786cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor 1787c8e27cc402043ec86c1698c09e4ee9e415b16207Chris Lattner bool AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, 1788059101f922de6eb765601459925f4c8914420b23Douglas Gregor CXXScopeSpec &SS, 1789ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor UnqualifiedId &TemplateName, 179039a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor SourceLocation TemplateKWLoc = SourceLocation(), 179139a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor bool AllowTypeAnnotation = true); 1792059101f922de6eb765601459925f4c8914420b23Douglas Gregor void AnnotateTemplateIdTokenAsType(); 1793d5ab9b0a0ae24f7d0f49f6f10fd1b247e64b3306Douglas Gregor bool IsTemplateArgumentList(unsigned Skip = 0); 1794314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs); 1795788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor ParsedTemplateArgument ParseTemplateTemplateArgument(); 1796314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor ParsedTemplateArgument ParseTemplateArgument(); 1797d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseExplicitInstantiation(SourceLocation ExternLoc, 1798d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall SourceLocation TemplateLoc, 1799d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall SourceLocation &DeclEnd); 180064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 180164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl //===--------------------------------------------------------------------===// 180264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // GNU G++: Type Traits [Type-Traits.html in the GCC manual] 180360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseUnaryTypeTrait(); 18046ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet ExprResult ParseBinaryTypeTrait(); 1805f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor 1806f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor //===--------------------------------------------------------------------===// 1807552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Embarcadero: Expression Traits 1808552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExprResult ParseExpressionTrait(); 1809552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1810552622067dc45013d240f73952fece703f5e63bdJohn Wiegley //===--------------------------------------------------------------------===// 1811f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor // Preprocessor code-completion pass-through 1812f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor virtual void CodeCompleteDirective(bool InConditional); 1813f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor virtual void CodeCompleteInConditionalExclusion(); 18141fbb447e9d43c2c676e94081fbfee7eb6cbe933bDouglas Gregor virtual void CodeCompleteMacroName(bool IsDefinition); 1815f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor virtual void CodeCompletePreprocessorExpression(); 1816f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro, 1817f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor MacroInfo *MacroInfo, 1818f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor unsigned ArgumentIndex); 181955817afdf9d453a443262a733f6caf6692dca118Douglas Gregor virtual void CodeCompleteNaturalLanguage(); 18205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 18215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 18225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 18235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 18245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1825