diff options
author | ed <ed@FreeBSD.org> | 2009-06-14 09:24:02 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-14 09:24:02 +0000 |
commit | b8e7410b22fa573fb0078712439f343bc69208dd (patch) | |
tree | d472a7615b5c7e413aa62a77d0777c1a9cf76478 /include/clang | |
parent | 6514d87c1aa5b544d02c3822fe41217e2051673d (diff) | |
download | FreeBSD-src-b8e7410b22fa573fb0078712439f343bc69208dd.zip FreeBSD-src-b8e7410b22fa573fb0078712439f343bc69208dd.tar.gz |
Import Clang r73340.
Diffstat (limited to 'include/clang')
27 files changed, 259 insertions, 100 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index b02faa8..f4313f4 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -17,13 +17,11 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LangOptions.h" #include "clang/AST/Attr.h" -#include "clang/AST/Builtins.h" #include "clang/AST/Decl.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" -#include "clang/Basic/SourceLocation.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/OwningPtr.h" @@ -56,6 +54,8 @@ namespace clang { class ObjCIvarRefExpr; class ObjCIvarDecl; + namespace Builtin { class Context; } + /// ASTContext - This class holds long-lived AST nodes (such as types and /// decls) that can be referred to throughout the semantic analysis of a file. class ASTContext { @@ -142,6 +142,7 @@ public: TargetInfo &Target; IdentifierTable &Idents; SelectorTable &Selectors; + Builtin::Context &BuiltinInfo; DeclarationNameTable DeclarationNames; llvm::OwningPtr<ExternalASTSource> ExternalSource; clang::PrintingPolicy PrintingPolicy; @@ -164,7 +165,6 @@ public: TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } - Builtin::Context BuiltinInfo; // Builtin Types. QualType VoidTy; @@ -181,21 +181,12 @@ public: QualType DependentTy; ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t, - IdentifierTable &idents, SelectorTable &sels, - bool FreeMemory = true, unsigned size_reserve=0, - bool InitializeBuiltins = true); + IdentifierTable &idents, SelectorTable &sels, + Builtin::Context &builtins, + bool FreeMemory = true, unsigned size_reserve=0); ~ASTContext(); - /// \brief Initialize builtins. - /// - /// Typically, this routine will be called automatically by the - /// constructor. However, in certain cases (e.g., when there is a - /// PCH file to be loaded), the constructor does not perform - /// initialization for builtins. This routine can be called to - /// perform the initialization. - void InitializeBuiltins(IdentifierTable &idents); - /// \brief Attach an external AST source to the AST context. /// /// The external AST source provides the ability to load parts of @@ -455,6 +446,14 @@ public: TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name); + enum GetBuiltinTypeError { + GE_None, //< No error + GE_Missing_FILE //< Missing the FILE type from <stdio.h> + }; + + /// GetBuiltinType - Return the type for the specified builtin. + QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error); + private: QualType getFromTargetType(unsigned Type) const; diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index 244ca9e..e9f1505 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define ASTSTART #include "clang/Basic/DiagnosticASTKinds.inc" #undef DIAG diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 0427f00..a5b7ad4 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -24,10 +24,16 @@ namespace clang { } -// Defined in ASTContext.cpp +// Defined in ASTContext.h void *operator new(size_t Bytes, clang::ASTContext &C, size_t Alignment = 16) throw (); +// It is good practice to pair new/delete operators. Also, MSVC gives many +// warnings if a matching delete overload is not declared, even though the +// throw() spec guarantees it will not be implicitly called. +void operator delete(void *Ptr, clang::ASTContext &C, size_t) + throw (); + namespace clang { /// Attr - This represents one attribute. diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index c061b85..5c9fd34 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -298,9 +298,13 @@ public: static bool CollectingStats(bool Enable = false); static void PrintStats(); - /// isTemplateParameter - Determines whether this declartion is a + /// isTemplateParameter - Determines whether this declaration is a /// template parameter. bool isTemplateParameter() const; + + /// isTemplateParameter - Determines whether this declaration is a + /// template parameter pack. + bool isTemplateParameterPack() const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *) { return true; } diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index d189900..a480f54 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -17,6 +17,7 @@ #include "clang/AST/DeclCXX.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/PointerUnion.h" namespace clang { @@ -29,6 +30,10 @@ class TemplateTypeParmDecl; class NonTypeTemplateParmDecl; class TemplateTemplateParmDecl; +/// \brief Stores a template parameter of any kind. +typedef llvm::PointerUnion3<TemplateTypeParmDecl*, NonTypeTemplateParmDecl*, + TemplateTemplateParmDecl*> TemplateParameter; + /// TemplateParameterList - Stores a list of template parameters for a /// TemplateDecl and its derived classes. class TemplateParameterList { @@ -69,6 +74,11 @@ public: unsigned size() const { return NumParams; } + Decl* getParam(unsigned Idx) { + assert(Idx < size() && "Template parameter index out-of-range"); + return begin()[Idx]; + } + const Decl* getParam(unsigned Idx) const { assert(Idx < size() && "Template parameter index out-of-range"); return begin()[Idx]; @@ -77,7 +87,7 @@ public: /// \btief Returns the minimum number of arguments needed to form a /// template specialization. This may be fewer than the number of /// template parameters, if some of the parameters have default - /// arguments. + /// arguments or if there is a parameter pack. unsigned getMinRequiredArguments() const; SourceLocation getTemplateLoc() const { return TemplateLoc; } @@ -223,6 +233,9 @@ class TemplateTypeParmDecl : public TypeDecl { /// default argument. bool InheritedDefault : 1; + /// \brief Whether this is a parameter pack. + bool ParameterPack : 1; + /// \brief The location of the default argument, if any. SourceLocation DefaultArgumentLoc; @@ -230,16 +243,17 @@ class TemplateTypeParmDecl : public TypeDecl { QualType DefaultArgument; TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - bool Typename, QualType Type) + bool Typename, QualType Type, bool ParameterPack) : TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename), - InheritedDefault(false), DefaultArgument() { + InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() { TypeForDecl = Type.getTypePtr(); } public: static TemplateTypeParmDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, - IdentifierInfo *Id, bool Typename); + IdentifierInfo *Id, bool Typename, + bool ParameterPack); /// \brief Whether this template type parameter was declared with /// the 'typename' keyword. If not, it was declared with the 'class' @@ -270,6 +284,9 @@ public: InheritedDefault = Inherited; } + /// \brief Returns whether this is a parameter pack. + bool isParameterPack() const { return ParameterPack; } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == TemplateTypeParm; @@ -575,17 +592,38 @@ public: /// \brief A helper class for making template argument lists. class TemplateArgumentListBuilder { + /// Args - contains the template arguments. llvm::SmallVector<TemplateArgument, 16> Args; + + llvm::SmallVector<unsigned, 32> Indices; ASTContext &Context; + + /// isAddingFromParameterPack - Returns whether we're adding arguments from + /// a parameter pack. + bool isAddingFromParameterPack() const { return Indices.size() % 2; } + public: TemplateArgumentListBuilder(ASTContext &Context) : Context(Context) { } - // FIXME: Should use the index array size. - size_t size() const { return Args.size(); } + size_t size() const { + assert(!isAddingFromParameterPack() && + "Size is not valid when adding from a parameter pack"); + + return Indices.size() / 2; + } + size_t flatSize() const { return Args.size(); } void push_back(const TemplateArgument& Arg); + + /// BeginParameterPack - Start adding arguments from a parameter pack. + void BeginParameterPack(); + + /// EndParameterPack - Finish adding arguments from a parameter pack. + void EndParameterPack(); + + const TemplateArgument *getFlatArgumentList() const { return Args.data(); } TemplateArgument *getFlatArgumentList() { return Args.data(); } }; @@ -733,6 +771,7 @@ public: static void Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs) { + ID.AddInteger(NumTemplateArgs); for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg) TemplateArgs[Arg].Profile(ID); } diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 3656333..a8688f6 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -709,14 +709,14 @@ class DoStmt : public Stmt { Stmt* SubExprs[END_EXPR]; SourceLocation DoLoc; SourceLocation WhileLoc; + SourceLocation RParenLoc; // Location of final ')' in do stmt condition. public: - DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL) - : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL) { + DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL, + SourceLocation RP) + : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) { SubExprs[COND] = reinterpret_cast<Stmt*>(cond); SubExprs[BODY] = body; - DoLoc = DL; - WhileLoc = WL; } /// \brief Build an empty do-while statement. @@ -734,8 +734,11 @@ public: SourceLocation getWhileLoc() const { return WhileLoc; } void setWhileLoc(SourceLocation L) { WhileLoc = L; } + SourceLocation getRParenLoc() const { return RParenLoc; } + void setRParenLoc(SourceLocation L) { RParenLoc = L; } + virtual SourceRange getSourceRange() const { - return SourceRange(DoLoc, SubExprs[BODY]->getLocEnd()); + return SourceRange(DoLoc, RParenLoc); } static bool classof(const Stmt *T) { return T->getStmtClass() == DoStmtClass; diff --git a/include/clang/Analysis/AnalysisDiagnostic.h b/include/clang/Analysis/AnalysisDiagnostic.h index e82dc9e..3ee7335 100644 --- a/include/clang/Analysis/AnalysisDiagnostic.h +++ b/include/clang/Analysis/AnalysisDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define ANALYSISSTART #include "clang/Basic/DiagnosticAnalysisKinds.inc" #undef DIAG diff --git a/include/clang/AST/Builtins.def b/include/clang/Basic/Builtins.def index c2f4061..c2f4061 100644 --- a/include/clang/AST/Builtins.def +++ b/include/clang/Basic/Builtins.def diff --git a/include/clang/AST/Builtins.h b/include/clang/Basic/Builtins.h index b16d3bf..6463a4f 100644 --- a/include/clang/AST/Builtins.h +++ b/include/clang/Basic/Builtins.h @@ -12,12 +12,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_AST_BUILTINS_H -#define LLVM_CLANG_AST_BUILTINS_H +#ifndef LLVM_CLANG_BASIC_BUILTINS_H +#define LLVM_CLANG_BASIC_BUILTINS_H #include <cstring> -#include <string> -#include "llvm/ADT/SmallVector.h" + +namespace llvm { + template <typename T> class SmallVectorImpl; +} namespace clang { class TargetInfo; @@ -29,7 +31,7 @@ namespace Builtin { enum ID { NotBuiltin = 0, // This is not a builtin function. #define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "clang/AST/Builtins.def" +#include "clang/Basic/Builtins.def" FirstTSBuiltin }; @@ -53,14 +55,11 @@ class Context { public: Context() : TSRecords(0), NumTSRecords(0) {} - /// \brief Load all of the target builtins. This should be called - /// prior to initializing the builtin identifiers. - void InitializeTargetBuiltins(const TargetInfo &Target); - /// InitializeBuiltins - Mark the identifiers for all the builtins with their /// appropriate builtin ID # and mark any non-portable builtin identifiers as /// such. - void InitializeBuiltins(IdentifierTable &Table, bool NoBuiltins = false); + void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target, + bool NoBuiltins = false); /// \brief Popular the vector with the names of all of the builtins. void GetBuiltinNames(llvm::SmallVectorImpl<const char *> &Names, @@ -72,6 +71,11 @@ public: return GetRecord(ID).Name; } + /// GetTypeString - Get the type descriptor string for the specified builtin. + const char *GetTypeString(unsigned ID) const { + return GetRecord(ID).Type; + } + /// isConst - Return true if this function has no side effects and doesn't /// read memory. bool isConst(unsigned ID) const { @@ -121,13 +125,6 @@ public: return strchr(GetRecord(ID).Attributes, 'e') != 0; } - /// GetBuiltinType - Return the type for the specified builtin. - enum GetBuiltinTypeError { - GE_None, //< No error - GE_Missing_FILE //< Missing the FILE type from <stdio.h> - }; - QualType GetBuiltinType(unsigned ID, ASTContext &Context, - GetBuiltinTypeError &Error) const; private: const Info &GetRecord(unsigned ID) const; }; diff --git a/include/clang/AST/PPCBuiltins.def b/include/clang/Basic/BuiltinsPPC.def index b8c7912..817a032 100644 --- a/include/clang/AST/PPCBuiltins.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -1,4 +1,4 @@ -//===--- PPCBuiltins.def - PowerPC Builtin function database ----*- C++ -*-===// +//===--- BuiltinsPPC.def - PowerPC Builtin function database ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,7 +15,7 @@ // FIXME: this needs to be the full list supported by GCC. Right now, I'm just // adding stuff on demand. -// The format of this database matches clang/AST/Builtins.def. +// The format of this database matches clang/Basic/Builtins.def. // This is just a placeholder, the types and attributes are wrong. BUILTIN(__builtin_altivec_abs_v4sf , "ii" , "nc") diff --git a/include/clang/AST/X86Builtins.def b/include/clang/Basic/BuiltinsX86.def index 85381c0..2af9580 100644 --- a/include/clang/AST/X86Builtins.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -1,4 +1,4 @@ -//===--- X86Builtins.def - X86 Builtin function database --------*- C++ -*-===// +//===--- BuiltinsX86.def - X86 Builtin function database --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -// The format of this database matches clang/AST/Builtins.def. +// The format of this database matches clang/Basic/Builtins.def. // FIXME: In GCC, these builtins are defined depending on whether support for // MMX/SSE/etc is turned on. We should do this too. diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 22e7fb3..207710b 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -50,7 +50,7 @@ namespace clang { // Get typedefs for common diagnostics. enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #include "clang/Basic/DiagnosticCommonKinds.inc" NUM_BUILTIN_COMMON_DIAGNOSTICS #undef DIAG @@ -313,6 +313,16 @@ public: /// the diagnostic, this returns null. static const char *getWarningOptionForDiag(unsigned DiagID); + /// \brief Determines whether the given built-in diagnostic ID is + /// for an error that is suppressed if it occurs during C++ template + /// argument deduction. + /// + /// When an error is suppressed due to SFINAE, the template argument + /// deduction fails but no diagnostic is emitted. Certain classes of + /// errors, such as those errors that involve C++ access control, + /// are not SFINAE errors. + static bool isBuiltinSFINAEDiag(unsigned DiagID); + /// getDiagnosticLevel - Based on the way the client configured the Diagnostic /// object, classify the specified diagnostic ID into a Level, consumable by /// the DiagnosticClient. @@ -409,7 +419,10 @@ private: /// ProcessDiag - This is the method used to report a diagnostic that is /// finally fully formed. - void ProcessDiag(); + /// + /// \returns true if the diagnostic was emitted, false if it was + /// suppressed. + bool ProcessDiag(); }; //===----------------------------------------------------------------------===// @@ -448,14 +461,26 @@ public: NumCodeModificationHints = D.NumCodeModificationHints; } + /// \brief Simple enumeration value used to give a name to the + /// suppress-diagnostic constructor. + enum SuppressKind { Suppress }; + + /// \brief Create an empty DiagnosticBuilder object that represents + /// no actual diagnostic. + explicit DiagnosticBuilder(SuppressKind) + : DiagObj(0), NumArgs(0), NumRanges(0), NumCodeModificationHints(0) { } + /// \brief Force the diagnostic builder to emit the diagnostic now. /// /// Once this function has been called, the DiagnosticBuilder object /// should not be used again before it is destroyed. - void Emit() { + /// + /// \returns true if a diagnostic was emitted, false if the + /// diagnostic was suppressed. + bool Emit() { // If DiagObj is null, then its soul was stolen by the copy ctor // or the user called Emit(). - if (DiagObj == 0) return; + if (DiagObj == 0) return false; // When emitting diagnostics, we set the final argument count into // the Diagnostic object. @@ -465,13 +490,15 @@ public: // Process the diagnostic, sending the accumulated information to the // DiagnosticClient. - DiagObj->ProcessDiag(); + bool Emitted = DiagObj->ProcessDiag(); // Clear out the current diagnostic object. DiagObj->Clear(); // This diagnostic is dead. DiagObj = 0; + + return Emitted; } /// Destructor - The dtor emits the diagnostic if it hasn't already @@ -486,28 +513,34 @@ public: void AddString(const std::string &S) const { assert(NumArgs < Diagnostic::MaxArguments && "Too many arguments to diagnostic!"); - DiagObj->DiagArgumentsKind[NumArgs] = Diagnostic::ak_std_string; - DiagObj->DiagArgumentsStr[NumArgs++] = S; + if (DiagObj) { + DiagObj->DiagArgumentsKind[NumArgs] = Diagnostic::ak_std_string; + DiagObj->DiagArgumentsStr[NumArgs++] = S; + } } void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const { assert(NumArgs < Diagnostic::MaxArguments && "Too many arguments to diagnostic!"); - DiagObj->DiagArgumentsKind[NumArgs] = Kind; - DiagObj->DiagArgumentsVal[NumArgs++] = V; + if (DiagObj) { + DiagObj->DiagArgumentsKind[NumArgs] = Kind; + DiagObj->DiagArgumentsVal[NumArgs++] = V; + } } void AddSourceRange(const SourceRange &R) const { assert(NumRanges < sizeof(DiagObj->DiagRanges)/sizeof(DiagObj->DiagRanges[0]) && "Too many arguments to diagnostic!"); - DiagObj->DiagRanges[NumRanges++] = &R; + if (DiagObj) + DiagObj->DiagRanges[NumRanges++] = &R; } void AddCodeModificationHint(const CodeModificationHint &Hint) const { assert(NumCodeModificationHints < Diagnostic::MaxCodeModificationHints && "Too many code modification hints!"); - DiagObj->CodeModificationHints[NumCodeModificationHints++] = Hint; + if (DiagObj) + DiagObj->CodeModificationHints[NumCodeModificationHints++] = Hint; } }; diff --git a/include/clang/Basic/Diagnostic.td b/include/clang/Basic/Diagnostic.td index 67d8eaa..6aa3b43 100644 --- a/include/clang/Basic/Diagnostic.td +++ b/include/clang/Basic/Diagnostic.td @@ -45,6 +45,7 @@ class Diagnostic<string text, DiagClass DC, DiagMapping defaultmapping> { string Component = ?; string Text = text; DiagClass Class = DC; + bit SFINAE = 1; DiagMapping DefaultMapping = defaultmapping; DiagGroup Group; } @@ -61,6 +62,8 @@ class DefaultWarn { DiagMapping DefaultMapping = MAP_WARNING; } class DefaultError { DiagMapping DefaultMapping = MAP_ERROR; } class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; } +class NoSFINAE { bit SFINAE = 0; } + // Definitions for Diagnostics. include "DiagnosticASTKinds.td" include "DiagnosticAnalysisKinds.td" diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 3d1f932..6ca50db 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -205,6 +205,10 @@ def err_pp_expr_bad_token_start_expr : Error< "invalid token at start of a preprocessor expression">; def err_pp_invalid_poison : Error<"can only poison identifier tokens">; def err_pp_used_poisoned_id : Error<"attempt to use a poisoned identifier">; + +def err_feature_check_malformed : Error< + "builtin feature check macro requires a parenthesized identifier">; + def err__Pragma_malformed : Error< "_Pragma takes a parenthesized string literal">; def err_pragma_comment_malformed : Error< diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 81afac9..e2b9eb7 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -100,10 +100,16 @@ def err_expected_comma : Error<"expected ','">; def err_expected_lbrace_in_compound_literal : Error< "expected '{' in compound literal">; def err_expected_while : Error<"expected 'while' in do/while loop">; + def err_expected_semi_after : Error<"expected ';' after %0">; +def err_expected_semi_after_stmt : Error<"expected ';' after %0 statement">; def err_expected_semi_after_expr : Error<"expected ';' after expression">; def err_expected_semi_after_method_proto : Error< "expected ';' after method prototype">; +def err_expected_semi_after_namespace_name : Error< + "expected ';' after namespace name">; +def err_expected_semi_after_attribute_list : Error< + "expected ';' after attribute list">; def err_expected_semi_after_static_assert : Error< "expected ';' after static_assert">; def err_expected_semi_for : Error<"expected ';' in 'for' statement specifier">; @@ -256,6 +262,9 @@ def err_typename_refers_to_non_type_template : Error< def err_expected_type_name_after_typename : Error< "expected an identifier or template-id after '::'">; +def err_variadic_templates : Error< + "variadic templates are only allowed in C++0x">; + // Language specific pragmas // - Generic warnings def warn_pragma_expected_lparen : Warning< diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 4b9b703..fa4f430 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -331,7 +331,7 @@ def note_overridden_virtual_function : Note< def err_covariant_return_inaccessible_base : Error< "return type of virtual function %2 is not covariant with the return type " "of the function it overrides " - "(conversion from %0 to inaccessible base class %1)">; + "(conversion from %0 to inaccessible base class %1)">, NoSFINAE; def err_covariant_return_ambiguous_derived_to_base_conv : Error< "return type of virtual function %3 is not covariant with the return type of " "the function it overrides (ambiguous conversion from derived class " @@ -572,6 +572,11 @@ def err_param_default_argument_nonfunc : Error< "default arguments can only be specified for parameters in a function " "declaration">; +def err_use_of_default_argument_to_function_declared_later : Error< + "use of default argument to function %0 that is declared later in class %1">; +def note_default_argument_declared_here : Note< + "default argument declared here">; + def ext_param_promoted_not_compatible_with_prototype : ExtWarn< "promoted type %0 of K&R function parameter is not compatible with the " "parameter type %1 declared in a previous prototype">; @@ -737,26 +742,48 @@ def err_template_spec_needs_header : Error< "template specialization requires 'template<>'">; def err_template_spec_extra_headers : Error< "template specialization must have a single 'template<>' header">; -def unsup_template_partial_spec_ordering : Error< - "partial ordering of class template partial specializations is not yet " - "supported">; def err_template_spec_decl_out_of_scope_global : Error< - "class template specialization of %0 must occur in the global scope">; + "class template %select{|partial }0specialization of %1 must occur in the " + "global scope">; def err_template_spec_decl_out_of_scope : Error< - "class template specialization of %0 not in namespace %1">; + "class template %select{|partial }0specialization of %1 not in namespace %2">; def err_template_spec_decl_function_scope : Error< - "%select{class template specialization|explicit instantiation}0 of %1 " - "in function scope">; + "%select{class template specialization|class template partial specialization|" + "explicit instantiation}0 of %1 in function scope">; def err_template_spec_redecl_out_of_scope : Error< - "%select{class template specialization|explicit instantiation}0 of %1 " - "not in a namespace enclosing %2">; + "%select{class template specialization|class template partial specialization|" + "explicit instantiation}0 of %1 not in a namespace enclosing %2">; def err_template_spec_redecl_global_scope : Error< - "%select{class template specialization|explicit instantiation}0 of %1 must " - "occur at global scope">; + "%select{class template specialization|class template partial specialization|" + "explicit instantiation}0 of %1 must occur at global scope">; + +// C++ Class Template Partial Specialization +def err_default_arg_in_partial_spec : Error< + "default template argument in a class template partial specialization">; +def err_dependent_non_type_arg_in_partial_spec : Error< + "non-type template argument depends on a template parameter of the " + "partial specialization">; +def err_dependent_typed_non_type_arg_in_partial_spec : Error< + "non-type template argument specializes a template parameter with " + "dependent type %0">; +def err_partial_spec_args_match_primary_template : Error< + "class template partial specialization does not specialize any template " + "argument; to %select{declare|define}0 the primary template, remove the " + "template argument list">; +def warn_partial_specs_not_deducible : Warning< + "class template partial specialization contains " + "%select{a template parameter|template parameters}0 that can not be " + "deduced; this partial specialization will never be used">; +def note_partial_spec_unused_parameter : Note< + "non-deducible template parameter %0">; +def unsup_template_partial_spec_ordering : Error< + "partial ordering of class template partial specializations is not yet " + "supported">; // C++ Template Instantiation def err_template_recursion_depth_exceeded : Error< - "recursive template instantiation exceeded maximum depth of %0">,DefaultFatal; + "recursive template instantiation exceeded maximum depth of %0">, + DefaultFatal, NoSFINAE; def note_template_recursion_depth : Note< "use -ftemplate-depth-N to increase recursive template instantiation depth">; @@ -772,6 +799,9 @@ def note_template_member_function_here : Note< "in instantiation of member function %q0 requested here">; def note_default_arg_instantiation_here : Note< "in instantiation of default argument for '%0' required here">; +def note_partial_spec_deduct_instantiation_here : Note< + "during template argument deduction for class template partial " + "specialization %0, here">; def err_field_instantiates_to_function : Error< "data member instantiated with function type %0">; def err_nested_name_spec_non_tag : Error< @@ -810,6 +840,12 @@ def err_template_kw_refers_to_non_template : Error< def err_template_kw_refers_to_function_template : Error< "%0 following the 'template' keyword refers to a function template">; +// C++0x Variadic Templates +def err_template_param_pack_default_arg : Error< + "template parameter pack cannot have a default argument">; +def err_template_param_pack_must_be_last_template_parameter : Error< + "template parameter pack must be the last template parameter">; + def err_unexpected_typedef : Error< "unexpected type name %0: expected expression">; def err_unexpected_namespace : Error< @@ -1001,6 +1037,8 @@ def err_illegal_decl_mempointer_to_void : Error< "'%0' declared as a member pointer to void">; def err_illegal_decl_mempointer_in_nonclass : Error< "'%0' does not point into a class">; +def err_mempointer_in_nonclass_type : Error< + "member pointer refers into non-class type %0">; def err_reference_to_void : Error<"cannot form a reference to 'void'">; def err_qualified_block_pointer_type : Error< "qualifier specification on block pointer type not allowed">; @@ -1567,7 +1605,7 @@ def err_memptr_conv_via_virtual : Error< // C++ access control def err_conv_to_inaccessible_base : Error< - "conversion from %0 to inaccessible base class %1">; + "conversion from %0 to inaccessible base class %1">, NoSFINAE; def note_inheritance_specifier_here : Note< "'%0' inheritance specifier here">; def note_inheritance_implicitly_private_here : Note< @@ -1814,8 +1852,10 @@ def warn_ivar_use_hidden : Warning< "local declaration of %0 hides instance variable">; def error_ivar_use_in_class_method : Error< "instance variable %0 accessed in class method">; -def error_private_ivar_access : Error<"instance variable %0 is private">; -def error_protected_ivar_access : Error<"instance variable %0 is protected">; +def error_private_ivar_access : Error<"instance variable %0 is private">, + NoSFINAE; +def error_protected_ivar_access : Error<"instance variable %0 is protected">, + NoSFINAE; def warn_maynot_respond : Warning<"%0 may not respond to %1">; def warn_attribute_method_def : Warning< "method attribute can only be specified on method declarations">; diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 4336982..57ae9a4 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -593,6 +593,12 @@ public: return getFileCharacteristic(Loc) != SrcMgr::C_User; } + /// isInExternCSystemHeader - Returns if a SourceLocation is in an "extern C" + /// system header. + bool isInExternCSystemHeader(SourceLocation Loc) const { + return getFileCharacteristic(Loc) == SrcMgr::C_ExternCSystem; + } + //===--------------------------------------------------------------------===// // Line Table Manipulation Routines //===--------------------------------------------------------------------===// diff --git a/include/clang/AST/TargetBuiltins.h b/include/clang/Basic/TargetBuiltins.h index d425a9b..d2e9495 100644 --- a/include/clang/AST/TargetBuiltins.h +++ b/include/clang/Basic/TargetBuiltins.h @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_AST_TARGET_BUILTINS_H -#define LLVM_CLANG_AST_TARGET_BUILTINS_H +#ifndef LLVM_CLANG_BASIC_TARGET_BUILTINS_H +#define LLVM_CLANG_BASIC_TARGET_BUILTINS_H -#include "clang/AST/Builtins.h" +#include "clang/Basic/Builtins.h" #undef PPC namespace clang { @@ -19,7 +19,7 @@ namespace clang { enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "X86Builtins.def" +#include "clang/Basic/BuiltinsX86.def" LastTSBuiltin }; } @@ -29,7 +29,7 @@ namespace clang { enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, -#include "PPCBuiltins.def" +#include "clang/Basic/BuiltinsPPC.def" LastTSBuiltin }; } diff --git a/include/clang/Driver/DriverDiagnostic.h b/include/clang/Driver/DriverDiagnostic.h index 2a4413c..705c342 100644 --- a/include/clang/Driver/DriverDiagnostic.h +++ b/include/clang/Driver/DriverDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define DRIVERSTART #include "clang/Basic/DiagnosticDriverKinds.inc" #undef DIAG diff --git a/include/clang/Driver/Options.def b/include/clang/Driver/Options.def index 742a04a..7045f14 100644 --- a/include/clang/Driver/Options.def +++ b/include/clang/Driver/Options.def @@ -419,6 +419,7 @@ OPTION("-fno-keep-inline-functions", fno_keep_inline_functions, Flag, clang_igno OPTION("-fno-math-errno", fno_math_errno, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-pascal-strings", fno_pascal_strings, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-show-column", fno_show_column, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-show-source-location", fno_show_source_location, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-stack-protector", fno_stack_protector, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-strict-aliasing", fno_strict_aliasing, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-unit-at-a-time", fno_unit_at_a_time, Flag, f_Group, INVALID, "", 0, 0, 0) @@ -446,6 +447,7 @@ OPTION("-fpie", fpie, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fprofile-arcs", fprofile_arcs, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fprofile-generate", fprofile_generate, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-framework", framework, Separate, INVALID, INVALID, "l", 0, 0, 0) +OPTION("-fshow-source-location", fshow_source_location, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fsigned-bitfields", fsigned_bitfields, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fsigned-char", fsigned_char, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fstack-protector", fstack_protector, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h index 02432ca..079abae 100644 --- a/include/clang/Frontend/FrontendDiagnostic.h +++ b/include/clang/Frontend/FrontendDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define FRONTENDSTART #include "clang/Basic/DiagnosticFrontendKinds.inc" #undef DIAG diff --git a/include/clang/Lex/LexDiagnostic.h b/include/clang/Lex/LexDiagnostic.h index 1502efb..03d9b7b 100644 --- a/include/clang/Lex/LexDiagnostic.h +++ b/include/clang/Lex/LexDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define LEXSTART #include "clang/Basic/DiagnosticLexKinds.inc" #undef DIAG diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 5b9959c..f229881 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -19,6 +19,7 @@ #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/TokenLexer.h" #include "clang/Lex/PTHManager.h" +#include "clang/Basic/Builtins.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" @@ -69,6 +70,8 @@ class Preprocessor { IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ IdentifierInfo *Ident__COUNTER__; // __COUNTER__ IdentifierInfo *Ident_Pragma, *Ident__VA_ARGS__; // _Pragma, __VA_ARGS__ + IdentifierInfo *Ident__has_feature; // __has_feature + IdentifierInfo *Ident__has_builtin; // __has_builtin SourceLocation DATELoc, TIMELoc; unsigned CounterValue; // Next __COUNTER__ value. @@ -99,6 +102,9 @@ class Preprocessor { /// the lifetime fo the preprocessor. SelectorTable Selectors; + /// BuiltinInfo - Information about builtins. + Builtin::Context BuiltinInfo; + /// PragmaHandlers - This tracks all of the pragmas that the client registered /// with this preprocessor. PragmaNamespace *PragmaHandlers; @@ -194,14 +200,13 @@ private: // Cached tokens state. public: Preprocessor(Diagnostic &diags, const LangOptions &opts, TargetInfo &target, SourceManager &SM, HeaderSearch &Headers, - IdentifierInfoLookup* IILookup = 0); + IdentifierInfoLookup *IILookup = 0); ~Preprocessor(); Diagnostic &getDiagnostics() const { return *Diags; } void setDiagnostics(Diagnostic &D) { Diags = &D; } - const LangOptions &getLangOptions() const { return Features; } TargetInfo &getTargetInfo() const { return Target; } FileManager &getFileManager() const { return FileMgr; } @@ -210,6 +215,7 @@ public: IdentifierTable &getIdentifierTable() { return Identifiers; } SelectorTable &getSelectorTable() { return Selectors; } + Builtin::Context &getBuiltinInfo() { return BuiltinInfo; } llvm::BumpPtrAllocator &getPreprocessorAllocator() { return BP; } void setPTHManager(PTHManager* pm); @@ -667,7 +673,6 @@ private: /// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the /// identifier table. void RegisterBuiltinMacros(); - IdentifierInfo *RegisterBuiltinMacro(const char *Name); /// HandleMacroExpandedIdentifier - If an identifier token is read that is to /// be expanded as a macro, handle it and return the next token as 'Tok'. If diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 579fe6c..f1207e4 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -517,7 +517,10 @@ public: return StmtEmpty(); } virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, - SourceLocation WhileLoc, ExprArg Cond) { + SourceLocation WhileLoc, + SourceLocation CondLParen, + ExprArg Cond, + SourceLocation CondRParen) { return StmtEmpty(); } virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, @@ -916,7 +919,8 @@ public: /// because we're inside a class definition. Note that this default /// argument will be parsed later. virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, - SourceLocation EqualLoc) { } + SourceLocation EqualLoc, + SourceLocation ArgLoc) { } /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of /// the default argument for the parameter param failed. @@ -1165,16 +1169,18 @@ public: /// ActOnTypeParameter - Called when a C++ template type parameter /// (e.g., "typename T") has been parsed. Typename specifies whether /// the keyword "typename" was used to declare the type parameter - /// (otherwise, "class" was used), and KeyLoc is the location of the - /// "class" or "typename" keyword. ParamName is the name of the - /// parameter (NULL indicates an unnamed template parameter) and - /// ParamNameLoc is the location of the parameter name (if any). + /// (otherwise, "class" was used), ellipsis specifies whether this is a + /// C++0x parameter pack, EllipsisLoc specifies the start of the ellipsis, + /// and KeyLoc is the location of the "class" or "typename" keyword. + // ParamName is the name of the parameter (NULL indicates an unnamed template + // parameter) and ParamNameLoc is the location of the parameter name (if any) /// If the type parameter has a default argument, it will be added /// later via ActOnTypeParameterDefault. Depth and Position provide /// the number of enclosing templates (see /// ActOnTemplateParameterList) and the number of previous /// parameters within this template parameter list. - virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, + virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, + SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, diff --git a/include/clang/Parse/ParseDiagnostic.h b/include/clang/Parse/ParseDiagnostic.h index a85c6ad..fa600dd 100644 --- a/include/clang/Parse/ParseDiagnostic.h +++ b/include/clang/Parse/ParseDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define PARSESTART #include "clang/Basic/DiagnosticParseKinds.inc" #undef DIAG diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 6125fc6..d613ae1 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -868,7 +868,9 @@ private: OwningStmtResult ParseCompoundStatement(bool isStmtExpr = false); OwningStmtResult ParseCompoundStatementBody(bool isStmtExpr = false); bool ParseParenExprOrCondition(OwningExprResult &CondExp, - bool OnlyAllowCondition = false); + bool OnlyAllowCondition = false, + SourceLocation *LParenLoc = 0, + SourceLocation *RParenLoc = 0); OwningStmtResult ParseIfStatement(); OwningStmtResult ParseSwitchStatement(); OwningStmtResult ParseWhileStatement(); @@ -1064,7 +1066,8 @@ private: // EndLoc, if non-NULL, is filled with the location of the last token of // the attribute list. AttributeList *ParseAttributes(SourceLocation *EndLoc = 0); - AttributeList *ParseMicrosoftDeclSpec(); + AttributeList *ParseMicrosoftDeclSpec(AttributeList* CurrAttr = 0); + AttributeList *ParseMicrosoftTypeAttributes(AttributeList* CurrAttr = 0); void ParseTypeofSpecifier(DeclSpec &DS); /// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to diff --git a/include/clang/Sema/SemaDiagnostic.h b/include/clang/Sema/SemaDiagnostic.h index e215ed4..de92844 100644 --- a/include/clang/Sema/SemaDiagnostic.h +++ b/include/clang/Sema/SemaDiagnostic.h @@ -15,7 +15,7 @@ namespace clang { namespace diag { enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP) ENUM, +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define SEMASTART #include "clang/Basic/DiagnosticSemaKinds.inc" #undef DIAG |