Parser.h revision 161db02a747e0c8e717f542674c0581c03fc3c93
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" 224726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek#include "llvm/ADT/OwningPtr.h" 23eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski#include "llvm/ADT/SmallVector.h" 24aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h" 25aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/PrettyStackTrace.h" 2694f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose#include "llvm/Support/SaveAndRestore.h" 274cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis#include <stack> 285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 30fcdd8fe26de3eee44927600bf1853e21bd90dd84Daniel Dunbar class PragmaHandler; 315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Scope; 32c86c40b912e53fb11ff8f745ed616035b8b7259cDouglas Gregor class BalancedDelimiterTracker; 330576681bac125be07f77f66b02a3dba2c3a24557Richard Smith class CorrectionCandidateCallback; 342b5289b6fd7e3d9899868410a498c081c9595662John McCall class DeclGroupRef; 353cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner class DiagnosticBuilder; 360102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner class Parser; 379257664568bf375b7790131a84d9a4fa30a5b7e3John McCall class ParsingDeclRAIIObject; 389257664568bf375b7790131a84d9a4fa30a5b7e3John McCall class ParsingDeclSpec; 399257664568bf375b7790131a84d9a4fa30a5b7e3John McCall class ParsingDeclarator; 40f66a0dda541cd859a928193efba6dc5d7ba8fe54Eli Friedman class ParsingFieldDeclarator; 414726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek class PragmaUnusedHandler; 4208d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner class ColonProtectionRAIIObject; 430fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor class InMessageExpressionRAIIObject; 4428bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley class PoisonSEHIdentifiersRAIIObject; 450a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor class VersionTuple; 46a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 470102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// PrettyStackTraceParserEntry - If a crash happens while the parser is active, 480102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner/// an entry is printed for it. 490102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerclass PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry { 500102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner const Parser &P; 510102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattnerpublic: 520102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner PrettyStackTraceParserEntry(const Parser &p) : P(p) {} 538cc488fefb2fb04bc8d5398da29f0182f97934cfChris Lattner virtual void print(raw_ostream &OS) const; 540102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner}; 551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 566aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// PrecedenceLevels - These are precedences for the binary/ternary 576aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// operators in the C99 grammar. These have been named to relate 586aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// with the C99 grammar productions. Low precedences numbers bind 596aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor/// more weakly than high numbers. 606aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregornamespace prec { 616aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor enum Level { 626aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Unknown = 0, // Not binary operator. 636aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Comma = 1, // , 646aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Assignment = 2, // =, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= 656aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Conditional = 3, // ? 666aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor LogicalOr = 4, // || 676aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor LogicalAnd = 5, // && 686aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor InclusiveOr = 6, // | 696aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor ExclusiveOr = 7, // ^ 706aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor And = 8, // & 716aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Equality = 9, // ==, != 726aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Relational = 10, // >=, <=, >, < 736aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Shift = 11, // <<, >> 746aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Additive = 12, // -, + 756aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor Multiplicative = 13, // *, /, % 766aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor PointerToMember = 14 // .*, ->* 776aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor }; 786aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor} 791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Parser - This implements a parser for the C family of languages. After 815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// parsing units of the grammar, productions are invoked to handle whatever has 825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// been read. 835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 84f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregorclass Parser : public CodeCompletionHandler { 854726d03ab3abce41911c31d1354a18f1258cae4dTed Kremenek friend class PragmaUnusedHandler; 8608d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner friend class ColonProtectionRAIIObject; 870fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor friend class InMessageExpressionRAIIObject; 8828bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley friend class PoisonSEHIdentifiersRAIIObject; 8994f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose friend class ObjCDeclContextSwitch; 9036d36806f1972f7ec1d2a3f59155187278c56508Argyrios Kyrtzidis friend class ParenBraceBracketBalancer; 91c86c40b912e53fb11ff8f745ed616035b8b7259cDouglas Gregor friend class BalancedDelimiterTracker; 921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Preprocessor &PP; 941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9597d0205d16fef2a783e785459b5f30f6a9dfbcb9Eric Christopher /// Tok - The current token we are peeking ahead. All parsing methods assume 965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// that this is valid. 97d217773f106856a11879ec79dc468efefaf2ee75Chris Lattner Token Tok; 981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 994b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // PrevTokLocation - The location of the token we previously 1004b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // consumed. This token is used for diagnostics where we expected to 1014b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // see a token following another token (e.g., the ';' at the end of 1024b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor // a statement). 1034b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor SourceLocation PrevTokLocation; 1044b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor 1055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned short ParenCount, BracketCount, BraceCount; 106c86c40b912e53fb11ff8f745ed616035b8b7259cDouglas Gregor 1075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Actions - These are the callbacks we invoke as we parse various constructs 108a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// in the file. 109f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema &Actions; 1101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 111d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags; 1121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1139e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner /// ScopeCache - Cache scopes to reduce malloc traffic. 1149e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner enum { ScopeCacheSize = 16 }; 1159e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner unsigned NumCachedScopes; 1169e344c65b1e8b83e1d3ada507cf653526ff2c005Chris Lattner Scope *ScopeCache[ScopeCacheSize]; 117662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar 11828bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley /// Identifiers used for SEH handling in Borland. These are only 11928bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley /// allowed in particular circumstances 120a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie // __except block 121a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie IdentifierInfo *Ident__exception_code, 122a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident___exception_code, 123a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident_GetExceptionCode; 124a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie // __except filter expression 125a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie IdentifierInfo *Ident__exception_info, 126a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident___exception_info, 127a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident_GetExceptionInfo; 128a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie // __finally 129a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie IdentifierInfo *Ident__abnormal_termination, 130a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident___abnormal_termination, 131a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie *Ident_AbnormalTermination; 13228bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley 133b57791e5b40afa6691063c83d0e95c416fb19fdeDouglas Gregor /// Contextual keywords for Microsoft extensions. 134b57791e5b40afa6691063c83d0e95c416fb19fdeDouglas Gregor IdentifierInfo *Ident__except; 135a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 136662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar /// Ident_super - IdentifierInfo for "super", to support fast 137662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar /// comparison. 138662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar IdentifierInfo *Ident_super; 13982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// Ident_vector and Ident_pixel - cached IdentifierInfo's for 14082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// "vector" and "pixel" fast comparison. Only present if 14182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// AltiVec enabled. 14282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson IdentifierInfo *Ident_vector; 14382287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson IdentifierInfo *Ident_pixel; 144662e8b5647adbb1bc9eeceece7b64600cfa87471Daniel Dunbar 145e97179c675b341927807c718be215c8d1aab8acbDouglas Gregor /// Objective-C contextual keywords. 146e97179c675b341927807c718be215c8d1aab8acbDouglas Gregor mutable IdentifierInfo *Ident_instancetype; 147a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1480a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "introduced". 1490a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_introduced; 1500a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1510a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "deprecated". 1520a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_deprecated; 1530a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1540a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Identifier for "obsoleted". 1550a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor IdentifierInfo *Ident_obsoleted; 1560a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 157b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor /// \brief Identifier for "unavailable". 158b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor IdentifierInfo *Ident_unavailable; 159006e42f0c8b65b783d565ef10b938a9e82fc02e3Fariborz Jahanian 160006e42f0c8b65b783d565ef10b938a9e82fc02e3Fariborz Jahanian /// \brief Identifier for "message". 161006e42f0c8b65b783d565ef10b938a9e82fc02e3Fariborz Jahanian IdentifierInfo *Ident_message; 162b53e417ba487f4193ef3b0485b420e0fdae643a2Douglas Gregor 163a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// C++0x contextual keywords. 1647eeb4ec11043d4860361348f2b19299d957d47a9Anders Carlsson mutable IdentifierInfo *Ident_final; 1657eeb4ec11043d4860361348f2b19299d957d47a9Anders Carlsson mutable IdentifierInfo *Ident_override; 1661f3b6fdabbb10779a473d6315154d7325ce20aeaAnders Carlsson 167d295970adc93ed4035d18df23673c2a72d124cc8Douglas Gregor // C++ type trait keywords that have can be reverted to identifiers and 168d295970adc93ed4035d18df23673c2a72d124cc8Douglas Gregor // still used as type traits. 169d295970adc93ed4035d18df23673c2a72d124cc8Douglas Gregor llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertableTypeTraits; 170d295970adc93ed4035d18df23673c2a72d124cc8Douglas Gregor 1716f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> AlignHandler; 1726f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> GCCVisibilityHandler; 1736f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> OptionsHandler; 1746f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> PackHandler; 1756f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> MSStructHandler; 1766f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> UnusedHandler; 1776f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> WeakHandler; 1785f3c163b7b19a0c7e02509a0984ee1256bca890dDavid Chisnall OwningPtr<PragmaHandler> RedefineExtnameHandler; 1796f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> FPContractHandler; 1806f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<PragmaHandler> OpenCLExtensionHandler; 181056e2c30050a94141150ba561268d90b4d18e378Dmitri Gribenko OwningPtr<CommentHandler> CommentSemaHandler; 1821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 18355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// Whether the '>' token acts as an operator or not. This will be 18455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// true except when we are parsing an expression within a C++ 18555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// template argument list, where the '>' closes the template 18655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// argument list. 18755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor bool GreaterThanIsOperator; 188a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 18908d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// ColonIsSacred - When this is false, we aggressively try to recover from 19008d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// code like "foo : bar" as if it were a typo for "foo :: bar". This is not 19108d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// safe in case statements and a few other things. This is managed by the 19208d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner /// ColonProtectionRAIIObject RAII object. 19308d92ecf6e5b1fd23177a08c2312b58d63d863dbChris Lattner bool ColonIsSacred; 19455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 195a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// \brief When true, we are directly inside an Objective-C messsage 1960fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// send expression. 1970fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// 1980fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// This is managed by the \c InMessageExpressionRAIIObject class, and 1990fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor /// should not be set directly. 2000fbda68b50ce17d7ad36ef7a5ed77518a5cd272eDouglas Gregor bool InMessageExpression; 201a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 202c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor /// The "depth" of the template parameters currently being parsed. 203c3058338075a2132e057f1249a13b55a81fe021cDouglas Gregor unsigned TemplateParameterDepth; 204a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 2058113ecfa4e41e2c888b1794389dfe3bce6386493Ted Kremenek /// Factory object for creating AttributeList objects. 2060b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall AttributeFactory AttrFactory; 2071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20813bb701f2f876356400a34b0917a417c66b5d70dBenjamin Kramer /// \brief Gathers and cleans up TemplateIdAnnotations when parsing of a 20913bb701f2f876356400a34b0917a417c66b5d70dBenjamin Kramer /// top-level declaration is finished. 21013bb701f2f876356400a34b0917a417c66b5d70dBenjamin Kramer SmallVector<TemplateIdAnnotation *, 16> TemplateIds; 21125a767651d14db87aa03dd5fe3e011d877dd4100Argyrios Kyrtzidis 2120576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// \brief Identifiers which have been declared within a tentative parse. 2130576681bac125be07f77f66b02a3dba2c3a24557Richard Smith SmallVector<IdentifierInfo *, 8> TentativelyDeclaredIdentifiers; 2140576681bac125be07f77f66b02a3dba2c3a24557Richard Smith 215b57791e5b40afa6691063c83d0e95c416fb19fdeDouglas Gregor IdentifierInfo *getSEHExceptKeyword(); 216a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 21794f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose /// True if we are within an Objective-C container while parsing C-like decls. 21894f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose /// 21994f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose /// This is necessary because Sema thinks we have left the container 22094f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose /// to parse the C-like decls, meaning Actions.getObjCDeclContext() will 22194f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose /// be NULL. 22294f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose bool ParsingInObjCContainer; 22394f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose 2246a91d385618ea4d28236c496f540a26877c95525Erik Verbruggen bool SkipFunctionBodies; 2256a91d385618ea4d28236c496f540a26877c95525Erik Verbruggen 2265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 2276a91d385618ea4d28236c496f540a26877c95525Erik Verbruggen Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies); 2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ~Parser(); 2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2304e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie const LangOptions &getLangOpts() const { return PP.getLangOpts(); } 231444be7366d0a1e172c0290a1ea54c1cb16b5947cDaniel Dunbar const TargetInfo &getTargetInfo() const { return PP.getTargetInfo(); } 2320102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner Preprocessor &getPreprocessor() const { return PP; } 233f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema &getActions() const { return Actions; } 2349257664568bf375b7790131a84d9a4fa30a5b7e3John McCall AttributeFactory &getAttrFactory() { return AttrFactory; } 2351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2360102c30896c83f70cf6b6519fd5c674cb981c0b5Chris Lattner const Token &getCurToken() const { return Tok; } 23723c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor Scope *getCurScope() const { return Actions.getCurScope(); } 238a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 239a28948f34817476d02412fa204cae038e228c827Fariborz Jahanian Decl *getObjCDeclContext() const { return Actions.getObjCDeclContext(); } 240a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 2415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Type forwarding. All of these are statically 'void*', but they may all be 2425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // different actual classes based on the actions in place. 2432b5289b6fd7e3d9899868410a498c081c9595662John McCall typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy; 2442b5289b6fd7e3d9899868410a498c081c9595662John McCall typedef OpaquePtr<TemplateName> TemplateTy; 2457ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor 246686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<TemplateParameterList *, 4> TemplateParameterLists; 247c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor 2489ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::ExprResult ExprResult; 2499ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::StmtResult StmtResult; 2509ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::BaseResult BaseResult; 2519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::MemInitResult MemInitResult; 2529ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef clang::TypeResult TypeResult; 25315faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 2549ae2f076ca5ab1feb3ba95629099ec2319833701John McCall typedef Expr *ExprArg; 2555354e77e60e82828c7c2361f5c688c2667ab59ccBenjamin Kramer typedef llvm::MutableArrayRef<Stmt*> MultiStmtArg; 256f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall typedef Sema::FullExprArg FullExprArg; 2571d922960e083906a586609ac6978678147250177Sebastian Redl 25860d7b3a319d84d688752be3870615ac0f111fb16John McCall /// Adorns a ExprResult with Actions to make it an ExprResult 25960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Owned(ExprResult res) { 26060d7b3a319d84d688752be3870615ac0f111fb16John McCall return ExprResult(res); 26161364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 26260d7b3a319d84d688752be3870615ac0f111fb16John McCall /// Adorns a StmtResult with Actions to make it an StmtResult 26360d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Owned(StmtResult res) { 26460d7b3a319d84d688752be3870615ac0f111fb16John McCall return StmtResult(res); 26561364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 26661364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 26760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprError() { return ExprResult(true); } 26860d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult StmtError() { return StmtResult(true); } 269d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor 27060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); } 27160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); } 27261364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 27360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ExprEmpty() { return ExprResult(false); } 2745ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis 2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Parsing methods. 2761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParseTranslationUnit - All in one method that initializes parses, and 2785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// shuts down the parser. 2795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseTranslationUnit(); 2801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Initialize - Warm up the parser. 2825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Initialize(); 2841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if 2861f6443255894429fba384de0d5b6389ef578a5e9Steve Naroff /// the EOF was encountered. 287682bf92db408a6cbc3d37b5496a99b6ef85041ecChris Lattner bool ParseTopLevelDecl(DeclGroupPtrTy &Result); 2881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2896944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann /// ConsumeToken - Consume the current 'peek token' and lex the next one. 2906944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann /// This does not work with all kinds of tokens: strings and specific other 2916944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann /// tokens must be consumed with custom methods below. This returns the 2926944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann /// location of the consumed token. 2936944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann SourceLocation ConsumeToken() { 2946944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann assert(!isTokenStringLiteral() && !isTokenParen() && !isTokenBracket() && 2956944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann !isTokenBrace() && 2966944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann "Should consume special tokens with Consume*Token"); 2976944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 2986944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann if (Tok.is(tok::code_completion)) 2996944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann return handleUnexpectedCodeCompletionToken(); 3006944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 3016944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann PrevTokLocation = Tok.getLocation(); 3026944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann PP.Lex(Tok); 3036944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann return PrevTokLocation; 3046944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann } 3056944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 3065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 3075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 3085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Low-Level token peeking and consumption methods. 3095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // 3101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenParen - Return true if the cur token is '(' or ')'. 3125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenParen() const { 3135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_paren || Tok.getKind() == tok::r_paren; 3145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenBracket - Return true if the cur token is '[' or ']'. 3165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenBracket() const { 3175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_square || Tok.getKind() == tok::r_square; 3185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenBrace - Return true if the cur token is '{' or '}'. 3205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenBrace() const { 3215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::l_brace || Tok.getKind() == tok::r_brace; 3225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isTokenStringLiteral - True if this token is a string-literal. 3255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isTokenStringLiteral() const { 3275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Tok.getKind() == tok::string_literal || 3285cee1195584fa8672253139c86e922daeda69b9eDouglas Gregor Tok.getKind() == tok::wide_string_literal || 3295cee1195584fa8672253139c86e922daeda69b9eDouglas Gregor Tok.getKind() == tok::utf8_string_literal || 3305cee1195584fa8672253139c86e922daeda69b9eDouglas Gregor Tok.getKind() == tok::utf16_string_literal || 3315cee1195584fa8672253139c86e922daeda69b9eDouglas Gregor Tok.getKind() == tok::utf32_string_literal; 3325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 333eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 334fcaf27e185695bdf755e202aeba9632e0a8ef3c6Richard Trieu /// \brief Returns true if the current token is '=' or is a type of '='. 335fcaf27e185695bdf755e202aeba9632e0a8ef3c6Richard Trieu /// For typos, give a fixit to '=' 336fcaf27e185695bdf755e202aeba9632e0a8ef3c6Richard Trieu bool isTokenEqualOrEqualTypo(); 337a6eb5f81d13bacac01faff70a947047725b4413fArgyrios Kyrtzidis 3385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeAnyToken - Dispatch to the right Consume* method based on the 3395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// current token type. This should only be used in cases where the type of 3405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// the token really isn't known, e.g. in error recovery. 3415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeAnyToken() { 3425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (isTokenParen()) 3435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeParen(); 3445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (isTokenBracket()) 3455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeBracket(); 3465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (isTokenBrace()) 3475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeBrace(); 348d62701bc5321049353017e9abf1963edd57646aaSteve Naroff else if (isTokenStringLiteral()) 349d62701bc5321049353017e9abf1963edd57646aaSteve Naroff return ConsumeStringToken(); 3505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else 3515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ConsumeToken(); 3525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeParen - This consume method keeps the paren count up-to-date. 3555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeParen() { 3575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenParen() && "wrong consume method"); 3585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_paren) 3595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++ParenCount; 3605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (ParenCount) 3615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --ParenCount; // Don't let unbalanced )'s drive the count negative. 3624b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3644b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeBracket - This consume method keeps the bracket count up-to-date. 3685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeBracket() { 3705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenBracket() && "wrong consume method"); 3715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_square) 3725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++BracketCount; 3735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (BracketCount) 3745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --BracketCount; // Don't let unbalanced ]'s drive the count negative. 3751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3764b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3784b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeBrace - This consume method keeps the brace count up-to-date. 3825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 3835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeBrace() { 3845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenBrace() && "wrong consume method"); 3855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer if (Tok.getKind() == tok::l_brace) 3865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ++BraceCount; 3875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer else if (BraceCount) 3885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer --BraceCount; // Don't let unbalanced }'s drive the count negative. 3891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3904b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 3915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 3924b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 3935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 3941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ConsumeStringToken - Consume the current 'peek token', lexing a new one 3965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// and returning the token kind. This method is specific to strings, as it 3975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// handles string literal concatenation, as per C99 5.1.1.2, translation 3985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// phase #6. 3995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SourceLocation ConsumeStringToken() { 4005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(isTokenStringLiteral() && 4015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer "Should only consume string literals with this method"); 4024b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor PrevTokLocation = Tok.getLocation(); 4035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PP.Lex(Tok); 4044b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor return PrevTokLocation; 4055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 4061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 407dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// \brief Consume the current code-completion token. 408dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// 409dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// This routine should be called to consume the code-completion token once 410dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// a code-completion action has already been invoked. 411dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor SourceLocation ConsumeCodeCompletionToken() { 412dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor assert(Tok.is(tok::code_completion)); 413dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor PrevTokLocation = Tok.getLocation(); 414dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor PP.Lex(Tok); 415a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie return PrevTokLocation; 416dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor } 417a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 4187d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis ///\ brief When we are consuming a code-completion token without having 419dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// matched specific position in the grammar, provide code-completion results 420dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor /// based on context. 4217d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis /// 4227d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis /// \returns the source location of the code-completion token. 4237d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis SourceLocation handleUnexpectedCodeCompletionToken(); 4247d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis 4257d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis /// \brief Abruptly cut off parsing; mainly used when we have reached the 4267d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis /// code-completion point. 4277d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis void cutOffParsing() { 4287d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis PP.setCodeCompletionReached(); 4297d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis // Cut off parsing by acting as if we reached the end-of-file. 4307d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis Tok.setKind(tok::eof); 4317d100872341f233c81e1d7b72b40457e62c36862Argyrios Kyrtzidis } 432dc8453422bec3bbf70c03920e01498d75783d122Douglas Gregor 433b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis /// \brief Handle the annotation token produced for #pragma unused(...) 434b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis void HandlePragmaUnused(); 435b918d0f5d8f147e1e26c34e6cf42a79af2d2ec41Argyrios Kyrtzidis 436426fc94ed3bce15b55c43692537e3833388f0352Rafael Espindola /// \brief Handle the annotation token produced for 437426fc94ed3bce15b55c43692537e3833388f0352Rafael Espindola /// #pragma GCC visibility... 438426fc94ed3bce15b55c43692537e3833388f0352Rafael Espindola void HandlePragmaVisibility(); 439426fc94ed3bce15b55c43692537e3833388f0352Rafael Espindola 440aa5ab26ed93382b812147f532dcbf4afb5494040Eli Friedman /// \brief Handle the annotation token produced for 441aa5ab26ed93382b812147f532dcbf4afb5494040Eli Friedman /// #pragma pack... 442aa5ab26ed93382b812147f532dcbf4afb5494040Eli Friedman void HandlePragmaPack(); 443aa5ab26ed93382b812147f532dcbf4afb5494040Eli Friedman 4449595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4459595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma ms_struct... 4469595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaMSStruct(); 4479595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4489595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4499595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma align... 4509595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaAlign(); 4519595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4529595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4539595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma weak id... 4549595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaWeak(); 4559595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4569595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4579595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma weak id = id... 4589595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaWeakAlias(); 4599595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4609595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4619595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma redefine_extname... 4629595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaRedefineExtname(); 4639595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4649595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4659595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma STDC FP_CONTRACT... 4669595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaFPContract(); 4679595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4689595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// \brief Handle the annotation token produced for 4699595c7e2533c836537dc300e75d059c29feb7094Eli Friedman /// #pragma OPENCL EXTENSION... 4709595c7e2533c836537dc300e75d059c29feb7094Eli Friedman void HandlePragmaOpenCLExtension(); 4719595c7e2533c836537dc300e75d059c29feb7094Eli Friedman 4726b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// GetLookAheadToken - This peeks ahead N tokens and returns that token 4736b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// without consuming any tokens. LookAhead(0) returns 'Tok', LookAhead(1) 4746b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// returns the token after Tok, etc. 4756b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// 4766b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// Note that this differs from the Preprocessor's LookAhead method, because 4776b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// the Parser always has one token lexed that the preprocessor doesn't. 4786b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner /// 47903db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis const Token &GetLookAheadToken(unsigned N) { 4806b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner if (N == 0 || Tok.is(tok::eof)) return Tok; 4816b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner return PP.LookAhead(N-1); 4826b884508c3bc97cc9df9516adb92fbf88dd0a2e4Chris Lattner } 483f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis 4846944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 485f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis /// NextToken - This peeks ahead one token and returns it without 486f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis /// consuming it. 487f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis const Token &NextToken() { 48803db1b31dd926409b7defc1c90b66549464652c0Argyrios Kyrtzidis return PP.LookAhead(0); 489f7da726f09a6b7c5b9f5308e9690cb015398e671Argyrios Kyrtzidis } 4905404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 491b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall /// getTypeAnnotation - Read a parsed type out of an annotation token. 492b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall static ParsedType getTypeAnnotation(Token &Tok) { 493b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall return ParsedType::getFromOpaquePtr(Tok.getAnnotationValue()); 494b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall } 495b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall 4966944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 497b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall static void setTypeAnnotation(Token &Tok, ParsedType T) { 498b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall Tok.setAnnotationValue(T.getAsOpaquePtr()); 499b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall } 500a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 5015ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor /// \brief Read an already-translated primary expression out of an annotation 5025ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor /// token. 5035ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor static ExprResult getExprAnnotation(Token &Tok) { 5045ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor if (Tok.getAnnotationValue()) 5055ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor return ExprResult((Expr *)Tok.getAnnotationValue()); 506a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 5075ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor return ExprResult(true); 5085ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor } 509a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 5105ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor /// \brief Set the primary expression corresponding to the given annotation 5115ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor /// token. 5125ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor static void setExprAnnotation(Token &Tok, ExprResult ER) { 5135ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor if (ER.isInvalid()) 5145ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor Tok.setAnnotationValue(0); 5155ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor else 5165ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor Tok.setAnnotationValue(ER.get()); 5175ecdd78408a1c6f4be506d94f776642570d27336Douglas Gregor } 518b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall 5196944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 520fac9467d1676dc05761e12e41e13e01a3a3da52bKaelyn Uhrain // If NeedType is true, then TryAnnotateTypeOrScopeToken will try harder to 521fac9467d1676dc05761e12e41e13e01a3a3da52bKaelyn Uhrain // find a type name by attempting typo correction. 522fac9467d1676dc05761e12e41e13e01a3a3da52bKaelyn Uhrain bool TryAnnotateTypeOrScopeToken(bool EnteringContext = false, 523fac9467d1676dc05761e12e41e13e01a3a3da52bKaelyn Uhrain bool NeedType = false); 5240576681bac125be07f77f66b02a3dba2c3a24557Richard Smith bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool EnteringContext, 5250576681bac125be07f77f66b02a3dba2c3a24557Richard Smith bool NeedType, 5260576681bac125be07f77f66b02a3dba2c3a24557Richard Smith CXXScopeSpec &SS, 5270576681bac125be07f77f66b02a3dba2c3a24557Richard Smith bool IsNewScope); 528495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor bool TryAnnotateCXXScopeToken(bool EnteringContext = false); 5296944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 5306944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 5310576681bac125be07f77f66b02a3dba2c3a24557Richard Smith enum AnnotatedNameKind { 5320576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// Annotation has failed and emitted an error. 5330576681bac125be07f77f66b02a3dba2c3a24557Richard Smith ANK_Error, 5340576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// The identifier is a tentatively-declared name. 5350576681bac125be07f77f66b02a3dba2c3a24557Richard Smith ANK_TentativeDecl, 5360576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// The identifier is a template name. FIXME: Add an annotation for that. 5370576681bac125be07f77f66b02a3dba2c3a24557Richard Smith ANK_TemplateName, 5380576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// The identifier can't be resolved. 5390576681bac125be07f77f66b02a3dba2c3a24557Richard Smith ANK_Unresolved, 5400576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// Annotation was successful. 5410576681bac125be07f77f66b02a3dba2c3a24557Richard Smith ANK_Success 5420576681bac125be07f77f66b02a3dba2c3a24557Richard Smith }; 5430576681bac125be07f77f66b02a3dba2c3a24557Richard Smith AnnotatedNameKind TryAnnotateName(bool IsAddressOfOperand, 5440576681bac125be07f77f66b02a3dba2c3a24557Richard Smith CorrectionCandidateCallback *CCC = 0); 5450576681bac125be07f77f66b02a3dba2c3a24557Richard Smith 5460576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// Push a tok::annot_cxxscope token onto the token stream. 5470576681bac125be07f77f66b02a3dba2c3a24557Richard Smith void AnnotateScopeToken(CXXScopeSpec &SS, bool IsNewAnnotation); 548eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 54982287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// TryAltiVecToken - Check for context-sensitive AltiVec identifier tokens, 55082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// replacing them with the non-context-sensitive keywords. This returns 55182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// true if the token was replaced. 55282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc, 553b3a4e432c90be98c6d918087750397e86d030368Chris Lattner const char *&PrevSpec, unsigned &DiagID, 554b3a4e432c90be98c6d918087750397e86d030368Chris Lattner bool &isInvalid) { 5554e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (!getLangOpts().AltiVec || 5561b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner (Tok.getIdentifierInfo() != Ident_vector && 5571b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner Tok.getIdentifierInfo() != Ident_pixel)) 5581b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return false; 559a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 5601b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid); 56182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson } 56282287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson 56382287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// TryAltiVecVectorToken - Check for context-sensitive AltiVec vector 56482287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// identifier token, replacing it with the non-context-sensitive __vector. 56582287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson /// This returns true if the token was replaced. 56682287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson bool TryAltiVecVectorToken() { 5674e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (!getLangOpts().AltiVec || 568b3a4e432c90be98c6d918087750397e86d030368Chris Lattner Tok.getIdentifierInfo() != Ident_vector) return false; 5691b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner return TryAltiVecVectorTokenOutOfLine(); 57082287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson } 571a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 5721b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool TryAltiVecVectorTokenOutOfLine(); 5731b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc, 5741b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner const char *&PrevSpec, unsigned &DiagID, 5751b49242de4e8bc718d7611c33a1d76ce35864020Chris Lattner bool &isInvalid); 57625a767651d14db87aa03dd5fe3e011d877dd4100Argyrios Kyrtzidis 57713bb701f2f876356400a34b0917a417c66b5d70dBenjamin Kramer /// \brief Get the TemplateIdAnnotation from the token. 57825a767651d14db87aa03dd5fe3e011d877dd4100Argyrios Kyrtzidis TemplateIdAnnotation *takeTemplateIdAnnotation(const Token &tok); 57925a767651d14db87aa03dd5fe3e011d877dd4100Argyrios Kyrtzidis 5805404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// TentativeParsingAction - An object that is used as a kind of "tentative 5815404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// parsing transaction". It gets instantiated to mark the token position and 5825404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// after the token consumption is done, Commit() or Revert() is called to 5835404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// either "commit the consumed tokens" or revert to the previously marked 5845404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// token position. Example: 5855404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// 586314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor /// TentativeParsingAction TPA(*this); 5875404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// ConsumeToken(); 5885404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// .... 5895404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// TPA.Revert(); 5905404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// 5915404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis class TentativeParsingAction { 5925404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis Parser &P; 5935404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis Token PrevTok; 5940576681bac125be07f77f66b02a3dba2c3a24557Richard Smith size_t PrevTentativelyDeclaredIdentifierCount; 595de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount; 5965404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isActive; 5975404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 5985404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis public: 5995404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis explicit TentativeParsingAction(Parser& p) : P(p) { 6005404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis PrevTok = P.Tok; 6010576681bac125be07f77f66b02a3dba2c3a24557Richard Smith PrevTentativelyDeclaredIdentifierCount = 6020576681bac125be07f77f66b02a3dba2c3a24557Richard Smith P.TentativelyDeclaredIdentifiers.size(); 603de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor PrevParenCount = P.ParenCount; 604de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor PrevBracketCount = P.BracketCount; 605de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor PrevBraceCount = P.BraceCount; 6065404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.EnableBacktrackAtThisPos(); 6075404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = true; 6085404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 6095404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis void Commit() { 6105404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(isActive && "Parsing action was finished!"); 6110576681bac125be07f77f66b02a3dba2c3a24557Richard Smith P.TentativelyDeclaredIdentifiers.resize( 6120576681bac125be07f77f66b02a3dba2c3a24557Richard Smith PrevTentativelyDeclaredIdentifierCount); 6135404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.CommitBacktrackedTokens(); 6145404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = false; 6155404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 6165404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis void Revert() { 6175404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(isActive && "Parsing action was finished!"); 6185404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.PP.Backtrack(); 6195404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis P.Tok = PrevTok; 6200576681bac125be07f77f66b02a3dba2c3a24557Richard Smith P.TentativelyDeclaredIdentifiers.resize( 6210576681bac125be07f77f66b02a3dba2c3a24557Richard Smith PrevTentativelyDeclaredIdentifierCount); 622de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor P.ParenCount = PrevParenCount; 623de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor P.BracketCount = PrevBracketCount; 624de88246a7bc57bc4995ad4e6fde8f245d70b130eDouglas Gregor P.BraceCount = PrevBraceCount; 6255404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis isActive = false; 6265404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 6275404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis ~TentativeParsingAction() { 6285404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis assert(!isActive && "Forgot to call Commit or Revert!"); 6295404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 6305404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis }; 6311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6329735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian /// ObjCDeclContextSwitch - An object used to switch context from 6339735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian /// an objective-c decl context to its enclosing decl context and 6349735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian /// back. 6359735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian class ObjCDeclContextSwitch { 6369735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian Parser &P; 6379735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian Decl *DC; 63894f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose SaveAndRestore<bool> WithinObjCContainer; 6399735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian public: 64094f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose explicit ObjCDeclContextSwitch(Parser &p) 64194f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose : P(p), DC(p.getObjCDeclContext()), 64294f29f4bf5d6b49dd1b7fc16cfa1521adc0c71c0Jordan Rose WithinObjCContainer(P.ParsingInObjCContainer, DC != 0) { 6439735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian if (DC) 644458bacff986ed8d30e7ae191c823d4db6cfaf16bArgyrios Kyrtzidis P.Actions.ActOnObjCTemporaryExitContainerContext(cast<DeclContext>(DC)); 6459735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian } 6469735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian ~ObjCDeclContextSwitch() { 6479735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian if (DC) 648458bacff986ed8d30e7ae191c823d4db6cfaf16bArgyrios Kyrtzidis P.Actions.ActOnObjCReenterContainerContext(cast<DeclContext>(DC)); 6499735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian } 6509735c5e60027b26a809df19677ff16a4d13f1321Fariborz Jahanian }; 6511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ExpectAndConsume - The parser expects that 'ExpectedTok' is next in the 6535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// input. If so, it is consumed and false is returned. 6545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 6555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// If the input is malformed, this emits the specified diagnostic. Next, if 6565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SkipToTok is specified, it calls SkipUntil(SkipToTok). Finally, true is 6575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// returned. 6585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned Diag, 6595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *DiagMsg = "", 6605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer tok::TokenKind SkipToTok = tok::unknown); 6615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6629ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// \brief The parser expects a semicolon and, if present, will consume it. 6639ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// 6649ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// If the next token is not a semicolon, this emits the specified diagnostic, 6659ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// or, if there's just some closing-delimiter noise (e.g., ')' or ']') prior 6669ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor /// to the semicolon, consumes that extra token. 6679ba23b4ceacd77cd264501690a7a9e94184ef71bDouglas Gregor bool ExpectAndConsumeSemi(unsigned DiagID); 668a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 669eab9d6f9065b042d39fbaf9842c9d8cc968dd6d0Richard Smith /// \brief The kind of extra semi diagnostic to emit. 6704b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu enum ExtraSemiKind { 6714b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu OutsideFunction = 0, 6724b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu InsideStruct = 1, 6734b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu InstanceVariableList = 2, 674eab9d6f9065b042d39fbaf9842c9d8cc968dd6d0Richard Smith AfterMemberFunctionDefinition = 3 6754b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu }; 6764b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu 6774b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu /// \brief Consume any extra semi-colons until the end of the line. 678eab9d6f9065b042d39fbaf9842c9d8cc968dd6d0Richard Smith void ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST = TST_unspecified); 6794b0e6f1da341510c1ad83eaf4c836f3134d0156aRichard Trieu 6806944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 6815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 6825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Scope manipulation 6831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6848935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// ParseScope - Introduces a new scope for parsing. The kind of 6858935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// scope is determined by ScopeFlags. Objects of this type should 6868935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// be created on the stack to coincide with the position where the 6878935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// parser enters the new scope, and this object's constructor will 6888935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// create that new scope. Similarly, once the object is destroyed 6898935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor /// the parser will exit the scope. 6908935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor class ParseScope { 6918935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Parser *Self; 692f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko ParseScope(const ParseScope &) LLVM_DELETED_FUNCTION; 693f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko void operator=(const ParseScope &) LLVM_DELETED_FUNCTION; 6948935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 6958935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor public: 6968935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ParseScope - Construct a new object to manage a scope in the 6978935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // parser Self where the new Scope is created with the flags 6988935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ScopeFlags, but only when ManageScope is true (the default). If 6998935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // ManageScope is false, this object does nothing. 7001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ParseScope(Parser *Self, unsigned ScopeFlags, bool ManageScope = true) 7018935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor : Self(Self) { 7028935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor if (ManageScope) 7038935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self->EnterScope(ScopeFlags); 7048935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor else 7058935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor this->Self = 0; 7068935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 7078935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 7088935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // Exit - Exit the scope associated with this object now, rather 7098935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor // than waiting until the object is destroyed. 7108935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor void Exit() { 7118935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor if (Self) { 7128935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self->ExitScope(); 7138935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Self = 0; 7148935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 7158935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 7168935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 7178935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor ~ParseScope() { 7188935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor Exit(); 7198935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor } 7208935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor }; 7218935b8b49053122ddd3ab4cd59af0fe5eb9c23cfDouglas Gregor 7225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// EnterScope - Start a new scope. 7235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void EnterScope(unsigned ScopeFlags); 7241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ExitScope - Pop a scope off the scope stack. 7265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ExitScope(); 7275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 7286944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 7297a614d8380297fcd2bc23986241905d97222948cRichard Smith /// \brief RAII object used to modify the scope flags for the current scope. 7307a614d8380297fcd2bc23986241905d97222948cRichard Smith class ParseScopeFlags { 7317a614d8380297fcd2bc23986241905d97222948cRichard Smith Scope *CurScope; 7327a614d8380297fcd2bc23986241905d97222948cRichard Smith unsigned OldFlags; 733f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko ParseScopeFlags(const ParseScopeFlags &) LLVM_DELETED_FUNCTION; 734f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko void operator=(const ParseScopeFlags &) LLVM_DELETED_FUNCTION; 7357a614d8380297fcd2bc23986241905d97222948cRichard Smith 7367a614d8380297fcd2bc23986241905d97222948cRichard Smith public: 7377a614d8380297fcd2bc23986241905d97222948cRichard Smith ParseScopeFlags(Parser *Self, unsigned ScopeFlags, bool ManageFlags = true); 7387a614d8380297fcd2bc23986241905d97222948cRichard Smith ~ParseScopeFlags(); 7397a614d8380297fcd2bc23986241905d97222948cRichard Smith }; 7407a614d8380297fcd2bc23986241905d97222948cRichard Smith 7415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 7425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Diagnostic Emission and Error recovery. 74315faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 7446aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorpublic: 7453cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 7463cbfe2c4159e0a219ae660d50625c013aa4afbd0Chris Lattner DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID); 747d73ef135ba029db59c0b5649e6117845d9e39600Jordan Rose DiagnosticBuilder Diag(unsigned DiagID) { 748d73ef135ba029db59c0b5649e6117845d9e39600Jordan Rose return Diag(Tok, DiagID); 749d73ef135ba029db59c0b5649e6117845d9e39600Jordan Rose } 75015faa7fdfb496489dec9470aa5eb699b29ecdaccSebastian Redl 7516aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregorprivate: 7521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void SuggestParentheses(SourceLocation Loc, unsigned DK, 7534b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor SourceRange ParenRange); 754d64251fd56577dd5c78903454632361e094c6dc1Erik Verbruggen void CheckNestedObjCContexts(SourceLocation AtLoc); 7554b2d3f7bcc4df31157df443af1b80bcaa9b58bbaDouglas Gregor 7566944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 7575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SkipUntil - Read tokens until we get to the specified token, then consume 75882c7e6d8215567935d3d52741ccca9876a8ea461Steve Naroff /// it (unless DontConsume is true). Because we cannot guarantee that the 7595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// token will ever occur, this skips to the next token, or to some likely 7605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// good stopping point. If StopAtSemi is true, skipping will stop at a ';' 7615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// character. 7621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 7635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// If SkipUntil finds the specified token, it returns true, otherwise it 7641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returns false. 7655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true, 7663437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool DontConsume = false, bool StopAtCodeCompletion = false) { 767eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie return SkipUntil(llvm::makeArrayRef(T), StopAtSemi, DontConsume, 768eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie StopAtCodeCompletion); 7695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 7705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true, 7713437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool DontConsume = false, bool StopAtCodeCompletion = false) { 7725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer tok::TokenKind TokArray[] = {T1, T2}; 773eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); 7745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 775eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, 7763437f1f1294499d4ef306c1089fcb3e29ec2aa68Argyrios Kyrtzidis bool StopAtSemi = true, bool DontConsume = false, 777eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie bool StopAtCodeCompletion = false) { 778eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie tok::TokenKind TokArray[] = {T1, T2, T3}; 779eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); 780eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie } 781eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie bool SkipUntil(ArrayRef<tok::TokenKind> Toks, bool StopAtSemi = true, 782eb52f86a62db523e3c993686b3ed92c55d59d53cDavid Blaikie bool DontConsume = false, bool StopAtCodeCompletion = false); 7837ad8390f7992ab7f19b1460c5f0b9d96f165c4e9Douglas Gregor 784994d73f8473cb2cd3ce2f69c9575c95015be788aRichard Smith /// SkipMalformedDecl - Read tokens until we get to some likely good stopping 785994d73f8473cb2cd3ce2f69c9575c95015be788aRichard Smith /// point for skipping past a simple-declaration. 786994d73f8473cb2cd3ce2f69c9575c95015be788aRichard Smith void SkipMalformedDecl(); 787994d73f8473cb2cd3ce2f69c9575c95015be788aRichard Smith 7886944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 7895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 7904cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis // Lexing and parsing of C++ inline methods. 7914cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 792d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct ParsingClass; 793d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 794d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// [class.mem]p1: "... the class is regarded as complete within 795d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - function bodies 796d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - default arguments 797d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// - exception-specifications (TODO: C++0x) 7987a614d8380297fcd2bc23986241905d97222948cRichard Smith /// - and brace-or-equal-initializers for non-static data members 7997a614d8380297fcd2bc23986241905d97222948cRichard Smith /// (including such things in nested classes)." 800d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarations build the tree of those elements so they can 801d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// be parsed after parsing the top-level class. 802d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor class LateParsedDeclaration { 803d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor public: 804d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual ~LateParsedDeclaration(); 805d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 806d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 8077a614d8380297fcd2bc23986241905d97222948cRichard Smith virtual void ParseLexedMemberInitializers(); 808d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 809eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski virtual void ParseLexedAttributes(); 810d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor }; 811d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 812d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// Inner node of the LateParsedDeclaration tree that parses 813d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// all its members recursively. 814d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor class LateParsedClass : public LateParsedDeclaration { 815d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor public: 816d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor LateParsedClass(Parser *P, ParsingClass *C); 817d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual ~LateParsedClass(); 818d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 819d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 8207a614d8380297fcd2bc23986241905d97222948cRichard Smith virtual void ParseLexedMemberInitializers(); 821d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 822eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski virtual void ParseLexedAttributes(); 823d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 824d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor private: 825d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser *Self; 826d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor ParsingClass *Class; 827d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor }; 828d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 829a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// Contains the lexed tokens of an attribute with arguments that 830a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// may reference member variables and so need to be parsed at the 831a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// end of the class declaration after parsing all other member 832eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski /// member declarations. 833eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski /// FIXME: Perhaps we should change the name of LateParsedDeclaration to 834eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski /// LateParsedTokens. 835eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski struct LateParsedAttribute : public LateParsedDeclaration { 836eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski Parser *Self; 837eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski CachedTokens Toks; 838eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski IdentifierInfo &AttrName; 839eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski SourceLocation AttrNameLoc; 8402287c5e2352fc51cd74e8a9a7725cbf87e41c007DeLesley Hutchins SmallVector<Decl*, 2> Decls; 841eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 842a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie explicit LateParsedAttribute(Parser *P, IdentifierInfo &Name, 843eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski SourceLocation Loc) 8442287c5e2352fc51cd74e8a9a7725cbf87e41c007DeLesley Hutchins : Self(P), AttrName(Name), AttrNameLoc(Loc) {} 845eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 846eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski virtual void ParseLexedAttributes(); 847eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 8482287c5e2352fc51cd74e8a9a7725cbf87e41c007DeLesley Hutchins void addDecl(Decl *D) { Decls.push_back(D); } 849eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski }; 850eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 851161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins // A list of late-parsed attributes. Used by ParseGNUAttributes. 852161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins class LateParsedAttrList: public llvm::SmallVector<LateParsedAttribute*, 2> { 853161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins public: 854161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins LateParsedAttrList(bool PSoon = false) : ParseSoon(PSoon) { } 855161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins 856161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins bool parseSoon() { return ParseSoon; } 857eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 858161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins private: 859161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins bool ParseSoon; // Are we planning to parse these shortly after creation? 860161db02a747e0c8e717f542674c0581c03fc3c93DeLesley Hutchins }; 861eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski 862d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// Contains the lexed tokens of a member function definition 863d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// which needs to be parsed at the end of the class declaration 864d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// after parsing all other member declarations. 865d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct LexedMethod : public LateParsedDeclaration { 866d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser *Self; 867d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *D; 86872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens Toks; 869d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor 870d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// \brief Whether this member function had an associated template 871d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// scope. When true, D is a template declaration. 872d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// othewise, it is a member function declaration. 873d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor bool TemplateScope; 874d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor 875d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor explicit LexedMethod(Parser* P, Decl *MD) 876d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor : Self(P), D(MD), TemplateScope(false) {} 877d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 878d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDefs(); 8794cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis }; 8804cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 88172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// LateParsedDefaultArgument - Keeps track of a parameter that may 88272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// have a default argument that cannot be parsed yet because it 88372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// occurs within a member function declaration inside the class 88472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// (C++ [class.mem]p2). 88572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor struct LateParsedDefaultArgument { 886d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall explicit LateParsedDefaultArgument(Decl *P, 88772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens *Toks = 0) 88872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor : Param(P), Toks(Toks) { } 88972b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 89072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Param - The parameter declaration for this parameter. 891d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *Param; 89272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 89372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Toks - The sequence of tokens that comprises the default 89472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// argument expression, not including the '=' or the terminating 89572b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// ')' or ','. This will be NULL for parameters that have no 89672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// default argument. 89772b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor CachedTokens *Toks; 89872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 8991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 90072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// LateParsedMethodDeclaration - A method declaration inside a class that 90172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// contains at least one entity whose parsing needs to be delayed 90272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// until the class itself is completely-defined, such as a default 90372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// argument (C++ [class.mem]p2). 904d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor struct LateParsedMethodDeclaration : public LateParsedDeclaration { 905d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor explicit LateParsedMethodDeclaration(Parser *P, Decl *M) 90674e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor : Self(P), Method(M), TemplateScope(false), ExceptionSpecTokens(0) { } 907d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 908d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor virtual void ParseLexedMethodDeclarations(); 909d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor 910d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor Parser* Self; 91172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 91272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// Method - The method declaration. 913d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *Method; 91472b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 915d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// \brief Whether this member function had an associated template 916d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// scope. When true, D is a template declaration. 917d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor /// othewise, it is a member function declaration. 918d83d04041f64a2c89123d227fa8003b482391279Douglas Gregor bool TemplateScope; 9191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 92072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// DefaultArgs - Contains the parameters of the function and 92172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// their default arguments. At least one of the parameters will 92272b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// have a default argument, but all of the parameters of the 92372b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor /// method will be stored so that they can be reintroduced into 9241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// scope at the appropriate times. 925686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<LateParsedDefaultArgument, 8> DefaultArgs; 92674e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor 92774e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor /// \brief The set of tokens that make up an exception-specification that 92874e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor /// has not yet been parsed. 92974e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor CachedTokens *ExceptionSpecTokens; 93072b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 93172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 9327a614d8380297fcd2bc23986241905d97222948cRichard Smith /// LateParsedMemberInitializer - An initializer for a non-static class data 9337a614d8380297fcd2bc23986241905d97222948cRichard Smith /// member whose parsing must to be delayed until the class is completely 9347a614d8380297fcd2bc23986241905d97222948cRichard Smith /// defined (C++11 [class.mem]p2). 9357a614d8380297fcd2bc23986241905d97222948cRichard Smith struct LateParsedMemberInitializer : public LateParsedDeclaration { 9367a614d8380297fcd2bc23986241905d97222948cRichard Smith LateParsedMemberInitializer(Parser *P, Decl *FD) 9377a614d8380297fcd2bc23986241905d97222948cRichard Smith : Self(P), Field(FD) { } 9387a614d8380297fcd2bc23986241905d97222948cRichard Smith 9397a614d8380297fcd2bc23986241905d97222948cRichard Smith virtual void ParseLexedMemberInitializers(); 9407a614d8380297fcd2bc23986241905d97222948cRichard Smith 9417a614d8380297fcd2bc23986241905d97222948cRichard Smith Parser *Self; 9427a614d8380297fcd2bc23986241905d97222948cRichard Smith 9437a614d8380297fcd2bc23986241905d97222948cRichard Smith /// Field - The field declaration. 9447a614d8380297fcd2bc23986241905d97222948cRichard Smith Decl *Field; 9457a614d8380297fcd2bc23986241905d97222948cRichard Smith 9467a614d8380297fcd2bc23986241905d97222948cRichard Smith /// CachedTokens - The sequence of tokens that comprises the initializer, 9477a614d8380297fcd2bc23986241905d97222948cRichard Smith /// including any leading '='. 9487a614d8380297fcd2bc23986241905d97222948cRichard Smith CachedTokens Toks; 9497a614d8380297fcd2bc23986241905d97222948cRichard Smith }; 9507a614d8380297fcd2bc23986241905d97222948cRichard Smith 951d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarationsContainer - During parsing of a top (non-nested) 952d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// C++ class, its method declarations that contain parts that won't be 953fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// parsed until after the definition is completed (C++ [class.mem]p2), 954d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// the method declarations and possibly attached inline definitions 955a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// will be stored here with the tokens that will be parsed to create those 956a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// entities. 957a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer; 95872b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 9596569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Representation of a class that has been parsed, including 9606569d68745c8213709740337d2be52b031384f58Douglas Gregor /// any member function declarations or definitions that need to be 9616569d68745c8213709740337d2be52b031384f58Douglas Gregor /// parsed after the corresponding top-level class is complete. 9626569d68745c8213709740337d2be52b031384f58Douglas Gregor struct ParsingClass { 963e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall ParsingClass(Decl *TagOrTemplate, bool TopLevelClass, bool IsInterface) 9641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : TopLevelClass(TopLevelClass), TemplateScope(false), 965e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { } 9666569d68745c8213709740337d2be52b031384f58Douglas Gregor 9676569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Whether this is a "top-level" class, meaning that it is 9686569d68745c8213709740337d2be52b031384f58Douglas Gregor /// not nested within another class. 9696569d68745c8213709740337d2be52b031384f58Douglas Gregor bool TopLevelClass : 1; 9706569d68745c8213709740337d2be52b031384f58Douglas Gregor 9716569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Whether this class had an associated template 9726569d68745c8213709740337d2be52b031384f58Douglas Gregor /// scope. When true, TagOrTemplate is a template declaration; 9736569d68745c8213709740337d2be52b031384f58Douglas Gregor /// othewise, it is a tag declaration. 9746569d68745c8213709740337d2be52b031384f58Douglas Gregor bool TemplateScope : 1; 9756569d68745c8213709740337d2be52b031384f58Douglas Gregor 976e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall /// \brief Whether this class is an __interface. 977e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall bool IsInterface : 1; 978e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall 9796569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief The class or class template whose definition we are parsing. 980d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagOrTemplate; 98172b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor 982d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// LateParsedDeclarations - Method declarations, inline definitions and 983d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// nested classes that contain pieces whose parsing will be delayed until 984d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor /// the top-level class is fully defined. 985d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor LateParsedDeclarationsContainer LateParsedDeclarations; 98672b505b7904b3c9320a1312998800ba76e4f5841Douglas Gregor }; 9874cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 9886569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief The stack of classes that is currently being 9896569d68745c8213709740337d2be52b031384f58Douglas Gregor /// parsed. Nested and local classes will be pushed onto this stack 9906569d68745c8213709740337d2be52b031384f58Douglas Gregor /// when they are parsed, and removed afterward. 9916569d68745c8213709740337d2be52b031384f58Douglas Gregor std::stack<ParsingClass *> ClassStack; 9924cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 9936569d68745c8213709740337d2be52b031384f58Douglas Gregor ParsingClass &getCurrentClass() { 9946569d68745c8213709740337d2be52b031384f58Douglas Gregor assert(!ClassStack.empty() && "No lexed method stacks!"); 9956569d68745c8213709740337d2be52b031384f58Douglas Gregor return *ClassStack.top(); 9964cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis } 9974cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 9989257664568bf375b7790131a84d9a4fa30a5b7e3John McCall /// \brief RAII object used to manage the parsing of a class definition. 9996569d68745c8213709740337d2be52b031384f58Douglas Gregor class ParsingClassDefinition { 10006569d68745c8213709740337d2be52b031384f58Douglas Gregor Parser &P; 10016569d68745c8213709740337d2be52b031384f58Douglas Gregor bool Popped; 1002eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Sema::ParsingClassState State; 10036569d68745c8213709740337d2be52b031384f58Douglas Gregor 10046569d68745c8213709740337d2be52b031384f58Douglas Gregor public: 1005e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall ParsingClassDefinition(Parser &P, Decl *TagOrTemplate, bool TopLevelClass, 1006e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall bool IsInterface) 1007eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall : P(P), Popped(false), 1008e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) { 10096569d68745c8213709740337d2be52b031384f58Douglas Gregor } 10106569d68745c8213709740337d2be52b031384f58Douglas Gregor 10116569d68745c8213709740337d2be52b031384f58Douglas Gregor /// \brief Pop this class of the stack. 10121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void Pop() { 10136569d68745c8213709740337d2be52b031384f58Douglas Gregor assert(!Popped && "Nested class has already been popped"); 10146569d68745c8213709740337d2be52b031384f58Douglas Gregor Popped = true; 1015eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall P.PopParsingClass(State); 10166569d68745c8213709740337d2be52b031384f58Douglas Gregor } 10176569d68745c8213709740337d2be52b031384f58Douglas Gregor 10181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~ParsingClassDefinition() { 10196569d68745c8213709740337d2be52b031384f58Douglas Gregor if (!Popped) 1020eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall P.PopParsingClass(State); 10216569d68745c8213709740337d2be52b031384f58Douglas Gregor } 10226569d68745c8213709740337d2be52b031384f58Douglas Gregor }; 10236569d68745c8213709740337d2be52b031384f58Douglas Gregor 10244d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief Contains information about any template-specific 10254d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// information that has been parsed prior to parsing declaration 10264d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// specifiers. 10274d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor struct ParsedTemplateInfo { 10281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ParsedTemplateInfo() 10294d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor : Kind(NonTemplate), TemplateParams(0), TemplateLoc() { } 10304d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 10314d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ParsedTemplateInfo(TemplateParameterLists *TemplateParams, 1032c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool isSpecialization, 1033c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool lastParameterListWasEmpty = false) 10344d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor : Kind(isSpecialization? ExplicitSpecialization : Template), 1035a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie TemplateParams(TemplateParams), 1036c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor LastParameterListWasEmpty(lastParameterListWasEmpty) { } 10374d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 103845f965581935791a018df829a14dff53c1dd8f47Douglas Gregor explicit ParsedTemplateInfo(SourceLocation ExternLoc, 103945f965581935791a018df829a14dff53c1dd8f47Douglas Gregor SourceLocation TemplateLoc) 10401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Kind(ExplicitInstantiation), TemplateParams(0), 1041c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor ExternLoc(ExternLoc), TemplateLoc(TemplateLoc), 1042c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor LastParameterListWasEmpty(false){ } 10434d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 10444d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The kind of template we are parsing. 10454d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor enum { 10464d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are not parsing a template at all. 10474d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor NonTemplate = 0, 10484d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing a template declaration. 10494d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor Template, 10504d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing an explicit specialization. 10514d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ExplicitSpecialization, 10524d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief We are parsing an explicit instantiation. 10534d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor ExplicitInstantiation 10544d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor } Kind; 10554d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 10564d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The template parameter lists, for template declarations 10574d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// and explicit specializations. 10584d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor TemplateParameterLists *TemplateParams; 10594d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 106045f965581935791a018df829a14dff53c1dd8f47Douglas Gregor /// \brief The location of the 'extern' keyword, if any, for an explicit 106145f965581935791a018df829a14dff53c1dd8f47Douglas Gregor /// instantiation 106245f965581935791a018df829a14dff53c1dd8f47Douglas Gregor SourceLocation ExternLoc; 10631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10644d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// \brief The location of the 'template' keyword, for an explicit 10654d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor /// instantiation. 10664d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor SourceLocation TemplateLoc; 1067a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1068c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor /// \brief Whether the last template parameter list was empty. 1069c78c06d81f9838aea4198e4965cc1b26bb0bf838Douglas Gregor bool LastParameterListWasEmpty; 107078b810559d89e996e00684335407443936ce34a1John McCall 1071aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar SourceRange getSourceRange() const LLVM_READONLY; 10724d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor }; 10731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10748387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// \brief Contains a late templated function. 10758387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// Will be parsed at the end of the translation unit. 10768387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet struct LateParsedTemplatedFunction { 1077e1fca502e7f1349e9b4520a4ca9a02413bcf2b14Francois Pichet explicit LateParsedTemplatedFunction(Decl *MD) 10788387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet : D(MD) {} 10798387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 10808387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet CachedTokens Toks; 1081a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 10828387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet /// \brief The template function declaration to be late parsed. 1083a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie Decl *D; 10848387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet }; 10858387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 10868387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet void LexTemplateFunctionForLateParsing(CachedTokens &Toks); 10878387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet void ParseLateTemplatedFuncDef(LateParsedTemplatedFunction &LMT); 10888387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet typedef llvm::DenseMap<const FunctionDecl*, LateParsedTemplatedFunction*> 10898387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet LateParsedTemplateMapT; 10908387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet LateParsedTemplateMapT LateParsedTemplateMap; 10918387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 10924a47e8d35dc1778ef7e428d9edd7676be67e725fFrancois Pichet static void LateTemplateParserCallback(void *P, const FunctionDecl *FD); 10934a47e8d35dc1778ef7e428d9edd7676be67e725fFrancois Pichet void LateTemplateParser(const FunctionDecl *FD); 10948387e2a41eef6fa17fb140a18c29b6eee9dd2b8aFrancois Pichet 1095eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall Sema::ParsingClassState 1096e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall PushParsingClass(Decl *TagOrTemplate, bool TopLevelClass, bool IsInterface); 109737b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void DeallocateParsedClasses(ParsingClass *Class); 1098eee1d5434ebfa955ffc3c493aecd68bb7b3f4838John McCall void PopParsingClass(Sema::ParsingClassState); 109937b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor 11005f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen Decl *ParseCXXInlineMethodDef(AccessSpecifier AS, AttributeList *AccessAttrs, 11015f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen ParsingDeclarator &D, 11024867347e82648d3baf09524b98b09c297a5a198fNico Weber const ParsedTemplateInfo &TemplateInfo, 1103a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie const VirtSpecifiers& VS, 110445fa560c72441069d9e4eb1e66efd87349caa552Douglas Gregor FunctionDefinitionKind DefinitionKind, 110545fa560c72441069d9e4eb1e66efd87349caa552Douglas Gregor ExprResult& Init); 11067a614d8380297fcd2bc23986241905d97222948cRichard Smith void ParseCXXNonStaticMemberInitializer(Decl *VarD); 1107eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski void ParseLexedAttributes(ParsingClass &Class); 1108c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D, 1109c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins bool EnterScope, bool OnDefinition); 1110c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins void ParseLexedAttribute(LateParsedAttribute &LA, 1111c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins bool EnterScope, bool OnDefinition); 111237b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void ParseLexedMethodDeclarations(ParsingClass &Class); 1113d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM); 111437b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor void ParseLexedMethodDefs(ParsingClass &Class); 1115d54eb4410330383f48d3cc22b2ad8d23f120836bDouglas Gregor void ParseLexedMethodDef(LexedMethod &LM); 11167a614d8380297fcd2bc23986241905d97222948cRichard Smith void ParseLexedMemberInitializers(ParsingClass &Class); 11177a614d8380297fcd2bc23986241905d97222948cRichard Smith void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI); 11186c89eafc90f5c51a0bf185a993961170aee530c2Fariborz Jahanian void ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod); 1119a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl bool ConsumeAndStoreFunctionPrologue(CachedTokens &Toks); 112014b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool ConsumeAndStoreUntil(tok::TokenKind T1, 112114b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis CachedTokens &Toks, 112214b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool StopAtSemi = true, 112314b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool ConsumeFinalToken = true) { 112414b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis return ConsumeAndStoreUntil(T1, T1, Toks, StopAtSemi, ConsumeFinalToken); 112514b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis } 11261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, 112737b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor CachedTokens &Toks, 112814b91628961ab50cc6e724bbcd408fdee100662dArgyrios Kyrtzidis bool StopAtSemi = true, 112937b372b76a3fafe77186d7e6079e5642e2017478Douglas Gregor bool ConsumeFinalToken = true); 11304d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 11314cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 11325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.9: External Definitions. 11337f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall struct ParsedAttributesWithRange : ParsedAttributes { 11340b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange(AttributeFactory &factory) 11350b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall : ParsedAttributes(factory) {} 11360b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall 11377f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceRange Range; 11387f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall }; 11397f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 11407f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs, 114109a63c97b95eb4dc6fd6b2323929e8cf12af03ffDouglas Gregor ParsingDeclSpec *DS = 0); 1142e4246a633b13197634225971b25df0cbdcec0c5dSean Hunt bool isDeclarationAfterDeclarator(); 1143004659a56916f2f81ede507c12516c146d6c0df3Chris Lattner bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator); 11442edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt DeclGroupPtrTy ParseDeclarationOrFunctionDefinition( 11452edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt ParsedAttributesWithRange &attrs, 11462edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt ParsingDeclSpec *DS = 0, 11473acd9aaa4ddd14afecb4f1c02ca6f585a6d51849Fariborz Jahanian AccessSpecifier AS = AS_none); 11482edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, 11492edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt ParsingDeclSpec &DS, 11502edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt AccessSpecifier AS); 1151a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1152d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseFunctionDefinition(ParsingDeclarator &D, 1153c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 1154c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins LateParsedAttrList *LateParsedAttrs = 0); 11555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseKNRParamDeclarations(Declarator &D); 1156ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // EndLoc, if non-NULL, is filled with the location of the last token of 1157ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // the simple-asm. 115860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseSimpleAsm(SourceLocation *EndLoc = 0); 115960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseAsmStringLiteral(); 11605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11613536b443bc50d58a79f14fca9b6842541a434854Steve Naroff // Objective-C External Declarations 1162bd9482d859a74bf2c45ef8b8aedec61c0e1c8374Douglas Gregor DeclGroupPtrTy ParseObjCAtDirectives(); 1163bd9482d859a74bf2c45ef8b8aedec61c0e1c8374Douglas Gregor DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc); 1164d64251fd56577dd5c78903454632361e094c6dc1Erik Verbruggen Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, 11657f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &prefixAttrs); 1166d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseObjCClassInstanceVariables(Decl *interfaceDecl, 116783c481ade785a919ba21a33f9a8b1b21c1212fb3Fariborz Jahanian tok::ObjCKeywordKind visibility, 116860fcceeedbfc8b4a99cb942e2bc5aeb9e2f92a1fSteve Naroff SourceLocation atLoc); 1169686775deca8b8685eb90801495880e3abdd844c2Chris Lattner bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &P, 1170686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<SourceLocation> &PLocs, 11711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool WarnOnDeclarations, 117271b0addffbdeed29cc062c962e236c34107755d6Argyrios Kyrtzidis SourceLocation &LAngleLoc, 1173e13b9595dc1e2f4288bec34f3412359f648e84a5Chris Lattner SourceLocation &EndProtoLoc); 117446f936e055d763437accd1e5a1bc49e7e5dbc0a3Douglas Gregor bool ParseObjCProtocolQualifiers(DeclSpec &DS); 11752f64cfe19e8bf6b6ba1660e38da8c421440457feFariborz Jahanian void ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, 11762f64cfe19e8bf6b6ba1660e38da8c421440457feFariborz Jahanian Decl *CDecl); 1177bd9482d859a74bf2c45ef8b8aedec61c0e1c8374Douglas Gregor DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc, 1178bd9482d859a74bf2c45ef8b8aedec61c0e1c8374Douglas Gregor ParsedAttributes &prefixAttrs); 11791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1180849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis struct ObjCImplParsingDataRAII { 1181849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis Parser &P; 1182849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis Decl *Dcl; 11836c89eafc90f5c51a0bf185a993961170aee530c2Fariborz Jahanian bool HasCFunction; 1184849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer; 1185849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis LateParsedObjCMethodContainer LateParsedObjCMethods; 1186849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis 1187849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis ObjCImplParsingDataRAII(Parser &parser, Decl *D) 11886c89eafc90f5c51a0bf185a993961170aee530c2Fariborz Jahanian : P(parser), Dcl(D), HasCFunction(false) { 1189849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis P.CurParsedObjCImpl = this; 1190849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis Finished = false; 1191849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis } 1192849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis ~ObjCImplParsingDataRAII(); 1193849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis 1194849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis void finish(SourceRange AtEnd); 1195849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis bool isFinished() const { return Finished; } 1196849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis 1197849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis private: 1198849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis bool Finished; 1199849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis }; 1200849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis ObjCImplParsingDataRAII *CurParsedObjCImpl; 12016c89eafc90f5c51a0bf185a993961170aee530c2Fariborz Jahanian void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl); 12020416fb9f379b49abb3eb0c1cb2ca75107e5a71d1Steve Naroff 1203849639d8b548519cc5a00c0c9253f0c0d525060dArgyrios Kyrtzidis DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc); 1204140ab234c23f392d5422691c5de1ee3c15026defFariborz Jahanian DeclGroupPtrTy ParseObjCAtEndDeclaration(SourceRange atEnd); 1205d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc); 1206d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCPropertySynthesize(SourceLocation atLoc); 1207d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCPropertyDynamic(SourceLocation atLoc); 12081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12092fc5c2428ecb450a3256c8316b93b8655cb76a0fChris Lattner IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation); 121034870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner // Definitions for Objective-c context sensitive keywords recognition. 121134870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner enum ObjCTypeQual { 121234870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref, 121334870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner objc_NumQuals 121434870da70fa42b0391b79627ebd0cfc6eb22213bChris Lattner }; 1215a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek IdentifierInfo *ObjCTypeQuals[objc_NumQuals]; 12161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1217335a2d4122e41343fe11a775889b8bec5b14be60Fariborz Jahanian bool isTokIdentifier_in() const; 1218d0f97d1716a138a8d9e0df8e5af77334663723d8Fariborz Jahanian 1219cdda47faab5c2c61c239491a1a091e071ed3e38eJohn McCall ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, Declarator::TheContext Ctx, 1220cdda47faab5c2c61c239491a1a091e071ed3e38eJohn McCall ParsedAttributes *ParamAttrs); 1221294494e1cce92043562b4680c613df7fd028c02eSteve Naroff void ParseObjCMethodRequirement(); 1222a28948f34817476d02412fa204cae038e228c827Fariborz Jahanian Decl *ParseObjCMethodPrototype( 122390ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword, 122490ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian bool MethodDefinition = true); 1225d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCMethodDecl(SourceLocation mLoc, tok::TokenKind mType, 122690ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword, 122790ba78c64d0c24cfbc1bf88728db9775d44d7f9fFariborz Jahanian bool MethodDefinition=true); 1228a28948f34817476d02412fa204cae038e228c827Fariborz Jahanian void ParseObjCPropertyAttribute(ObjCDeclSpec &DS); 12291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1230d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseObjCMethodDefinition(); 12311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12326944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 12335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 12345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.5: Expressions. 1235a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1236cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain /// TypeCastState - State whether an expression is or may be a type cast. 1237cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain enum TypeCastState { 1238cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain NotTypeCast = 0, 1239cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain MaybeTypeCast, 1240cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain IsTypeCast 1241cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain }; 1242cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain 1243cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast); 1244e43fe993a079795ac3d2ba7c9ec5e2a0c8069918Kaelyn Uhrain ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast); 12452f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl // Expr that doesn't include commas. 1246cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain ExprResult ParseAssignmentExpression(TypeCastState isTypeCast = NotTypeCast); 12472f7ece7c77eb17e24e8f0f4e1b7fb01aa5111f96Sebastian Redl 12486944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 124960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseExpressionWithLeadingAt(SourceLocation AtLoc); 12505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 125160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseExpressionWithLeadingExtension(SourceLocation ExtLoc); 1252adf077f46ba5cddcd801a647a5e9a3eb97060df4Eli Friedman 125360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseRHSOfBinaryExpression(ExprResult LHS, 1254312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor prec::Level MinPrec); 125560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCastExpression(bool isUnaryExpression, 1256312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool isAddressOfOperand, 1257312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool &NotCastExpr, 1258cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain TypeCastState isTypeCast); 125960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCastExpression(bool isUnaryExpression, 1260312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor bool isAddressOfOperand = false, 1261cd78e612d6fa8e214e6a6bb0e739a0c3e419df91Kaelyn Uhrain TypeCastState isTypeCast = NotTypeCast); 12629c72c6088d591ace8503b842d39448c2040f3033John McCall 12634b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith /// Returns true if the next token cannot start an expression. 12644b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith bool isNotExpressionStart(); 12654b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith 12669c72c6088d591ace8503b842d39448c2040f3033John McCall /// Returns true if the next token would start a postfix-expression 12679c72c6088d591ace8503b842d39448c2040f3033John McCall /// suffix. 12689c72c6088d591ace8503b842d39448c2040f3033John McCall bool isPostfixExpressionSuffixStart() { 12699c72c6088d591ace8503b842d39448c2040f3033John McCall tok::TokenKind K = Tok.getKind(); 12709c72c6088d591ace8503b842d39448c2040f3033John McCall return (K == tok::l_square || K == tok::l_paren || 12719c72c6088d591ace8503b842d39448c2040f3033John McCall K == tok::period || K == tok::arrow || 12729c72c6088d591ace8503b842d39448c2040f3033John McCall K == tok::plusplus || K == tok::minusminus); 12739c72c6088d591ace8503b842d39448c2040f3033John McCall } 12749c72c6088d591ace8503b842d39448c2040f3033John McCall 127560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParsePostfixExpressionSuffix(ExprResult LHS); 1276f4e3cfbe8abd124be6341ef5d714819b4fbd9082Peter Collingbourne ExprResult ParseUnaryExprOrTypeTraitExpression(); 127760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBuiltinPrimaryExpression(); 12781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1279f4e3cfbe8abd124be6341ef5d714819b4fbd9082Peter Collingbourne ExprResult ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, 12805ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis bool &isCastExpr, 1281b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType &CastTy, 12825ab0640efb436a721d408c853b771932d1a6ffceArgyrios Kyrtzidis SourceRange &CastRange); 12830cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis 1284686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<Expr*, 20> ExprListTy; 1285686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<SourceLocation, 20> CommaLocsTy; 12860cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis 12870cd5b429fad6833dda23f0aced14a10907ac5539Argyrios Kyrtzidis /// ParseExpressionList - Used for C/C++ (argument-)expression-list. 1288686775deca8b8685eb90801495880e3abdd844c2Chris Lattner bool ParseExpressionList(SmallVectorImpl<Expr*> &Exprs, 1289686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<SourceLocation> &CommaLocs, 1290f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall void (Sema::*Completer)(Scope *S, 1291f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Expr *Data, 129213a140caba448a66ffcc5ff0d32a87d6e4f4ad3fAhmed Charles llvm::ArrayRef<Expr *> Args) = 0, 1293ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall Expr *Data = 0); 1294d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl 12955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParenParseOption - Control what ParseParenExpression will parse. 12965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum ParenParseOption { 12975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SimpleExpr, // Only parse '(' expression ')' 12985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CompoundStmt, // Also allow '(' compound-statement ')' 12995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' 13005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CastExpr // Also allow '(' type-name ')' <anything> 13015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 130260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseParenExpression(ParenParseOption &ExprType, 13030350ca519405051e8d45d12ee7d09569a6a9c4c9Argyrios Kyrtzidis bool stopIfCastExpr, 13040a85183be6930571f3af8e5a976d24c3f95e5b25Argyrios Kyrtzidis bool isTypeCast, 1305b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType &CastTy, 1306d8c4e15138e69a51754cc259c8a592cc47950c8eSebastian Redl SourceLocation &RParenLoc); 13071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 130860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, 13094a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor ParsedType &CastTy, 13104a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor BalancedDelimiterTracker &Tracker); 131160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCompoundLiteralExpression(ParsedType Ty, 1312d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis SourceLocation LParenLoc, 1313d974a7b72eb84cdc735b189bcea56fd37e13ebf6Argyrios Kyrtzidis SourceLocation RParenLoc); 13141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 131599831e4677a7e2e051af636221694d60ba31fcdbRichard Smith ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral = false); 1316eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1317f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne ExprResult ParseGenericSelectionExpression(); 1318ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 1319ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCBoolLiteral(); 1320f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne 1321eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis //===--------------------------------------------------------------------===// 1322eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis // C++ Expressions 132360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXIdExpression(bool isAddressOfOperand = false); 13244bdd91c09fd59e0c154d759288beff300e31e1d0Argyrios Kyrtzidis 132519a2702042b7e3ee838cca458b35f607111a3897Richard Smith bool areTokensAdjacent(const Token &A, const Token &B); 132619a2702042b7e3ee838cca458b35f607111a3897Richard Smith 1327950be71c745409e373ae8a834490f9026c8ac222Richard Trieu void CheckForTemplateAndDigraph(Token &Next, ParsedType ObjectTypePtr, 1328950be71c745409e373ae8a834490f9026c8ac222Richard Trieu bool EnteringContext, IdentifierInfo &II, 1329950be71c745409e373ae8a834490f9026c8ac222Richard Trieu CXXScopeSpec &SS); 1330950be71c745409e373ae8a834490f9026c8ac222Richard Trieu 13311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, 1332b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 1333b10cd04880672103660e5844e51ee91af7361a20Douglas Gregor bool EnteringContext, 13344147d307086cf024a40a080e2bf379e9725f6f41Francois Pichet bool *MayBePseudoDestructor = 0, 13354147d307086cf024a40a080e2bf379e9725f6f41Francois Pichet bool IsTypename = false); 13361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1337919b9557b4f0155dfaaea309493ff2a702fca676Richard Trieu void CheckForLParenAfterColonColon(); 1338919b9557b4f0155dfaaea309493ff2a702fca676Richard Trieu 13395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1340ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor // C++0x 5.1.2: Lambda expressions 1341ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor 1342ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor // [...] () -> type {...} 1343ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor ExprResult ParseLambdaExpression(); 1344ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor ExprResult TryParseLambdaExpression(); 1345ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor llvm::Optional<unsigned> ParseLambdaIntroducer(LambdaIntroducer &Intro); 1346ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor bool TryParseLambdaIntroducer(LambdaIntroducer &Intro); 1347ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor ExprResult ParseLambdaExpressionAfterIntroducer( 1348ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor LambdaIntroducer &Intro); 1349ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor 1350ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor //===--------------------------------------------------------------------===// 13515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C++ 5.2p1: C++ Casts 135260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXCasts(); 13535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 13545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1355c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // C++ 5.2p1: C++ Type Identification 135660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXTypeid(); 1357c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 1358c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl //===--------------------------------------------------------------------===// 135901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // C++ : Microsoft __uuidof Expression 136001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet ExprResult ParseCXXUuidof(); 136101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 136201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet //===--------------------------------------------------------------------===// 1363d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor // C++ 5.2.4: C++ Pseudo-Destructor Expressions 136460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc, 1365d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor tok::TokenKind OpKind, 1366d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor CXXScopeSpec &SS, 1367b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType); 1368d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor 1369d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor //===--------------------------------------------------------------------===// 13704cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis // C++ 9.3.2: C++ 'this' pointer 137160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXThis(); 13724cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis 13734cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 137450dd289f45738ed22b7583d52ed2525b927042ffChris Lattner // C++ 15: C++ Throw Expression 137560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseThrowExpression(); 13767acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl 137774e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor ExceptionSpecificationType tryParseExceptionSpecification( 13787acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl SourceRange &SpecificationRange, 1379686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<ParsedType> &DynamicExceptions, 1380686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<SourceRange> &DynamicExceptionRanges, 1381a058fd4f0a944174295f77169b438510dad389f8Richard Smith ExprResult &NoexceptExpr); 13827acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl 1383ab197baec16bacade82325fb274cf6b992ac5d8aSebastian Redl // EndLoc is filled with the location of the last token of the specification. 13847acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl ExceptionSpecificationType ParseDynamicExceptionSpecification( 13857acafd032e145dbdbbed9274ca57ec2c86b912bcSebastian Redl SourceRange &SpecificationRange, 1386686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<ParsedType> &Exceptions, 1387686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<SourceRange> &Ranges); 138850dd289f45738ed22b7583d52ed2525b927042ffChris Lattner 138950dd289f45738ed22b7583d52ed2525b927042ffChris Lattner //===--------------------------------------------------------------------===// 1390dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // C++0x 8: Function declaration trailing-return-type 1391ae7902c4293d9de8b9591759513f0d075f45022aDouglas Gregor TypeResult ParseTrailingReturnType(SourceRange &Range); 1392dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 1393dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor //===--------------------------------------------------------------------===// 13945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C++ 2.13.5: C++ Boolean Literals 139560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXBoolLiteral(); 13965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 13975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1398987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // C++ 5.2.3: Explicit type conversion (functional notation) 139960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS); 1400987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 1401987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers. 1402987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// This should only be called when the current token is known to be part of 1403987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis /// simple-type-specifier. 1404987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis void ParseCXXSimpleTypeSpecifier(DeclSpec &DS); 1405987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 14062f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor bool ParseCXXTypeSpecifierSeq(DeclSpec &DS); 14072f1bc5285ccd40f411af5f5993f013e27e74ab78Douglas Gregor 1408987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis //===--------------------------------------------------------------------===// 14094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // C++ 5.3.4 and 5.3.5: C++ new and delete 1410686775deca8b8685eb90801495880e3abdd844c2Chris Lattner bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs, 1411ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall Declarator &D); 14124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl void ParseDirectNewDeclarator(Declarator &D); 141360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start); 141460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseCXXDeleteExpression(bool UseGlobal, 141559232d35f5820e334b6c8b007ae8006f4390055dChris Lattner SourceLocation Start); 14164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 14174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl //===--------------------------------------------------------------------===// 141899e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor // C++ if/switch/while condition expression. 141960d7b3a319d84d688752be3870615ac0f111fb16John McCall bool ParseCXXCondition(ExprResult &ExprResult, Decl *&DeclResult, 1420586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor SourceLocation Loc, bool ConvertToBoolean); 142171b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis 142271b914b999d9c4b6df11068fc5a3291ac4770492Argyrios Kyrtzidis //===--------------------------------------------------------------------===// 142312e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor // C++ types 142412e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor 142512e083c805c0f86be4f8e54b06e75b2c3dc1da64Douglas Gregor //===--------------------------------------------------------------------===// 14265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.7.8: Initialization. 14271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14280eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// ParseInitializer 14290eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// initializer: [C99 6.7.8] 14300eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// assignment-expression 14310eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner /// '{' ... 143260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseInitializer() { 14330eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner if (Tok.isNot(tok::l_brace)) 143420df9b7ab9388b2a488c5b1293cd196b1e073b4eSebastian Redl return ParseAssignmentExpression(); 14350eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner return ParseBraceInitializer(); 14360eec2b58678f71af6b5fcf4c439290c0d640546bChris Lattner } 1437b3f323d6c41cb614a249dbc4af7493762786521aDouglas Gregor bool MayBeDesignationStart(); 143860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBraceInitializer(); 143960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseInitializerWithPotentialDesignator(); 14401d922960e083906a586609ac6978678147250177Sebastian Redl 14415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 1442296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff // clang Expressions 14431d922960e083906a586609ac6978678147250177Sebastian Redl 144460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseBlockLiteralExpression(); // ^{...} 1445296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff 1446296e8d5fdcf9946f51e866adc8d281379e51efe9Steve Naroff //===--------------------------------------------------------------------===// 14475508518a2702b00be3b15a26d772bde968972f54Anders Carlsson // Objective-C Expressions 144860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCAtExpression(SourceLocation AtLocation); 144960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCStringLiteral(SourceLocation AtLoc); 1450ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc); 1451ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc); 1452ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc, bool ArgValue); 1453ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc); 1454ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc); 1455eb382ec1507cf2c8c12d7443d0b67c076223aec6Patrick Beard ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc); 145660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc); 145760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc); 145860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc); 14591b730e847ded503f2e615154035c083c4f94a067Douglas Gregor bool isSimpleObjCMessageExpression(); 146060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCMessageExpression(); 146160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc, 14625cb94a78202ccb1007df0be86884297761f4a53aNico Weber SourceLocation SuperLoc, 14635cb94a78202ccb1007df0be86884297761f4a53aNico Weber ParsedType ReceiverType, 14645cb94a78202ccb1007df0be86884297761f4a53aNico Weber ExprArg ReceiverExpr); 146560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseAssignmentExprWithObjCMessageExprStart( 14662725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor SourceLocation LBracloc, SourceLocation SuperLoc, 1467b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ReceiverType, ExprArg ReceiverExpr); 14686aa14d832704ae176c92d4e0f22dfb3f3d83a70aDouglas Gregor bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr); 1469ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 14705508518a2702b00be3b15a26d772bde968972f54Anders Carlsson //===--------------------------------------------------------------------===// 14715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.8: Statements and Blocks. 147261364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl 14734e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer /// A SmallVector of statements, with stack size 32 (as that is the only one 14744e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer /// used.) 14754e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer typedef SmallVector<Stmt*, 32> StmtVector; 14764e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer /// A SmallVector of expressions, with stack size 12 (the maximum used.) 14774e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer typedef SmallVector<Expr*, 12> ExprVector; 14784e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer /// A SmallVector of types. 14794e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer typedef SmallVector<ParsedType, 12> TypeVector; 14804e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer 1481534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseStatement(SourceLocation *TrailingElseLoc = 0) { 14824e28d9e2ba9ce237549b45cfd4136ec6536d1325Benjamin Kramer StmtVector Stmts; 14835cb94a78202ccb1007df0be86884297761f4a53aNico Weber return ParseStatementOrDeclaration(Stmts, true, TrailingElseLoc); 148461364dddc33383e62cfe3b841dbc0f471280d95bSebastian Redl } 1485534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseStatementOrDeclaration(StmtVector &Stmts, 14865cb94a78202ccb1007df0be86884297761f4a53aNico Weber bool OnlyStatement, 1487534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith SourceLocation *TrailingElseLoc = 0); 1488534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseStatementOrDeclarationAfterAttributes( 1489534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtVector &Stmts, 1490534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith bool OnlyStatement, 1491534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith SourceLocation *TrailingElseLoc, 1492534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith ParsedAttributesWithRange &Attrs); 1493534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseExprStatement(); 1494534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs); 1495534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseCaseStatement(bool MissingCase = false, 1496bb9b80c308d7d3f758886243c7145404a50c66cfRichard Trieu ExprResult Expr = ExprResult()); 1497534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseDefaultStatement(); 1498534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseCompoundStatement(bool isStmtExpr = false); 1499534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseCompoundStatement(bool isStmtExpr, 1500bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor unsigned ScopeFlags); 150160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); 150260d7b3a319d84d688752be3870615ac0f111fb16John McCall bool ParseParenExprOrCondition(ExprResult &ExprResult, 1503d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *&DeclResult, 1504586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor SourceLocation Loc, 150544aa1f397855f130e88e62ffc1029f7f83bb5d2eArgyrios Kyrtzidis bool ConvertToBoolean); 1506534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); 1507534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); 1508534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); 1509534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseDoStatement(); 1510534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseForStatement(SourceLocation *TrailingElseLoc); 1511534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseGotoStatement(); 1512534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseContinueStatement(); 1513534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseBreakStatement(); 1514534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseReturnStatement(); 151560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseAsmStatement(bool &msAsm); 15163fedbe1f71c18fba01d39109d606f421a0103a2aEli Friedman StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc); 1517a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 15183896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief Describes the behavior that should be taken for an __if_exists 15193896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// block. 15203896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor enum IfExistsBehavior { 15213896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief Parse the block; this code is always used. 15223896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor IEB_Parse, 15233896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief Skip the block entirely; this code is never used. 15243896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor IEB_Skip, 15253896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief Parse the block as a dependent block, which may be used in 15263896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// some template instantiations but not others. 15273896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor IEB_Dependent 15283896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor }; 1529a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1530a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// \brief Describes the condition of a Microsoft __if_exists or 15313896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// __if_not_exists block. 15323896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor struct IfExistsCondition { 15333896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief The location of the initial keyword. 15343896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor SourceLocation KeywordLoc; 1535a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie /// \brief Whether this is an __if_exists block (rather than an 15363896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// __if_not_exists block). 15373896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor bool IsIfExists; 1538a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 15393896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief Nested-name-specifier preceding the name. 15403896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor CXXScopeSpec SS; 1541a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 15423896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief The name we're looking for. 15433896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor UnqualifiedId Name; 15443896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor 15453896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// \brief The behavior of this __if_exists or __if_not_exists block 15463896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor /// should. 15473896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor IfExistsBehavior Behavior; 1548534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith }; 1549a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 15503896fc5d4daaf003e451e797e37de57dd8cf9cd5Douglas Gregor bool ParseMicrosoftIfExistsCondition(IfExistsCondition& Result); 15511e862693c63067ae467b0b3884c44f753cd6e821Francois Pichet void ParseMicrosoftIfExistsStatement(StmtVector &Stmts); 1552563a645de82231a55e221fe655b7188bf8369662Francois Pichet void ParseMicrosoftIfExistsExternalDeclaration(); 1553563a645de82231a55e221fe655b7188bf8369662Francois Pichet void ParseMicrosoftIfExistsClassDeclaration(DeclSpec::TST TagType, 1554563a645de82231a55e221fe655b7188bf8369662Francois Pichet AccessSpecifier& CurAS); 15559d24a8be93b28488dbfb9bbe8aa6fe35b21a5b0cFrancois Pichet bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs, 15569d24a8be93b28488dbfb9bbe8aa6fe35b21a5b0cFrancois Pichet bool &InitExprsOk); 1557f81e5a9e3f3ff80c56e4afb4fe6311a8735f36e8Richard Trieu bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names, 1558f81e5a9e3f3ff80c56e4afb4fe6311a8735f36e8Richard Trieu SmallVectorImpl<Expr *> &Constraints, 1559f81e5a9e3f3ff80c56e4afb4fe6311a8735f36e8Richard Trieu SmallVectorImpl<Expr *> &Exprs); 1560a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 1561a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl //===--------------------------------------------------------------------===// 1562a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl // C++ 6: Statements and Blocks 1563a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 1564534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseCXXTryBlock(); 156560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc); 156660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseCXXCatchBlock(); 1567a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 1568a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl //===--------------------------------------------------------------------===// 156928bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley // MS: SEH Statements and Blocks 157028bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley 1571534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith StmtResult ParseSEHTryBlock(); 157228bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley StmtResult ParseSEHTryBlockCommon(SourceLocation Loc); 157328bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley StmtResult ParseSEHExceptBlock(SourceLocation Loc); 157428bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley StmtResult ParseSEHFinallyBlock(SourceLocation Loc); 157528bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley 157628bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley //===--------------------------------------------------------------------===// 1577a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl // Objective-C Statements 1578a0fd8652f3302d0f39ed9849b521ee5b76597b0aSebastian Redl 157960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCAtStatement(SourceLocation atLoc); 158060d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCTryStmt(SourceLocation atLoc); 158160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCThrowStmt(SourceLocation atLoc); 158260d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc); 1583f85e193739c953358c865005855253af4f68a497John McCall StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc); 1584b235fc2cf37621c7fc6511bb2b8788c95f9fb9fcAnders Carlsson 15855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 15865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer //===--------------------------------------------------------------------===// 15875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // C99 6.7: Declarations. 158867d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall 158967d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// A context for parsing declaration specifiers. TODO: flesh this 159067d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// out, there are other significant restrictions on specifiers than 159167d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall /// would be best implemented in the parser. 159267d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall enum DeclSpecContext { 159367d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall DSC_normal, // normal context 15940efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DSC_class, // class context, enables 'friend' 1595a971d2410fabb093954c4119d2287ac24208ea8dRichard Smith DSC_type_specifier, // C++ type-specifier-seq or C specifier-qualifier-list 15967796eb5643244f3134834253ce5ea89107ac21c1Richard Smith DSC_trailing, // C++11 trailing-type-specifier in a trailing return type 15970efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DSC_top_level // top-level/namespace declaration context 159867d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall }; 15991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1600ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// Information on a C++0x for-range-initializer found while parsing a 1601ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// declaration which turns out to be a for-range-declaration. 1602ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith struct ForRangeInit { 1603ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith SourceLocation ColonLoc; 1604ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ExprResult RangeExpr; 1605ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 1606ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool ParsedForRangeDecl() { return !ColonLoc.isInvalid(); } 1607ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith }; 1608ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 1609c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian DeclGroupPtrTy ParseDeclaration(StmtVector &Stmts, 1610c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian unsigned Context, SourceLocation &DeclEnd, 16117f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributesWithRange &attrs); 1612c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian DeclGroupPtrTy ParseSimpleDeclaration(StmtVector &Stmts, 1613c5be7b0fc804d8e6f87298ec03c94d8cccd74f29Fariborz Jahanian unsigned Context, 1614bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt SourceLocation &DeclEnd, 16152edf0a2520313cde900799b1eb9bd11c9c776afeSean Hunt ParsedAttributesWithRange &attrs, 1616ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool RequireSemi, 1617ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ForRangeInit *FRI = 0); 16180706df40064d4d7559b4304af79d519033414b84Richard Smith bool MightBeDeclarator(unsigned Context); 161954abf7d4fa3123b8324c09d2a4dfb789fd818403John McCall DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context, 1620d8ac05753dc4506224d445ff98399c01da3136e5John McCall bool AllowFunctionDefinitions, 1621ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith SourceLocation *DeclEnd = 0, 1622ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ForRangeInit *FRI = 0); 1623d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseDeclarationAfterDeclarator(Declarator &D, 1624e542c862bdf9a9bcb4f468be8fa6561372430611Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo()); 1625c24a2335677f3d1bd2cab1019ac445d650f52123DeLesley Hutchins bool ParseAsmAttributesAfterDeclarator(Declarator &D); 1626ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith Decl *ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D, 1627ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo()); 1628c9977d09a2de7f7d2245973413d4caf86c736640Douglas Gregor Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope); 1629c9977d09a2de7f7d2245973413d4caf86c736640Douglas Gregor Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope); 1630d3a413d3b8eb39bcee5944bc545d9997c1abe492Sebastian Redl 16310fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// \brief When in code-completion, skip parsing of the function/method body 16320fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// unless the body contains the code-completion point. 16330fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// 16340fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis /// \returns true if the function body was skipped. 16356a91d385618ea4d28236c496f540a26877c95525Erik Verbruggen bool trySkippingFunctionBody(); 16360fe5397b26695926a835fa99eceb7fc879b307afArgyrios Kyrtzidis 1637f4382f50b7ab9f445c3f5b3ddaa59e6da25ea3bbChris Lattner bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, 16384d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo, 163969730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith AccessSpecifier AS, DeclSpecContext DSC); 16400efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor DeclSpecContext getDeclSpecContextFromDeclaratorContext(unsigned Context); 16411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void ParseDeclarationSpecifiers(DeclSpec &DS, 16424d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 164367d1a67f3db2f1aa69083c5c94164d6e0ee05b32John McCall AccessSpecifier AS = AS_none, 16442287c5e2352fc51cd74e8a9a7725cbf87e41c007DeLesley Hutchins DeclSpecContext DSC = DSC_normal, 16452287c5e2352fc51cd74e8a9a7725cbf87e41c007DeLesley Hutchins LateParsedAttrList *LateAttrs = 0); 16464d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor 164769730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith void ParseSpecifierQualifierList(DeclSpec &DS, AccessSpecifier AS = AS_none, 164869730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith DeclSpecContext DSC = DSC_normal); 16491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1650cdda47faab5c2c61c239491a1a091e071ed3e38eJohn McCall void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, 1651cdda47faab5c2c61c239491a1a091e071ed3e38eJohn McCall Declarator::TheContext Context); 16525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16534c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS, 165469730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith const ParsedTemplateInfo &TemplateInfo, 165569730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith AccessSpecifier AS, DeclSpecContext DSC); 1656d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl); 16575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType, 1658d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagDecl); 1659bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall 1660bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall struct FieldCallback { 1661dcdff46dd8e6d749283fe6c43adfcfe780c1d562Eli Friedman virtual void invoke(ParsingFieldDeclarator &Field) = 0; 16626c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall virtual ~FieldCallback() {} 16636c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall 16646c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall private: 16656c94a6d77f456f23ecd4c2061e6413786b5e6571John McCall virtual void _anchor(); 1666bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall }; 1667d0014540005f2a5ab837365db6bd40f479406758John McCall struct ObjCPropertyCallback; 1668bdd563ec391b0a83fc6d04b8a8ea3022aa702f74John McCall 1669f66a0dda541cd859a928193efba6dc5d7ba8fe54Eli Friedman void ParseStructDeclaration(ParsingDeclSpec &DS, FieldCallback &Callback); 16701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16719497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false); 1672eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis bool isTypeSpecifierQualifier(); 16735f8aa696619e32bf307232841fedb704ba733b4dSteve Naroff bool isTypeQualifier() const; 1674a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 1675b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// isKnownToBeTypeSpecifier - Return true if we know that the specified token 1676b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// is definitely a type-specifier. Return false if it isn't part of a type 1677b3a4e432c90be98c6d918087750397e86d030368Chris Lattner /// specifier or if we're not sure. 1678b3a4e432c90be98c6d918087750397e86d030368Chris Lattner bool isKnownToBeTypeSpecifier(const Token &Tok) const; 16795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16804b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith /// \brief Return true if we know that we are definitely looking at a 16814b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith /// decl-specifier, and isn't part of an expression such as a function-style 16824b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith /// cast. Return false if it's no a decl-specifier, or we're not sure. 16834b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith bool isKnownToBeDeclarationSpecifier() { 16844b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith if (getLangOpts().CPlusPlus) 16854b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith return isCXXDeclarationSpecifier() == TPResult::True(); 16864b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith return isDeclarationSpecifier(true); 16874b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith } 16884b0824229b96d024a96f3c7dd75ab70652c05c5bRichard Smith 16895404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isDeclarationStatement - Disambiguates between a declaration or an 16905404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// expression statement, when parsing function bodies. 16915404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns true for declaration, false for expression. 16925404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isDeclarationStatement() { 16934e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (getLangOpts().CPlusPlus) 16945404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis return isCXXDeclarationStatement(); 16959497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor return isDeclarationSpecifier(true); 16965404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis } 16975404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 16989490ab433deef70105d817616928d700f87642d9Eli Friedman /// isForInitDeclaration - Disambiguates between a declaration or an 16999490ab433deef70105d817616928d700f87642d9Eli Friedman /// expression in the context of the C 'clause-1' or the C++ 1700bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis // 'for-init-statement' part of a 'for' statement. 1701bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis /// Returns true for declaration, false for expression. 17029490ab433deef70105d817616928d700f87642d9Eli Friedman bool isForInitDeclaration() { 17034e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (getLangOpts().CPlusPlus) 17049490ab433deef70105d817616928d700f87642d9Eli Friedman return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/true); 17059497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor return isDeclarationSpecifier(true); 1706bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis } 1707bbc70c019f7b7f9a256ee29dab5287ecc82c6553Argyrios Kyrtzidis 17089497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor /// \brief Determine whether we are currently at the start of an Objective-C 17099497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor /// class message that appears to be missing the open bracket '['. 17109497a73ad0d54859edbf48beb93ebb19a7ae50c9Douglas Gregor bool isStartOfObjCClassMessageMissingOpenBracket(); 1711a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 17120efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// \brief Starting with a scope specifier, identifier, or 17130efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// template-id that refers to the current class, determine whether 17140efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor /// this is a constructor declarator. 17150efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor bool isConstructorDeclarator(); 17160efc2c1716be4f1c5f1343cad3b047e74861f030Douglas Gregor 17178b642592a35167a3780074e78674e0bece87c40cDouglas Gregor /// \brief Specifies the context in which type-id/expression 17188b642592a35167a3780074e78674e0bece87c40cDouglas Gregor /// disambiguation will occur. 17198b642592a35167a3780074e78674e0bece87c40cDouglas Gregor enum TentativeCXXTypeIdContext { 17208b642592a35167a3780074e78674e0bece87c40cDouglas Gregor TypeIdInParens, 17218b642592a35167a3780074e78674e0bece87c40cDouglas Gregor TypeIdAsTemplateArgument 17228b642592a35167a3780074e78674e0bece87c40cDouglas Gregor }; 17238b642592a35167a3780074e78674e0bece87c40cDouglas Gregor 17248b642592a35167a3780074e78674e0bece87c40cDouglas Gregor 172578c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// isTypeIdInParens - Assumes that a '(' was parsed and now we want to know 172678c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// whether the parens contain an expression or a type-id. 172778c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis /// Returns true for a type-id and false for an expression. 1728f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isTypeIdInParens(bool &isAmbiguous) { 17294e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (getLangOpts().CPlusPlus) 1730f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isCXXTypeId(TypeIdInParens, isAmbiguous); 1731f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis isAmbiguous = false; 173278c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis return isTypeSpecifierQualifier(); 173378c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis } 1734f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isTypeIdInParens() { 1735f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isAmbiguous; 1736f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isTypeIdInParens(isAmbiguous); 1737f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis } 173878c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis 17395404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXDeclarationStatement - C++-specialized function that disambiguates 17405404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// between a declaration or an expression statement, when parsing function 17415404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// bodies. Returns true for declaration, false for expression. 17425404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis bool isCXXDeclarationStatement(); 17435404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 17445404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXSimpleDeclaration - C++-specialized function that disambiguates 17455404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// between a simple-declaration or an expression-statement. 17465404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 17475404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 17485404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns false if the statement is disambiguated as expression. 17499490ab433deef70105d817616928d700f87642d9Eli Friedman bool isCXXSimpleDeclaration(bool AllowForRangeDecl); 17505404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 17515404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// isCXXFunctionDeclarator - Disambiguates between a function declarator or 17525404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// a constructor-style initializer, when parsing declaration statements. 17535404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Returns true for function declarator and false for constructor-style 1754b9c6261d02f688d0a9a36b736ad5956fbc737854Richard Smith /// initializer. Sets 'IsAmbiguous' to true to indicate that this declaration 1755b9c6261d02f688d0a9a36b736ad5956fbc737854Richard Smith /// might be a constructor-style initializer. 17565404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 17575404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 1758b9c6261d02f688d0a9a36b736ad5956fbc737854Richard Smith bool isCXXFunctionDeclarator(bool *IsAmbiguous = 0); 17595404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 1760a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// isCXXConditionDeclaration - Disambiguates between a declaration or an 1761a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// expression for a condition of a if/switch/while/for statement. 1762a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// If during the disambiguation process a parsing error is encountered, 1763a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis /// the function returns true to let the declaration parsing code handle it. 1764a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis bool isCXXConditionDeclaration(); 1765a8a4598b6f2a07339ab8a1248295a07d771a2b2aArgyrios Kyrtzidis 1766f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous); 1767f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isCXXTypeId(TentativeCXXTypeIdContext Context) { 1768f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis bool isAmbiguous; 1769f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis return isCXXTypeId(Context, isAmbiguous); 1770f58f45e6d76792df8c643ce1c6d364dce5db4826Argyrios Kyrtzidis } 177178c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis 1772b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// TPResult - Used as the result value for functions whose purpose is to 1773b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// disambiguate C++ constructs by "tentatively parsing" them. 1774b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// This is a class instead of a simple enum because the implicit enum-to-bool 1775b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// conversions may cause subtle bugs. 1776b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis class TPResult { 1777b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis enum Result { 1778b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_true, 1779b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_false, 1780b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_ambiguous, 1781b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPR_error 1782b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis }; 1783b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis Result Res; 1784b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult(Result result) : Res(result) {} 1785b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis public: 1786b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult True() { return TPR_true; } 1787b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult False() { return TPR_false; } 1788b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult Ambiguous() { return TPR_ambiguous; } 1789b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis static TPResult Error() { return TPR_error; } 1790b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis 1791b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis bool operator==(const TPResult &RHS) const { return Res == RHS.Res; } 1792b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis bool operator!=(const TPResult &RHS) const { return Res != RHS.Res; } 1793b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis }; 1794b47e38683f288cd4a73098091d629df417377a6bArgyrios Kyrtzidis 1795a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// \brief Based only on the given token kind, determine whether we know that 1796a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// we're at the start of an expression or a type-specifier-seq (which may 1797a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// be an expression, in C++). 1798a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// 1799a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// This routine does not attempt to resolve any of the trick cases, e.g., 1800a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// those involving lookup of identifiers. 1801a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// 1802a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// \returns \c TPR_true if this token starts an expression, \c TPR_false if 1803a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// this token starts a type-specifier-seq, or \c TPR_ambiguous if it cannot 1804a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor /// tell. 1805a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor TPResult isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind); 1806a61b3e7443056f8d05b24ca4cbea90fe66235d6bDouglas Gregor 1807b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// isCXXDeclarationSpecifier - Returns TPResult::True() if it is a 1808b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// declaration specifier, TPResult::False() if it is not, 1809b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// TPResult::Ambiguous() if it could be either a decl-specifier or a 1810b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis /// function-style cast, and TPResult::Error() if a parsing error was 1811d81e961f905e3ea57f6808e5a5686a8324270984Richard Smith /// encountered. If it could be a braced C++11 function-style cast, returns 1812d81e961f905e3ea57f6808e5a5686a8324270984Richard Smith /// BracedCastResult. 18135404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis /// Doesn't consume tokens. 1814d81e961f905e3ea57f6808e5a5686a8324270984Richard Smith TPResult 181525582fc0aeac053cdc115ee95cbed53f28bf592eRichard Smith isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False(), 181625582fc0aeac053cdc115ee95cbed53f28bf592eRichard Smith bool *HasMissingTypename = 0); 1817a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 18180576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// \brief Determine whether an identifier has been tentatively declared as a 18190576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// non-type. Such tentative declarations should not be found to name a type 18200576681bac125be07f77f66b02a3dba2c3a24557Richard Smith /// during a tentative parse, but also should not be annotated as a non-type. 18210576681bac125be07f77f66b02a3dba2c3a24557Richard Smith bool isTentativelyDeclared(IdentifierInfo *II); 18220576681bac125be07f77f66b02a3dba2c3a24557Richard Smith 18235404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis // "Tentative parsing" functions, used for disambiguation. If a parsing error 1824b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // is encountered they will return TPResult::Error(). 1825b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // Returning TPResult::True()/False() indicates that the ambiguity was 1826b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // resolved and tentative parsing may stop. TPResult::Ambiguous() indicates 1827b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis // that more tentative parsing is necessary for disambiguation. 18285404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis // They all consume tokens, so backtracking should be used after calling them. 18295404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 183025582fc0aeac053cdc115ee95cbed53f28bf592eRichard Smith TPResult TryParseDeclarationSpecifier(bool *HasMissingTypename = 0); 18319490ab433deef70105d817616928d700f87642d9Eli Friedman TPResult TryParseSimpleDeclaration(bool AllowForRangeDecl); 1832b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseTypeofSpecifier(); 18339bd1d8d174a9d15ae343246c8322299248b9e92aDouglas Gregor TPResult TryParseProtocolQualifiers(); 1834b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseInitDeclaratorList(); 183578c8d80f19cb0bccd4f3d590e71a230e727cfab5Argyrios Kyrtzidis TPResult TryParseDeclarator(bool mayBeAbstract, bool mayHaveIdentifier=true); 183625582fc0aeac053cdc115ee95cbed53f28bf592eRichard Smith TPResult TryParseParameterDeclarationClause(bool *InvalidAsDeclaration = 0); 1837b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseFunctionDeclarator(); 1838b9f341916e484ff6ba2c2d28c8b2dd5fa12b0015Argyrios Kyrtzidis TPResult TryParseBracketDeclarator(); 18395404a156be26de1c63ca9916187f970848bb4dbbArgyrios Kyrtzidis 18406944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 1841683a81f4373cf1fa9d41a751dca6f7c36125b058Douglas Gregor TypeResult ParseTypeName(SourceRange *Range = 0, 1842683a81f4373cf1fa9d41a751dca6f7c36125b058Douglas Gregor Declarator::TheContext Context 1843f85e193739c953358c865005855253af4f68a497John McCall = Declarator::TypeNameContext, 1844c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith AccessSpecifier AS = AS_none, 1845c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith Decl **OwnedType = 0); 18466944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 18476944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 184803f1eb031b84e93415b792c4b45d8da71c88e92dDouglas Gregor void ParseBlockId(SourceLocation CaretLoc); 18497f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 18506ee326af4e77e6f05973486097884d7431f2108dRichard Smith // Check for the start of a C++11 attribute-specifier-seq in a context where 18516ee326af4e77e6f05973486097884d7431f2108dRichard Smith // an attribute is not allowed. 18526ee326af4e77e6f05973486097884d7431f2108dRichard Smith bool CheckProhibitedCXX11Attribute() { 18536ee326af4e77e6f05973486097884d7431f2108dRichard Smith assert(Tok.is(tok::l_square)); 18546ee326af4e77e6f05973486097884d7431f2108dRichard Smith if (!getLangOpts().CPlusPlus0x || NextToken().isNot(tok::l_square)) 18556ee326af4e77e6f05973486097884d7431f2108dRichard Smith return false; 18566ee326af4e77e6f05973486097884d7431f2108dRichard Smith return DiagnoseProhibitedCXX11Attribute(); 18576ee326af4e77e6f05973486097884d7431f2108dRichard Smith } 18586ee326af4e77e6f05973486097884d7431f2108dRichard Smith bool DiagnoseProhibitedCXX11Attribute(); 18596ee326af4e77e6f05973486097884d7431f2108dRichard Smith 18607f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ProhibitAttributes(ParsedAttributesWithRange &attrs) { 18617f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (!attrs.Range.isValid()) return; 18627f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall DiagnoseProhibitedAttributes(attrs); 1863534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith attrs.clear(); 18647f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 18657f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs); 18667f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 1867eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski void MaybeParseGNUAttributes(Declarator &D, 1868eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski LateParsedAttrList *LateAttrs = 0) { 18697f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (Tok.is(tok::kw___attribute)) { 18700b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributes attrs(AttrFactory); 18717f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation endLoc; 1872eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski ParseGNUAttributes(attrs, &endLoc, LateAttrs); 18730b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall D.takeAttributes(attrs, endLoc); 18747f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 18757f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 18767f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseGNUAttributes(ParsedAttributes &attrs, 1877eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski SourceLocation *endLoc = 0, 1878eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski LateParsedAttrList *LateAttrs = 0) { 18797f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall if (Tok.is(tok::kw___attribute)) 1880eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski ParseGNUAttributes(attrs, endLoc, LateAttrs); 18817f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 18827f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseGNUAttributes(ParsedAttributes &attrs, 1883eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski SourceLocation *endLoc = 0, 1884eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski LateParsedAttrList *LateAttrs = 0); 1885eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski void ParseGNUAttributeArgs(IdentifierInfo *AttrName, 1886eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski SourceLocation AttrNameLoc, 1887eff98fc3561f6b717f6348f04b3f4fe03e934466Caitlin Sadowski ParsedAttributes &Attrs, 18886880f492365cc4fa4c941aa83688635003ee7498Michael Han SourceLocation *EndLoc, 18896880f492365cc4fa4c941aa83688635003ee7498Michael Han IdentifierInfo *ScopeName, 18906880f492365cc4fa4c941aa83688635003ee7498Michael Han SourceLocation ScopeLoc, 18916880f492365cc4fa4c941aa83688635003ee7498Michael Han AttributeList::Syntax Syntax); 18927f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 18937f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(Declarator &D) { 18946ee326af4e77e6f05973486097884d7431f2108dRichard Smith if (getLangOpts().CPlusPlus0x && isCXX11AttributeSpecifier()) { 18950b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange attrs(AttrFactory); 18967f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation endLoc; 1897c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith ParseCXX11Attributes(attrs, &endLoc); 18980b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall D.takeAttributes(attrs, endLoc); 18997f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19007f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19017f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(ParsedAttributes &attrs, 19027f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 19036ee326af4e77e6f05973486097884d7431f2108dRichard Smith if (getLangOpts().CPlusPlus0x && isCXX11AttributeSpecifier()) { 19040b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall ParsedAttributesWithRange attrsWithRange(AttrFactory); 1905c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith ParseCXX11Attributes(attrsWithRange, endLoc); 19060b7e678a11ece4288dc01aebb5b17e5eef8f8d2dJohn McCall attrs.takeAllFrom(attrsWithRange); 19077f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19087f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19097f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseCXX0XAttributes(ParsedAttributesWithRange &attrs, 19106ee326af4e77e6f05973486097884d7431f2108dRichard Smith SourceLocation *endLoc = 0, 19116ee326af4e77e6f05973486097884d7431f2108dRichard Smith bool OuterMightBeMessageSend = false) { 19126ee326af4e77e6f05973486097884d7431f2108dRichard Smith if (getLangOpts().CPlusPlus0x && 19136ee326af4e77e6f05973486097884d7431f2108dRichard Smith isCXX11AttributeSpecifier(false, OuterMightBeMessageSend)) 1914c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith ParseCXX11Attributes(attrs, endLoc); 19157f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19163497fdfdb742f55d7b7ec8e22779fb08962b8441Peter Collingbourne 1917c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith void ParseCXX11AttributeSpecifier(ParsedAttributes &attrs, 19183497fdfdb742f55d7b7ec8e22779fb08962b8441Peter Collingbourne SourceLocation *EndLoc = 0); 1919c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith void ParseCXX11Attributes(ParsedAttributesWithRange &attrs, 19207f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *EndLoc = 0); 19216880f492365cc4fa4c941aa83688635003ee7498Michael Han 1922c56298d87a9df507805a548d7d515e8b511df2c0Richard Smith IdentifierInfo *TryParseCXX11AttributeIdentifier(SourceLocation &Loc); 19237f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 19247f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void MaybeParseMicrosoftAttributes(ParsedAttributes &attrs, 19257f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0) { 19264e4d08403ca5cfd4d558fa2936215d3a4e5a528dDavid Blaikie if (getLangOpts().MicrosoftExt && Tok.is(tok::l_square)) 19277f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParseMicrosoftAttributes(attrs, endLoc); 19287f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall } 19297f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseMicrosoftAttributes(ParsedAttributes &attrs, 19307f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation *endLoc = 0); 1931fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman void ParseMicrosoftDeclSpec(ParsedAttributes &Attrs); 1932fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman bool IsSimpleMicrosoftDeclSpec(IdentifierInfo *Ident); 1933fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman void ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident, 1934fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman SourceLocation Loc, 1935fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman ParsedAttributes &Attrs); 1936fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman void ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName, 1937fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman SourceLocation AttrNameLoc, 1938fc685ace387734599c475426b1a8efdb491054b8Aaron Ballman ParsedAttributes &Attrs); 19397f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs); 1940c052dbb2d8fe0e23e90d81236aab0f864f712b45John McCall void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs); 19417f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall void ParseBorlandTypeAttributes(ParsedAttributes &attrs); 1942f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne void ParseOpenCLAttributes(ParsedAttributes &attrs); 1943207f4d8543529221932af82836016a2ef066c917Peter Collingbourne void ParseOpenCLQualifiers(DeclSpec &DS); 19447f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 19450a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor VersionTuple ParseVersionTuple(SourceRange &Range); 19460a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor void ParseAvailabilityAttribute(IdentifierInfo &Availability, 19470a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor SourceLocation AvailabilityLoc, 19480a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor ParsedAttributes &attrs, 19490a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor SourceLocation *endLoc); 19500a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 1951b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski bool IsThreadSafetyAttribute(llvm::StringRef AttrName); 1952b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski void ParseThreadSafetyAttribute(IdentifierInfo &AttrName, 1953b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski SourceLocation AttrNameLoc, 1954b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski ParsedAttributes &Attrs, 1955b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski SourceLocation *EndLoc); 1956b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski 19570d5a069f66df09b3308ccfdce84a88170034c657Dmitri Gribenko void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName, 19580d5a069f66df09b3308ccfdce84a88170034c657Dmitri Gribenko SourceLocation AttrNameLoc, 19590d5a069f66df09b3308ccfdce84a88170034c657Dmitri Gribenko ParsedAttributes &Attrs, 19600d5a069f66df09b3308ccfdce84a88170034c657Dmitri Gribenko SourceLocation *EndLoc); 1961b51e0315d4ffd12670441ea2284ae1188485df14Caitlin Sadowski 1962d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff void ParseTypeofSpecifier(DeclSpec &DS); 196342d6d0c91ab089cb252ab2f91c16d4557f458a2cDavid Blaikie SourceLocation ParseDecltypeSpecifier(DeclSpec &DS); 1964534986f2b21e6050bf00163cd6423fd92155a6edRichard Smith void AnnotateExistingDecltypeSpecifier(const DeclSpec &DS, 196542d6d0c91ab089cb252ab2f91c16d4557f458a2cDavid Blaikie SourceLocation StartLoc, 196642d6d0c91ab089cb252ab2f91c16d4557f458a2cDavid Blaikie SourceLocation EndLoc); 1967db5d44b775c60166074acd184ca9f1981c10c2a7Sean Hunt void ParseUnderlyingTypeSpecifier(DeclSpec &DS); 1968b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman void ParseAtomicSpecifier(DeclSpec &DS); 1969b001de7458d17c17e6d8b8034c7cfcefd3b70c00Eli Friedman 19700b64ba926752110cff1344a46b36e29396cc4d25Peter Collingbourne ExprResult ParseAlignArgument(SourceLocation Start, 19710b64ba926752110cff1344a46b36e29396cc4d25Peter Collingbourne SourceLocation &EllipsisLoc); 197282d0b0aab9088e977c2a44c4a5a90479c63149fePeter Collingbourne void ParseAlignmentSpecifier(ParsedAttributes &Attrs, 197382d0b0aab9088e977c2a44c4a5a90479c63149fePeter Collingbourne SourceLocation *endLoc = 0); 1974eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 19751c94c16317c1a35c1549e022958188eea2567089Richard Smith VirtSpecifiers::Specifier isCXX0XVirtSpecifier(const Token &Tok) const; 19761c94c16317c1a35c1549e022958188eea2567089Richard Smith VirtSpecifiers::Specifier isCXX0XVirtSpecifier() const { 19771c94c16317c1a35c1549e022958188eea2567089Richard Smith return isCXX0XVirtSpecifier(Tok); 19781c94c16317c1a35c1549e022958188eea2567089Richard Smith } 1979e402e72273cde2a64fa6097c1fe93f500038675dJohn McCall void ParseOptionalCXX0XVirtSpecifierSeq(VirtSpecifiers &VS, bool IsInterface); 19801f3b6fdabbb10779a473d6315154d7325ce20aeaAnders Carlsson 19818a29ba0d66bce99014651f1e3351aef6c3361d3fAnders Carlsson bool isCXX0XFinalKeyword() const; 1982cc54d594d4f6509c0e3a8e349e481d9b5d899df6Anders Carlsson 1983eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to 1984eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// enter a new C++ declarator scope and exit it when the function is 1985eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis /// finished. 1986eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis class DeclaratorScopeObj { 1987eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis Parser &P; 1988751810234ffb45327f23c5f9fda0b944e480bd2bArgyrios Kyrtzidis CXXScopeSpec &SS; 1989f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis bool EnteredScope; 1990f7f3d0db754db0500b56d49ac19f795f13965912John McCall bool CreatedScope; 1991eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis public: 1992f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss) 1993f7f3d0db754db0500b56d49ac19f795f13965912John McCall : P(p), SS(ss), EnteredScope(false), CreatedScope(false) {} 1994eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 1995eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis void EnterDeclaratorScope() { 19962bcb3439b50c7f227a21d7118a2a76904ec60331Argyrios Kyrtzidis assert(!EnteredScope && "Already entered the scope!"); 1997f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis assert(SS.isSet() && "C++ scope was not set!"); 1998f7f3d0db754db0500b56d49ac19f795f13965912John McCall 1999f7f3d0db754db0500b56d49ac19f795f13965912John McCall CreatedScope = true; 2000f7f3d0db754db0500b56d49ac19f795f13965912John McCall P.EnterScope(0); // Not a decl scope. 2001f7f3d0db754db0500b56d49ac19f795f13965912John McCall 200223c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS)) 20033fdbed594f4cb238fe37cad2ec3fefa3b6f67125Douglas Gregor EnteredScope = true; 2004eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis } 2005eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis 2006eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis ~DeclaratorScopeObj() { 2007f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis if (EnteredScope) { 2008f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis assert(SS.isSet() && "C++ scope was cleared ?"); 200923c94dbb6631fecdb55ba401aa93722803d980c6Douglas Gregor P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS); 2010f37006bc8a9d398d40d6ce329f023ed1a92fe484Argyrios Kyrtzidis } 2011f7f3d0db754db0500b56d49ac19f795f13965912John McCall if (CreatedScope) 2012f7f3d0db754db0500b56d49ac19f795f13965912John McCall P.ExitScope(); 2013eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis } 2014eb83ecde1a822b1c38cd060a85a08c1ac9f82cf8Argyrios Kyrtzidis }; 20151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ParseDeclarator - Parse and verify a newly-initialized declarator. 20175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseDeclarator(Declarator &D); 20184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl /// A function that parses a variant of direct-declarator. 20194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef void (Parser::*DirectDeclParseFunction)(Declarator&); 20204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl void ParseDeclaratorInternal(Declarator &D, 20214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl DirectDeclParseFunction DirectDeclParser); 20227f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall 2023bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt void ParseTypeQualifierListOpt(DeclSpec &DS, bool GNUAttributesAllowed = true, 2024bbd37c62e34db3f5a95c899723484a76c71d7757Sean Hunt bool CXX0XAttributesAllowed = true); 20255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseDirectDeclarator(Declarator &D); 20265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseParenDeclarator(Declarator &D); 20274a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor void ParseFunctionDeclarator(Declarator &D, 20287f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &attrs, 20294a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor BalancedDelimiterTracker &Tracker, 2030b9c6261d02f688d0a9a36b736ad5956fbc737854Richard Smith bool IsAmbiguous, 20317399ee0aa6ffaeab0a8f83408b1c5127fb2bf5b8Chris Lattner bool RequiresArg = false); 20323fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor bool isFunctionDeclaratorIdentifierList(); 20333fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor void ParseFunctionDeclaratorIdentifierList( 20343fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor Declarator &D, 2035686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<DeclaratorChunk::ParamInfo, 16> &ParamInfo); 20363fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor void ParseParameterDeclarationClause( 20373fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor Declarator &D, 20383fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor ParsedAttributes &attrs, 2039686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<DeclaratorChunk::ParamInfo, 16> &ParamInfo, 20403fd1ba0fa133d1c6e641770d0bc56606587d3eefDouglas Gregor SourceLocation &EllipsisLoc); 20415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void ParseBracketDeclarator(Declarator &D); 20421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20438f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner //===--------------------------------------------------------------------===// 20448f08cb7d0b97786b17ef05e05caa55aad4d6bd39Chris Lattner // C++ 7: Declarations [dcl.dcl] 20451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20466ee326af4e77e6f05973486097884d7431f2108dRichard Smith /// The kind of attribute specifier we have found. 20476ee326af4e77e6f05973486097884d7431f2108dRichard Smith enum CXX11AttributeKind { 20486ee326af4e77e6f05973486097884d7431f2108dRichard Smith /// This is not an attribute specifier. 20496ee326af4e77e6f05973486097884d7431f2108dRichard Smith CAK_NotAttributeSpecifier, 20506ee326af4e77e6f05973486097884d7431f2108dRichard Smith /// This should be treated as an attribute-specifier. 20516ee326af4e77e6f05973486097884d7431f2108dRichard Smith CAK_AttributeSpecifier, 20526ee326af4e77e6f05973486097884d7431f2108dRichard Smith /// The next tokens are '[[', but this is not an attribute-specifier. This 20536ee326af4e77e6f05973486097884d7431f2108dRichard Smith /// is ill-formed by C++11 [dcl.attr.grammar]p6. 20546ee326af4e77e6f05973486097884d7431f2108dRichard Smith CAK_InvalidAttributeSpecifier 20556ee326af4e77e6f05973486097884d7431f2108dRichard Smith }; 20566ee326af4e77e6f05973486097884d7431f2108dRichard Smith CXX11AttributeKind 20576ee326af4e77e6f05973486097884d7431f2108dRichard Smith isCXX11AttributeSpecifier(bool Disambiguate = false, 20586ee326af4e77e6f05973486097884d7431f2108dRichard Smith bool OuterMightBeMessageSend = false); 2059a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 2060d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl Decl *ParseNamespace(unsigned Context, SourceLocation &DeclEnd, 2061d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation InlineLoc = SourceLocation()); 2062f858bd817e8d6eac58ae496fa96a2f508fbb286fRichard Trieu void ParseInnerNamespace(std::vector<SourceLocation>& IdentLoc, 2063f858bd817e8d6eac58ae496fa96a2f508fbb286fRichard Trieu std::vector<IdentifierInfo*>& Ident, 2064f858bd817e8d6eac58ae496fa96a2f508fbb286fRichard Trieu std::vector<SourceLocation>& NamespaceLoc, 2065f858bd817e8d6eac58ae496fa96a2f508fbb286fRichard Trieu unsigned int index, SourceLocation& InlineLoc, 20664a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor ParsedAttributes& attrs, 20674a8dfb511e8f84b2e38b7a86d8ddf05ac1e1a41bDouglas Gregor BalancedDelimiterTracker &Tracker); 2068d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseLinkage(ParsingDeclSpec &DS, unsigned Context); 2069d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseUsingDirectiveOrDeclaration(unsigned Context, 207078b810559d89e996e00684335407443936ce34a1John McCall const ParsedTemplateInfo &TemplateInfo, 2071d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd, 2072c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith ParsedAttributesWithRange &attrs, 2073c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith Decl **OwnedType = 0); 207478b810559d89e996e00684335407443936ce34a1John McCall Decl *ParseUsingDirective(unsigned Context, 207578b810559d89e996e00684335407443936ce34a1John McCall SourceLocation UsingLoc, 20767f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall SourceLocation &DeclEnd, 20777f040a9d817cd1c72b565e92abff473510bf9e1dJohn McCall ParsedAttributes &attrs); 207878b810559d89e996e00684335407443936ce34a1John McCall Decl *ParseUsingDeclaration(unsigned Context, 207978b810559d89e996e00684335407443936ce34a1John McCall const ParsedTemplateInfo &TemplateInfo, 208078b810559d89e996e00684335407443936ce34a1John McCall SourceLocation UsingLoc, 2081d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd, 2082c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith AccessSpecifier AS = AS_none, 2083c89edf5aaa08683f4afcf61a7a1d183c08b76498Richard Smith Decl **OwnedType = 0); 2084d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd); 2085d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc, 2086d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation AliasLoc, IdentifierInfo *Alias, 2087d078e641450bbc5a20df8d3b54f87b27e398acb3Sebastian Redl SourceLocation &DeclEnd); 20881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2089e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor //===--------------------------------------------------------------------===// 2090e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor // C++ 9: classes [class] and C structs/unions. 2091139be7007eba3bd491ca50297888be507753a95dRichard Smith bool isValidAfterTypeSpecifier(bool CouldBeBitfield); 20924c97d762d8c5a84f6554e5bfb31d28c90df64158Chris Lattner void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc, 209369730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, 209469730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith AccessSpecifier AS, bool EnteringContext, 209569730c115c2d0fec2f20609d905d920a5a41b29bRichard Smith DeclSpecContext DSC); 20964cc18a4d5222e04bd568b1e3e4d86127dbbcdf3fArgyrios Kyrtzidis void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType, 2097d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *TagDecl); 2098552e29985a710f4ced62b39d70557501bd31ca9bDouglas Gregor ExprResult ParseCXXMemberInitializer(Decl *D, bool IsFunction, 20997a614d8380297fcd2bc23986241905d97222948cRichard Smith SourceLocation &EqualLoc); 21005f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen void ParseCXXClassMemberDeclaration(AccessSpecifier AS, AttributeList *Attr, 2101c9068d7dd94d439cec66c421115d15303e481025John McCall const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), 2102c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject *DiagsFromTParams = 0); 2103d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseConstructorInitializer(Decl *ConstructorDecl); 2104d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall MemInitResult ParseMemInitializer(Decl *ConstructorDecl); 210574e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo, 210674e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor Decl *ThisDecl); 2107e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor 2108e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor //===--------------------------------------------------------------------===// 2109e37ac4ff1620ed2d7026f52baccbfa022d79ced1Douglas Gregor // C++ 10: Derived classes [class.derived] 2110a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc, 211122216eb4fb0936d2488fc03abd285d135c36ff01David Blaikie SourceLocation &EndLocation); 2112d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall void ParseBaseClause(Decl *ClassDecl); 2113d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall BaseResult ParseBaseSpecifier(Decl *ClassDecl); 21141b7f89846f10681ce3cbe89ef5d60691d55bd918Douglas Gregor AccessSpecifier getAccessSpecifierIfPresent() const; 21151cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor 2116a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, 2117e4b92761b43ced611c417ae478568610f1ad7b1eAbramo Bagnara SourceLocation TemplateKWLoc, 21183f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor IdentifierInfo *Name, 21193f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor SourceLocation NameLoc, 21203f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor bool EnteringContext, 2121b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 2122d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor UnqualifiedId &Id, 2123e4b92761b43ced611c417ae478568610f1ad7b1eAbramo Bagnara bool AssumeTemplateId); 2124ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, 2125b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 2126ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor UnqualifiedId &Result); 21276944e20065955414a56a6aab9b7e271e3e826a88Axel Naumann 21286944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannpublic: 21293f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, 213002a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor bool AllowDestructorName, 213102a24ee67c0a91bdb0db8a651d5748595652e670Douglas Gregor bool AllowConstructorName, 2132b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectType, 2133e4b92761b43ced611c417ae478568610f1ad7b1eAbramo Bagnara SourceLocation& TemplateKWLoc, 21343f9a0566e6793151b99a65ab936220971cf96c1bDouglas Gregor UnqualifiedId &Result); 2135a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 21366944e20065955414a56a6aab9b7e271e3e826a88Axel Naumannprivate: 21371cd1b1e987f5e2f060d7972b13d83239b36d77d6Douglas Gregor //===--------------------------------------------------------------------===// 2138adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor // C++ 14: Templates [temp] 2139c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor 2140adcac8824a9cff13f1ef61a69e38c1041cba12eeDouglas Gregor // C++ 14.1: Template Parameters [temp.param] 2141d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseDeclarationStartingWithTemplate(unsigned Context, 21425f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen SourceLocation &DeclEnd, 21435f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AccessSpecifier AS = AS_none, 21445f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AttributeList *AccessAttrs = 0); 2145d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateDeclarationOrSpecialization(unsigned Context, 21465f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen SourceLocation &DeclEnd, 21475f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AccessSpecifier AS, 21485f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AttributeList *AccessAttrs); 2149d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseSingleDeclarationAfterTemplate( 21501426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor unsigned Context, 21514d9a16f36d3b768672d50e6d02000f982ae448d7Douglas Gregor const ParsedTemplateInfo &TemplateInfo, 2152c9068d7dd94d439cec66c421115d15303e481025John McCall ParsingDeclRAIIObject &DiagsFromParams, 21531426e534b4fca6a05b1120d634aae46be79ca17cDouglas Gregor SourceLocation &DeclEnd, 21545f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AccessSpecifier AS=AS_none, 21555f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen AttributeList *AccessAttrs = 0); 21561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool ParseTemplateParameters(unsigned Depth, 2157686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<Decl*> &TemplateParams, 21581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation &LAngleLoc, 2159c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor SourceLocation &RAngleLoc); 2160c4b4e7b8f6ca9b036824e048af49cd2a52b57cdfDouglas Gregor bool ParseTemplateParameterList(unsigned Depth, 2161686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<Decl*> &TemplateParams); 216298440b4ac17dc5f85ea3db683c1c1785449c17e1Douglas Gregor bool isStartOfTemplateTypeParameter(); 2163d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateParameter(unsigned Depth, unsigned Position); 2164d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTypeParameter(unsigned Depth, unsigned Position); 2165d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position); 2166d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall Decl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position); 2167d6fb7ef028d9aa0b3e8943b7bc049c524437b407Douglas Gregor // C++ 14.3: Template arguments [temp.arg] 2168686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList; 2169cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor 21707532dc66648cfe7432c9fe66dec5225f0ab301c6Douglas Gregor bool ParseTemplateIdAfterTemplateName(TemplateTy Template, 21711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation TemplateNameLoc, 2172059101f922de6eb765601459925f4c8914420b23Douglas Gregor const CXXScopeSpec &SS, 2173cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor bool ConsumeLastToken, 2174cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor SourceLocation &LAngleLoc, 2175cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor TemplateArgList &TemplateArgs, 2176cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor SourceLocation &RAngleLoc); 2177cc636688c4fd10b1732ce3e33b2b106024d545caDouglas Gregor 2178c8e27cc402043ec86c1698c09e4ee9e415b16207Chris Lattner bool AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, 2179059101f922de6eb765601459925f4c8914420b23Douglas Gregor CXXScopeSpec &SS, 2180e4b92761b43ced611c417ae478568610f1ad7b1eAbramo Bagnara SourceLocation TemplateKWLoc, 2181ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor UnqualifiedId &TemplateName, 218239a8de10c18365bde7062d8959b7ed525449c561Douglas Gregor bool AllowTypeAnnotation = true); 2183059101f922de6eb765601459925f4c8914420b23Douglas Gregor void AnnotateTemplateIdTokenAsType(); 2184d5ab9b0a0ae24f7d0f49f6f10fd1b247e64b3306Douglas Gregor bool IsTemplateArgumentList(unsigned Skip = 0); 2185314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs); 2186788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor ParsedTemplateArgument ParseTemplateTemplateArgument(); 2187314b97f8c564b465af605efaee23f91ec18a982bDouglas Gregor ParsedTemplateArgument ParseTemplateArgument(); 21889241057266d3460392cbb7fec6ec942d3330ece3Argyrios Kyrtzidis Decl *ParseExplicitInstantiation(unsigned Context, 21899241057266d3460392cbb7fec6ec942d3330ece3Argyrios Kyrtzidis SourceLocation ExternLoc, 21909241057266d3460392cbb7fec6ec942d3330ece3Argyrios Kyrtzidis SourceLocation TemplateLoc, 21919241057266d3460392cbb7fec6ec942d3330ece3Argyrios Kyrtzidis SourceLocation &DeclEnd, 21929241057266d3460392cbb7fec6ec942d3330ece3Argyrios Kyrtzidis AccessSpecifier AS = AS_none); 219364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 219464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl //===--------------------------------------------------------------------===// 21956aa52ec6b969faabf3764baf79d89810b8249a7eDouglas Gregor // Modules 21965948ae1021122164b22f74353bb7fe325a64f616Douglas Gregor DeclGroupPtrTy ParseModuleImport(SourceLocation AtLoc); 2197a8fbc053eb08c929174bf519a0e9733e4ef90bfaDavid Blaikie 21986aa52ec6b969faabf3764baf79d89810b8249a7eDouglas Gregor //===--------------------------------------------------------------------===// 219964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // GNU G++: Type Traits [Type-Traits.html in the GCC manual] 220060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ParseUnaryTypeTrait(); 22016ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet ExprResult ParseBinaryTypeTrait(); 22024ca8ac2e61c37ddadf37024af86f3e1019af8532Douglas Gregor ExprResult ParseTypeTrait(); 22034ca8ac2e61c37ddadf37024af86f3e1019af8532Douglas Gregor 2204f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor //===--------------------------------------------------------------------===// 220521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley // Embarcadero: Arary and Expression Traits 220621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ExprResult ParseArrayTypeTrait(); 2207552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExprResult ParseExpressionTrait(); 2208552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 2209552622067dc45013d240f73952fece703f5e63bdJohn Wiegley //===--------------------------------------------------------------------===// 2210f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor // Preprocessor code-completion pass-through 2211f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor virtual void CodeCompleteDirective(bool InConditional); 2212f44e854ed1e3aa86d2ed6d615ccd109d50ddcff9Douglas Gregor virtual void CodeCompleteInConditionalExclusion(); 22131fbb447e9d43c2c676e94081fbfee7eb6cbe933bDouglas Gregor virtual void CodeCompleteMacroName(bool IsDefinition); 2214f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor virtual void CodeCompletePreprocessorExpression(); 2215f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro, 2216f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor MacroInfo *MacroInfo, 2217f29c5233085a5af795c3c01b94d319e5b3235d56Douglas Gregor unsigned ArgumentIndex); 221855817afdf9d453a443262a733f6caf6692dca118Douglas Gregor virtual void CodeCompleteNaturalLanguage(); 22195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 22205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 22215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 22225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 22235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 2224