diff options
Diffstat (limited to 'include')
33 files changed, 396 insertions, 82 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 91b3d11a549a..417ac9fd369a 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 41 +#define CINDEX_VERSION_MINOR 43 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -1234,7 +1234,12 @@ enum CXTranslationUnit_Flags { * purposes of an IDE, this is undesirable behavior and as much information * as possible should be reported. Use this flag to enable this behavior. */ - CXTranslationUnit_KeepGoing = 0x200 + CXTranslationUnit_KeepGoing = 0x200, + + /** + * \brief Sets the preprocessor in a mode for parsing a single file only. + */ + CXTranslationUnit_SingleFileParse = 0x400 }; /** @@ -3417,6 +3422,16 @@ CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); /** + * \brief Returns the address space of the given type. + */ +CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T); + +/** + * \brief Returns the typedef name of the given type. + */ +CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT); + +/** * \brief For pointer types, returns the type of the pointee. */ CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 4f8042ac9291..9d49bac26a86 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -851,6 +851,7 @@ protected: class NonParmVarDeclBitfields { friend class VarDecl; + friend class ImplicitParamDecl; friend class ASTDeclReader; unsigned : NumVarDeclBits; @@ -894,6 +895,10 @@ protected: /// declared in the same block scope. This controls whether we should merge /// the type of this declaration with its previous declaration. unsigned PreviousDeclInSameBlockScope : 1; + + /// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or + /// something else. + unsigned ImplicitParamKind : 3; }; union { @@ -1376,20 +1381,50 @@ public: class ImplicitParamDecl : public VarDecl { void anchor() override; + public: + /// Defines the kind of the implicit parameter: is this an implicit parameter + /// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured + /// context or something else. + enum ImplicitParamKind : unsigned { + ObjCSelf, /// Parameter for Objective-C 'self' argument + ObjCCmd, /// Parameter for Objective-C '_cmd' argument + CXXThis, /// Parameter for C++ 'this' argument + CXXVTT, /// Parameter for C++ virtual table pointers + CapturedContext, /// Parameter for captured context + Other, /// Other implicit parameter + }; + + /// Create implicit parameter. static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, - QualType T); + QualType T, ImplicitParamKind ParamKind); + static ImplicitParamDecl *Create(ASTContext &C, QualType T, + ImplicitParamKind ParamKind); static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID); ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, - IdentifierInfo *Id, QualType Type) - : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, - /*tinfo*/ nullptr, SC_None) { + IdentifierInfo *Id, QualType Type, + ImplicitParamKind ParamKind) + : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, + /*TInfo=*/nullptr, SC_None) { + NonParmVarDeclBits.ImplicitParamKind = ParamKind; + setImplicit(); + } + + ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind) + : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(), + SourceLocation(), /*Id=*/nullptr, Type, + /*TInfo=*/nullptr, SC_None) { + NonParmVarDeclBits.ImplicitParamKind = ParamKind; setImplicit(); } + /// Returns the implicit parameter kind. + ImplicitParamKind getParameterKind() const { + return static_cast<ImplicitParamKind>(NonParmVarDeclBits.ImplicitParamKind); + } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ImplicitParam; } @@ -1829,14 +1864,15 @@ public: return getBody(Definition); } - /// isThisDeclarationADefinition - Returns whether this specific - /// declaration of the function is also a definition. This does not - /// determine whether the function has been defined (e.g., in a - /// previous definition); for that information, use isDefined. Note - /// that this returns false for a defaulted function unless that function - /// has been implicitly defined (possibly as deleted). + /// Returns whether this specific declaration of the function is also a + /// definition that does not contain uninstantiated body. + /// + /// This does not determine whether the function has been defined (e.g., in a + /// previous definition); for that information, use isDefined. + /// bool isThisDeclarationADefinition() const { - return IsDeleted || Body || IsLateTemplateParsed; + return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed || + hasDefiningAttr(); } /// doesThisDeclarationHaveABody - Returns whether this specific diff --git a/include/clang/AST/ExternalASTMerger.h b/include/clang/AST/ExternalASTMerger.h index 55459df1fe6b..92d7b39c48d2 100644 --- a/include/clang/AST/ExternalASTMerger.h +++ b/include/clang/AST/ExternalASTMerger.h @@ -45,6 +45,8 @@ public: llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl<Decl *> &Result) override; + using ExternalASTSource::CompleteType; + void CompleteType(TagDecl *Tag) override; }; diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index cd2a39449825..ad3f40d0d3f6 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -1021,8 +1021,12 @@ DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, { DEF_TRAVERSE_TYPE(RecordType, {}) DEF_TRAVERSE_TYPE(EnumType, {}) DEF_TRAVERSE_TYPE(TemplateTypeParmType, {}) -DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {}) -DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {}) +DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, { + TRY_TO(TraverseType(T->getReplacementType())); +}) +DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, { + TRY_TO(TraverseTemplateArgument(T->getArgumentPack())); +}) DEF_TRAVERSE_TYPE(TemplateSpecializationType, { TRY_TO(TraverseTemplateName(T->getTemplateName())); @@ -1249,8 +1253,12 @@ DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, { DEF_TRAVERSE_TYPELOC(RecordType, {}) DEF_TRAVERSE_TYPELOC(EnumType, {}) DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {}) -DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {}) -DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {}) +DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, { + TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType())); +}) +DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, { + TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack())); +}) // FIXME: use the loc for the template name? DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, { diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 0ab8d5fe4fc1..cba4c99be959 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -3806,14 +3806,22 @@ AST_MATCHER_P(CompoundStmt, statementCountIs, unsigned, N) { return Node.size() == N; } -/// \brief Matches literals that are equal to the given value. +/// \brief Matches literals that are equal to the given value of type ValueT. /// -/// Example matches true (matcher = cxxBoolLiteral(equals(true))) +/// Given /// \code -/// true +/// f('\0', false, 3.14, 42); /// \endcode +/// characterLiteral(equals(0)) +/// matches '\0' +/// cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) +/// match false +/// floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) +/// match 3.14 +/// integerLiteral(equals(42)) +/// matches 42 /// -/// Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteral>, +/// Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>, /// Matcher<FloatingLiteral>, Matcher<IntegerLiteral> template <typename ValueT> internal::PolymorphicMatcherWithParam1<internal::ValueEqualsMatcher, ValueT> @@ -3823,6 +3831,34 @@ equals(const ValueT &Value) { ValueT>(Value); } +AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals, + AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, + CXXBoolLiteralExpr, + IntegerLiteral), + bool, Value, 0) { + return internal::ValueEqualsMatcher<NodeType, ParamT>(Value) + .matchesNode(Node); +} + +AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals, + AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, + CXXBoolLiteralExpr, + IntegerLiteral), + unsigned, Value, 1) { + return internal::ValueEqualsMatcher<NodeType, ParamT>(Value) + .matchesNode(Node); +} + +AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals, + AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, + CXXBoolLiteralExpr, + FloatingLiteral, + IntegerLiteral), + double, Value, 2) { + return internal::ValueEqualsMatcher<NodeType, ParamT>(Value) + .matchesNode(Node); +} + /// \brief Matches the operator Name of operator expressions (binary or /// unary). /// diff --git a/include/clang/ASTMatchers/Dynamic/Diagnostics.h b/include/clang/ASTMatchers/Dynamic/Diagnostics.h index 2c76ddaa07d9..908fa0db622d 100644 --- a/include/clang/ASTMatchers/Dynamic/Diagnostics.h +++ b/include/clang/ASTMatchers/Dynamic/Diagnostics.h @@ -76,7 +76,7 @@ public: ET_ParserInvalidToken = 106, ET_ParserMalformedBindExpr = 107, ET_ParserTrailingCode = 108, - ET_ParserUnsignedError = 109, + ET_ParserNumberError = 109, ET_ParserOverloadedType = 110 }; diff --git a/include/clang/ASTMatchers/Dynamic/Parser.h b/include/clang/ASTMatchers/Dynamic/Parser.h index 76926f09dbcb..5ec4a9abf4bf 100644 --- a/include/clang/ASTMatchers/Dynamic/Parser.h +++ b/include/clang/ASTMatchers/Dynamic/Parser.h @@ -19,8 +19,10 @@ /// \code /// Grammar for the expressions supported: /// <Expression> := <Literal> | <NamedValue> | <MatcherExpression> -/// <Literal> := <StringLiteral> | <Unsigned> +/// <Literal> := <StringLiteral> | <Boolean> | <Double> | <Unsigned> /// <StringLiteral> := "quoted string" +/// <Boolean> := true | false +/// <Double> := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+ /// <Unsigned> := [0-9]+ /// <NamedValue> := <Identifier> /// <MatcherExpression> := <Identifier>(<ArgumentList>) | diff --git a/include/clang/ASTMatchers/Dynamic/VariantValue.h b/include/clang/ASTMatchers/Dynamic/VariantValue.h index c5426dd75ef5..f9efe0f16f43 100644 --- a/include/clang/ASTMatchers/Dynamic/VariantValue.h +++ b/include/clang/ASTMatchers/Dynamic/VariantValue.h @@ -35,6 +35,8 @@ class ArgKind { public: enum Kind { AK_Matcher, + AK_Boolean, + AK_Double, AK_Unsigned, AK_String }; @@ -241,6 +243,8 @@ struct VariantMatcher::TypedMatcherOps final : VariantMatcher::MatcherOps { /// copy/assignment. /// /// Supported types: +/// - \c bool +// - \c double /// - \c unsigned /// - \c llvm::StringRef /// - \c VariantMatcher (\c DynTypedMatcher / \c Matcher<T>) @@ -253,14 +257,29 @@ public: VariantValue &operator=(const VariantValue &Other); /// \brief Specific constructors for each supported type. + VariantValue(bool Boolean); + VariantValue(double Double); VariantValue(unsigned Unsigned); VariantValue(StringRef String); VariantValue(const VariantMatcher &Matchers); + /// \brief Constructs an \c unsigned value (disambiguation from bool). + VariantValue(int Signed) : VariantValue(static_cast<unsigned>(Signed)) {} + /// \brief Returns true iff this is not an empty value. explicit operator bool() const { return hasValue(); } bool hasValue() const { return Type != VT_Nothing; } + /// \brief Boolean value functions. + bool isBoolean() const; + bool getBoolean() const; + void setBoolean(bool Boolean); + + /// \brief Double value functions. + bool isDouble() const; + double getDouble() const; + void setDouble(double Double); + /// \brief Unsigned value functions. bool isUnsigned() const; unsigned getUnsigned() const; @@ -303,6 +322,8 @@ private: /// \brief All supported value types. enum ValueType { VT_Nothing, + VT_Boolean, + VT_Double, VT_Unsigned, VT_String, VT_Matcher @@ -311,6 +332,8 @@ private: /// \brief All supported value types. union AllValues { unsigned Unsigned; + double Double; + bool Boolean; std::string *String; VariantMatcher *Matcher; }; diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 9da2cc376d54..bc36fd8c8297 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -1683,6 +1683,42 @@ def Section : InheritableAttr { let Documentation = [SectionDocs]; } +def PragmaClangBSSSection : InheritableAttr { + // This attribute has no spellings as it is only ever created implicitly. + let Spellings = []; + let Args = [StringArgument<"Name">]; + let Subjects = SubjectList<[GlobalVar], ErrorDiag, + "ExpectedFunctionMethodOrGlobalVar">; + let Documentation = [Undocumented]; +} + +def PragmaClangDataSection : InheritableAttr { + // This attribute has no spellings as it is only ever created implicitly. + let Spellings = []; + let Args = [StringArgument<"Name">]; + let Subjects = SubjectList<[GlobalVar], ErrorDiag, + "ExpectedFunctionMethodOrGlobalVar">; + let Documentation = [Undocumented]; +} + +def PragmaClangRodataSection : InheritableAttr { + // This attribute has no spellings as it is only ever created implicitly. + let Spellings = []; + let Args = [StringArgument<"Name">]; + let Subjects = SubjectList<[GlobalVar], ErrorDiag, + "ExpectedFunctionMethodOrGlobalVar">; + let Documentation = [Undocumented]; +} + +def PragmaClangTextSection : InheritableAttr { + // This attribute has no spellings as it is only ever created implicitly. + let Spellings = []; + let Args = [StringArgument<"Name">]; + let Subjects = SubjectList<[Function], ErrorDiag, + "ExpectedFunctionMethodOrGlobalVar">; + let Documentation = [Undocumented]; +} + def Sentinel : InheritableAttr { let Spellings = [GCC<"sentinel">]; let Args = [DefaultIntArgument<"Sentinel", 0>, diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 1267f8d09f58..8b4cb47e545d 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -196,6 +196,7 @@ def err_no_submodule_suggest : Error< "no submodule named %0 in module '%1'; did you mean '%2'?">; def warn_missing_submodule : Warning<"missing submodule '%0'">, InGroup<IncompleteUmbrella>; +def note_module_import_here : Note<"module imported here">; def err_module_cannot_create_includes : Error< "cannot create includes file for module %0: %1">; def warn_module_config_macro_undef : Warning< diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 447f06945660..d6de5c04a74d 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -527,6 +527,10 @@ def err_pp_module_end_without_module_begin : Error< "'#pragma clang module end'">; def note_pp_module_begin_here : Note< "entering module '%0' due to this pragma">; +def err_pp_module_build_pth : Error< + "'#pragma clang module build' not supported in pretokenized header">; +def err_pp_module_build_missing_end : Error< + "no matching '#pragma clang module endbuild' for this '#pragma clang module build'">; def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">; def err_paste_at_start : Error< diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index f04ed8ed4ce6..f39ffeae61f4 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -887,9 +887,18 @@ def warn_pragma_expected_rparen : Warning< "missing ')' after '#pragma %0' - ignoring">, InGroup<IgnoredPragmas>; def warn_pragma_expected_identifier : Warning< "expected identifier in '#pragma %0' - ignored">, InGroup<IgnoredPragmas>; + +// '#pragma clang section' related errors +def err_pragma_expected_clang_section_name : Error< + "expected one of [bss|data|rodata|text] section kind in '#pragma %0'">; +def err_pragma_clang_section_expected_equal : Error< + "expected '=' following '#pragma clang section %select{invalid|bss|data|rodata|text}0'">; +def err_pragma_clang_section_expected_name_or_clear : Error< + "expected section name or '\"\"' following '#pragma clang section %select{invalid|bss|data|rodata|text}0'">; def warn_pragma_expected_section_name : Warning< "expected a string literal for the section name in '#pragma %0' - ignored">, InGroup<IgnoredPragmas>; + def warn_pragma_expected_section_push_pop_or_name : Warning< "expected push, pop or a string literal for the section name in '#pragma %0' - ignored">, InGroup<IgnoredPragmas>; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index a5a5c74afe69..aa73a6934518 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5613,6 +5613,11 @@ def err_enumerator_does_not_exist : Error< def note_enum_specialized_here : Note< "enum %0 was explicitly specialized here">; +def err_specialization_not_primary_template : Error< + "cannot reference member of primary template because deduced class " + "template specialization %0 is %select{instantiated from a partial|" + "an explicit}1 specialization">; + def err_member_redeclared : Error<"class member cannot be redeclared">; def ext_member_redeclared : ExtWarn<"class member cannot be redeclared">, InGroup<RedeclaredClassMember>; diff --git a/include/clang/Basic/DiagnosticSerializationKinds.td b/include/clang/Basic/DiagnosticSerializationKinds.td index f9e7b8fa9b56..7c9e8c8980aa 100644 --- a/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/include/clang/Basic/DiagnosticSerializationKinds.td @@ -174,6 +174,15 @@ def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found " "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|" "method %2 with %ordinal3 parameter named %4}1">; +def err_module_odr_violation_mismatch_decl_unknown : Error< + "%q0 %select{with definition in module '%2'|defined here}1 has different " + "definitions in different modules; first difference is this " + "%select{||||static assert|field|method|unexpected decl}3">; +def note_module_odr_violation_mismatch_decl_unknown : Note< + "but in '%0' found " + "%select{||||different static assert|different field|different method|" + "another unexpected decl}1">; + def warn_duplicate_module_file_extension : Warning< "duplicate module file extension block name '%0'">, InGroup<ModuleFileExtension>; diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 2513de70e721..8488515d2b67 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -58,6 +58,7 @@ public: SOB_Trapping // -ftrapv }; + // FIXME: Unify with TUKind. enum CompilingModuleKind { CMK_None, ///< Not compiling a module interface at all. CMK_ModuleMap, ///< Compiling a module from a module map. diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index eda802934006..5e01f6416748 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -722,6 +722,10 @@ public: void clearIDTables(); + /// Initialize this source manager suitably to replay the compilation + /// described by \p Old. Requires that \p Old outlive \p *this. + void initializeForReplay(const SourceManager &Old); + DiagnosticsEngine &getDiagnostics() const { return Diag; } FileManager &getFileManager() const { return FileMgr; } diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 12e36cc52b0b..6c51976e98fe 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -932,6 +932,10 @@ def frewrite_includes : Flag<["-"], "frewrite-includes">, Group<f_Group>, Flags<[CC1Option]>; def fno_rewrite_includes : Flag<["-"], "fno-rewrite-includes">, Group<f_Group>; +def frewrite_imports : Flag<["-"], "frewrite-imports">, Group<f_Group>, + Flags<[CC1Option]>; +def fno_rewrite_imports : Flag<["-"], "fno-rewrite-imports">, Group<f_Group>; + def frewrite_map_file : Separate<["-"], "frewrite-map-file">, Group<f_Group>, Flags<[ DriverOption, CC1Option ]>; @@ -2001,6 +2005,10 @@ def mdspr2 : Flag<["-"], "mdspr2">, Group<m_Group>; def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group<m_Group>; def msingle_float : Flag<["-"], "msingle-float">, Group<m_Group>; def mdouble_float : Flag<["-"], "mdouble-float">, Group<m_Group>; +def mmadd4 : Flag<["-"], "mmadd4">, Group<m_Group>, + HelpText<"Enable the generation of 4-operand madd.s, madd.d and related instructions.">; +def mno_madd4 : Flag<["-"], "mno-madd4">, Group<m_Group>, + HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; def mmsa : Flag<["-"], "mmsa">, Group<m_Group>, HelpText<"Enable MSA ASE (MIPS only)">; def mno_msa : Flag<["-"], "mno-msa">, Group<m_Group>, diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h index b082e4e0a3df..970791420734 100644 --- a/include/clang/Edit/EditedSource.h +++ b/include/clang/Edit/EditedSource.h @@ -41,9 +41,11 @@ class EditedSource { typedef std::map<FileOffset, FileEdit> FileEditsTy; FileEditsTy FileEdits; - llvm::DenseMap<unsigned, llvm::TinyPtrVector<IdentifierInfo*>> + // Location of argument use inside the macro body + typedef std::pair<IdentifierInfo*, SourceLocation> MacroArgUse; + llvm::DenseMap<unsigned, SmallVector<MacroArgUse, 2>> ExpansionToArgMap; - SmallVector<std::pair<SourceLocation, IdentifierInfo*>, 2> + SmallVector<std::pair<SourceLocation, MacroArgUse>, 2> CurrCommitMacroArgExps; IdentifierTable IdentTable; @@ -84,7 +86,7 @@ private: FileEditsTy::iterator getActionForOffset(FileOffset Offs); void deconstructMacroArgLoc(SourceLocation Loc, SourceLocation &ExpansionLoc, - IdentifierInfo *&II); + MacroArgUse &ArgUse); void startingCommit(); void finishedCommit(); diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index fb0a5e8acd4a..ae54d4151415 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -51,8 +51,10 @@ class DiagnosticsEngine; class FileEntry; class FileManager; class HeaderSearch; +class InputKind; class MemoryBufferCache; class Preprocessor; +class PreprocessorOptions; class PCHContainerOperations; class PCHContainerReader; class TargetInfo; @@ -65,7 +67,7 @@ class FileSystem; /// \brief Utility class for loading a ASTContext from an AST file. /// -class ASTUnit : public ModuleLoader { +class ASTUnit { public: struct StandaloneFixIt { std::pair<unsigned, unsigned> RemoveRange; @@ -96,6 +98,7 @@ private: IntrusiveRefCntPtr<ASTContext> Ctx; std::shared_ptr<TargetOptions> TargetOpts; std::shared_ptr<HeaderSearchOptions> HSOpts; + std::shared_ptr<PreprocessorOptions> PPOpts; IntrusiveRefCntPtr<ASTReader> Reader; bool HadModuleLoaderFatalFailure; @@ -116,10 +119,13 @@ private: /// LoadFromCommandLine available. std::shared_ptr<CompilerInvocation> Invocation; + /// Fake module loader: the AST unit doesn't need to load any modules. + TrivialModuleLoader ModuleLoader; + // OnlyLocalDecls - when true, walking this AST should only visit declarations // that come from the AST itself, not from included precompiled headers. // FIXME: This is temporary; eventually, CIndex will always do this. - bool OnlyLocalDecls; + bool OnlyLocalDecls; /// \brief Whether to capture any diagnostics produced. bool CaptureDiagnostics; @@ -185,6 +191,14 @@ private: /// some number of calls. unsigned PreambleRebuildCounter; + /// \brief Cache pairs "filename - source location" + /// + /// Cache contains only source locations from preamble so it is + /// guaranteed that they stay valid when the SourceManager is recreated. + /// This cache is used when loading preambule to increase performance + /// of that loading. It must be cleared when preamble is recreated. + llvm::StringMap<SourceLocation> PreambleSrcLocCache; + public: class PreambleData { const FileEntry *File; @@ -305,9 +319,6 @@ private: /// (likely to change while trying to use them). bool UserFilesAreVolatile : 1; - /// \brief The language options used when we load an AST file. - LangOptions ASTFileLangOpts; - static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags, ASTUnit &AST, bool CaptureDiagnostics); @@ -488,7 +499,7 @@ public: }; friend class ConcurrencyCheck; - ~ASTUnit() override; + ~ASTUnit(); bool isMainFileAST() const { return MainFileIsAST; } @@ -518,9 +529,19 @@ public: } const LangOptions &getLangOpts() const { - assert(LangOpts && " ASTUnit does not have language options"); + assert(LangOpts && "ASTUnit does not have language options"); return *LangOpts; } + + const HeaderSearchOptions &getHeaderSearchOpts() const { + assert(HSOpts && "ASTUnit does not have header search options"); + return *HSOpts; + } + + const PreprocessorOptions &getPreprocessorOpts() const { + assert(PPOpts && "ASTUnit does not have preprocessor options"); + return *PPOpts; + } const FileManager &getFileManager() const { return *FileMgr; } FileManager &getFileManager() { return *FileMgr; } @@ -702,6 +723,9 @@ public: /// \brief Determine what kind of translation unit this AST represents. TranslationUnitKind getTranslationUnitKind() const { return TUKind; } + /// \brief Determine the input kind this AST unit represents. + InputKind getInputKind() const; + /// \brief A mapping from a file name to the memory buffer that stores the /// remapped contents of that file. typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile; @@ -858,6 +882,7 @@ public: bool CacheCodeCompletionResults = false, bool IncludeBriefCommentsInCodeCompletion = false, bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, + bool SingleFileParse = false, bool UserFilesAreVolatile = false, bool ForSerialization = false, llvm::Optional<StringRef> ModuleFormat = llvm::None, std::unique_ptr<ASTUnit> *ErrAST = nullptr, @@ -923,21 +948,6 @@ public: /// /// \returns True if an error occurred, false otherwise. bool serialize(raw_ostream &OS); - - ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, - Module::NameVisibilityKind Visibility, - bool IsInclusionDirective) override { - // ASTUnit doesn't know how to load modules (not that this matters). - return ModuleLoadResult(); - } - - void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, - SourceLocation ImportLoc) override {} - - GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override - { return nullptr; } - bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override - { return 0; } }; } // namespace clang diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def index d7cd805fa10a..f3deb05ec6df 100644 --- a/include/clang/Frontend/CodeGenOptions.def +++ b/include/clang/Frontend/CodeGenOptions.def @@ -29,7 +29,8 @@ CODEGENOPT(Name, Bits, Default) #endif CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as -CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections +ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2, + llvm::DebugCompressionType::None) CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm. CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments. diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 4f7149fcb8b3..5b5c75298a31 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -136,6 +136,13 @@ class CompilerInstance : public ModuleLoader { /// along with the module map llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules; + /// \brief The set of top-level modules that has already been built on the + /// fly as part of this overall compilation action. + std::map<std::string, std::string> BuiltModules; + + /// Should we delete the BuiltModules when we're done? + bool DeleteBuiltModules = true; + /// \brief The location of the module-import keyword for the last module /// import. SourceLocation LastModuleImportLoc; @@ -773,6 +780,9 @@ public: Module::NameVisibilityKind Visibility, bool IsInclusionDirective) override; + void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName, + StringRef Source) override; + void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc) override; diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h index 8d690a448f85..7ae6173512a6 100644 --- a/include/clang/Frontend/FrontendAction.h +++ b/include/clang/Frontend/FrontendAction.h @@ -76,8 +76,7 @@ protected: /// /// \return True on success; on failure ExecutionAction() and /// EndSourceFileAction() will not be called. - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) { + virtual bool BeginSourceFileAction(CompilerInstance &CI) { return true; } @@ -176,10 +175,10 @@ public: virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; } /// \brief Does this action support use with PCH? - virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); } + virtual bool hasPCHSupport() const { return true; } /// \brief Does this action support use with AST files? - virtual bool hasASTFileSupport() const { return !usesPreprocessorOnly(); } + virtual bool hasASTFileSupport() const { return true; } /// \brief Does this action support use with IR files? virtual bool hasIRSupport() const { return false; } @@ -291,7 +290,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; bool BeginInvocation(CompilerInstance &CI) override; - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; void EndSourceFileAction() override; diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h index cb4498514955..84db293c46f3 100644 --- a/include/clang/Frontend/FrontendActions.h +++ b/include/clang/Frontend/FrontendActions.h @@ -91,7 +91,7 @@ public: ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile, std::string &Sysroot, std::string &OutputFile); - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; }; class GenerateModuleAction : public ASTFrontendAction { @@ -111,15 +111,13 @@ protected: class GenerateModuleFromModuleMapAction : public GenerateModuleAction { private: - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; - std::unique_ptr<raw_pwrite_stream> CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; }; class GenerateModuleInterfaceAction : public GenerateModuleAction { private: - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; std::unique_ptr<raw_pwrite_stream> CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; @@ -181,8 +179,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; void EndSourceFileAction() override; diff --git a/include/clang/Frontend/PreprocessorOutputOptions.h b/include/clang/Frontend/PreprocessorOutputOptions.h index 3261b6653809..94afcd06a398 100644 --- a/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/include/clang/Frontend/PreprocessorOutputOptions.h @@ -24,6 +24,7 @@ public: unsigned ShowMacros : 1; ///< Print macro definitions. unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output. unsigned RewriteIncludes : 1; ///< Preprocess include directives only. + unsigned RewriteImports : 1; ///< Include contents of transitively-imported modules. public: PreprocessorOutputOptions() { @@ -35,6 +36,7 @@ public: ShowMacros = 0; ShowIncludeDirectives = 0; RewriteIncludes = 0; + RewriteImports = 0; } }; diff --git a/include/clang/Lex/ModuleLoader.h b/include/clang/Lex/ModuleLoader.h index 70770d17e9ff..ee0638b57f87 100644 --- a/include/clang/Lex/ModuleLoader.h +++ b/include/clang/Lex/ModuleLoader.h @@ -109,6 +109,16 @@ public: Module::NameVisibilityKind Visibility, bool IsInclusionDirective) = 0; + /// Attempt to load the given module from the specified source buffer. Does + /// not make any submodule visible; for that, use loadModule or + /// makeModuleVisible. + /// + /// \param Loc The location at which the module was loaded. + /// \param ModuleName The name of the module to build. + /// \param Source The source of the module: a (preprocessed) module map. + virtual void loadModuleFromSource(SourceLocation Loc, StringRef ModuleName, + StringRef Source) = 0; + /// \brief Make the given module visible. virtual void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, @@ -136,6 +146,30 @@ public: bool HadFatalFailure; }; + +/// A module loader that doesn't know how to load modules. +class TrivialModuleLoader : public ModuleLoader { +public: + ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, + Module::NameVisibilityKind Visibility, + bool IsInclusionDirective) override { + return ModuleLoadResult(); + } + + void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName, + StringRef Source) override {} + + void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, + SourceLocation ImportLoc) override {} + + GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override { + return nullptr; + } + bool lookupMissingImports(StringRef Name, + SourceLocation TriggerLoc) override { + return 0; + } +}; } diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index aeca83a90716..302d006ea16c 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -1954,6 +1954,13 @@ private: void HandleMicrosoftImportDirective(Token &Tok); public: + /// Check that the given module is available, producing a diagnostic if not. + /// \return \c true if the check failed (because the module is not available). + /// \c false if the module appears to be usable. + static bool checkModuleIsAvailable(const LangOptions &LangOpts, + const TargetInfo &TargetInfo, + DiagnosticsEngine &Diags, Module *M); + // Module inclusion testing. /// \brief Find the module that owns the source or header file that /// \p Loc points to. If the location is in a file that was included @@ -2021,6 +2028,7 @@ public: void HandlePragmaPushMacro(Token &Tok); void HandlePragmaPopMacro(Token &Tok); void HandlePragmaIncludeAlias(Token &Tok); + void HandlePragmaModuleBuild(Token &Tok); IdentifierInfo *ParsePragmaPushOrPopMacro(Token &Tok); // Return true and store the first token only if any CommentHandler diff --git a/include/clang/Lex/PreprocessorOptions.h b/include/clang/Lex/PreprocessorOptions.h index c85d2384fa47..f536be8d8e69 100644 --- a/include/clang/Lex/PreprocessorOptions.h +++ b/include/clang/Lex/PreprocessorOptions.h @@ -95,6 +95,9 @@ public: /// If given, a PTH cache file to use for speeding up header parsing. std::string TokenCache; + /// When enabled, preprocessor is in a mode for parsing a single file only. + bool SingleFileParseMode = false; + /// \brief True if the SourceManager should report the original file name for /// contents of files that were remapped to other files. Defaults to true. bool RemappedFilesKeepOriginalName; @@ -181,6 +184,7 @@ public: ImplicitPCHInclude.clear(); ImplicitPTHInclude.clear(); TokenCache.clear(); + SingleFileParseMode = false; RetainRemappedFileBuffers = true; PrecompiledPreambleBytes.first = 0; PrecompiledPreambleBytes.second = 0; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 537796fa6465..a51d3a51d435 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -166,6 +166,7 @@ class Parser : public CodeCompletionHandler { std::unique_ptr<PragmaHandler> FPContractHandler; std::unique_ptr<PragmaHandler> OpenCLExtensionHandler; std::unique_ptr<PragmaHandler> OpenMPHandler; + std::unique_ptr<PragmaHandler> PCSectionHandler; std::unique_ptr<PragmaHandler> MSCommentHandler; std::unique_ptr<PragmaHandler> MSDetectMismatchHandler; std::unique_ptr<PragmaHandler> MSPointersToMembers; @@ -1460,7 +1461,8 @@ public: }; ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast); - ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast); + ExprResult ParseConstantExpressionInExprEvalContext( + TypeCastState isTypeCast = NotTypeCast); ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast); ExprResult ParseConstraintExpression(); // Expr that doesn't include commas. diff --git a/include/clang/Rewrite/Frontend/FrontendActions.h b/include/clang/Rewrite/Frontend/FrontendActions.h index 27976eac4ed2..5f83ac16fedf 100644 --- a/include/clang/Rewrite/Frontend/FrontendActions.h +++ b/include/clang/Rewrite/Frontend/FrontendActions.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H #include "clang/Frontend/FrontendAction.h" +#include "llvm/Support/raw_ostream.h" namespace clang { class FixItRewriter; @@ -34,8 +35,7 @@ protected: std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override; + bool BeginSourceFileAction(CompilerInstance &CI) override; void EndSourceFileAction() override; @@ -74,7 +74,10 @@ protected: }; class RewriteIncludesAction : public PreprocessorFrontendAction { + std::shared_ptr<raw_ostream> OutputStream; + class RewriteImportsListener; protected: + bool BeginSourceFileAction(CompilerInstance &CI) override; void ExecuteAction() override; }; diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 941b772b7880..ffdf011d1dcb 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -633,12 +633,9 @@ namespace clang { /// Might be a UsingShadowDecl or a FunctionTemplateDecl. DeclAccessPair FoundDecl; - // BuiltinTypes - Provides the return and parameter types of a - // built-in overload candidate. Only valid when Function is NULL. - struct { - QualType ResultTy; - QualType ParamTypes[3]; - } BuiltinTypes; + /// BuiltinParamTypes - Provides the parameter types of a built-in overload + /// candidate. Only valid when Function is NULL. + QualType BuiltinParamTypes[3]; /// Surrogate - The conversion function for which this candidate /// is a surrogate, but only if IsSurrogate is true. diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 4c9f18a0724c..8025668e664e 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -336,6 +336,35 @@ public: /// \brief Source location for newly created implicit MSInheritanceAttrs SourceLocation ImplicitMSInheritanceAttrLoc; + /// \brief pragma clang section kind + enum PragmaClangSectionKind { + PCSK_Invalid = 0, + PCSK_BSS = 1, + PCSK_Data = 2, + PCSK_Rodata = 3, + PCSK_Text = 4 + }; + + enum PragmaClangSectionAction { + PCSA_Set = 0, + PCSA_Clear = 1 + }; + + struct PragmaClangSection { + std::string SectionName; + bool Valid = false; + SourceLocation PragmaLocation; + + void Act(SourceLocation PragmaLocation, + PragmaClangSectionAction Action, + StringLiteral* Name); + }; + + PragmaClangSection PragmaClangBSSSection; + PragmaClangSection PragmaClangDataSection; + PragmaClangSection PragmaClangRodataSection; + PragmaClangSection PragmaClangTextSection; + enum PragmaMsStackAction { PSK_Reset = 0x0, // #pragma () PSK_Set = 0x1, // #pragma (value) @@ -2698,8 +2727,7 @@ public: SourceLocation OpLoc, ArrayRef<Expr *> Args, OverloadCandidateSet& CandidateSet, SourceRange OpRange = SourceRange()); - void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, - ArrayRef<Expr *> Args, + void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args, OverloadCandidateSet& CandidateSet, bool IsAssignmentOperator = false, unsigned NumContextualBoolArguments = 0); @@ -7526,6 +7554,10 @@ public: unsigned ThisTypeQuals); void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args); + bool SubstExceptionSpec(SourceLocation Loc, + FunctionProtoType::ExceptionSpecInfo &ESI, + SmallVectorImpl<QualType> &ExceptionStorage, + const MultiLevelTemplateArgumentList &Args); ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, @@ -7611,6 +7643,9 @@ public: LateInstantiatedAttrVec *LateAttrs = nullptr, LocalInstantiationScope *OuterMostScope = nullptr); + bool usesPartialOrExplicitSpecialization( + SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec); + bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, @@ -7685,7 +7720,8 @@ public: const MultiLevelTemplateArgumentList &TemplateArgs); NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, - const MultiLevelTemplateArgumentList &TemplateArgs); + const MultiLevelTemplateArgumentList &TemplateArgs, + bool FindingInstantiatedContext = false); DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -8117,6 +8153,11 @@ public: POAK_Reset // #pragma options align=reset }; + /// ActOnPragmaClangSection - Called on well formed \#pragma clang section + void ActOnPragmaClangSection(SourceLocation PragmaLoc, + PragmaClangSectionAction Action, + PragmaClangSectionKind SecKind, StringRef SecName); + /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align. void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc); diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index dc6e54a33206..a07cd88950d8 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -550,13 +550,15 @@ public: class PathDiagnosticCallPiece : public PathDiagnosticPiece { PathDiagnosticCallPiece(const Decl *callerD, const PathDiagnosticLocation &callReturnPos) - : PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr), - NoExit(false), callReturn(callReturnPos) {} + : PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr), + NoExit(false), IsCalleeAnAutosynthesizedPropertyAccessor(false), + callReturn(callReturnPos) {} PathDiagnosticCallPiece(PathPieces &oldPath, const Decl *caller) - : PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr), - NoExit(true), path(oldPath) {} - + : PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr), + NoExit(true), IsCalleeAnAutosynthesizedPropertyAccessor(false), + path(oldPath) {} + const Decl *Caller; const Decl *Callee; @@ -564,6 +566,10 @@ class PathDiagnosticCallPiece : public PathDiagnosticPiece { // call exit. bool NoExit; + // Flag signifying that the callee function is an Objective-C autosynthesized + // property getter or setter. + bool IsCalleeAnAutosynthesizedPropertyAccessor; + // The custom string, which should appear after the call Return Diagnostic. // TODO: Should we allow multiple diagnostics? std::string CallStackMessage; diff --git a/include/clang/Tooling/Tooling.h b/include/clang/Tooling/Tooling.h index 10e26ac25d17..1c974f998852 100644 --- a/include/clang/Tooling/Tooling.h +++ b/include/clang/Tooling/Tooling.h @@ -116,7 +116,7 @@ public: /// \brief Called before a source file is processed by a FrontEndAction. /// \see clang::FrontendAction::BeginSourceFileAction - virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) { + virtual bool handleBeginSource(CompilerInstance &CI) { return true; } @@ -388,12 +388,11 @@ inline std::unique_ptr<FrontendActionFactory> newFrontendActionFactory( } protected: - bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override { - if (!clang::ASTFrontendAction::BeginSourceFileAction(CI, Filename)) + bool BeginSourceFileAction(CompilerInstance &CI) override { + if (!clang::ASTFrontendAction::BeginSourceFileAction(CI)) return false; if (Callbacks) - return Callbacks->handleBeginSource(CI, Filename); + return Callbacks->handleBeginSource(CI); return true; } void EndSourceFileAction() override { |