diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-02 08:55:10 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-02 08:55:10 +0000 |
commit | 11d2b2d2bb706fca0656f2760839721bb7f6cb6f (patch) | |
tree | d374cdca417e76f1bf101f139dba2db1d10ee8f7 /include/clang/Basic | |
parent | c0c7bca4e5b8d12699dc93a0da49e9e4bb79671b (diff) | |
download | src-11d2b2d2bb706fca0656f2760839721bb7f6cb6f.tar.gz src-11d2b2d2bb706fca0656f2760839721bb7f6cb6f.zip |
Update clang to r100181.
Notes
Notes:
svn path=/vendor/clang/dist/; revision=206084
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/Builtins.def | 15 | ||||
-rw-r--r-- | include/clang/Basic/BuiltinsX86.def | 8 | ||||
-rw-r--r-- | include/clang/Basic/CMakeLists.txt | 8 | ||||
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 160 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticFrontendKinds.td | 5 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 5 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 22 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 82 | ||||
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 177 | ||||
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 1 |
10 files changed, 314 insertions, 169 deletions
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index 3afdaf5b0eb1..453f660c360a 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -397,13 +397,6 @@ BUILTIN(__sync_fetch_and_xor_4, "ii*i.", "n") BUILTIN(__sync_fetch_and_xor_8, "LLiLLi*LLi.", "n") BUILTIN(__sync_fetch_and_xor_16, "LLLiLLLi*LLLi.", "n") -BUILTIN(__sync_fetch_and_nand, "v.", "") -BUILTIN(__sync_fetch_and_nand_1, "cc*c.", "n") -BUILTIN(__sync_fetch_and_nand_2, "ss*s.", "n") -BUILTIN(__sync_fetch_and_nand_4, "ii*i.", "n") -BUILTIN(__sync_fetch_and_nand_8, "LLiLLi*LLi.", "n") -BUILTIN(__sync_fetch_and_nand_16, "LLLiLLLi*LLLi.", "n") - BUILTIN(__sync_add_and_fetch, "v.", "") BUILTIN(__sync_add_and_fetch_1, "cc*c.", "n") @@ -440,14 +433,6 @@ BUILTIN(__sync_xor_and_fetch_4, "ii*i.", "n") BUILTIN(__sync_xor_and_fetch_8, "LLiLLi*LLi.", "n") BUILTIN(__sync_xor_and_fetch_16, "LLLiLLLi*LLLi.", "n") -BUILTIN(__sync_nand_and_fetch, "v.", "") -BUILTIN(__sync_nand_and_fetch_1, "cc*c.", "n") -BUILTIN(__sync_nand_and_fetch_2, "ss*s.", "n") -BUILTIN(__sync_nand_and_fetch_4, "ii*i.", "n") -BUILTIN(__sync_nand_and_fetch_8, "LLiLLi*LLi.", "n") -BUILTIN(__sync_nand_and_fetch_16, "LLLiLLLi*LLLi.", "n") - - BUILTIN(__sync_bool_compare_and_swap, "v.", "") BUILTIN(__sync_bool_compare_and_swap_1, "bcD*cc.", "n") BUILTIN(__sync_bool_compare_and_swap_2, "bsD*ss.", "n") diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index 00b076aa1004..5c75d3799bcb 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -317,4 +317,12 @@ BUILTIN(__builtin_ia32_crc32qi, "iic", "") BUILTIN(__builtin_ia32_crc32hi, "iis", "") BUILTIN(__builtin_ia32_crc32si, "iii", "") BUILTIN(__builtin_ia32_crc32di, "LLiLLiLLi", "") + +// AES +BUILTIN(__builtin_ia32_aesenc128, "V2LLiV2LLiV2LLi", "") +BUILTIN(__builtin_ia32_aesenclast128, "V2LLiV2LLiV2LLi", "") +BUILTIN(__builtin_ia32_aesdec128, "V2LLiV2LLiV2LLi", "") +BUILTIN(__builtin_ia32_aesdeclast128, "V2LLiV2LLiV2LLi", "") +BUILTIN(__builtin_ia32_aesimc128, "V2LLiV2LLi", "") +BUILTIN(__builtin_ia32_aeskeygenassist128, "V2LLiV2LLii", "") #undef BUILTIN diff --git a/include/clang/Basic/CMakeLists.txt b/include/clang/Basic/CMakeLists.txt index 9e643bb3c2c1..c2a4e1364a9e 100644 --- a/include/clang/Basic/CMakeLists.txt +++ b/include/clang/Basic/CMakeLists.txt @@ -1,8 +1,8 @@ macro(clang_diag_gen component) - tablegen(Diagnostic${component}Kinds.inc - -gen-clang-diags-defs -clang-component=${component}) + tablegen(Diagnostic${component}Kinds.inc + -gen-clang-diags-defs -clang-component=${component}) add_custom_target(ClangDiagnostic${component} - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Diagnostic${component}Kinds.inc) + DEPENDS Diagnostic${component}Kinds.inc) endmacro(clang_diag_gen) set(LLVM_TARGET_DEFINITIONS Diagnostic.td) @@ -17,4 +17,4 @@ clang_diag_gen(Sema) tablegen(DiagnosticGroups.inc -gen-clang-diag-groups) add_custom_target(ClangDiagnosticGroups - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/DiagnosticGroups.inc) + DEPENDS DiagnosticGroups.inc) diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index d6c8797fc901..643868506d8f 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -95,7 +95,7 @@ namespace clang { /// should also provide full recovery from such errors, such that /// suppressing the diagnostic output can still result in successful /// compilation. -class CodeModificationHint { +class FixItHint { public: /// \brief Tokens that should be removed to correct the error. SourceRange RemoveRange; @@ -110,7 +110,7 @@ public: /// \brief Empty code modification hint, indicating that no code /// modification is known. - CodeModificationHint() : RemoveRange(), InsertionLoc() { } + FixItHint() : RemoveRange(), InsertionLoc() { } bool isNull() const { return !RemoveRange.isValid() && !InsertionLoc.isValid(); @@ -118,9 +118,9 @@ public: /// \brief Create a code modification hint that inserts the given /// code string at a specific location. - static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc, - llvm::StringRef Code) { - CodeModificationHint Hint; + static FixItHint CreateInsertion(SourceLocation InsertionLoc, + llvm::StringRef Code) { + FixItHint Hint; Hint.InsertionLoc = InsertionLoc; Hint.CodeToInsert = Code; return Hint; @@ -128,17 +128,17 @@ public: /// \brief Create a code modification hint that removes the given /// source range. - static CodeModificationHint CreateRemoval(SourceRange RemoveRange) { - CodeModificationHint Hint; + static FixItHint CreateRemoval(SourceRange RemoveRange) { + FixItHint Hint; Hint.RemoveRange = RemoveRange; return Hint; } /// \brief Create a code modification hint that replaces the given /// source range with the given code string. - static CodeModificationHint CreateReplacement(SourceRange RemoveRange, - llvm::StringRef Code) { - CodeModificationHint Hint; + static FixItHint CreateReplacement(SourceRange RemoveRange, + llvm::StringRef Code) { + FixItHint Hint; Hint.RemoveRange = RemoveRange; Hint.InsertionLoc = RemoveRange.getBegin(); Hint.CodeToInsert = Code; @@ -234,6 +234,18 @@ private: void *Cookie); void *ArgToStringCookie; ArgToStringFnTy ArgToStringFn; + + /// \brief ID of the "delayed" diagnostic, which is a (typically + /// fatal) diagnostic that had to be delayed because it was found + /// while emitting another diagnostic. + unsigned DelayedDiagID; + + /// \brief First string argument for the delayed diagnostic. + std::string DelayedDiagArg1; + + /// \brief Second string argument for the delayed diagnostic. + std::string DelayedDiagArg2; + public: explicit Diagnostic(DiagnosticClient *client = 0); ~Diagnostic(); @@ -377,6 +389,28 @@ public: /// the diagnostic, this returns null. static const char *getWarningOptionForDiag(unsigned DiagID); + /// \brief Enumeration describing how the the emission of a diagnostic should + /// be treated when it occurs during C++ template argument deduction. + enum SFINAEResponse { + /// \brief The diagnostic should not be reported, but it should cause + /// template argument deduction to fail. + /// + /// The vast majority of errors that occur during template argument + /// deduction fall into this category. + SFINAE_SubstitutionFailure, + + /// \brief The diagnostic should be suppressed entirely. + /// + /// Warnings generally fall into this category. + SFINAE_Suppress, + + /// \brief The diagnostic should be reported. + /// + /// The diagnostic should be reported. Various fatal errors (e.g., + /// template instantiation depth exceeded) fall into this category. + SFINAE_Report + }; + /// \brief Determines whether the given built-in diagnostic ID is /// for an error that is suppressed if it occurs during C++ template /// argument deduction. @@ -385,7 +419,7 @@ public: /// 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); + static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID); /// getDiagnosticLevel - Based on the way the client configured the Diagnostic /// object, classify the specified diagnostic ID into a Level, consumable by @@ -400,10 +434,41 @@ public: inline DiagnosticBuilder Report(FullSourceLoc Pos, unsigned DiagID); inline DiagnosticBuilder Report(unsigned DiagID); + /// \brief Determine whethere there is already a diagnostic in flight. + bool isDiagnosticInFlight() const { return CurDiagID != ~0U; } + + /// \brief Set the "delayed" diagnostic that will be emitted once + /// the current diagnostic completes. + /// + /// If a diagnostic is already in-flight but the front end must + /// report a problem (e.g., with an inconsistent file system + /// state), this routine sets a "delayed" diagnostic that will be + /// emitted after the current diagnostic completes. This should + /// only be used for fatal errors detected at inconvenient + /// times. If emitting a delayed diagnostic causes a second delayed + /// diagnostic to be introduced, that second delayed diagnostic + /// will be ignored. + /// + /// \param DiagID The ID of the diagnostic being delayed. + /// + /// \param Arg1 A string argument that will be provided to the + /// diagnostic. A copy of this string will be stored in the + /// Diagnostic object itself. + /// + /// \param Arg2 A string argument that will be provided to the + /// diagnostic. A copy of this string will be stored in the + /// Diagnostic object itself. + void SetDelayedDiagnostic(unsigned DiagID, llvm::StringRef Arg1 = "", + llvm::StringRef Arg2 = ""); + /// \brief Clear out the current diagnostic. void Clear() { CurDiagID = ~0U; } private: + /// \brief Report the delayed diagnostic. + void ReportDelayed(); + + /// getDiagnosticMappingInfo - Return the mapping info currently set for the /// specified builtin diagnostic. This returns the high bit encoding, or zero /// if the field is completely uninitialized. @@ -454,8 +519,8 @@ private: /// NumRanges - This is the number of ranges in the DiagRanges array. unsigned char NumDiagRanges; /// \brief The number of code modifications hints in the - /// CodeModificationHints array. - unsigned char NumCodeModificationHints; + /// FixItHints array. + unsigned char NumFixItHints; /// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum /// values, with one for each argument. This specifies whether the argument @@ -477,11 +542,11 @@ private: /// only support 10 ranges, could easily be extended if needed. SourceRange DiagRanges[10]; - enum { MaxCodeModificationHints = 3 }; + enum { MaxFixItHints = 3 }; - /// CodeModificationHints - If valid, provides a hint with some code + /// FixItHints - If valid, provides a hint with some code /// to insert, remove, or modify at a particular position. - CodeModificationHint CodeModificationHints[MaxCodeModificationHints]; + FixItHint FixItHints[MaxFixItHints]; /// ProcessDiag - This is the method used to report a diagnostic that is /// finally fully formed. @@ -508,13 +573,12 @@ private: /// for example. class DiagnosticBuilder { mutable Diagnostic *DiagObj; - mutable unsigned NumArgs, NumRanges, NumCodeModificationHints; + mutable unsigned NumArgs, NumRanges, NumFixItHints; void operator=(const DiagnosticBuilder&); // DO NOT IMPLEMENT friend class Diagnostic; explicit DiagnosticBuilder(Diagnostic *diagObj) - : DiagObj(diagObj), NumArgs(0), NumRanges(0), - NumCodeModificationHints(0) {} + : DiagObj(diagObj), NumArgs(0), NumRanges(0), NumFixItHints(0) {} public: /// Copy constructor. When copied, this "takes" the diagnostic info from the @@ -524,7 +588,7 @@ public: D.DiagObj = 0; NumArgs = D.NumArgs; NumRanges = D.NumRanges; - NumCodeModificationHints = D.NumCodeModificationHints; + NumFixItHints = D.NumFixItHints; } /// \brief Simple enumeration value used to give a name to the @@ -534,7 +598,7 @@ public: /// \brief Create an empty DiagnosticBuilder object that represents /// no actual diagnostic. explicit DiagnosticBuilder(SuppressKind) - : DiagObj(0), NumArgs(0), NumRanges(0), NumCodeModificationHints(0) { } + : DiagObj(0), NumArgs(0), NumRanges(0), NumFixItHints(0) { } /// \brief Force the diagnostic builder to emit the diagnostic now. /// @@ -543,29 +607,7 @@ public: /// /// \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 false; - - // When emitting diagnostics, we set the final argument count into - // the Diagnostic object. - DiagObj->NumDiagArgs = NumArgs; - DiagObj->NumDiagRanges = NumRanges; - DiagObj->NumCodeModificationHints = NumCodeModificationHints; - - // Process the diagnostic, sending the accumulated information to the - // DiagnosticClient. - bool Emitted = DiagObj->ProcessDiag(); - - // Clear out the current diagnostic object. - DiagObj->Clear(); - - // This diagnostic is dead. - DiagObj = 0; - - return Emitted; - } + bool Emit(); /// Destructor - The dtor emits the diagnostic if it hasn't already /// been emitted. @@ -605,14 +647,14 @@ public: DiagObj->DiagRanges[NumRanges++] = R; } - void AddCodeModificationHint(const CodeModificationHint &Hint) const { + void AddFixItHint(const FixItHint &Hint) const { if (Hint.isNull()) return; - assert(NumCodeModificationHints < Diagnostic::MaxCodeModificationHints && - "Too many code modification hints!"); + assert(NumFixItHints < Diagnostic::MaxFixItHints && + "Too many fix-it hints!"); if (DiagObj) - DiagObj->CodeModificationHints[NumCodeModificationHints++] = Hint; + DiagObj->FixItHints[NumFixItHints++] = Hint; } }; @@ -673,8 +715,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, } inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const CodeModificationHint &Hint) { - DB.AddCodeModificationHint(Hint); + const FixItHint &Hint) { + DB.AddFixItHint(Hint); return DB; } @@ -770,17 +812,17 @@ public: return DiagObj->DiagRanges[Idx]; } - unsigned getNumCodeModificationHints() const { - return DiagObj->NumCodeModificationHints; + unsigned getNumFixItHints() const { + return DiagObj->NumFixItHints; } - const CodeModificationHint &getCodeModificationHint(unsigned Idx) const { - return DiagObj->CodeModificationHints[Idx]; + const FixItHint &getFixItHint(unsigned Idx) const { + return DiagObj->FixItHints[Idx]; } - const CodeModificationHint *getCodeModificationHints() const { - return DiagObj->NumCodeModificationHints? - &DiagObj->CodeModificationHints[0] : 0; + const FixItHint *getFixItHints() const { + return DiagObj->NumFixItHints? + &DiagObj->FixItHints[0] : 0; } /// FormatDiagnostic - Format this diagnostic into a string, substituting the @@ -803,7 +845,7 @@ class StoredDiagnostic { FullSourceLoc Loc; std::string Message; std::vector<SourceRange> Ranges; - std::vector<CodeModificationHint> FixIts; + std::vector<FixItHint> FixIts; public: StoredDiagnostic(); @@ -823,7 +865,7 @@ public: range_iterator range_end() const { return Ranges.end(); } unsigned range_size() const { return Ranges.size(); } - typedef std::vector<CodeModificationHint>::const_iterator fixit_iterator; + typedef std::vector<FixItHint>::const_iterator fixit_iterator; fixit_iterator fixit_begin() const { return FixIts.begin(); } fixit_iterator fixit_end() const { return FixIts.end(); } unsigned fixit_size() const { return FixIts.size(); } diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 3a28282d5522..2e0b4bad6b5b 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -22,7 +22,7 @@ def err_fe_stdout_binary : Error<"unable to change standard output to binary">, def err_fe_stderr_binary : Error<"unable to change standard error to binary">, DefaultFatal; def err_fe_dependency_file_requires_MT : Error< - "-dependency-file requires at least one -MT option">; + "-dependency-file requires at least one -MT or -MQ option">; def err_fe_incompatible_options : Error< "'%0' cannot be used with '%1'">, DefaultFatal; def err_fe_no_fixit_and_codegen : Error< @@ -57,6 +57,9 @@ def err_fe_pch_malformed_block : Error< "malformed block record in PCH file: '%0'">, DefaultFatal; def err_fe_pch_error_at_end_block : Error< "error at end of module block in PCH file: '%0'">, DefaultFatal; +def err_fe_pch_file_modified : Error< + "file '%0' has been modified since the precompiled header was built">, + DefaultFatal; def err_fe_unable_to_open_output : Error< "unable to open output file '%0': '%1'">; def err_fe_unable_to_open_logfile : Error< diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 203ab1eed547..b0c016bbfd28 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -31,6 +31,7 @@ def : DiagGroup<"char-align">; def Comment : DiagGroup<"comment">; def : DiagGroup<"ctor-dtor-privacy">; def : DiagGroup<"declaration-after-statement">; +def GNUDesignator : DiagGroup<"gnu-designator">; def Deprecated : DiagGroup<"deprecated">; def : DiagGroup<"disabled-optimization">; def : DiagGroup<"discard-qual">; @@ -115,6 +116,7 @@ def UnusedVariable : DiagGroup<"unused-variable">; def ReadOnlySetterAttrs : DiagGroup<"readonly-setter-attrs">; def Reorder : DiagGroup<"reorder">; def UndeclaredSelector : DiagGroup<"undeclared-selector">; +def Protocol : DiagGroup<"protocol">; def SuperSubClassMismatch : DiagGroup<"super-class-method-mismatch">; def : DiagGroup<"variadic-macros">; def VariadicMacros : DiagGroup<"variadic-macros">; @@ -185,3 +187,6 @@ def : DiagGroup<"comments", [Comment]>; // -Wcomments = -Wcomment // but which aren't on by default in GCC. def NonGCC : DiagGroup<"non-gcc", [SignCompare, Conversion, LiteralRange]>; + +// A warning group for warnings about GCC extensions. +def GNU : DiagGroup<"gnu", [GNUDesignator]>; diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 9d001d48cc2a..facf15f52e85 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -50,22 +50,26 @@ def ext_enumerator_list_comma : Extension< "feature">; def ext_gnu_indirect_goto : Extension< - "use of GNU indirect-goto extension">; + "use of GNU indirect-goto extension">, InGroup<GNU>; def ext_gnu_address_of_label : Extension< - "use of GNU address-of-label extension">; + "use of GNU address-of-label extension">, InGroup<GNU>; def ext_gnu_statement_expr : Extension< - "use of GNU statement expression extension">; + "use of GNU statement expression extension">, InGroup<GNU>; def ext_gnu_conditional_expr : Extension< - "use of GNU ?: expression extension, eliding middle term">; + "use of GNU ?: expression extension, eliding middle term">, InGroup<GNU>; def ext_gnu_empty_initializer : Extension< - "use of GNU empty initializer extension">; -def ext_gnu_array_range : Extension<"use of GNU array range extension">; + "use of GNU empty initializer extension">, InGroup<GNU>; +def ext_gnu_array_range : Extension<"use of GNU array range extension">, + InGroup<GNUDesignator>; def ext_gnu_missing_equal_designator : ExtWarn< - "use of GNU 'missing =' extension in designator">; + "use of GNU 'missing =' extension in designator">, + InGroup<GNUDesignator>; def err_expected_equal_designator : Error<"expected '=' or another designator">; def ext_gnu_old_style_field_designator : ExtWarn< - "use of GNU old-style field designator extension">; -def ext_gnu_case_range : Extension<"use of GNU case range extension">; + "use of GNU old-style field designator extension">, + InGroup<GNUDesignator>; +def ext_gnu_case_range : Extension<"use of GNU case range extension">, + InGroup<GNU>; // Generic errors. def err_parse_error : Error<"parse error">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 752be5df7a12..be00972dac5c 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -68,7 +68,7 @@ def err_designator_into_flexible_array_member : Error< def note_flexible_array_member : Note< "initialized flexible array member %0 is here">; def ext_flexible_array_init : Extension< - "flexible array initialization is a GNU extension">; + "flexible array initialization is a GNU extension">, InGroup<GNU>; // Declarations. def ext_vla : Extension< @@ -268,8 +268,6 @@ def err_duplicate_ivar_declaration : Error< "instance variable is already declared">; def warn_on_superclass_use : Warning< "class implementation may not have super class">; -def err_non_private_ivar_declaration : Error< - "only private ivars may be declared in implementation">; def err_conflicting_ivar_bitwidth : Error< "instance variable %0 has conflicting bit-field width">; def err_conflicting_ivar_name : Error< @@ -277,7 +275,9 @@ def err_conflicting_ivar_name : Error< def err_inconsistant_ivar_count : Error< "inconsistent number of instance variables specified">; def warn_incomplete_impl : Warning<"incomplete implementation">; -def warn_undef_method_impl : Warning<"method definition for %0 not found">; +def note_undef_method_impl : Note<"method definition for %0 not found">; +def note_required_for_protocol_at : + Note<"required for direct or indirect protocol %0">; def warn_conflicting_ret_types : Warning< "conflicting return type in implementation of %0: %1 vs %2">; @@ -350,7 +350,7 @@ def error_synthesized_ivar_yet_not_supported : Error< " (need to declare %0 explicitly)">; def error_property_ivar_type : Error< - "type of property %0 does not match type of ivar %1">; + "type of property %0 (%1) does not match type of ivar %2 (%3)">; def error_ivar_in_superclass_use : Error< "property %0 attempting to use ivar %1 declared in super class %2">; def error_weak_property : Error< @@ -367,6 +367,8 @@ def warn_objc_property_attr_mutually_exclusive : Warning< InGroup<ReadOnlySetterAttrs>, DefaultIgnore; def warn_undeclared_selector : Warning< "undeclared selector %0">, InGroup<UndeclaredSelector>, DefaultIgnore; +def warn_unimplemented_protocol_method : Warning< + "method in protocol not implemented">, InGroup<Protocol>; // C++ declarations def err_static_assert_expression_is_not_constant : Error< @@ -393,7 +395,11 @@ def err_abstract_type_in_decl : Error< "%select{return|parameter|variable|field}0 type %1 is an abstract class">; def err_allocation_of_abstract_type : Error< "allocation of an object of abstract type %0">; - + +def err_multiple_final_overriders : Error< + "virtual function %q0 has more than one final overrider in %1">; +def note_final_overrider : Note<"final overrider of %q0 in %1">; + def err_type_defined_in_type_specifier : Error< "%0 can not be defined in a type specifier">; def err_type_defined_in_result_type : Error< @@ -432,6 +438,8 @@ def err_incompatible_exception_specs : Error< "target exception specification is not superset of source">; def err_deep_exception_specs_differ : Error< "exception specifications of %select{return|argument}0 types differ">; +def warn_missing_exception_specification : Warning< + "%0 is missing exception specification '%1'">; // C++ access checking def err_class_redeclared_with_different_access : Error< @@ -532,6 +540,7 @@ def err_implicit_object_parameter_init : Error< "of type %1">; def note_field_decl : Note<"member is declared here">; +def note_ivar_decl : Note<"ivar is declared here">; def note_bitfield_decl : Note<"bit-field is declared here">; def note_previous_decl : Note<"%0 declared here">; def note_member_synthesized_at : Note< @@ -776,8 +785,9 @@ def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning< def warn_attribute_ignored : Warning<"%0 attribute ignored">; def warn_attribute_precede_definition : Warning< "attribute declaration must precede definition">; -def warn_attribute_void_function : Warning< - "attribute %0 cannot be applied to functions without return value">; +def warn_attribute_void_function_method : Warning< + "attribute %0 cannot be applied to " + "%select{functions|Objective-C method}1 without return value">; def warn_attribute_weak_on_field : Warning< "__weak attribute cannot be specified on a field declaration">; def warn_attribute_weak_on_local : Warning< @@ -1199,26 +1209,40 @@ def err_template_arg_not_integral_or_enumeral : Error< def err_template_arg_not_ice : Error< "non-type template argument of type %0 is not an integral constant " "expression">; +def err_deduced_non_type_template_arg_type_mismatch : Error< + "deduced non-type template argument does not have the same type as the " + "its corresponding template parameter (%0 vs %1)">; def err_template_arg_not_convertible : Error< "non-type template argument of type %0 cannot be converted to a value " "of type %1">; -def err_template_arg_negative : Error< - "non-type template argument provides negative value '%0' for unsigned " - "template parameter of type %1">; -def err_template_arg_too_large : Error< - "non-type template argument value '%0' is too large for template " - "parameter of type %1">; +def warn_template_arg_negative : Warning< + "non-type template argument with value '%0' converted to '%1' for unsigned " + "template parameter of type %2">; +def warn_template_arg_too_large : Warning< + "non-type template argument value '%0' truncated to '%1' for " + "template parameter of type %2">; def err_template_arg_no_ref_bind : Error< "non-type template parameter of reference type %0 cannot bind to template " "argument of type %1">; def err_template_arg_ref_bind_ignores_quals : Error< "reference binding of non-type template parameter of type %0 to template " "argument of type %1 ignores qualifiers">; +def err_template_arg_unresolved_overloaded_function : Error< + "overloaded function cannot be resolved to a non-type template parameter of " + "type %0">; def err_template_arg_not_decl_ref : Error< "non-type template argument does not refer to any declaration">; def err_template_arg_not_object_or_func_form : Error< "non-type template argument does not directly refer to an object or " "function">; +def err_template_arg_not_address_of : Error< + "non-type template argument for template parameter of pointer type %0 must " + "have its address taken">; +def err_template_arg_address_of_non_pointer : Error< + "address taken in non-type template argument for template parameter of " + "reference type %0">; +def err_template_arg_reference_var : Error< + "non-type template argument of reference type %0 is not an object">; def err_template_arg_field : Error< "non-type template argument refers to non-static data member %0">; def err_template_arg_method : Error< @@ -1251,6 +1275,8 @@ def err_template_spec_decl_function_scope : Error< "explicit specialization of %0 in function scope">; def err_template_spec_decl_class_scope : Error< "explicit specialization of %0 in class scope">; +def err_template_spec_decl_friend : Error< + "cannot declare an explicit specialization in a friend">; def err_template_spec_decl_out_of_scope_global : Error< "%select{class template|class template partial|function template|member " "function|static data member|member class}0 specialization of %1 must " @@ -1372,13 +1398,13 @@ def note_default_function_arg_instantiation_here : Note< "for '%0' required here">; def note_explicit_template_arg_substitution_here : Note< "while substituting explicitly-specified template arguments into function " - "template %f, here">; + "template %0 %1">; def note_function_template_deduction_instantiation_here : Note< - "while substituting deduced template arguments into function template %0, " - "here">; + "while substituting deduced template arguments into function template %0 " + "%1">; def note_partial_spec_deduct_instantiation_here : Note< "during template argument deduction for class template partial " - "specialization %0, here">; + "specialization %0 %1">; def note_prior_template_arg_substitution : Note< "while substituting prior template arguments into %select{non-type|template}0" " template parameter%1 %2">; @@ -1537,7 +1563,8 @@ def err_forward_ref_enum : Error< "ISO C++ forbids forward references to 'enum' types">; def err_redefinition_of_enumerator : Error<"redefinition of enumerator %0">; def err_duplicate_member : Error<"duplicate member %0">; -def err_misplaced_ivar : Error<"ivars may not be placed in categories">; +def err_misplaced_ivar : Error< + "ivars may not be placed in %select{categories|class extension}0">; def ext_enum_value_not_int : Extension< "ISO C restricts enumerator values to range of 'int' (%0 is too " "%select{small|large}1)">; @@ -1575,6 +1602,8 @@ def err_typecheck_invalid_restrict_invalid_pointee : Error< "pointer to function type %0 may not be 'restrict' qualified">; def ext_typecheck_zero_array_size : Extension< "zero size arrays are an extension">; +def err_typecheck_zero_array_size : Error< + "zero-length arrays are not permitted in C++">; def err_at_least_one_initializer_needed_to_size_array : Error< "at least one initializer value required to size array">; def err_array_size_non_int : Error<"size of array has non-integer type %0">; @@ -1664,7 +1693,7 @@ def err_field_declared_as_function : Error<"field %0 declared as a function">; def err_field_incomplete : Error<"field has incomplete type %0">; def ext_variable_sized_type_in_struct : ExtWarn< "field %0 with variable sized type %1 not at the end of a struct or class is" - " a GNU extension">; + " a GNU extension">, InGroup<GNU>; def err_flexible_array_empty_struct : Error< "flexible array %0 not allowed in otherwise empty struct">; @@ -2164,7 +2193,7 @@ def err_invalid_declarator_global_scope : Error< def err_invalid_declarator_in_function : Error< "definition or redeclaration of %0 not allowed inside a function">; def err_not_tag_in_scope : Error< - "%0 does not name a tag member in the specified scope">; + "no %select{struct|union|class|enum}0 named %1 in %2">; def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; @@ -2322,7 +2351,8 @@ def warn_typecheck_cond_pointer_integer_mismatch : ExtWarn< def err_typecheck_choose_expr_requires_constant : Error< "'__builtin_choose_expr' requires a constant expression">; def ext_typecheck_expression_not_constant_but_accepted : Extension< - "expression is not a constant, but is accepted as one by GNU extensions">; + "expression is not a constant, but is accepted as one by GNU extensions">, + InGroup<GNU>; def warn_unused_expr : Warning<"expression result unused">, InGroup<UnusedValue>; def warn_unused_property_expr : Warning< @@ -2334,6 +2364,7 @@ def warn_unused_call : Warning< def err_incomplete_type_used_in_type_trait_expr : Error< "incomplete type %0 used in type trait expression">; +def err_expected_ident_or_lparen : Error<"expected identifier or '('">; // inline asm. def err_asm_wide_character : Error<"wide string is invalid in 'asm'">; @@ -2413,9 +2444,9 @@ def err_in_class_initializer_non_constant : Error< // C++ anonymous unions and GNU anonymous structs/unions def ext_anonymous_union : Extension< - "anonymous unions are a GNU extension in C">; + "anonymous unions are a GNU extension in C">, InGroup<GNU>; def ext_anonymous_struct : Extension< - "anonymous structs are a GNU extension">; + "anonymous structs are a GNU extension">, InGroup<GNU>; def err_anonymous_union_not_static : Error< "anonymous unions at namespace or global scope must be declared 'static'">; def err_anonymous_union_with_storage_spec : Error< @@ -2584,6 +2615,9 @@ def warn_printf_missing_format_string : Warning< def warn_printf_conversion_argument_type_mismatch : Warning< "conversion specifies type %0 but the argument has type %1">, InGroup<Format>; +def warn_printf_positional_arg_exceeds_data_args : Warning < + "data argument position '%0' exceeds the number of data arguments (%1)">, + InGroup<Format>; def warn_printf_zero_positional_specifier : Warning< "position arguments in format strings start counting at 1 (not 0)">, InGroup<Format>; diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h index fb861dcf934d..89fae87ae8ef 100644 --- a/include/clang/Basic/PartialDiagnostic.h +++ b/include/clang/Basic/PartialDiagnostic.h @@ -15,19 +15,18 @@ #ifndef LLVM_CLANG_PARTIALDIAGNOSTIC_H #define LLVM_CLANG_PARTIALDIAGNOSTIC_H -#include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/System/DataTypes.h" +#include <cassert> namespace clang { -class DeclarationName; - class PartialDiagnostic { +public: struct Storage { - Storage() : NumDiagArgs(0), NumDiagRanges(0), NumCodeModificationHints(0) { - } + Storage() : NumDiagArgs(0), NumDiagRanges(0), NumFixItHints(0) { } enum { /// MaxArguments - The maximum number of arguments we can hold. We @@ -44,8 +43,8 @@ class PartialDiagnostic { unsigned char NumDiagRanges; /// \brief The number of code modifications hints in the - /// CodeModificationHints array. - unsigned char NumCodeModificationHints; + /// FixItHints array. + unsigned char NumFixItHints; /// DiagArgumentsKind - This is an array of ArgumentKind::ArgumentKind enum /// values, with one for each argument. This specifies whether the argument @@ -62,13 +61,49 @@ class PartialDiagnostic { /// only support 10 ranges, could easily be extended if needed. SourceRange DiagRanges[10]; - enum { MaxCodeModificationHints = 3 }; + enum { MaxFixItHints = 3 }; - /// CodeModificationHints - If valid, provides a hint with some code + /// FixItHints - If valid, provides a hint with some code /// to insert, remove, or modify at a particular position. - CodeModificationHint CodeModificationHints[MaxCodeModificationHints]; + FixItHint FixItHints[MaxFixItHints]; }; + /// \brief An allocator for Storage objects, which uses a small cache to + /// objects, used to reduce malloc()/free() traffic for partial diagnostics. + class StorageAllocator { + static const unsigned NumCached = 4; + Storage Cached[NumCached]; + Storage *FreeList[NumCached]; + unsigned NumFreeListEntries; + + public: + StorageAllocator(); + ~StorageAllocator(); + + /// \brief Allocate new storage. + Storage *Allocate() { + if (NumFreeListEntries == 0) + return new Storage; + + Storage *Result = FreeList[--NumFreeListEntries]; + Result->NumDiagArgs = 0; + Result->NumDiagRanges = 0; + Result->NumFixItHints = 0; + return Result; + } + + /// \brief Free the given storage object. + void Deallocate(Storage *S) { + if (S >= Cached && S <= Cached + NumCached) { + FreeList[NumFreeListEntries++] = S; + return; + } + + delete S; + } + }; + +private: // NOTE: Sema assumes that PartialDiagnostic is location-invariant // in the sense that its bits can be safely memcpy'ed and destructed // in the new location. @@ -76,22 +111,40 @@ class PartialDiagnostic { /// DiagID - The diagnostic ID. mutable unsigned DiagID; - /// DiagStorare - Storge for args and ranges. + /// DiagStorage - Storage for args and ranges. mutable Storage *DiagStorage; - void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const { - if (!DiagStorage) + /// \brief Allocator used to allocate storage for this diagnostic. + StorageAllocator *Allocator; + + /// \brief Retrieve storage for this particular diagnostic. + Storage *getStorage() const { + if (DiagStorage) + return DiagStorage; + + if (Allocator) + DiagStorage = Allocator->Allocate(); + else { + assert(Allocator != reinterpret_cast<StorageAllocator *>(~uintptr_t(0))); DiagStorage = new Storage; + } + return DiagStorage; + } + + void freeStorage() { + if (!DiagStorage) + return; - assert(DiagStorage->NumDiagArgs < Storage::MaxArguments && - "Too many arguments to diagnostic!"); - DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = Kind; - DiagStorage->DiagArgumentsVal[DiagStorage->NumDiagArgs++] = V; + if (Allocator) + Allocator->Deallocate(DiagStorage); + else if (Allocator != reinterpret_cast<StorageAllocator *>(~uintptr_t(0))) + delete DiagStorage; + DiagStorage = 0; } - + void AddSourceRange(const SourceRange &R) const { if (!DiagStorage) - DiagStorage = new Storage; + DiagStorage = getStorage(); assert(DiagStorage->NumDiagRanges < llvm::array_lengthof(DiagStorage->DiagRanges) && @@ -99,53 +152,70 @@ class PartialDiagnostic { DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R; } - void AddCodeModificationHint(const CodeModificationHint &Hint) const { + void AddFixItHint(const FixItHint &Hint) const { if (Hint.isNull()) return; if (!DiagStorage) - DiagStorage = new Storage; + DiagStorage = getStorage(); - assert(DiagStorage->NumCodeModificationHints < - Storage::MaxCodeModificationHints && + assert(DiagStorage->NumFixItHints < Storage::MaxFixItHints && "Too many code modification hints!"); - DiagStorage->CodeModificationHints[DiagStorage->NumCodeModificationHints++] + DiagStorage->FixItHints[DiagStorage->NumFixItHints++] = Hint; } public: - PartialDiagnostic(unsigned DiagID) - : DiagID(DiagID), DiagStorage(0) { } - + PartialDiagnostic(unsigned DiagID, StorageAllocator &Allocator) + : DiagID(DiagID), DiagStorage(0), Allocator(&Allocator) { } + PartialDiagnostic(const PartialDiagnostic &Other) - : DiagID(Other.DiagID), DiagStorage(0) + : DiagID(Other.DiagID), DiagStorage(0), Allocator(Other.Allocator) { - if (Other.DiagStorage) - DiagStorage = new Storage(*Other.DiagStorage); + if (Other.DiagStorage) { + DiagStorage = getStorage(); + *DiagStorage = *Other.DiagStorage; + } } + PartialDiagnostic(const PartialDiagnostic &Other, Storage *DiagStorage) + : DiagID(Other.DiagID), DiagStorage(DiagStorage), + Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0))) + { + if (Other.DiagStorage) + *this->DiagStorage = *Other.DiagStorage; + } + PartialDiagnostic &operator=(const PartialDiagnostic &Other) { DiagID = Other.DiagID; if (Other.DiagStorage) { - if (DiagStorage) - *DiagStorage = *Other.DiagStorage; - else - DiagStorage = new Storage(*Other.DiagStorage); + if (!DiagStorage) + DiagStorage = getStorage(); + + *DiagStorage = *Other.DiagStorage; } else { - delete DiagStorage; - DiagStorage = 0; + freeStorage(); } return *this; } ~PartialDiagnostic() { - delete DiagStorage; + freeStorage(); } - unsigned getDiagID() const { return DiagID; } + void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const { + if (!DiagStorage) + DiagStorage = getStorage(); + + assert(DiagStorage->NumDiagArgs < Storage::MaxArguments && + "Too many arguments to diagnostic!"); + DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = Kind; + DiagStorage->DiagArgumentsVal[DiagStorage->NumDiagArgs++] = V; + } + void Emit(const DiagnosticBuilder &DB) const { if (!DiagStorage) return; @@ -161,17 +231,19 @@ public: DB.AddSourceRange(DiagStorage->DiagRanges[i]); // Add all code modification hints - for (unsigned i = 0, e = DiagStorage->NumCodeModificationHints; i != e; ++i) - DB.AddCodeModificationHint(DiagStorage->CodeModificationHints[i]); + for (unsigned i = 0, e = DiagStorage->NumFixItHints; i != e; ++i) + DB.AddFixItHint(DiagStorage->FixItHints[i]); } - friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - QualType T) { - PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()), - Diagnostic::ak_qualtype); - return PD; + /// \brief Clear out this partial diagnostic, giving it a new diagnostic ID + /// and removing all of its arguments, ranges, and fix-it hints. + void Reset(unsigned DiagID = 0) { + this->DiagID = DiagID; + freeStorage(); } - + + bool hasStorage() const { return DiagStorage != 0; } + friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, unsigned I) { PD.AddTaggedVal(I, Diagnostic::ak_uint); @@ -197,20 +269,13 @@ public: } friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - DeclarationName N); - - friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, - const CodeModificationHint &Hint) { - PD.AddCodeModificationHint(Hint); + const FixItHint &Hint) { + PD.AddFixItHint(Hint); return PD; } }; -inline PartialDiagnostic PDiag(unsigned DiagID = 0) { - return PartialDiagnostic(DiagID); -} - inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, const PartialDiagnostic &PD) { PD.Emit(DB); @@ -219,4 +284,4 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, } // end namespace clang -#endif +#endif diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index f7ea331e1cc7..555e6f5a919a 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -28,7 +28,6 @@ namespace llvm { namespace clang { class SourceManager; -class FileEntry; /// FileID - This is an opaque identifier used by SourceManager which refers to /// a source file (MemoryBuffer) along with its #include path and #line data. |