Parser.h revision 334d47e92e9f241576fdeb7477b69a03136ba854
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>
251100258c19dd8967ba078c0bc81fc06cea9d033fChris Lattner#include <list>
265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
28fcdd8fe26de3eee44927600bf1853e21bd90dd84Daniel Dunbar  class AttributeList;
29bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  struct CXX0XAttributeList;
30fcdd8fe26de3eee44927600bf1853e21bd90dd84Daniel Dunbar  class PragmaHandler;
315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  class Scope;
322b5289b6fd7e3d9899868410a498c081c9595662John McCall  class DeclGroupRef;
333cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner  class DiagnosticBuilder;
340102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  class Parser;
354726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek  class PragmaUnusedHandler;
3608d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  class ColonProtectionRAIIObject;
370fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  class InMessageExpressionRAIIObject;
380fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor
390102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// PrettyStackTraceParserEntry - If a crash happens while the parser is active,
400102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// an entry is printed for it.
410102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerclass PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry {
420102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  const Parser &P;
430102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerpublic:
440102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  PrettyStackTraceParserEntry(const Parser &p) : P(p) {}
450102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  virtual void print(llvm::raw_ostream &OS) const;
460102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner};
471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
486aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// PrecedenceLevels - These are precedences for the binary/ternary
496aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// operators in the C99 grammar.  These have been named to relate
506aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// with the C99 grammar productions.  Low precedences numbers bind
516aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// more weakly than high numbers.
526aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregornamespace prec {
536aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor  enum Level {
546aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Unknown         = 0,    // Not binary operator.
556aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Comma           = 1,    // ,
566aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Assignment      = 2,    // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=
576aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Conditional     = 3,    // ?
586aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    LogicalOr       = 4,    // ||
596aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    LogicalAnd      = 5,    // &&
606aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    InclusiveOr     = 6,    // |
616aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    ExclusiveOr     = 7,    // ^
626aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    And             = 8,    // &
636aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Equality        = 9,    // ==, !=
646aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Relational      = 10,   //  >=, <=, >, <
656aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Shift           = 11,   // <<, >>
666aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Additive        = 12,   // -, +
676aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    Multiplicative  = 13,   // *, /, %
686aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor    PointerToMember = 14    // .*, ->*
696aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor  };
706aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor}
711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Parser - This implements a parser for the C family of languages.  After
735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// parsing units of the grammar, productions are invoked to handle whatever has
745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// been read.
755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
76f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregorclass Parser : public CodeCompletionHandler {
774726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek  friend class PragmaUnusedHandler;
7808d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  friend class ColonProtectionRAIIObject;
790fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  friend class InMessageExpressionRAIIObject;
8036d36806f1972f7ec1d2a3f59155187278c56508Argyrios Kyrtzidis  friend class ParenBraceBracketBalancer;
810102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  PrettyStackTraceParserEntry CrashInfo;
821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Preprocessor &PP;
841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8597d0205d16fef2a783e785459b5f30f6a9dfbcb9Eric Christopher  /// Tok - The current token we are peeking ahead.  All parsing methods assume
865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// that this is valid.
87d217773f106856a11879ec79dc468efefaf2ee75Chris Lattner  Token Tok;
881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
894b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor  // PrevTokLocation - The location of the token we previously
904b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor  // consumed. This token is used for diagnostics where we expected to
914b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor  // see a token following another token (e.g., the ';' at the end of
924b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor  // a statement).
934b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor  SourceLocation PrevTokLocation;
944b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor
955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  unsigned short ParenCount, BracketCount, BraceCount;
965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// Actions - These are the callbacks we invoke as we parse various constructs
9887c300738174924453648c3b2d6f366c8284fac4Douglas Gregor  /// in the file.
99f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall  Sema &Actions;
1001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  Diagnostic &Diags;
1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1039e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner  /// ScopeCache - Cache scopes to reduce malloc traffic.
1049e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner  enum { ScopeCacheSize = 16 };
1059e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner  unsigned NumCachedScopes;
1069e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner  Scope *ScopeCache[ScopeCacheSize];
107662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar
108662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar  /// Ident_super - IdentifierInfo for "super", to support fast
109662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar  /// comparison.
110662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar  IdentifierInfo *Ident_super;
11182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// Ident_vector and Ident_pixel - cached IdentifierInfo's for
11282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// "vector" and "pixel" fast comparison.  Only present if
11382287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// AltiVec enabled.
11482287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  IdentifierInfo *Ident_vector;
11582287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  IdentifierInfo *Ident_pixel;
116662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar
117cbb98edd530787c2ac019e437e7c599df8004ba7Daniel Dunbar  llvm::OwningPtr<PragmaHandler> AlignHandler;
118aa8b0d19244a6e7e8e5798fcc6aef003c274d3e0Eli Friedman  llvm::OwningPtr<PragmaHandler> GCCVisibilityHandler;
119861800c676004eabed5927f0552620d06c80a40aDaniel Dunbar  llvm::OwningPtr<PragmaHandler> OptionsHandler;
1204726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek  llvm::OwningPtr<PragmaHandler> PackHandler;
1214726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek  llvm::OwningPtr<PragmaHandler> UnusedHandler;
1229991479ad5dde617168cc1e4b18425cdbbfd9fa9Eli Friedman  llvm::OwningPtr<PragmaHandler> WeakHandler;
1231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor  /// Whether the '>' token acts as an operator or not. This will be
12555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor  /// true except when we are parsing an expression within a C++
12655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor  /// template argument list, where the '>' closes the template
12755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor  /// argument list.
12855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor  bool GreaterThanIsOperator;
12908d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner
13008d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  /// ColonIsSacred - When this is false, we aggressively try to recover from
13108d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  /// code like "foo : bar" as if it were a typo for "foo :: bar".  This is not
13208d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  /// safe in case statements and a few other things.  This is managed by the
13308d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  /// ColonProtectionRAIIObject RAII object.
13408d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner  bool ColonIsSacred;
13555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor
1360fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  /// \brief When true, we are directly inside an Ojective-C messsage
1370fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  /// send expression.
1380fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  ///
1390fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  /// This is managed by the \c InMessageExpressionRAIIObject class, and
1400fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  /// should not be set directly.
1410fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor  bool InMessageExpression;
1420fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor
143c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor  /// The "depth" of the template parameters currently being parsed.
144c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor  unsigned TemplateParameterDepth;
1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic:
147f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall  Parser(Preprocessor &PP, Sema &Actions);
1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ~Parser();
1495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  const LangOptions &getLang() const { return PP.getLangOptions(); }
151444be7366d0a1e172c0290a1ea54c1cb16b5947cDaniel Dunbar  const TargetInfo &getTargetInfo() const { return PP.getTargetInfo(); }
1520102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  Preprocessor &getPreprocessor() const { return PP; }
153f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall  Sema &getActions() const { return Actions; }
1541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1550102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner  const Token &getCurToken() const { return Tok; }
15623c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor  Scope *getCurScope() const { return Actions.getCurScope(); }
15723c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor
1585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // Type forwarding.  All of these are statically 'void*', but they may all be
1595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // different actual classes based on the actions in place.
160ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef Expr ExprTy;
161ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef Stmt StmtTy;
1622b5289b6fd7e3d9899868410a498c081c9595662John McCall  typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
163ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef CXXBaseSpecifier BaseTy;
164ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef CXXBaseOrMemberInitializer MemInitTy;
165ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef NestedNameSpecifier CXXScopeTy;
166ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef TemplateParameterList TemplateParamsTy;
1672b5289b6fd7e3d9899868410a498c081c9595662John McCall  typedef OpaquePtr<TemplateName> TemplateTy;
1687ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor
169ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef llvm::SmallVector<TemplateParameterList *, 4> TemplateParameterLists;
170c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor
1719ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef clang::ExprResult        ExprResult;
1729ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef clang::StmtResult        StmtResult;
1739ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef clang::BaseResult        BaseResult;
1749ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef clang::MemInitResult     MemInitResult;
1759ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef clang::TypeResult        TypeResult;
17615faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl
1779ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef Expr *ExprArg;
1789ae2f076ca5ab1feb3ba95629099ec2319833701John McCall  typedef ASTMultiPtr<Stmt*> MultiStmtArg;
179f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall  typedef Sema::FullExprArg FullExprArg;
1801d922960e083906a586609ac6978678147250177Sebastian Redl
18160d7b3a319d84d688752be3870615ac0f111fb16John McCall  /// Adorns a ExprResult with Actions to make it an ExprResult
18260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult Owned(ExprResult res) {
18360d7b3a319d84d688752be3870615ac0f111fb16John McCall    return ExprResult(res);
18461364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl  }
18560d7b3a319d84d688752be3870615ac0f111fb16John McCall  /// Adorns a StmtResult with Actions to make it an StmtResult
18660d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult Owned(StmtResult res) {
18760d7b3a319d84d688752be3870615ac0f111fb16John McCall    return StmtResult(res);
18861364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl  }
18961364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl
19060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ExprError() { return ExprResult(true); }
19160d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult StmtError() { return StmtResult(true); }
192d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor
19360d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); }
19460d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); }
19561364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl
19660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ExprEmpty() { return ExprResult(false); }
1975ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis
1985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // Parsing methods.
1991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ParseTranslationUnit - All in one method that initializes parses, and
2015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// shuts down the parser.
2025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseTranslationUnit();
2031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// Initialize - Warm up the parser.
2055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
2065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void Initialize();
2071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if
2091f6443255894429fba384de0d5b6389ef578a5e9Steve Naroff  /// the EOF was encountered.
210682bf92db408a6cbc3d37b5496a99b6ef85041ecChris Lattner  bool ParseTopLevelDecl(DeclGroupPtrTy &Result);
2111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2123fe104154dd2e8ffb351142d74f308938b5c99bfFariborz Jahanian  DeclGroupPtrTy FinishPendingObjCActions();
21363e963cdffca9530f920dbab58b9b4eecb2a582cFariborz Jahanian
2145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate:
2155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
2165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // Low-Level token peeking and consumption methods.
2175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //
2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isTokenParen - Return true if the cur token is '(' or ')'.
2205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isTokenParen() const {
2215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return Tok.getKind() == tok::l_paren || Tok.getKind() == tok::r_paren;
2225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isTokenBracket - Return true if the cur token is '[' or ']'.
2245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isTokenBracket() const {
2255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return Tok.getKind() == tok::l_square || Tok.getKind() == tok::r_square;
2265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isTokenBrace - Return true if the cur token is '{' or '}'.
2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isTokenBrace() const {
2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return Tok.getKind() == tok::l_brace || Tok.getKind() == tok::r_brace;
2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// isTokenStringLiteral - True if this token is a string-literal.
2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
2345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool isTokenStringLiteral() const {
2355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return Tok.getKind() == tok::string_literal ||
2365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           Tok.getKind() == tok::wide_string_literal;
2375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
238eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
239a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis  /// \brief Returns true if the current token is a '=' or '==' and
240a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis  /// false otherwise. If it's '==', we assume that it's a typo and we emit
241a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis  /// DiagID and a fixit hint to turn '==' -> '='.
242a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis  bool isTokenEqualOrMistypedEqualEqual(unsigned DiagID);
243a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis
2445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeToken - Consume the current 'peek token' and lex the next one.
245d6ecc5cf945ccdf2b931137e364a69cde59ab18bZhongxing Xu  /// This does not work with all kinds of tokens: strings and specific other
2465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// tokens must be consumed with custom methods below.  This returns the
2475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// location of the consumed token.
2485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeToken() {
2495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(!isTokenStringLiteral() && !isTokenParen() && !isTokenBracket() &&
2505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           !isTokenBrace() &&
2515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           "Should consume special tokens with Consume*Token");
252dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    if (Tok.is(tok::code_completion)) {
253dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor      CodeCompletionRecovery();
254dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor      return ConsumeCodeCompletionToken();
255dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    }
256dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor
2574b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    PrevTokLocation = Tok.getLocation();
2585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PP.Lex(Tok);
2594b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    return PrevTokLocation;
2605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeAnyToken - Dispatch to the right Consume* method based on the
2635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// current token type.  This should only be used in cases where the type of
2645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// the token really isn't known, e.g. in error recovery.
2655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeAnyToken() {
2665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    if (isTokenParen())
2675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return ConsumeParen();
2685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else if (isTokenBracket())
2695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return ConsumeBracket();
2705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else if (isTokenBrace())
2715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return ConsumeBrace();
272d62701bc5321049353017e9abf1963edd57646aaSteve Naroff    else if (isTokenStringLiteral())
273d62701bc5321049353017e9abf1963edd57646aaSteve Naroff      return ConsumeStringToken();
2745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else
2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      return ConsumeToken();
2765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeParen - This consume method keeps the paren count up-to-date.
2795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
2805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeParen() {
2815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(isTokenParen() && "wrong consume method");
2825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    if (Tok.getKind() == tok::l_paren)
2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      ++ParenCount;
2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else if (ParenCount)
2855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      --ParenCount;       // Don't let unbalanced )'s drive the count negative.
2864b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    PrevTokLocation = Tok.getLocation();
2875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PP.Lex(Tok);
2884b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    return PrevTokLocation;
2895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeBracket - This consume method keeps the bracket count up-to-date.
2925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
2935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeBracket() {
2945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(isTokenBracket() && "wrong consume method");
2955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    if (Tok.getKind() == tok::l_square)
2965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      ++BracketCount;
2975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else if (BracketCount)
2985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      --BracketCount;     // Don't let unbalanced ]'s drive the count negative.
2991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3004b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    PrevTokLocation = Tok.getLocation();
3015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PP.Lex(Tok);
3024b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    return PrevTokLocation;
3035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeBrace - This consume method keeps the brace count up-to-date.
3065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
3075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeBrace() {
3085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(isTokenBrace() && "wrong consume method");
3095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    if (Tok.getKind() == tok::l_brace)
3105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      ++BraceCount;
3115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    else if (BraceCount)
3125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer      --BraceCount;     // Don't let unbalanced }'s drive the count negative.
3131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3144b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    PrevTokLocation = Tok.getLocation();
3155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PP.Lex(Tok);
3164b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    return PrevTokLocation;
3175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ConsumeStringToken - Consume the current 'peek token', lexing a new one
3205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// and returning the token kind.  This method is specific to strings, as it
3215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// handles string literal concatenation, as per C99 5.1.1.2, translation
3225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// phase #6.
3235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation ConsumeStringToken() {
3245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    assert(isTokenStringLiteral() &&
3255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer           "Should only consume string literals with this method");
3264b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    PrevTokLocation = Tok.getLocation();
3275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    PP.Lex(Tok);
3284b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor    return PrevTokLocation;
3295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
3301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
331dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  /// \brief Consume the current code-completion token.
332dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  ///
333dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  /// This routine should be called to consume the code-completion token once
334dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  /// a code-completion action has already been invoked.
335dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  SourceLocation ConsumeCodeCompletionToken() {
336dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    assert(Tok.is(tok::code_completion));
337dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    PrevTokLocation = Tok.getLocation();
338dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    PP.Lex(Tok);
339dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor    return PrevTokLocation;
340dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  }
341dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor
342dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  ///\ brief When we are consuming a code-completion token within having
343dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  /// matched specific position in the grammar, provide code-completion results
344dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  /// based on context.
345dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor  void CodeCompletionRecovery();
346dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor
3476b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  /// GetLookAheadToken - This peeks ahead N tokens and returns that token
3486b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  /// without consuming any tokens.  LookAhead(0) returns 'Tok', LookAhead(1)
3496b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  /// returns the token after Tok, etc.
3506b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  ///
3516b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  /// Note that this differs from the Preprocessor's LookAhead method, because
3526b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  /// the Parser always has one token lexed that the preprocessor doesn't.
3536b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  ///
35403db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis  const Token &GetLookAheadToken(unsigned N) {
3556b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner    if (N == 0 || Tok.is(tok::eof)) return Tok;
3566b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner    return PP.LookAhead(N-1);
3576b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner  }
358f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis
359f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis  /// NextToken - This peeks ahead one token and returns it without
360f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis  /// consuming it.
361f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis  const Token &NextToken() {
36203db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis    return PP.LookAhead(0);
363f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis  }
3645404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
365b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  /// getTypeAnnotation - Read a parsed type out of an annotation token.
366b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  static ParsedType getTypeAnnotation(Token &Tok) {
367b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall    return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue());
368b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  }
369b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall
370b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  static void setTypeAnnotation(Token &Tok, ParsedType T) {
371b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall    Tok.setAnnotationValue(T.getAsOpaquePtr());
372b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  }
373b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall
374eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// TryAnnotateTypeOrScopeToken - If the current token position is on a
375eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// typename (possibly qualified in C++) or a C++ scope specifier not followed
376eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// by a typename, TryAnnotateTypeOrScopeToken will replace one or more tokens
377eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// with a single annotation token representing the typename or C++ scope
378eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// respectively.
379eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// This simplifies handling of C++ scope specifiers and allows efficient
380eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// backtracking without the need to re-parse and resolve nested-names and
381eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// typenames.
38244802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis  /// It will mainly be called when we expect to treat identifiers as typenames
38344802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis  /// (if they are typenames). For example, in C we do not expect identifiers
38444802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis  /// inside expressions to be treated as typenames so it will not be called
38544802cc435d5122701e4f1a9354381cff4b171c0Argyrios Kyrtzidis  /// for expressions in C.
386a7bc7c880f86bc180684ef032d06df51bcae7a23Chris Lattner  ///
387a7bc7c880f86bc180684ef032d06df51bcae7a23Chris Lattner  /// This returns true if the token was annotated.
388495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor  bool TryAnnotateTypeOrScopeToken(bool EnteringContext = false);
389eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
3909ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall  /// TryAnnotateCXXScopeToken - Like TryAnnotateTypeOrScopeToken but
3919ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall  /// only annotates C++ scope specifiers.  This returns true if there
3929ba6166f4a78722e7df8ffbd64eb788bfdf2764aJohn McCall  /// was an unrecoverable error.
393495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor  bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
394eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
39582287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// TryAltiVecToken - Check for context-sensitive AltiVec identifier tokens,
39682287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// replacing them with the non-context-sensitive keywords.  This returns
39782287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// true if the token was replaced.
39882287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
399b3a4e432c90be98c6d918087750397e86d030368Chris Lattner                       const char *&PrevSpec, unsigned &DiagID,
400b3a4e432c90be98c6d918087750397e86d030368Chris Lattner                       bool &isInvalid) {
4011b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner    if (!getLang().AltiVec ||
4021b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner        (Tok.getIdentifierInfo() != Ident_vector &&
4031b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner         Tok.getIdentifierInfo() != Ident_pixel))
4041b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner      return false;
4051b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner
4061b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner    return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
40782287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  }
40882287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson
40982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// TryAltiVecVectorToken - Check for context-sensitive AltiVec vector
41082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// identifier token, replacing it with the non-context-sensitive __vector.
41182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  /// This returns true if the token was replaced.
41282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  bool TryAltiVecVectorToken() {
413b3a4e432c90be98c6d918087750397e86d030368Chris Lattner    if (!getLang().AltiVec ||
414b3a4e432c90be98c6d918087750397e86d030368Chris Lattner        Tok.getIdentifierInfo() != Ident_vector) return false;
4151b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner    return TryAltiVecVectorTokenOutOfLine();
41682287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson  }
4171b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner
4181b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner  bool TryAltiVecVectorTokenOutOfLine();
4191b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner  bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
4201b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner                                const char *&PrevSpec, unsigned &DiagID,
4211b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner                                bool &isInvalid);
4221b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner
4235404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// TentativeParsingAction - An object that is used as a kind of "tentative
4245404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// parsing transaction". It gets instantiated to mark the token position and
4255404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// after the token consumption is done, Commit() or Revert() is called to
4265404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// either "commit the consumed tokens" or revert to the previously marked
4275404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// token position. Example:
4285404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  ///
429314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor  ///   TentativeParsingAction TPA(*this);
4305404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  ///   ConsumeToken();
4315404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  ///   ....
4325404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  ///   TPA.Revert();
4335404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  ///
4345404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  class TentativeParsingAction {
4355404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    Parser &P;
4365404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    Token PrevTok;
4375404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    bool isActive;
4385404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
4395404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  public:
4405404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    explicit TentativeParsingAction(Parser& p) : P(p) {
4415404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      PrevTok = P.Tok;
4425404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      P.PP.EnableBacktrackAtThisPos();
4435404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      isActive = true;
4445404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    }
4455404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    void Commit() {
4465404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      assert(isActive && "Parsing action was finished!");
4475404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      P.PP.CommitBacktrackedTokens();
4485404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      isActive = false;
4495404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    }
4505404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    void Revert() {
4515404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      assert(isActive && "Parsing action was finished!");
4525404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      P.PP.Backtrack();
4535404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      P.Tok = PrevTok;
4545404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      isActive = false;
4555404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    }
4565404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    ~TentativeParsingAction() {
4575404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      assert(!isActive && "Forgot to call Commit or Revert!");
4585404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    }
4595404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  };
4601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
4635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// this helper function matches and consumes the specified RHS token if
4645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// present.  If not present, it emits the specified diagnostic indicating
4655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// that the parser failed to match the RHS of the token at LHSLoc.  LHSName
4665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// should be the name of the unmatched LHS token.  This returns the location
4675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// of the consumed token.
4685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  SourceLocation MatchRHSPunctuation(tok::TokenKind RHSTok,
4695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                                     SourceLocation LHSLoc);
4701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ExpectAndConsume - The parser expects that 'ExpectedTok' is next in the
4725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// input.  If so, it is consumed and false is returned.
4735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  ///
4745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// If the input is malformed, this emits the specified diagnostic.  Next, if
4755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// SkipToTok is specified, it calls SkipUntil(SkipToTok).  Finally, true is
4765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// returned.
4775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned Diag,
4785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                        const char *DiagMsg = "",
4795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                        tok::TokenKind SkipToTok = tok::unknown);
4805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4819ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  /// \brief The parser expects a semicolon and, if present, will consume it.
4829ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  ///
4839ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  /// If the next token is not a semicolon, this emits the specified diagnostic,
4849ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  /// or, if there's just some closing-delimiter noise (e.g., ')' or ']') prior
4859ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  /// to the semicolon, consumes that extra token.
4869ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor  bool ExpectAndConsumeSemi(unsigned DiagID);
4879ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor
4885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
4895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // Scope manipulation
4901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4918935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// ParseScope - Introduces a new scope for parsing. The kind of
4928935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// scope is determined by ScopeFlags. Objects of this type should
4938935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// be created on the stack to coincide with the position where the
4948935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// parser enters the new scope, and this object's constructor will
4958935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// create that new scope. Similarly, once the object is destroyed
4968935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  /// the parser will exit the scope.
4978935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  class ParseScope {
4988935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    Parser *Self;
4998935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    ParseScope(const ParseScope&); // do not implement
5008935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    ParseScope& operator=(const ParseScope&); // do not implement
5018935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor
5028935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  public:
5038935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // ParseScope - Construct a new object to manage a scope in the
5048935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // parser Self where the new Scope is created with the flags
5058935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // ScopeFlags, but only when ManageScope is true (the default). If
5068935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // ManageScope is false, this object does nothing.
5071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    ParseScope(Parser *Self, unsigned ScopeFlags, bool ManageScope = true)
5088935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      : Self(Self) {
5098935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      if (ManageScope)
5108935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor        Self->EnterScope(ScopeFlags);
5118935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      else
5128935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor        this->Self = 0;
5138935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    }
5148935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor
5158935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // Exit - Exit the scope associated with this object now, rather
5168935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    // than waiting until the object is destroyed.
5178935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    void Exit() {
5188935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      if (Self) {
5198935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor        Self->ExitScope();
5208935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor        Self = 0;
5218935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      }
5228935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    }
5238935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor
5248935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    ~ParseScope() {
5258935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor      Exit();
5268935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor    }
5278935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor  };
5288935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor
5295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// EnterScope - Start a new scope.
5305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void EnterScope(unsigned ScopeFlags);
5311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
5325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ExitScope - Pop a scope off the scope stack.
5335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ExitScope();
5345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
5365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // Diagnostic Emission and Error recovery.
53715faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl
5386aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorpublic:
5393cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
5403cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner  DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID);
54115faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl
5426aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorprivate:
5431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void SuggestParentheses(SourceLocation Loc, unsigned DK,
5444b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor                          SourceRange ParenRange);
5454b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor
5465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// SkipUntil - Read tokens until we get to the specified token, then consume
54782c7e6d8215567935d3d52741ccca9876a8ea461Steve Naroff  /// it (unless DontConsume is true).  Because we cannot guarantee that the
5485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// token will ever occur, this skips to the next token, or to some likely
5495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// good stopping point.  If StopAtSemi is true, skipping will stop at a ';'
5505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// character.
5511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ///
5525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// If SkipUntil finds the specified token, it returns true, otherwise it
5531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returns false.
5545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true,
5555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                 bool DontConsume = false) {
5565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SkipUntil(&T, 1, StopAtSemi, DontConsume);
5575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
5585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true,
5595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                 bool DontConsume = false) {
5605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    tok::TokenKind TokArray[] = {T1, T2};
5615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    return SkipUntil(TokArray, 2, StopAtSemi, DontConsume);
5625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
5635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  bool SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
5645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer                 bool StopAtSemi = true, bool DontConsume = false);
5657ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor
5665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
5674cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  // Lexing and parsing of C++ inline methods.
5684cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
5694cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  struct LexedMethod {
570d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    Decl *D;
57172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    CachedTokens Toks;
572d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor
573d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// \brief Whether this member function had an associated template
574d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// scope. When true, D is a template declaration.
575d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// othewise, it is a member function declaration.
576d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    bool TemplateScope;
577d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor
578d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    explicit LexedMethod(Decl *MD) : D(MD), TemplateScope(false) {}
5794cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  };
5804cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
58172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// LateParsedDefaultArgument - Keeps track of a parameter that may
58272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// have a default argument that cannot be parsed yet because it
58372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// occurs within a member function declaration inside the class
58472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// (C++ [class.mem]p2).
58572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  struct LateParsedDefaultArgument {
586d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    explicit LateParsedDefaultArgument(Decl *P,
58772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor                                       CachedTokens *Toks = 0)
58872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor      : Param(P), Toks(Toks) { }
58972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
59072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// Param - The parameter declaration for this parameter.
591d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    Decl *Param;
59272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
59372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// Toks - The sequence of tokens that comprises the default
59472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// argument expression, not including the '=' or the terminating
59572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// ')' or ','. This will be NULL for parameters that have no
59672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// default argument.
59772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    CachedTokens *Toks;
59872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  };
5991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
60072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// LateParsedMethodDeclaration - A method declaration inside a class that
60172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// contains at least one entity whose parsing needs to be delayed
60272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// until the class itself is completely-defined, such as a default
60372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// argument (C++ [class.mem]p2).
60472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  struct LateParsedMethodDeclaration {
605d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    explicit LateParsedMethodDeclaration(Decl *M)
606d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor      : Method(M), TemplateScope(false) { }
60772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
60872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// Method - The method declaration.
609d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    Decl *Method;
61072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
611d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// \brief Whether this member function had an associated template
612d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// scope. When true, D is a template declaration.
613d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    /// othewise, it is a member function declaration.
614d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor    bool TemplateScope;
6151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
61672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// DefaultArgs - Contains the parameters of the function and
61772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// their default arguments. At least one of the parameters will
61872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// have a default argument, but all of the parameters of the
61972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// method will be stored so that they can be reintroduced into
6201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    /// scope at the appropriate times.
62172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    llvm::SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
62272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  };
62372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
62472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// LateParsedMethodDecls - During parsing of a top (non-nested) C++
62572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// class, its method declarations that contain parts that won't be
62672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// parsed until after the definiton is completed (C++ [class.mem]p2),
62772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// the method declarations will be stored here with the tokens that
62872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  /// will be parsed to create those entities.
62972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  typedef std::list<LateParsedMethodDeclaration> LateParsedMethodDecls;
63072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
6314cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  /// LexedMethodsForTopClass - During parsing of a top (non-nested) C++ class,
6324cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  /// its inline method definitions and the inline method definitions of its
6334cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  /// nested classes are lexed and stored here.
63472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  typedef std::list<LexedMethod> LexedMethodsForTopClass;
63572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
6366569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// \brief Representation of a class that has been parsed, including
6376569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// any member function declarations or definitions that need to be
6386569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// parsed after the corresponding top-level class is complete.
6396569d68745c8213709740337d2be52b031384f58Douglas Gregor  struct ParsingClass {
640d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    ParsingClass(Decl *TagOrTemplate, bool TopLevelClass)
6411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      : TopLevelClass(TopLevelClass), TemplateScope(false),
6426569d68745c8213709740337d2be52b031384f58Douglas Gregor        TagOrTemplate(TagOrTemplate) { }
6436569d68745c8213709740337d2be52b031384f58Douglas Gregor
6446569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// \brief Whether this is a "top-level" class, meaning that it is
6456569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// not nested within another class.
6466569d68745c8213709740337d2be52b031384f58Douglas Gregor    bool TopLevelClass : 1;
6476569d68745c8213709740337d2be52b031384f58Douglas Gregor
6486569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// \brief Whether this class had an associated template
6496569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// scope. When true, TagOrTemplate is a template declaration;
6506569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// othewise, it is a tag declaration.
6516569d68745c8213709740337d2be52b031384f58Douglas Gregor    bool TemplateScope : 1;
6526569d68745c8213709740337d2be52b031384f58Douglas Gregor
6536569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// \brief The class or class template whose definition we are parsing.
654d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    Decl *TagOrTemplate;
65572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
65672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// MethodDecls - Method declarations that contain pieces whose
65772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// parsing will be delayed until the class is fully defined.
65872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    LateParsedMethodDecls MethodDecls;
65972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor
66072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// MethodDefs - Methods whose definitions will be parsed once the
66172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    /// class has been fully defined.
66272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor    LexedMethodsForTopClass MethodDefs;
6636569d68745c8213709740337d2be52b031384f58Douglas Gregor
6646569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// \brief Nested classes inside this class.
6656569d68745c8213709740337d2be52b031384f58Douglas Gregor    llvm::SmallVector<ParsingClass*, 4> NestedClasses;
66672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor  };
6674cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
6686569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// \brief The stack of classes that is currently being
6696569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// parsed. Nested and local classes will be pushed onto this stack
6706569d68745c8213709740337d2be52b031384f58Douglas Gregor  /// when they are parsed, and removed afterward.
6716569d68745c8213709740337d2be52b031384f58Douglas Gregor  std::stack<ParsingClass *> ClassStack;
6724cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
6736569d68745c8213709740337d2be52b031384f58Douglas Gregor  ParsingClass &getCurrentClass() {
6746569d68745c8213709740337d2be52b031384f58Douglas Gregor    assert(!ClassStack.empty() && "No lexed method stacks!");
6756569d68745c8213709740337d2be52b031384f58Douglas Gregor    return *ClassStack.top();
6764cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  }
6774cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
67854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// \brief RAII object used to inform the actions that we're
67954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// currently parsing a declaration.  This is active when parsing a
68054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// variable's initializer, but not when parsing the body of a
68154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// class or function definition.
68254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  class ParsingDeclRAIIObject {
683f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall    Sema &Actions;
684f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall    Sema::ParsingDeclStackState State;
68554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    bool Popped;
686c9068d7dd94d439cec66c421115d15303e481025John McCall
68754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  public:
68854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ParsingDeclRAIIObject(Parser &P) : Actions(P.Actions) {
68954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      push();
69054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
69154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
692c9068d7dd94d439cec66c421115d15303e481025John McCall    ParsingDeclRAIIObject(Parser &P, ParsingDeclRAIIObject *Other)
693c9068d7dd94d439cec66c421115d15303e481025John McCall        : Actions(P.Actions) {
694c9068d7dd94d439cec66c421115d15303e481025John McCall      if (Other) steal(*Other);
695c9068d7dd94d439cec66c421115d15303e481025John McCall      else push();
696c9068d7dd94d439cec66c421115d15303e481025John McCall    }
697c9068d7dd94d439cec66c421115d15303e481025John McCall
698c9068d7dd94d439cec66c421115d15303e481025John McCall    /// Creates a RAII object which steals the state from a different
699c9068d7dd94d439cec66c421115d15303e481025John McCall    /// object instead of pushing.
700c9068d7dd94d439cec66c421115d15303e481025John McCall    ParsingDeclRAIIObject(ParsingDeclRAIIObject &Other)
701c9068d7dd94d439cec66c421115d15303e481025John McCall        : Actions(Other.Actions) {
702c9068d7dd94d439cec66c421115d15303e481025John McCall      steal(Other);
703c9068d7dd94d439cec66c421115d15303e481025John McCall    }
704c9068d7dd94d439cec66c421115d15303e481025John McCall
70554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ~ParsingDeclRAIIObject() {
70654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      abort();
70754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
70854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
70954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    /// Resets the RAII object for a new declaration.
71054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    void reset() {
71154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      abort();
71254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      push();
71354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
71454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
71554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    /// Signals that the context was completed without an appropriate
71654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    /// declaration being parsed.
71754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    void abort() {
718d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall      pop(0);
71954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
72054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
721d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    void complete(Decl *D) {
72254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      assert(!Popped && "ParsingDeclaration has already been popped!");
72354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      pop(D);
72454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
72554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
72654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  private:
727c9068d7dd94d439cec66c421115d15303e481025John McCall    void steal(ParsingDeclRAIIObject &Other) {
728c9068d7dd94d439cec66c421115d15303e481025John McCall      State = Other.State;
729c9068d7dd94d439cec66c421115d15303e481025John McCall      Popped = Other.Popped;
730c9068d7dd94d439cec66c421115d15303e481025John McCall      Other.Popped = true;
731c9068d7dd94d439cec66c421115d15303e481025John McCall    }
732c9068d7dd94d439cec66c421115d15303e481025John McCall
73354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    void push() {
73454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      State = Actions.PushParsingDeclaration();
73554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      Popped = false;
73654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
73754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
738d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    void pop(Decl *D) {
73954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      if (!Popped) {
74054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall        Actions.PopParsingDeclaration(State, D);
74154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall        Popped = true;
74254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      }
74354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
74454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  };
74554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
74654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// A class for parsing a DeclSpec.
74754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  class ParsingDeclSpec : public DeclSpec {
74854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ParsingDeclRAIIObject ParsingRAII;
74954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
75054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  public:
751c9068d7dd94d439cec66c421115d15303e481025John McCall    ParsingDeclSpec(Parser &P) : ParsingRAII(P) {}
752c9068d7dd94d439cec66c421115d15303e481025John McCall    ParsingDeclSpec(ParsingDeclRAIIObject &RAII) : ParsingRAII(RAII) {}
753c9068d7dd94d439cec66c421115d15303e481025John McCall    ParsingDeclSpec(Parser &P, ParsingDeclRAIIObject *RAII)
754c9068d7dd94d439cec66c421115d15303e481025John McCall      : ParsingRAII(P, RAII) {}
75554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
756d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    void complete(Decl *D) {
75754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      ParsingRAII.complete(D);
75854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
75954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
76054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    void abort() {
76154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      ParsingRAII.abort();
76254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
76354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  };
76454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
76554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  /// A class for parsing a declarator.
76654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  class ParsingDeclarator : public Declarator {
76754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ParsingDeclRAIIObject ParsingRAII;
76854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
76954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  public:
77054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, TheContext C)
77154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      : Declarator(DS, C), ParsingRAII(P) {
77254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
77354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
77454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    const ParsingDeclSpec &getDeclSpec() const {
77554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      return static_cast<const ParsingDeclSpec&>(Declarator::getDeclSpec());
77654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
77754abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
77854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    ParsingDeclSpec &getMutableDeclSpec() const {
77954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      return const_cast<ParsingDeclSpec&>(getDeclSpec());
78054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
78154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
78254abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    void clear() {
78354abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      Declarator::clear();
78454abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      ParsingRAII.reset();
78554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
78654abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
787d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    void complete(Decl *D) {
78854abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall      ParsingRAII.complete(D);
78954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall    }
79054abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  };
79154abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall
7921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief RAII object used to
7936569d68745c8213709740337d2be52b031384f58Douglas Gregor  class ParsingClassDefinition {
7946569d68745c8213709740337d2be52b031384f58Douglas Gregor    Parser &P;
7956569d68745c8213709740337d2be52b031384f58Douglas Gregor    bool Popped;
7966569d68745c8213709740337d2be52b031384f58Douglas Gregor
7976569d68745c8213709740337d2be52b031384f58Douglas Gregor  public:
798d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    ParsingClassDefinition(Parser &P, Decl *TagOrTemplate, bool TopLevelClass)
7991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      : P(P), Popped(false) {
8006569d68745c8213709740337d2be52b031384f58Douglas Gregor      P.PushParsingClass(TagOrTemplate, TopLevelClass);
8016569d68745c8213709740337d2be52b031384f58Douglas Gregor    }
8026569d68745c8213709740337d2be52b031384f58Douglas Gregor
8036569d68745c8213709740337d2be52b031384f58Douglas Gregor    /// \brief Pop this class of the stack.
8041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    void Pop() {
8056569d68745c8213709740337d2be52b031384f58Douglas Gregor      assert(!Popped && "Nested class has already been popped");
8066569d68745c8213709740337d2be52b031384f58Douglas Gregor      Popped = true;
8076569d68745c8213709740337d2be52b031384f58Douglas Gregor      P.PopParsingClass();
8086569d68745c8213709740337d2be52b031384f58Douglas Gregor    }
8096569d68745c8213709740337d2be52b031384f58Douglas Gregor
8101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    ~ParsingClassDefinition() {
8116569d68745c8213709740337d2be52b031384f58Douglas Gregor      if (!Popped)
8121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump        P.PopParsingClass();
8136569d68745c8213709740337d2be52b031384f58Douglas Gregor    }
8146569d68745c8213709740337d2be52b031384f58Douglas Gregor  };
8156569d68745c8213709740337d2be52b031384f58Douglas Gregor
8164d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor  /// \brief Contains information about any template-specific
8174d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor  /// information that has been parsed prior to parsing declaration
8184d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor  /// specifiers.
8194d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor  struct ParsedTemplateInfo {
8201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    ParsedTemplateInfo()
8214d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      : Kind(NonTemplate), TemplateParams(0), TemplateLoc() { }
8224d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
8234d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
824c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor                       bool isSpecialization,
825c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor                       bool lastParameterListWasEmpty = false)
8264d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      : Kind(isSpecialization? ExplicitSpecialization : Template),
827c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor        TemplateParams(TemplateParams),
828c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor        LastParameterListWasEmpty(lastParameterListWasEmpty) { }
8294d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
83045f965581935791a018df829a14dff53c1dd8f47Douglas Gregor    explicit ParsedTemplateInfo(SourceLocation ExternLoc,
83145f965581935791a018df829a14dff53c1dd8f47Douglas Gregor                                SourceLocation TemplateLoc)
8321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      : Kind(ExplicitInstantiation), TemplateParams(0),
833c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor        ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
834c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor        LastParameterListWasEmpty(false){ }
8354d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
8364d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    /// \brief The kind of template we are parsing.
8374d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    enum {
8384d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      /// \brief We are not parsing a template at all.
8394d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      NonTemplate = 0,
8404d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      /// \brief We are parsing a template declaration.
8414d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      Template,
8424d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      /// \brief We are parsing an explicit specialization.
8434d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      ExplicitSpecialization,
8444d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      /// \brief We are parsing an explicit instantiation.
8454d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor      ExplicitInstantiation
8464d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    } Kind;
8474d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
8484d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    /// \brief The template parameter lists, for template declarations
8494d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    /// and explicit specializations.
8504d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    TemplateParameterLists *TemplateParams;
8514d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
85245f965581935791a018df829a14dff53c1dd8f47Douglas Gregor    /// \brief The location of the 'extern' keyword, if any, for an explicit
85345f965581935791a018df829a14dff53c1dd8f47Douglas Gregor    /// instantiation
85445f965581935791a018df829a14dff53c1dd8f47Douglas Gregor    SourceLocation ExternLoc;
8551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8564d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    /// \brief The location of the 'template' keyword, for an explicit
8574d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    /// instantiation.
8584d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor    SourceLocation TemplateLoc;
859c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor
860c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor    /// \brief Whether the last template parameter list was empty.
861c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor    bool LastParameterListWasEmpty;
8624d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor  };
8631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
864d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void PushParsingClass(Decl *TagOrTemplate, bool TopLevelClass);
86537b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor  void DeallocateParsedClasses(ParsingClass *Class);
86637b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor  void PopParsingClass();
86737b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor
868d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
869d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                     const ParsedTemplateInfo &TemplateInfo);
87037b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor  void ParseLexedMethodDeclarations(ParsingClass &Class);
87137b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor  void ParseLexedMethodDefs(ParsingClass &Class);
87214b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis  bool ConsumeAndStoreUntil(tok::TokenKind T1,
87314b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis                            CachedTokens &Toks,
87414b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis                            bool StopAtSemi = true,
87514b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis                            bool ConsumeFinalToken = true) {
87614b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis    return ConsumeAndStoreUntil(T1, T1, Toks, StopAtSemi, ConsumeFinalToken);
87714b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis  }
8781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
87937b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor                            CachedTokens &Toks,
88014b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis                            bool StopAtSemi = true,
88137b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor                            bool ConsumeFinalToken = true);
8824d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
8834cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  //===--------------------------------------------------------------------===//
8845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C99 6.9: External Definitions.
88509a63c97b95eb4dc6fd6b2323929e8cf12af03ffDouglas Gregor  DeclGroupPtrTy ParseExternalDeclaration(CXX0XAttributeList Attr,
88609a63c97b95eb4dc6fd6b2323929e8cf12af03ffDouglas Gregor                                          ParsingDeclSpec *DS = 0);
887c82daefa3062721e98947e08193cd81b4e9df915Chris Lattner  bool isDeclarationAfterDeclarator() const;
888004659a56916f2f81ede507c12516c146d6c0df3Chris Lattner  bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator);
889bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(AttributeList *Attr,
8905aeccdbb4bdc94e48c04cacc59fa812af32109b2Anders Carlsson            AccessSpecifier AS = AS_none);
8913acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian  DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(ParsingDeclSpec &DS,
8923acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian                                                  AttributeList *Attr,
8933acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian                                                  AccessSpecifier AS = AS_none);
8943acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian
895d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseFunctionDefinition(ParsingDeclarator &D,
89652591bf224b2c43e2b00e265bb8599a620081925Douglas Gregor                 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
8975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseKNRParamDeclarations(Declarator &D);
898ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl  // EndLoc, if non-NULL, is filled with the location of the last token of
899ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl  // the simple-asm.
90060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseSimpleAsm(SourceLocation *EndLoc = 0);
90160d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseAsmStringLiteral();
9025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
9033536b443bc50d58a79f14fca9b6842541a434854Steve Naroff  // Objective-C External Declarations
904d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtDirectives();
905d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtClassDeclaration(SourceLocation atLoc);
906d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtInterfaceDeclaration(SourceLocation atLoc,
907dac269b65eed82182fc3e96566dedd6562dfe11eSteve Naroff                                          AttributeList *prefixAttrs = 0);
908d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseObjCClassInstanceVariables(Decl *interfaceDecl,
90983c481ade785a919ba21a33f9a8b1b21c1212fb3Fariborz Jahanian                                       tok::ObjCKeywordKind visibility,
91060fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff                                       SourceLocation atLoc);
911d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Decl *> &P,
91271b0addffbdeed29cc062c962e236c34107755d6Argyrios Kyrtzidis                                   llvm::SmallVectorImpl<SourceLocation> &PLocs,
9131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                   bool WarnOnDeclarations,
91471b0addffbdeed29cc062c962e236c34107755d6Argyrios Kyrtzidis                                   SourceLocation &LAngleLoc,
915e13b9595dc1e2f4288bec34f3412359f648e84a5Chris Lattner                                   SourceLocation &EndProtoLoc);
916d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseObjCInterfaceDeclList(Decl *interfaceDecl,
917c81c8144a661a49d7b9dae8d2080dee2e43186ecChris Lattner                                  tok::ObjCKeywordKind contextKey);
918d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
919b28317a8e5e0e2953d1e5406d753d6c3c7f1e7d2Chris Lattner                                           AttributeList *prefixAttrs = 0);
9201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
921d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ObjCImpDecl;
922d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  llvm::SmallVector<Decl *, 4> PendingObjCImpDecl;
9230416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff
924d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtImplementationDeclaration(SourceLocation atLoc);
925d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtEndDeclaration(SourceRange atEnd);
926d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
927d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
928d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
9291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9302fc5c2428ecb450a3256c8316b93b8655cb76a0fChris Lattner  IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
93134870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner  // Definitions for Objective-c context sensitive keywords recognition.
93234870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner  enum ObjCTypeQual {
93334870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner    objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
93434870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner    objc_NumQuals
93534870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner  };
936a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek  IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
9371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
938335a2d4122e41343fe11a775889b8bec5b14be60Fariborz Jahanian  bool isTokIdentifier_in() const;
939d0f97d1716a138a8d9e0df8e5af77334663723d8Fariborz Jahanian
940b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall  ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, bool IsParameter);
941294494e1cce92043562b4680c613df7fd028c02eSteve Naroff  void ParseObjCMethodRequirement();
942d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCMethodPrototype(Decl *classOrCat,
943c81c8144a661a49d7b9dae8d2080dee2e43186ecChris Lattner            tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
944d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCMethodDecl(SourceLocation mLoc, tok::TokenKind mType,
945d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                Decl *classDecl,
94600933591a2795d09dd1acff12a2d21bce7cb12c5Fariborz Jahanian            tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
947d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl,
948d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                  Decl **Methods, unsigned NumMethods);
9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
950d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseObjCMethodDefinition();
9511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
9535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C99 6.5: Expressions.
9546aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor
95560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseExpression();
95660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseConstantExpression();
9572f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl  // Expr that doesn't include commas.
95860d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseAssignmentExpression();
9592f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl
96060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseExpressionWithLeadingAt(SourceLocation AtLoc);
9615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
96260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseExpressionWithLeadingExtension(SourceLocation ExtLoc);
963adf077f46ba5cddcd801a647a5e9a3eb97060df4Eli Friedman
96460d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseRHSOfBinaryExpression(ExprResult LHS,
9656aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor                                              prec::Level MinPrec);
96660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCastExpression(bool isUnaryExpression,
967f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis                                       bool isAddressOfOperand,
9682ef13e5abef0570a9f567b4671367275c05d4d34Nate Begeman                                       bool &NotCastExpr,
969b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                       ParsedType TypeOfCast);
97060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCastExpression(bool isUnaryExpression,
9712ef13e5abef0570a9f567b4671367275c05d4d34Nate Begeman                                       bool isAddressOfOperand = false,
972b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                       ParsedType TypeOfCast = ParsedType());
9739c72c6088d591ace8503b842d39448c2040f3033John McCall
9749c72c6088d591ace8503b842d39448c2040f3033John McCall  /// Returns true if the next token would start a postfix-expression
9759c72c6088d591ace8503b842d39448c2040f3033John McCall  /// suffix.
9769c72c6088d591ace8503b842d39448c2040f3033John McCall  bool isPostfixExpressionSuffixStart() {
9779c72c6088d591ace8503b842d39448c2040f3033John McCall    tok::TokenKind K = Tok.getKind();
9789c72c6088d591ace8503b842d39448c2040f3033John McCall    return (K == tok::l_square || K == tok::l_paren ||
9799c72c6088d591ace8503b842d39448c2040f3033John McCall            K == tok::period || K == tok::arrow ||
9809c72c6088d591ace8503b842d39448c2040f3033John McCall            K == tok::plusplus || K == tok::minusminus);
9819c72c6088d591ace8503b842d39448c2040f3033John McCall  }
9829c72c6088d591ace8503b842d39448c2040f3033John McCall
98360d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParsePostfixExpressionSuffix(ExprResult LHS);
98460d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseSizeofAlignofExpression();
98560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseBuiltinPrimaryExpression();
9861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
98760d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
9885ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis                                                     bool &isCastExpr,
989b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                                     ParsedType &CastTy,
9905ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis                                                     SourceRange &CastRange);
9910cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis
992ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef llvm::SmallVector<Expr*, 20> ExprListTy;
993ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  typedef llvm::SmallVector<SourceLocation, 20> CommaLocsTy;
9940cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis
9950cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis  /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
996ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  bool ParseExpressionList(llvm::SmallVectorImpl<Expr*> &Exprs,
997ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall                           llvm::SmallVectorImpl<SourceLocation> &CommaLocs,
998f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall                           void (Sema::*Completer)(Scope *S,
999f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall                                                   Expr *Data,
1000f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall                                                   Expr **Args,
1001f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall                                                   unsigned NumArgs) = 0,
1002ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall                           Expr *Data = 0);
1003d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl
10045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ParenParseOption - Control what ParseParenExpression will parse.
10055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  enum ParenParseOption {
10065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    SimpleExpr,      // Only parse '(' expression ')'
10075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    CompoundStmt,    // Also allow '(' compound-statement ')'
10085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}'
10095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer    CastExpr         // Also allow '(' type-name ')' <anything>
10105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  };
101160d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseParenExpression(ParenParseOption &ExprType,
10120350ca519405051e8d45d12ee7d09569a6a9c4c9Argyrios Kyrtzidis                                        bool stopIfCastExpr,
1013b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                        ParsedType TypeOfCast,
1014b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                        ParsedType &CastTy,
1015d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl                                        SourceLocation &RParenLoc);
10161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
101760d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
1018b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                                    ParsedType &CastTy,
1019f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis                                                    SourceLocation LParenLoc,
1020f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis                                                    SourceLocation &RParenLoc);
10211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
102260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCompoundLiteralExpression(ParsedType Ty,
1023d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis                                                  SourceLocation LParenLoc,
1024d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis                                                  SourceLocation RParenLoc);
10251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
102660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseStringLiteralExpression();
1027eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
1028eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  //===--------------------------------------------------------------------===//
1029eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  // C++ Expressions
103060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXIdExpression(bool isAddressOfOperand = false);
10314bdd91c09fd59e0c154d759288beff300e31e1d0Argyrios Kyrtzidis
10321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
1033b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                      ParsedType ObjectType,
1034b10cd04880672103660e5844e51ee91af7361a20Douglas Gregor                                      bool EnteringContext,
1035d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor                                      bool *MayBePseudoDestructor = 0);
10361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
10385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C++ 5.2p1: C++ Casts
103960d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXCasts();
10405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
10415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
1042c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // C++ 5.2p1: C++ Type Identification
104360d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXTypeid();
1044c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
1045c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  //===--------------------------------------------------------------------===//
104601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  //  C++ : Microsoft __uuidof Expression
104701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  ExprResult ParseCXXUuidof();
104801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
104901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  //===--------------------------------------------------------------------===//
1050d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor  // C++ 5.2.4: C++ Pseudo-Destructor Expressions
105160d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc,
1052d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor                                            tok::TokenKind OpKind,
1053d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor                                            CXXScopeSpec &SS,
1054b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                            ParsedType ObjectType);
1055d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor
1056d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor  //===--------------------------------------------------------------------===//
10574cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  // C++ 9.3.2: C++ 'this' pointer
105860d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXThis();
10594cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis
10604cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  //===--------------------------------------------------------------------===//
106150dd289f45738ed22b7583d52ed2525b927042ffChris Lattner  // C++ 15: C++ Throw Expression
106260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseThrowExpression();
1063ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl  // EndLoc is filled with the location of the last token of the specification.
10647dc813462dd9fd3f6f4296f896a12de14264fef8Sebastian Redl  bool ParseExceptionSpecification(SourceLocation &EndLoc,
1065b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                   llvm::SmallVectorImpl<ParsedType> &Exns,
1066b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                   llvm::SmallVectorImpl<SourceRange> &Ranges,
10677dc813462dd9fd3f6f4296f896a12de14264fef8Sebastian Redl                                   bool &hasAnyExceptionSpec);
106850dd289f45738ed22b7583d52ed2525b927042ffChris Lattner
106950dd289f45738ed22b7583d52ed2525b927042ffChris Lattner  //===--------------------------------------------------------------------===//
1070dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  // C++0x 8: Function declaration trailing-return-type
1071dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  TypeResult ParseTrailingReturnType();
1072dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor
1073dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor  //===--------------------------------------------------------------------===//
10745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C++ 2.13.5: C++ Boolean Literals
107560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXBoolLiteral();
10765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
10775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
1078987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // C++ 5.2.3: Explicit type conversion (functional notation)
107960d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS);
1080987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
10816aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor  bool isCXXSimpleTypeSpecifier() const;
10826aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor
1083987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
1084987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  /// This should only be called when the current token is known to be part of
1085987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  /// simple-type-specifier.
1086987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
1087987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
10882f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor  bool ParseCXXTypeSpecifierSeq(DeclSpec &DS);
10892f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor
1090987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  //===--------------------------------------------------------------------===//
10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // C++ 5.3.4 and 5.3.5: C++ new and delete
1092ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall  bool ParseExpressionListOrTypeId(llvm::SmallVectorImpl<Expr*> &Exprs,
1093ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall                                   Declarator &D);
10944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  void ParseDirectNewDeclarator(Declarator &D);
109560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start);
109660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXXDeleteExpression(bool UseGlobal,
109759232d35f5820e334b6c8b007ae8006f4390055dChris Lattner                                            SourceLocation Start);
10984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  //===--------------------------------------------------------------------===//
110099e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor  // C++ if/switch/while condition expression.
110160d7b3a319d84d688752be3870615ac0f111fb16John McCall  bool ParseCXXCondition(ExprResult &ExprResult, Decl *&DeclResult,
1102586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor                         SourceLocation Loc, bool ConvertToBoolean);
110371b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis
110471b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis  //===--------------------------------------------------------------------===//
110512e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor  // C++ types
110612e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor
110712e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor  //===--------------------------------------------------------------------===//
11085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C99 6.7.8: Initialization.
11091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11100eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner  /// ParseInitializer
11110eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner  ///       initializer: [C99 6.7.8]
11120eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner  ///         assignment-expression
11130eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner  ///         '{' ...
111460d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseInitializer() {
11150eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner    if (Tok.isNot(tok::l_brace))
111620df9b7ab9388b2a488c5b1293cd196b1e073b4eSebastian Redl      return ParseAssignmentExpression();
11170eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner    return ParseBraceInitializer();
11180eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner  }
111960d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseBraceInitializer();
112060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseInitializerWithPotentialDesignator();
11211d922960e083906a586609ac6978678147250177Sebastian Redl
11225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
1123296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff  // clang Expressions
11241d922960e083906a586609ac6978678147250177Sebastian Redl
112560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseBlockLiteralExpression();  // ^{...}
1126296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff
1127296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff  //===--------------------------------------------------------------------===//
11285508518a2702b00be3b15a26d772bde968972f54Anders Carlsson  // Objective-C Expressions
112960d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
113060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
113160d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
113260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
113360d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
11341b730e847ded503f2e615154035c083c4f94a067Douglas Gregor  bool isSimpleObjCMessageExpression();
113560d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCMessageExpression();
113660d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
11372725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor                                                  SourceLocation SuperLoc,
1138b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                                  ParsedType ReceiverType,
11391d922960e083906a586609ac6978678147250177Sebastian Redl                                                  ExprArg ReceiverExpr);
114060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseAssignmentExprWithObjCMessageExprStart(
11412725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor      SourceLocation LBracloc, SourceLocation SuperLoc,
1142b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall      ParsedType ReceiverType, ExprArg ReceiverExpr);
11436aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor  bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr);
114461364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl
11455508518a2702b00be3b15a26d772bde968972f54Anders Carlsson  //===--------------------------------------------------------------------===//
11465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C99 6.8: Statements and Blocks.
114761364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl
114860d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseStatement() {
1149c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian    StmtVector Stmts(Actions);
1150c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian    return ParseStatementOrDeclaration(Stmts, true);
115161364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl  }
1152c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian  StmtResult ParseStatementOrDeclaration(StmtVector& Stmts,
1153c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian                                         bool OnlyStatement = false);
115460d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseLabeledStatement(AttributeList *Attr);
115560d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCaseStatement(AttributeList *Attr);
115660d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseDefaultStatement(AttributeList *Attr);
115760d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCompoundStatement(AttributeList *Attr,
1158bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt                                          bool isStmtExpr = false);
115960d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCompoundStatementBody(bool isStmtExpr = false);
116060d7b3a319d84d688752be3870615ac0f111fb16John McCall  bool ParseParenExprOrCondition(ExprResult &ExprResult,
1161d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                 Decl *&DeclResult,
1162586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor                                 SourceLocation Loc,
1163586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor                                 bool ConvertToBoolean);
116460d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseIfStatement(AttributeList *Attr);
116560d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseSwitchStatement(AttributeList *Attr);
116660d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseWhileStatement(AttributeList *Attr);
116760d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseDoStatement(AttributeList *Attr);
116860d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseForStatement(AttributeList *Attr);
116960d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseGotoStatement(AttributeList *Attr);
117060d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseContinueStatement(AttributeList *Attr);
117160d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseBreakStatement(AttributeList *Attr);
117260d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseReturnStatement(AttributeList *Attr);
117360d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseAsmStatement(bool &msAsm);
117460d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult FuzzyParseMicrosoftAsmStatement();
1175ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson  bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names,
1176ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson                           llvm::SmallVectorImpl<ExprTy *> &Constraints,
1177ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson                           llvm::SmallVectorImpl<ExprTy *> &Exprs);
1178a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl
1179a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl  //===--------------------------------------------------------------------===//
1180a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl  // C++ 6: Statements and Blocks
1181a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl
118260d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCXXTryBlock(AttributeList *Attr);
118360d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc);
118460d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseCXXCatchBlock();
1185a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl
1186a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl  //===--------------------------------------------------------------------===//
1187a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl  // Objective-C Statements
1188a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl
118960d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseObjCAtStatement(SourceLocation atLoc);
119060d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseObjCTryStmt(SourceLocation atLoc);
119160d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
119260d7b3a319d84d688752be3870615ac0f111fb16John McCall  StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
1193b235fc2cf37621c7fc6511bb2b8788c95f9fb9fcAnders Carlsson
11945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
11955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  //===--------------------------------------------------------------------===//
11965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  // C99 6.7: Declarations.
119767d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall
119867d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall  /// A context for parsing declaration specifiers.  TODO: flesh this
119967d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall  /// out, there are other significant restrictions on specifiers than
120067d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall  /// would be best implemented in the parser.
120167d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall  enum DeclSpecContext {
120267d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall    DSC_normal, // normal context
12030efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor    DSC_class,  // class context, enables 'friend'
12040efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor    DSC_top_level // top-level/namespace declaration context
120567d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall  };
12061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1207c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian  DeclGroupPtrTy ParseDeclaration(StmtVector &Stmts,
1208c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian                                  unsigned Context, SourceLocation &DeclEnd,
1209bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt                                  CXX0XAttributeList Attr);
1210c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian  DeclGroupPtrTy ParseSimpleDeclaration(StmtVector &Stmts,
1211c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian                                        unsigned Context,
1212bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt                                        SourceLocation &DeclEnd,
12135c5db553b5c256d0a6f55dde7325c1c829b88e8eChris Lattner                                        AttributeList *Attr,
12145c5db553b5c256d0a6f55dde7325c1c829b88e8eChris Lattner                                        bool RequireSemi);
121554abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall  DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context,
1216d8ac05753dc4506224d445ff98399c01da3136e5John McCall                                bool AllowFunctionDefinitions,
1217d8ac05753dc4506224d445ff98399c01da3136e5John McCall                                SourceLocation *DeclEnd = 0);
1218d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseDeclarationAfterDeclarator(Declarator &D,
1219e542c862bdf9a9bcb4f468be8fa6561372430611Douglas Gregor               const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1220d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseFunctionStatementBody(Decl *Decl);
1221d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseFunctionTryBlock(Decl *Decl);
1222d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl
1223f4382f50b7ab9f445c3f5b3ddaa59e6da25ea3bbChris Lattner  bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
12244d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                        const ParsedTemplateInfo &TemplateInfo,
1225e40c295d017a8f75a945fe9ed2aa9d8bb7a7341aChris Lattner                        AccessSpecifier AS);
12260efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor  DeclSpecContext getDeclSpecContextFromDeclaratorContext(unsigned Context);
12271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  void ParseDeclarationSpecifiers(DeclSpec &DS,
12284d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
122967d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall                                  AccessSpecifier AS = AS_none,
123067d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall                                  DeclSpecContext DSC = DSC_normal);
12311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ParseOptionalTypeSpecifier(DeclSpec &DS, bool &isInvalid,
12327a0ab5f387722c83e19c7133b46b16988eb19e45Chris Lattner                                  const char *&PrevSpec,
1233fec54013fcd0eb72642741584ca04c1bc292bef8John McCall                                  unsigned &DiagID,
1234d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl               const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1235d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl                                  bool SuppressDeclarations = false);
12364d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor
12375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseSpecifierQualifierList(DeclSpec &DS);
12381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1239d32b0225e29fcafb2b2b2a4b1c51dcb1518af9c6Douglas Gregor  void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, bool IsParameter);
12405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
12414c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner  void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
12429b9edd619a7e616d3287435cb5a3f9b1aea648e8Douglas Gregor                const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),                          AccessSpecifier AS = AS_none);
1243d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
12445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType,
1245d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                            Decl *TagDecl);
1246bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall
1247bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall  struct FieldCallback {
1248d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall    virtual Decl *invoke(FieldDeclarator &Field) = 0;
12496c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall    virtual ~FieldCallback() {}
12506c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall
12516c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall  private:
12526c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall    virtual void _anchor();
1253bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall  };
1254d0014540005f2a5ab837365db6bd40f479406758John McCall  struct ObjCPropertyCallback;
1255bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall
1256bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall  void ParseStructDeclaration(DeclSpec &DS, FieldCallback &Callback);
12571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12589497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor  bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false);
1259eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  bool isTypeSpecifierQualifier();
12605f8aa696619e32bf307232841fedb704ba733b4dSteve Naroff  bool isTypeQualifier() const;
1261b3a4e432c90be98c6d918087750397e86d030368Chris Lattner
1262b3a4e432c90be98c6d918087750397e86d030368Chris Lattner  /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
1263b3a4e432c90be98c6d918087750397e86d030368Chris Lattner  /// is definitely a type-specifier.  Return false if it isn't part of a type
1264b3a4e432c90be98c6d918087750397e86d030368Chris Lattner  /// specifier or if we're not sure.
1265b3a4e432c90be98c6d918087750397e86d030368Chris Lattner  bool isKnownToBeTypeSpecifier(const Token &Tok) const;
12665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
12675404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// isDeclarationStatement - Disambiguates between a declaration or an
12685404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// expression statement, when parsing function bodies.
12695404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// Returns true for declaration, false for expression.
12705404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  bool isDeclarationStatement() {
12715404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis    if (getLang().CPlusPlus)
12725404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis      return isCXXDeclarationStatement();
12739497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor    return isDeclarationSpecifier(true);
12745404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  }
12755404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
1276bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  /// isSimpleDeclaration - Disambiguates between a declaration or an
1277bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  /// expression, mainly used for the C 'clause-1' or the C++
1278bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  // 'for-init-statement' part of a 'for' statement.
1279bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  /// Returns true for declaration, false for expression.
1280bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  bool isSimpleDeclaration() {
1281bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis    if (getLang().CPlusPlus)
1282bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis      return isCXXSimpleDeclaration();
12839497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor    return isDeclarationSpecifier(true);
1284bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis  }
1285bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis
12869497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor  /// \brief Determine whether we are currently at the start of an Objective-C
12879497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor  /// class message that appears to be missing the open bracket '['.
12889497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor  bool isStartOfObjCClassMessageMissingOpenBracket();
12899497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor
12900efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor  /// \brief Starting with a scope specifier, identifier, or
12910efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor  /// template-id that refers to the current class, determine whether
12920efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor  /// this is a constructor declarator.
12930efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor  bool isConstructorDeclarator();
12940efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor
12958b642592a35167a3780074e78674e0bece87c40cDouglas Gregor  /// \brief Specifies the context in which type-id/expression
12968b642592a35167a3780074e78674e0bece87c40cDouglas Gregor  /// disambiguation will occur.
12978b642592a35167a3780074e78674e0bece87c40cDouglas Gregor  enum TentativeCXXTypeIdContext {
12988b642592a35167a3780074e78674e0bece87c40cDouglas Gregor    TypeIdInParens,
12998b642592a35167a3780074e78674e0bece87c40cDouglas Gregor    TypeIdAsTemplateArgument
13008b642592a35167a3780074e78674e0bece87c40cDouglas Gregor  };
13018b642592a35167a3780074e78674e0bece87c40cDouglas Gregor
13028b642592a35167a3780074e78674e0bece87c40cDouglas Gregor
130378c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis  /// isTypeIdInParens - Assumes that a '(' was parsed and now we want to know
130478c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis  /// whether the parens contain an expression or a type-id.
130578c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis  /// Returns true for a type-id and false for an expression.
1306f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  bool isTypeIdInParens(bool &isAmbiguous) {
130778c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis    if (getLang().CPlusPlus)
1308f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis      return isCXXTypeId(TypeIdInParens, isAmbiguous);
1309f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis    isAmbiguous = false;
131078c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis    return isTypeSpecifierQualifier();
131178c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis  }
1312f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  bool isTypeIdInParens() {
1313f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis    bool isAmbiguous;
1314f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis    return isTypeIdInParens(isAmbiguous);
1315f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  }
131678c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis
13175404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// isCXXDeclarationStatement - C++-specialized function that disambiguates
13185404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// between a declaration or an expression statement, when parsing function
13195404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// bodies. Returns true for declaration, false for expression.
13205404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  bool isCXXDeclarationStatement();
13215404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
13225404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// isCXXSimpleDeclaration - C++-specialized function that disambiguates
13235404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// between a simple-declaration or an expression-statement.
13245404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// If during the disambiguation process a parsing error is encountered,
13255404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// the function returns true to let the declaration parsing code handle it.
13265404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// Returns false if the statement is disambiguated as expression.
13275404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  bool isCXXSimpleDeclaration();
13285404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
13295404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// isCXXFunctionDeclarator - Disambiguates between a function declarator or
13305404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// a constructor-style initializer, when parsing declaration statements.
13315404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// Returns true for function declarator and false for constructor-style
1332e75d849d9141d8e47d05a91b7b5c04194854e47aArgyrios Kyrtzidis  /// initializer. If 'warnIfAmbiguous' is true a warning will be emitted to
1333259b0d91f2ff90d8daf39221fe133bf1596c5ffbArgyrios Kyrtzidis  /// indicate that the parens were disambiguated as function declarator.
13345404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// If during the disambiguation process a parsing error is encountered,
13355404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// the function returns true to let the declaration parsing code handle it.
1336e75d849d9141d8e47d05a91b7b5c04194854e47aArgyrios Kyrtzidis  bool isCXXFunctionDeclarator(bool warnIfAmbiguous);
13375404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
1338a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis  /// isCXXConditionDeclaration - Disambiguates between a declaration or an
1339a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis  /// expression for a condition of a if/switch/while/for statement.
1340a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis  /// If during the disambiguation process a parsing error is encountered,
1341a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis  /// the function returns true to let the declaration parsing code handle it.
1342a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis  bool isCXXConditionDeclaration();
1343a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis
1344f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  bool isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous);
1345f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
1346f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis    bool isAmbiguous;
1347f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis    return isCXXTypeId(Context, isAmbiguous);
1348f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis  }
134978c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis
1350b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// TPResult - Used as the result value for functions whose purpose is to
1351b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// disambiguate C++ constructs by "tentatively parsing" them.
1352b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// This is a class instead of a simple enum because the implicit enum-to-bool
1353b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// conversions may cause subtle bugs.
1354b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  class TPResult {
1355b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    enum Result {
1356b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis      TPR_true,
1357b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis      TPR_false,
1358b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis      TPR_ambiguous,
1359b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis      TPR_error
1360b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    };
1361b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    Result Res;
1362b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    TPResult(Result result) : Res(result) {}
1363b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  public:
1364b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    static TPResult True() { return TPR_true; }
1365b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    static TPResult False() { return TPR_false; }
1366b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    static TPResult Ambiguous() { return TPR_ambiguous; }
1367b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    static TPResult Error() { return TPR_error; }
1368b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis
1369b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    bool operator==(const TPResult &RHS) const { return Res == RHS.Res; }
1370b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis    bool operator!=(const TPResult &RHS) const { return Res != RHS.Res; }
1371b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis  };
1372b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis
1373b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// isCXXDeclarationSpecifier - Returns TPResult::True() if it is a
1374b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// declaration specifier, TPResult::False() if it is not,
1375b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// TPResult::Ambiguous() if it could be either a decl-specifier or a
1376b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// function-style cast, and TPResult::Error() if a parsing error was
1377b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  /// encountered.
13785404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  /// Doesn't consume tokens.
1379b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult isCXXDeclarationSpecifier();
13805404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
13815404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  // "Tentative parsing" functions, used for disambiguation. If a parsing error
1382b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  // is encountered they will return TPResult::Error().
1383b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  // Returning TPResult::True()/False() indicates that the ambiguity was
1384b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  // resolved and tentative parsing may stop. TPResult::Ambiguous() indicates
1385b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  // that more tentative parsing is necessary for disambiguation.
13865404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis  // They all consume tokens, so backtracking should be used after calling them.
13875404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
1388b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseDeclarationSpecifier();
1389b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseSimpleDeclaration();
1390b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseTypeofSpecifier();
1391b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseInitDeclaratorList();
139278c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis  TPResult TryParseDeclarator(bool mayBeAbstract, bool mayHaveIdentifier=true);
1393b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseParameterDeclarationClause();
1394b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseFunctionDeclarator();
1395b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis  TPResult TryParseBracketDeclarator();
13965404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis
1397ef65f06e8e440aec541442cfd73a8a836e9bc842Sebastian Redl  TypeResult ParseTypeName(SourceRange *Range = 0);
139898eb8a7a702b95183ed015706b1f1c66f5cb27a4Mike Stump  void ParseBlockId();
1399ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl  // EndLoc, if non-NULL, is filled with the location of the last token of
1400ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl  // the attribute list.
1401bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  CXX0XAttributeList ParseCXX0XAttributes(SourceLocation *EndLoc = 0);
1402334d47e92e9f241576fdeb7477b69a03136ba854Francois Pichet  void ParseMicrosoftAttributes();
1403bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  AttributeList *ParseGNUAttributes(SourceLocation *EndLoc = 0);
1404290eeb0ec2b6b91f3621e05ef541deb257fbea73Eli Friedman  AttributeList *ParseMicrosoftDeclSpec(AttributeList* CurrAttr = 0);
1405290eeb0ec2b6b91f3621e05ef541deb257fbea73Eli Friedman  AttributeList *ParseMicrosoftTypeAttributes(AttributeList* CurrAttr = 0);
140652fc314e1b5e1baee6305067cf831763d02bd243Dawn Perchik  AttributeList *ParseBorlandTypeAttributes(AttributeList* CurrAttr = 0);
1407d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff  void ParseTypeofSpecifier(DeclSpec &DS);
14086fd634f4ac59f5923cffadadb99d19f23c18707aAnders Carlsson  void ParseDecltypeSpecifier(DeclSpec &DS);
1409bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt
141060d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseCXX0XAlignArgument(SourceLocation Start);
1411eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
1412eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
1413eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// enter a new C++ declarator scope and exit it when the function is
1414eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  /// finished.
1415eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  class DeclaratorScopeObj {
1416eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis    Parser &P;
1417751810234ffb45327f23c5f9fda0b944e480bd2bArgyrios Kyrtzidis    CXXScopeSpec &SS;
1418f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis    bool EnteredScope;
1419f7f3d0db754db0500b56d49ac19f795f13965912John McCall    bool CreatedScope;
1420eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  public:
1421f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis    DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
1422f7f3d0db754db0500b56d49ac19f795f13965912John McCall      : P(p), SS(ss), EnteredScope(false), CreatedScope(false) {}
1423eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
1424eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis    void EnterDeclaratorScope() {
14252bcb3439b50c7f227a21d7118a2a76904ec60331Argyrios Kyrtzidis      assert(!EnteredScope && "Already entered the scope!");
1426f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis      assert(SS.isSet() && "C++ scope was not set!");
1427f7f3d0db754db0500b56d49ac19f795f13965912John McCall
1428f7f3d0db754db0500b56d49ac19f795f13965912John McCall      CreatedScope = true;
1429f7f3d0db754db0500b56d49ac19f795f13965912John McCall      P.EnterScope(0); // Not a decl scope.
1430f7f3d0db754db0500b56d49ac19f795f13965912John McCall
143123c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor      if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS))
14323fdbed594f4cb238fe37cad2ec3fefa3b6f67125Douglas Gregor        EnteredScope = true;
1433eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis    }
1434eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis
1435eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis    ~DeclaratorScopeObj() {
1436f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis      if (EnteredScope) {
1437f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis        assert(SS.isSet() && "C++ scope was cleared ?");
143823c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor        P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS);
1439f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis      }
1440f7f3d0db754db0500b56d49ac19f795f13965912John McCall      if (CreatedScope)
1441f7f3d0db754db0500b56d49ac19f795f13965912John McCall        P.ExitScope();
1442eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis    }
1443eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis  };
14441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// ParseDeclarator - Parse and verify a newly-initialized declarator.
14465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseDeclarator(Declarator &D);
14474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  /// A function that parses a variant of direct-declarator.
14484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef void (Parser::*DirectDeclParseFunction)(Declarator&);
14494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  void ParseDeclaratorInternal(Declarator &D,
14504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                               DirectDeclParseFunction DirectDeclParser);
1451bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  void ParseTypeQualifierListOpt(DeclSpec &DS, bool GNUAttributesAllowed = true,
1452bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt                                 bool CXX0XAttributesAllowed = true);
14535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseDirectDeclarator(Declarator &D);
14545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseParenDeclarator(Declarator &D);
14557399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner  void ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
14567399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner                               AttributeList *AttrList = 0,
14577399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner                               bool RequiresArg = false);
145866d28650752eeac0b02802a1d8cea425cb6b1c0fChris Lattner  void ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
145983a944763b0948c608eb48f101ec10a1ae5da46aChris Lattner                                             IdentifierInfo *FirstIdent,
146083a944763b0948c608eb48f101ec10a1ae5da46aChris Lattner                                             SourceLocation FirstIdentLoc,
146166d28650752eeac0b02802a1d8cea425cb6b1c0fChris Lattner                                             Declarator &D);
14625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  void ParseBracketDeclarator(Declarator &D);
14631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14648f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner  //===--------------------------------------------------------------------===//
14658f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner  // C++ 7: Declarations [dcl.dcl]
14661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1467bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt  bool isCXX0XAttributeSpecifier(bool FullLookahead = false,
1468bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt                                 tok::TokenKind *After = 0);
1469bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt
1470d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl  Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd,
1471d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                       SourceLocation InlineLoc = SourceLocation());
1472d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseLinkage(ParsingDeclSpec &DS, unsigned Context);
1473d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseUsingDirectiveOrDeclaration(unsigned Context,
1474d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                                         SourceLocation &DeclEnd,
1475d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                                         CXX0XAttributeList Attrs);
1476d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseUsingDirective(unsigned Context, SourceLocation UsingLoc,
1477d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                            SourceLocation &DeclEnd, AttributeList *Attr);
1478d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseUsingDeclaration(unsigned Context, SourceLocation UsingLoc,
1479d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                              SourceLocation &DeclEnd,
1480d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                              AccessSpecifier AS = AS_none);
1481d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
1482d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
1483d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                            SourceLocation AliasLoc, IdentifierInfo *Alias,
1484d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl                            SourceLocation &DeclEnd);
14851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1486e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor  //===--------------------------------------------------------------------===//
1487e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor  // C++ 9: classes [class] and C structs/unions.
14881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  TypeResult ParseClassName(SourceLocation &EndLocation,
14899ab14541716928894821cf5d53d6b4c95ffdf3a3Jeffrey Yasskin                            CXXScopeSpec *SS = 0);
14904c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner  void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc,
14911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                           DeclSpec &DS,
14924d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1493d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl                           AccessSpecifier AS = AS_none,
1494d9bafa76f8d6eb9e4f4974ed322217f8df6bb82eSebastian Redl                           bool SuppressDeclarations = false);
14954cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis  void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType,
1496d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                   Decl *TagDecl);
149737b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor  void ParseCXXClassMemberDeclaration(AccessSpecifier AS,
1498c9068d7dd94d439cec66c421115d15303e481025John McCall                const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1499c9068d7dd94d439cec66c421115d15303e481025John McCall                                 ParsingDeclRAIIObject *DiagsFromTParams = 0);
1500d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseConstructorInitializer(Decl *ConstructorDecl);
1501d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  MemInitResult ParseMemInitializer(Decl *ConstructorDecl);
1502d33133cdc1af466f9c276249b2621be03867888bEli Friedman  void HandleMemberFunctionDefaultArgs(Declarator& DeclaratorInfo,
1503d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                       Decl *ThisDecl);
1504e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor
1505e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor  //===--------------------------------------------------------------------===//
1506e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor  // C++ 10: Derived classes [class.derived]
1507d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  void ParseBaseClause(Decl *ClassDecl);
1508d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  BaseResult ParseBaseSpecifier(Decl *ClassDecl);
15091b7f89846f10681ce3cbe89ef5d60691d55bd918Douglas Gregor  AccessSpecifier getAccessSpecifierIfPresent() const;
15101cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor
15113f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor  bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
15123f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor                                    IdentifierInfo *Name,
15133f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor                                    SourceLocation NameLoc,
15143f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor                                    bool EnteringContext,
1515b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                    ParsedType ObjectType,
1516d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor                                    UnqualifiedId &Id,
15170278e123b4606ea15dbfa717e9c5a76a5ef2bc7dDouglas Gregor                                    bool AssumeTemplateId,
15180278e123b4606ea15dbfa717e9c5a76a5ef2bc7dDouglas Gregor                                    SourceLocation TemplateKWLoc);
1519ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor  bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
1520b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                                  ParsedType ObjectType,
1521ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor                                  UnqualifiedId &Result);
15223f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor  bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
152302a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor                          bool AllowDestructorName,
152402a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor                          bool AllowConstructorName,
1525b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall                          ParsedType ObjectType,
15263f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor                          UnqualifiedId &Result);
15273f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor
15281cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor  //===--------------------------------------------------------------------===//
1529adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor  // C++ 14: Templates [temp]
1530c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor
1531adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor  // C++ 14.1: Template Parameters [temp.param]
1532d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseDeclarationStartingWithTemplate(unsigned Context,
15334d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                                                 SourceLocation &DeclEnd,
15344d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                                                 AccessSpecifier AS = AS_none);
1535d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseTemplateDeclarationOrSpecialization(unsigned Context,
153697144fc41a9419bf6d74fc9450e8ef3f6e11f7e0Chris Lattner                                                     SourceLocation &DeclEnd,
15374d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                                                     AccessSpecifier AS);
1538d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseSingleDeclarationAfterTemplate(
15391426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor                                       unsigned Context,
15404d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor                                       const ParsedTemplateInfo &TemplateInfo,
1541c9068d7dd94d439cec66c421115d15303e481025John McCall                                       ParsingDeclRAIIObject &DiagsFromParams,
15421426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor                                       SourceLocation &DeclEnd,
15431426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor                                       AccessSpecifier AS=AS_none);
15441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool ParseTemplateParameters(unsigned Depth,
15451f58816e6589ef15d1509c6c99bb8fabf2a4cda9John McCall                               llvm::SmallVectorImpl<Decl*> &TemplateParams,
15461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                               SourceLocation &LAngleLoc,
1547c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor                               SourceLocation &RAngleLoc);
1548c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor  bool ParseTemplateParameterList(unsigned Depth,
15491f58816e6589ef15d1509c6c99bb8fabf2a4cda9John McCall                                  llvm::SmallVectorImpl<Decl*> &TemplateParams);
155098440b4ac17dc5f85ea3db683c1c1785449c17e1Douglas Gregor  bool isStartOfTemplateTypeParameter();
1551d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseTemplateParameter(unsigned Depth, unsigned Position);
1552d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseTypeParameter(unsigned Depth, unsigned Position);
1553d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
1554d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
1555d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor  // C++ 14.3: Template arguments [temp.arg]
1556314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor  typedef llvm::SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
1557cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor
15587532dc66648cfe7432c9fe66dec5225f0ab301c6Douglas Gregor  bool ParseTemplateIdAfterTemplateName(TemplateTy Template,
15591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                        SourceLocation TemplateNameLoc,
1560cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor                                        const CXXScopeSpec *SS,
1561cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor                                        bool ConsumeLastToken,
1562cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor                                        SourceLocation &LAngleLoc,
1563cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor                                        TemplateArgList &TemplateArgs,
1564cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor                                        SourceLocation &RAngleLoc);
1565cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor
1566c8e27cc402043ec86c1698c09e4ee9e415b16207Chris Lattner  bool AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
156739a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor                               const CXXScopeSpec *SS,
1568ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor                               UnqualifiedId &TemplateName,
156939a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor                               SourceLocation TemplateKWLoc = SourceLocation(),
157039a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor                               bool AllowTypeAnnotation = true);
157131a19b6989bbf326d2de5ae12e712e2a65ca9c34Douglas Gregor  void AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS = 0);
1572d5ab9b0a0ae24f7d0f49f6f10fd1b247e64b3306Douglas Gregor  bool IsTemplateArgumentList(unsigned Skip = 0);
1573314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor  bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
1574788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor  ParsedTemplateArgument ParseTemplateTemplateArgument();
1575314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor  ParsedTemplateArgument ParseTemplateArgument();
1576d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall  Decl *ParseExplicitInstantiation(SourceLocation ExternLoc,
1577d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                        SourceLocation TemplateLoc,
1578d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall                                        SourceLocation &DeclEnd);
157964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
158064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  //===--------------------------------------------------------------------===//
158164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // GNU G++: Type Traits [Type-Traits.html in the GCC manual]
158260d7b3a319d84d688752be3870615ac0f111fb16John McCall  ExprResult ParseUnaryTypeTrait();
1583f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor
1584f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor  //===--------------------------------------------------------------------===//
1585f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor  // Preprocessor code-completion pass-through
1586f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor  virtual void CodeCompleteDirective(bool InConditional);
1587f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor  virtual void CodeCompleteInConditionalExclusion();
15881fbb447e9d43c2c676e94081fbfee7eb6cbe933bDouglas Gregor  virtual void CodeCompleteMacroName(bool IsDefinition);
1589f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor  virtual void CodeCompletePreprocessorExpression();
1590f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor  virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro,
1591f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor                                         MacroInfo *MacroInfo,
1592f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor                                         unsigned ArgumentIndex);
159355817afdf9d453a443262a733f6caf6692dca118Douglas Gregor  virtual void CodeCompleteNaturalLanguage();
15945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
15955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
15965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
15975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
15985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
1599