diff options
Diffstat (limited to 'include/clang')
59 files changed, 1166 insertions, 512 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index da288c4..682be3d 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -1664,6 +1664,9 @@ public: TypeInfo getTypeInfo(const Type *T) const; TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); } + /// \brief Get default simd alignment of the specified complete type in bits. + unsigned getOpenMPDefaultSimdAlign(QualType T) const; + /// \brief Return the size of the specified (complete) type \p T, in bits. uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; } uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; } @@ -1780,6 +1783,17 @@ public: /// \param method should be the declaration from the class definition void setNonKeyFunction(const CXXMethodDecl *method); + /// Loading virtual member pointers using the virtual inheritance model + /// always results in an adjustment using the vbtable even if the index is + /// zero. + /// + /// This is usually OK because the first slot in the vbtable points + /// backwards to the top of the MDC. However, the MDC might be reusing a + /// vbptr from an nv-base. In this case, the first slot in the vbtable + /// points to the start of the nv-base which introduced the vbptr and *not* + /// the MDC. Modify the NonVirtualBaseAdjustment to account for this. + CharUnits getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const; + /// Get the offset of a FieldDecl or IndirectFieldDecl, in bits. uint64_t getFieldOffset(const ValueDecl *FD) const; diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h index 4f3acc3..f4026e9 100644 --- a/include/clang/AST/ASTMutationListener.h +++ b/include/clang/AST/ASTMutationListener.h @@ -14,6 +14,7 @@ #define LLVM_CLANG_AST_ASTMUTATIONLISTENER_H namespace clang { + class Attr; class ClassTemplateDecl; class ClassTemplateSpecializationDecl; class CXXDestructorDecl; @@ -29,6 +30,7 @@ namespace clang { class ObjCInterfaceDecl; class ObjCPropertyDecl; class QualType; + class RecordDecl; class TagDecl; class VarDecl; class VarTemplateDecl; @@ -119,6 +121,14 @@ public: /// \param M The containing module in which the definition was made visible, /// if any. virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} + + /// \brief An attribute was added to a RecordDecl + /// + /// \param Attr The attribute that was added to the Record + /// + /// \param Record The RecordDecl that got a new attribute + virtual void AddedAttributeToRecord(const Attr *Attr, + const RecordDecl *Record) {} // NOTE: If new methods are added they should also be added to // MultiplexASTMutationListener. diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h index ef88176..923d98f 100644 --- a/include/clang/AST/DataRecursiveASTVisitor.h +++ b/include/clang/AST/DataRecursiveASTVisitor.h @@ -1861,8 +1861,8 @@ DEF_TRAVERSE_DECL(ParmVarDecl, { TRY_TO(WalkUpFrom##STMT(S)); \ StmtQueueAction StmtQueue(*this); \ { CODE; } \ - for (Stmt::child_range range = S->children(); range; ++range) { \ - StmtQueue.queue(*range); \ + for (Stmt *SubStmt : S->children()) { \ + StmtQueue.queue(SubStmt); \ } \ return true; \ } @@ -2011,8 +2011,8 @@ bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) { TRY_TO(WalkUpFromInitListExpr(S)); StmtQueueAction StmtQueue(*this); // All we need are the default actions. FIXME: use a helper function. - for (Stmt::child_range range = S->children(); range; ++range) { - StmtQueue.queue(*range); + for (Stmt *SubStmt : S->children()) { + StmtQueue.queue(SubStmt); } return true; } @@ -2358,6 +2358,12 @@ DEF_TRAVERSE_STMT(OMPTaskwaitDirective, DEF_TRAVERSE_STMT(OMPTaskgroupDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPCancellationPointDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPCancelDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPFlushDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) @@ -2622,6 +2628,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(OMPFlushClause *C) { return true; } +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(OMPDependClause *C) { + TRY_TO(VisitOMPClauseList(C)); + return true; +} + // FIXME: look at the following tricky-seeming exprs to see if we // need to recurse on anything. These are ones that have methods // returning decls or qualtypes or nestednamespecifier -- though I'm diff --git a/include/clang/AST/EvaluatedExprVisitor.h b/include/clang/AST/EvaluatedExprVisitor.h index 5cae5d9..ad52873 100644 --- a/include/clang/AST/EvaluatedExprVisitor.h +++ b/include/clang/AST/EvaluatedExprVisitor.h @@ -98,9 +98,9 @@ public: /// \brief The basis case walks all of the children of the statement or /// expression, assuming they are all potentially evaluated. void VisitStmt(PTR(Stmt) S) { - for (auto C = S->children(); C; ++C) - if (*C) - this->Visit(*C); + for (auto *SubStmt : S->children()) + if (SubStmt) + this->Visit(SubStmt); } #undef PTR diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index f296e8f..899e648 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -86,7 +86,7 @@ public: }; /// ObjCBoxedExpr - used for generalized expression boxing. -/// as in: @(strdup("hello world")) or @(random()) +/// as in: @(strdup("hello world")), @(random()) or @(view.frame) /// Also used for boxing non-parenthesized numeric literals; /// as in: @42 or \@true (c++/objc++) or \@__yes (c/objc). class ObjCBoxedExpr : public Expr { diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index 9a76080..08c2e0c 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -156,6 +156,20 @@ public: /// \brief Retrieve the module that corresponds to the given module ID. virtual Module *getModule(unsigned ID) { return nullptr; } + /// \brief Holds everything needed to generate debug info for an + /// imported module or precompiled header file. + struct ASTSourceDescriptor { + std::string ModuleName; + std::string Path; + std::string ASTFile; + uint64_t Signature; + }; + + /// \brief Return a descriptor for the corresponding module, if one exists. + virtual llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID); + /// \brief Return a descriptor for the module. + virtual ASTSourceDescriptor getSourceDescriptor(const Module &M); + /// \brief Finds all declarations lexically contained within the given /// DeclContext, after applying an optional filter predicate. /// diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index c5a7ea1..735ae11 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -204,6 +204,10 @@ public: virtual void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD, raw_ostream &) = 0; + virtual void mangleCXXVirtualDisplacementMap(const CXXRecordDecl *SrcRD, + const CXXRecordDecl *DstRD, + raw_ostream &Out) = 0; + virtual void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile, uint32_t NumEntries, raw_ostream &Out) = 0; diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h index fc994c1..ce2c7ce 100644 --- a/include/clang/AST/NSAPI.h +++ b/include/clang/AST/NSAPI.h @@ -37,8 +37,9 @@ public: ClassId_NSMutableSet, ClassId_NSCountedSet, ClassId_NSMutableOrderedSet, + ClassId_NSValue }; - static const unsigned NumClassIds = 10; + static const unsigned NumClassIds = 11; enum NSStringMethodKind { NSStr_stringWithString, diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index 386c8dd..fcfa1dd 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -2212,6 +2212,94 @@ public: } }; +/// \brief This represents implicit clause 'depend' for the '#pragma omp task' +/// directive. +/// +/// \code +/// #pragma omp task depend(in:a,b) +/// \endcode +/// In this example directive '#pragma omp task' with clause 'depend' with the +/// variables 'a' and 'b' with dependency 'in'. +/// +class OMPDependClause : public OMPVarListClause<OMPDependClause> { + friend class OMPClauseReader; + /// \brief Dependency type (one of in, out, inout). + OpenMPDependClauseKind DepKind; + /// \brief Dependency type location. + SourceLocation DepLoc; + /// \brief Colon location. + SourceLocation ColonLoc; + /// \brief Build clause with number of variables \a N. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param N Number of the variables in the clause. + /// + OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc, unsigned N) + : OMPVarListClause<OMPDependClause>(OMPC_depend, StartLoc, LParenLoc, + EndLoc, N), + DepKind(OMPC_DEPEND_unknown) {} + + /// \brief Build an empty clause. + /// + /// \param N Number of variables. + /// + explicit OMPDependClause(unsigned N) + : OMPVarListClause<OMPDependClause>(OMPC_depend, SourceLocation(), + SourceLocation(), SourceLocation(), + N), + DepKind(OMPC_DEPEND_unknown) {} + /// \brief Set dependency kind. + void setDependencyKind(OpenMPDependClauseKind K) { DepKind = K; } + + /// \brief Set dependency kind and its location. + void setDependencyLoc(SourceLocation Loc) { DepLoc = Loc; } + + /// \brief Set colon location. + void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } + +public: + /// \brief Creates clause with a list of variables \a VL. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param DepKind Dependency type. + /// \param DepLoc Location of the dependency type. + /// \param ColonLoc Colon location. + /// \param VL List of references to the variables. + /// + static OMPDependClause * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc, OpenMPDependClauseKind DepKind, + SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL); + /// \brief Creates an empty clause with \a N variables. + /// + /// \param C AST context. + /// \param N The number of variables. + /// + static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N); + + /// \brief Get dependency type. + OpenMPDependClauseKind getDependencyKind() const { return DepKind; } + /// \brief Get dependency type location. + SourceLocation getDependencyLoc() const { return DepLoc; } + /// \brief Get colon location. + SourceLocation getColonLoc() const { return ColonLoc; } + + StmtRange children() { + return StmtRange(reinterpret_cast<Stmt **>(varlist_begin()), + reinterpret_cast<Stmt **>(varlist_end())); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == OMPC_depend; + } +}; + } // end namespace clang #endif diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 95d7730..b118503 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -1881,8 +1881,8 @@ DEF_TRAVERSE_DECL(ParmVarDecl, { bool RecursiveASTVisitor<Derived>::Traverse##STMT(STMT *S) { \ TRY_TO(WalkUpFrom##STMT(S)); \ { CODE; } \ - for (Stmt::child_range range = S->children(); range; ++range) { \ - TRY_TO(TraverseStmt(*range)); \ + for (Stmt *SubStmt : S->children()) { \ + TRY_TO(TraverseStmt(SubStmt)); \ } \ return true; \ } @@ -2038,15 +2038,15 @@ bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) { if (Syn) { TRY_TO(WalkUpFromInitListExpr(Syn)); // All we need are the default actions. FIXME: use a helper function. - for (Stmt::child_range range = Syn->children(); range; ++range) { - TRY_TO(TraverseStmt(*range)); + for (Stmt *SubStmt : Syn->children()) { + TRY_TO(TraverseStmt(SubStmt)); } } InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm(); if (Sem) { TRY_TO(WalkUpFromInitListExpr(Sem)); - for (Stmt::child_range range = Sem->children(); range; ++range) { - TRY_TO(TraverseStmt(*range)); + for (Stmt *SubStmt : Sem->children()) { + TRY_TO(TraverseStmt(SubStmt)); } } return true; @@ -2391,6 +2391,12 @@ DEF_TRAVERSE_STMT(OMPTaskwaitDirective, DEF_TRAVERSE_STMT(OMPTaskgroupDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPCancellationPointDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPCancelDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPFlushDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) @@ -2655,6 +2661,12 @@ bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(OMPFlushClause *C) { return true; } +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(OMPDependClause *C) { + TRY_TO(VisitOMPClauseList(C)); + return true; +} + // FIXME: look at the following tricky-seeming exprs to see if we // need to recurse on anything. These are ones that have methods // returning decls or qualtypes or nestednamespecifier -- though I'm diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h index ec7329a..a5a57af 100644 --- a/include/clang/AST/StmtIterator.h +++ b/include/clang/AST/StmtIterator.h @@ -32,8 +32,10 @@ protected: enum { StmtMode = 0x0, SizeOfTypeVAMode = 0x1, DeclGroupMode = 0x2, Flags = 0x3 }; - Stmt **stmt; - Decl **DGI; + union { + Stmt **stmt; + Decl **DGI; + }; uintptr_t RawVAPtr; Decl **DGE; @@ -64,10 +66,10 @@ protected: Stmt*& GetDeclExpr() const; - StmtIteratorBase(Stmt **s) : stmt(s), DGI(nullptr), RawVAPtr(0) {} + StmtIteratorBase(Stmt **s) : stmt(s), RawVAPtr(0) {} StmtIteratorBase(const VariableArrayType *t); StmtIteratorBase(Decl **dgi, Decl **dge); - StmtIteratorBase() : stmt(nullptr), DGI(nullptr), RawVAPtr(0) {} + StmtIteratorBase() : stmt(nullptr), RawVAPtr(0) {} }; diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index 63f295d..b412daa 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -1856,6 +1856,121 @@ public: } }; +/// \brief This represents '#pragma omp cancellation point' directive. +/// +/// \code +/// #pragma omp cancellation point for +/// \endcode +/// +/// In this example a cancellation point is created for innermost 'for' region. +class OMPCancellationPointDirective : public OMPExecutableDirective { + friend class ASTStmtReader; + OpenMPDirectiveKind CancelRegion; + /// \brief Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPCancellationPointDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + OMPD_cancellation_point, StartLoc, EndLoc, 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Build an empty directive. + /// + explicit OMPCancellationPointDirective() + : OMPExecutableDirective(this, OMPCancellationPointDirectiveClass, + OMPD_cancellation_point, SourceLocation(), + SourceLocation(), 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Set cancel region for current cancellation point. + /// \param CR Cancellation region. + void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; } + +public: + /// \brief Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// + static OMPCancellationPointDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); + + /// \brief Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPCancellationPointDirective *CreateEmpty(const ASTContext &C, + EmptyShell); + + /// \brief Get cancellation region for the current cancellation point. + OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPCancellationPointDirectiveClass; + } +}; + +/// \brief This represents '#pragma omp cancel' directive. +/// +/// \code +/// #pragma omp cancel for +/// \endcode +/// +/// In this example a cancel is created for innermost 'for' region. +class OMPCancelDirective : public OMPExecutableDirective { + friend class ASTStmtReader; + OpenMPDirectiveKind CancelRegion; + /// \brief Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// + OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel, + StartLoc, EndLoc, 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Build an empty directive. + /// + explicit OMPCancelDirective() + : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel, + SourceLocation(), SourceLocation(), 0, 0), + CancelRegion(OMPD_unknown) {} + + /// \brief Set cancel region for current cancellation point. + /// \param CR Cancellation region. + void setCancelRegion(OpenMPDirectiveKind CR) { CancelRegion = CR; } + +public: + /// \brief Creates directive. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// + static OMPCancelDirective *Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); + + /// \brief Creates an empty directive. + /// + /// \param C AST context. + /// + static OMPCancelDirective *CreateEmpty(const ASTContext &C, EmptyShell); + + /// \brief Get cancellation region for the current cancellation point. + OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPCancelDirectiveClass; + } +}; + } // end namespace clang #endif diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index d903b9d..97f1331 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1564,6 +1564,7 @@ public: bool isRecordType() const; bool isClassType() const; bool isStructureType() const; + bool isObjCBoxableRecordType() const; bool isInterfaceType() const; bool isStructureOrClassType() const; bool isUnionType() const; diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 94c77f7..e7a97a7 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2528,6 +2528,23 @@ AST_MATCHER_P2(DeclStmt, containsDeclaration, unsigned, N, return InnerMatcher.matches(**Iterator, Finder, Builder); } +/// \brief Matches a C++ catch statement that has a catch-all handler. +/// +/// Given +/// \code +/// try { +/// // ... +/// } catch (int) { +/// // ... +/// } catch (...) { +/// // ... +/// } +/// /endcode +/// catchStmt(isCatchAll()) matches catch(...) but not catch(int). +AST_MATCHER(CXXCatchStmt, isCatchAll) { + return Node.getExceptionDecl() == nullptr; +} + /// \brief Matches a constructor initializer. /// /// Given diff --git a/include/clang/Analysis/Analyses/FormatString.h b/include/clang/Analysis/Analyses/FormatString.h index 2e8058da..4471311 100644 --- a/include/clang/Analysis/Analyses/FormatString.h +++ b/include/clang/Analysis/Analyses/FormatString.h @@ -40,6 +40,7 @@ public: void clear() { flag = false; } void setPosition(const char *position) { assert(position); + flag = true; this->position = position; } const char *getPosition() const { @@ -435,12 +436,14 @@ class PrintfSpecifier : public analyze_format_string::FormatSpecifier { OptionalFlag HasSpacePrefix; // ' ' OptionalFlag HasAlternativeForm; // '#' OptionalFlag HasLeadingZeroes; // '0' + OptionalFlag HasObjCTechnicalTerm; // '[tt]' OptionalAmount Precision; public: PrintfSpecifier() : FormatSpecifier(/* isPrintf = */ true), HasThousandsGrouping("'"), IsLeftJustified("-"), HasPlusPrefix("+"), - HasSpacePrefix(" "), HasAlternativeForm("#"), HasLeadingZeroes("0") {} + HasSpacePrefix(" "), HasAlternativeForm("#"), HasLeadingZeroes("0"), + HasObjCTechnicalTerm("tt") {} static PrintfSpecifier Parse(const char *beg, const char *end); @@ -449,29 +452,26 @@ public: CS = cs; } void setHasThousandsGrouping(const char *position) { - HasThousandsGrouping = true; HasThousandsGrouping.setPosition(position); } void setIsLeftJustified(const char *position) { - IsLeftJustified = true; IsLeftJustified.setPosition(position); } void setHasPlusPrefix(const char *position) { - HasPlusPrefix = true; HasPlusPrefix.setPosition(position); } void setHasSpacePrefix(const char *position) { - HasSpacePrefix = true; HasSpacePrefix.setPosition(position); } void setHasAlternativeForm(const char *position) { - HasAlternativeForm = true; HasAlternativeForm.setPosition(position); } void setHasLeadingZeros(const char *position) { - HasLeadingZeroes = true; HasLeadingZeroes.setPosition(position); } + void setHasObjCTechnicalTerm(const char *position) { + HasObjCTechnicalTerm.setPosition(position); + } void setUsesPositionalArg() { UsesPositionalArg = true; } // Methods for querying the format specifier. @@ -508,6 +508,7 @@ public: const OptionalFlag &hasAlternativeForm() const { return HasAlternativeForm; } const OptionalFlag &hasLeadingZeros() const { return HasLeadingZeroes; } const OptionalFlag &hasSpacePrefix() const { return HasSpacePrefix; } + const OptionalFlag &hasObjCTechnicalTerm() const { return HasObjCTechnicalTerm; } bool usesPositionalArg() const { return UsesPositionalArg; } /// Changes the specifier and length according to a QualType, retaining any @@ -565,7 +566,6 @@ public: SuppressAssignment("*") {} void setSuppressAssignment(const char *position) { - SuppressAssignment = true; SuppressAssignment.setPosition(position); } @@ -621,6 +621,15 @@ public: virtual void HandleIncompleteSpecifier(const char *startSpecifier, unsigned specifierLen) {} + virtual void HandleEmptyObjCModifierFlag(const char *startFlags, + unsigned flagsLen) {} + + virtual void HandleInvalidObjCModifierFlag(const char *startFlag, + unsigned flagLen) {} + + virtual void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart, + const char *flagsEnd, + const char *conversionPosition) {} // Printf-specific handlers. virtual bool HandleInvalidPrintfConversionSpecifier( diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index f36f654..2bbce37 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -950,30 +950,30 @@ def NonNull : InheritableAttr { } }]; // FIXME: We should merge duplicates into a single nonnull attribute. let DuplicatesAllowedWhileMerging = 1; - let Documentation = [Undocumented]; + let Documentation = [NonNullDocs]; } def ReturnsNonNull : InheritableAttr { let Spellings = [GCC<"returns_nonnull">]; let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag, "ExpectedFunctionOrMethod">; - let Documentation = [Undocumented]; + let Documentation = [ReturnsNonNullDocs]; } // Nullability type attributes. def TypeNonNull : TypeAttr { - let Spellings = [Keyword<"__nonnull">]; - let Documentation = [Undocumented]; + let Spellings = [Keyword<"_Nonnull">]; + let Documentation = [TypeNonNullDocs]; } def TypeNullable : TypeAttr { - let Spellings = [Keyword<"__nullable">]; - let Documentation = [Undocumented]; + let Spellings = [Keyword<"_Nullable">]; + let Documentation = [TypeNullableDocs]; } def TypeNullUnspecified : TypeAttr { - let Spellings = [Keyword<"__null_unspecified">]; - let Documentation = [Undocumented]; + let Spellings = [Keyword<"_Null_unspecified">]; + let Documentation = [TypeNullUnspecifiedDocs]; } def AssumeAligned : InheritableAttr { @@ -1125,6 +1125,12 @@ def ObjCRuntimeName : Attr { let Documentation = [ObjCRuntimeNameDocs]; } +def ObjCBoxable : Attr { + let Spellings = [GNU<"objc_boxable">]; + let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">; + let Documentation = [Undocumented]; +} + def OptimizeNone : InheritableAttr { let Spellings = [GNU<"optnone">, CXX11<"clang", "optnone">]; let Subjects = SubjectList<[Function, ObjCMethod]>; diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index 9314c44..107458e 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -181,6 +181,11 @@ to enforce the provided alignment assumption. def EnableIfDocs : Documentation { let Category = DocCatFunction; let Content = [{ +.. Note:: Some features of this attribute are experimental. The meaning of
+ multiple enable_if attributes on a single declaration is subject to change in
+ a future version of clang. Also, the ABI is not standardized and the name
+ mangling may change in future versions. To avoid that, use asm labels. + The ``enable_if`` attribute can be placed on function declarations to control which overload is selected based on the values of the function's arguments. When combined with the ``overloadable`` attribute, this feature is also @@ -1448,3 +1453,114 @@ private address space. Kernel function arguments of a pointer or an array type cannot point to the private address space. }]; } + +def NullabilityDocs : DocumentationCategory<"Nullability Attributes"> { + let Content = [{ +Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (``_Nullable``) or cannot be null (``_Nonnull``). + +The nullability (type) qualifiers express whether a value of a given pointer type can be null (the ``_Nullable`` qualifier), doesn't have a defined meaning for null (the ``_Nonnull`` qualifier), or for which the purpose of null is unclear (the ``_Null_unspecified`` qualifier). Because nullability qualifiers are expressed within the type system, they are more general than the ``nonnull`` and ``returns_nonnull`` attributes, allowing one to express (for example) a nullable pointer to an array of nonnull pointers. Nullability qualifiers are written to the right of the pointer to which they apply. For example: + + .. code-block:: c + + // No meaningful result when 'ptr' is null (here, it happens to be undefined behavior). + int fetch(int * _Nonnull ptr) { return *ptr; } + + // 'ptr' may be null. + int fetch_or_zero(int * _Nullable ptr) { + return ptr ? *ptr : 0; + } + + // A nullable pointer to non-null pointers to const characters. + const char *join_strings(const char * _Nonnull * _Nullable strings, unsigned n); + +In Objective-C, there is an alternate spelling for the nullability qualifiers that can be used in Objective-C methods and properties using context-sensitive, non-underscored keywords. For example: + + .. code-block:: objective-c + + @interface NSView : NSResponder + - (nullable NSView *)ancestorSharedWithView:(nonnull NSView *)aView; + @property (assign, nullable) NSView *superview; + @property (readonly, nonnull) NSArray *subviews; + @end + }]; +} + +def TypeNonNullDocs : Documentation { + let Category = NullabilityDocs; + let Heading = "_Nonnull"; + let Content = [{ +The ``_Nonnull`` nullability qualifier indicates that null is not a meaningful value for a value of the ``_Nonnull`` pointer type. For example, given a declaration such as: + + .. code-block:: c + + int fetch(int * _Nonnull ptr); + +a caller of ``fetch`` should not provide a null value, and the compiler will produce a warning if it sees a literal null value passed to ``fetch``. Note that, unlike the declaration attribute ``nonnull``, the presence of ``_Nonnull`` does not imply that passing null is undefined behavior: ``fetch`` is free to consider null undefined behavior or (perhaps for backward-compatibility reasons) defensively handle null. + }]; +} + +def TypeNullableDocs : Documentation { + let Category = NullabilityDocs; + let Heading = "_Nullable"; + let Content = [{ +The ``_Nullable`` nullability qualifier indicates that a value of the ``_Nullable`` pointer type can be null. For example, given: + + .. code-block:: c + + int fetch_or_zero(int * _Nullable ptr); + +a caller of ``fetch_or_zero`` can provide null. + }]; +} + +def TypeNullUnspecifiedDocs : Documentation { + let Category = NullabilityDocs; + let Heading = "_Null_unspecified"; + let Content = [{ +The ``_Null_unspecified`` nullability qualifier indicates that neither the ``_Nonnull`` nor ``_Nullable`` qualifiers make sense for a particular pointer type. It is used primarily to indicate that the role of null with specific pointers in a nullability-annotated header is unclear, e.g., due to overly-complex implementations or historical factors with a long-lived API. + }]; +} + +def NonNullDocs : Documentation { + let Category = NullabilityDocs; + let Heading = "nonnull"; + let Content = [{ +The ``nonnull`` attribute indicates that some function parameters must not be null, and can be used in several different ways. It's original usage (`from GCC <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes>`_) is as a function (or Objective-C method) attribute that specifies which parameters of the function are nonnull in a comma-separated list. For example: + + .. code-block:: c + + extern void * my_memcpy (void *dest, const void *src, size_t len) + __attribute__((nonnull (1, 2))); + +Here, the ``nonnull`` attribute indicates that parameters 1 and 2 +cannot have a null value. Omitting the parenthesized list of parameter indices means that all parameters of pointer type cannot be null: + + .. code-block:: c + + extern void * my_memcpy (void *dest, const void *src, size_t len) + __attribute__((nonnull)); + +Clang also allows the ``nonnull`` attribute to be placed directly on a function (or Objective-C method) parameter, eliminating the need to specify the parameter index ahead of type. For example: + + .. code-block:: c + + extern void * my_memcpy (void *dest __attribute__((nonnull)), + const void *src __attribute__((nonnull)), size_t len); + +Note that the ``nonnull`` attribute indicates that passing null to a non-null parameter is undefined behavior, which the optimizer may take advantage of to, e.g., remove null checks. The ``_Nonnull`` type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable. + }]; +} + +def ReturnsNonNullDocs : Documentation { + let Category = NullabilityDocs; + let Heading = "returns_nonnull"; + let Content = [{ +The ``returns_nonnull`` attribute indicates that a particular function (or Objective-C method) always returns a non-null pointer. For example, a particular system ``malloc`` might be defined to terminate a process when memory is not available rather than returning a null pointer: + + .. code-block:: c + + extern void * malloc (size_t size) __attribute__((returns_nonnull)); + +The ``returns_nonnull`` attribute implies that returning a null pointer is undefined behavior, which the optimizer may take advantage of. The ``_Nonnull`` type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable +}]; +} diff --git a/include/clang/Basic/BuiltinsARM.def b/include/clang/Basic/BuiltinsARM.def index 0610d47..c9cdb4b 100644 --- a/include/clang/Basic/BuiltinsARM.def +++ b/include/clang/Basic/BuiltinsARM.def @@ -105,10 +105,10 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveFromCoprocessor, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveFromCoprocessor2, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveToCoprocessor, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveToCoprocessor2, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveToCoprocessor, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveToCoprocessor2, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) #undef BUILTIN #undef LANGBUILTIN diff --git a/include/clang/Basic/BuiltinsNVPTX.def b/include/clang/Basic/BuiltinsNVPTX.def index 9c920dc..970f55f 100644 --- a/include/clang/Basic/BuiltinsNVPTX.def +++ b/include/clang/Basic/BuiltinsNVPTX.def @@ -501,7 +501,7 @@ BUILTIN(__nvvm_atom_min_s_ui, "UiUiD*3Ui", "n") BUILTIN(__nvvm_atom_min_gen_ui, "UiUiD*Ui", "n") BUILTIN(__nvvm_atom_min_g_l, "LiLiD*1Li", "n") BUILTIN(__nvvm_atom_min_s_l, "LiLiD*3Li", "n") -BUILTIN(__nvvm_atom_min_gen_l, "LiLi10D*Li", "n") +BUILTIN(__nvvm_atom_min_gen_l, "LiLiD*Li", "n") BUILTIN(__nvvm_atom_min_g_ul, "ULiULiD*1ULi", "n") BUILTIN(__nvvm_atom_min_s_ul, "ULiULiD*3ULi", "n") BUILTIN(__nvvm_atom_min_gen_ul, "ULiULiD*ULi", "n") diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def index 6f3bea8..02e5294 100644 --- a/include/clang/Basic/BuiltinsPPC.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -267,6 +267,18 @@ BUILTIN(__builtin_vsx_xsmindp, "ddd", "") BUILTIN(__builtin_vsx_xvdivdp, "V2dV2dV2d", "") BUILTIN(__builtin_vsx_xvdivsp, "V4fV4fV4f", "") +BUILTIN(__builtin_vsx_xvrdpip, "V2dV2d", "") +BUILTIN(__builtin_vsx_xvrspip, "V4fV4f", "") + +BUILTIN(__builtin_vsx_xvcmpeqdp, "V2ULLiV2dV2d", "") +BUILTIN(__builtin_vsx_xvcmpeqsp, "V4UiV4fV4f", "") + +BUILTIN(__builtin_vsx_xvcmpgedp, "V2ULLiV2dV2d", "") +BUILTIN(__builtin_vsx_xvcmpgesp, "V4UiV4fV4f", "") + +BUILTIN(__builtin_vsx_xvcmpgtdp, "V2ULLiV2dV2d", "") +BUILTIN(__builtin_vsx_xvcmpgtsp, "V4UiV4fV4f", "") + // HTM builtins BUILTIN(__builtin_tbegin, "UiUIi", "") BUILTIN(__builtin_tend, "UiUIi", "") diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index 00c1340..aaf279f 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -24,6 +24,11 @@ // FIXME: Are these nothrow/const? +// Miscellaneous builtin for checking x86 cpu features. +// TODO: Make this somewhat generic so that other backends +// can use it? +BUILTIN(__builtin_cpu_supports, "bcC*", "nc") + // 3DNow! // BUILTIN(__builtin_ia32_femms, "v", "") @@ -651,6 +656,12 @@ BUILTIN(__builtin_ia32_wrfsbase64, "vULLi", "") BUILTIN(__builtin_ia32_wrgsbase32, "vUi", "") BUILTIN(__builtin_ia32_wrgsbase64, "vULLi", "") +// FXSR +BUILTIN(__builtin_ia32_fxrstor, "vv*", "") +BUILTIN(__builtin_ia32_fxrstor64, "vv*", "") +BUILTIN(__builtin_ia32_fxsave, "vv*", "") +BUILTIN(__builtin_ia32_fxsave64, "vv*", "") + // ADX BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "") BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "") @@ -722,12 +733,72 @@ BUILTIN(__builtin_ia32_vfmaddsubps256, "V8fV8fV8fV8f", "") BUILTIN(__builtin_ia32_vfmaddsubpd256, "V4dV4dV4dV4d", "") BUILTIN(__builtin_ia32_vfmsubaddps256, "V8fV8fV8fV8f", "") BUILTIN(__builtin_ia32_vfmsubaddpd256, "V4dV4dV4dV4d", "") -BUILTIN(__builtin_ia32_vfmaddpd512_mask, "V8dV8dV8dV8dUcIi", "") -BUILTIN(__builtin_ia32_vfmsubpd512_mask, "V8dV8dV8dV8dUcIi", "") -BUILTIN(__builtin_ia32_vfnmaddpd512_mask, "V8dV8dV8dV8dUcIi", "") -BUILTIN(__builtin_ia32_vfmaddps512_mask, "V16fV16fV16fV16fUsIi", "") -BUILTIN(__builtin_ia32_vfmsubps512_mask, "V16fV16fV16fV16fUsIi", "") -BUILTIN(__builtin_ia32_vfnmaddps512_mask, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddpd128_mask, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd128_mask3, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd128_maskz, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd256_mask, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd256_mask3, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd256_maskz, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddpd512_mask, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddpd512_mask3, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddpd512_maskz, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddps128_mask, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddps128_mask3, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddps128_maskz, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddps256_mask, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddps256_mask3, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddps256_maskz, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddps512_mask, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddps512_mask3, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddps512_maskz, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddsubpd128_mask, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd128_mask3, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd128_maskz, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd256_mask, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd256_mask3, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd256_maskz, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmaddsubpd512_mask, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddsubpd512_mask3, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddsubpd512_maskz, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmaddsubps128_mask, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps128_mask3, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps128_maskz, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps256_mask, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps256_mask3, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps256_maskz, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmaddsubps512_mask, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddsubps512_mask3, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmaddsubps512_maskz, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmsubpd128_mask3, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmsubpd256_mask3, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmsubpd512_mask3, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmsubps128_mask3, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmsubps256_mask3, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmsubps512_mask3, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfmsubaddpd128_mask3, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfmsubaddpd256_mask3, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfmsubaddpd512_mask3, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfmsubaddps128_mask3, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfmsubaddps256_mask3, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfmsubaddps512_mask3, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfnmaddpd128_mask, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfnmaddpd256_mask, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfnmaddpd512_mask, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfnmaddps128_mask, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfnmaddps256_mask, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfnmaddps512_mask, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfnmsubpd128_mask, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfnmsubpd128_mask3, "V2dV2dV2dV2dUc", "") +BUILTIN(__builtin_ia32_vfnmsubpd256_mask, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfnmsubpd256_mask3, "V4dV4dV4dV4dUc", "") +BUILTIN(__builtin_ia32_vfnmsubpd512_mask, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfnmsubpd512_mask3, "V8dV8dV8dV8dUcIi", "") +BUILTIN(__builtin_ia32_vfnmsubps128_mask, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfnmsubps128_mask3, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_vfnmsubps256_mask, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfnmsubps256_mask3, "V8fV8fV8fV8fUc", "") +BUILTIN(__builtin_ia32_vfnmsubps512_mask, "V16fV16fV16fV16fUsIi", "") +BUILTIN(__builtin_ia32_vfnmsubps512_mask3, "V16fV16fV16fV16fUsIi", "") // XOP BUILTIN(__builtin_ia32_vpmacssww, "V8sV8sV8sV8s", "") @@ -1052,5 +1123,39 @@ BUILTIN(__builtin_ia32_orpd256_mask, "V4dV4dV4dV4dUc", "") BUILTIN(__builtin_ia32_orpd128_mask, "V2dV2dV2dV2dUc", "") BUILTIN(__builtin_ia32_orps256_mask, "V8fV8fV8fV8fUc", "") BUILTIN(__builtin_ia32_orps128_mask, "V4fV4fV4fV4fUc", "") +BUILTIN(__builtin_ia32_blendmb_512_mask, "V64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_blendmw_512_mask, "V32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pabsb512_mask, "V64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pabsw512_mask, "V32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_packssdw512_mask, "V32sV16iV16iV32sUi", "") +BUILTIN(__builtin_ia32_packsswb512_mask, "V64cV32sV32sV64cULLi", "") +BUILTIN(__builtin_ia32_packusdw512_mask, "V32sV16iV16iV32sUi", "") +BUILTIN(__builtin_ia32_packuswb512_mask, "V64cV32sV32sV64cULLi", "") +BUILTIN(__builtin_ia32_paddsb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_paddsw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_paddusb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_paddusw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pavgb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pavgw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pmaxsb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pmaxsw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pmaxub512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pmaxuw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pminsb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pminsw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pminub512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_pminuw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_pshufb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_psubsb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_psubsw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_psubusb512_mask, "V64cV64cV64cV64cULLi", "") +BUILTIN(__builtin_ia32_psubusw512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_vpermi2varhi512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_vpermt2varhi512_mask, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_vpermt2varhi512_maskz, "V32sV32sV32sV32sUi", "") +BUILTIN(__builtin_ia32_vpconflictdi_512_mask, "V8LLiV8LLiV8LLiUc", "") +BUILTIN(__builtin_ia32_vpconflictsi_512_mask, "V16iV16iV16iUs", "") +BUILTIN(__builtin_ia32_vplzcntd_512_mask, "V16iV16iV16iUs", "") +BUILTIN(__builtin_ia32_vplzcntq_512_mask, "V8LLiV8LLiV8LLiUc", "") #undef BUILTIN diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 0f3831d..3b7c282 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -18,6 +18,7 @@ #include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" @@ -1107,6 +1108,13 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, return DB; } +/// A nullability kind paired with a bit indicating whether it used a +/// context-sensitive keyword. +typedef std::pair<NullabilityKind, bool> DiagNullabilityKind; + +const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + DiagNullabilityKind nullability); + inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc, unsigned DiagID) { assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!"); diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index 82718d9..24813c6 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -102,31 +102,21 @@ def err_enum_template : Error<"enumeration cannot be a template">; let CategoryName = "Nullability Issue" in { def warn_nullability_duplicate : Warning< - "duplicate nullability specifier " - "'%select{__|}1%select{nonnull|nullable|null_unspecified}0'">, + "duplicate nullability specifier %0">, InGroup<Nullability>; def warn_conflicting_nullability_attr_overriding_ret_types : Warning< - "conflicting nullability specifier on return types, " - "'%select{%select{__|}1nonnull|" - "%select{__|}1nullable|%select{__|}1null_unspecified}0' " - "conflicts with existing specifier '%select{%select{__|}3nonnull|" - "%select{__|}3nullable|%select{__|}3null_unspecified}2'">, + "conflicting nullability specifier on return types, %0 " + "conflicts with existing specifier %1">, InGroup<Nullability>; def warn_conflicting_nullability_attr_overriding_param_types : Warning< - "conflicting nullability specifier on parameter types, " - "'%select{%select{__|}1nonnull|" - "%select{__|}1nullable|%select{__|}1null_unspecified}0' " - "conflicts with existing specifier '%select{%select{__|}3nonnull|" - "%select{__|}3nullable|%select{__|}3null_unspecified}2'">, + "conflicting nullability specifier on parameter types, %0 " + "conflicts with existing specifier %1">, InGroup<Nullability>; def err_nullability_conflicting : Error< - "nullability specifier " - "'%select{__|}1%select{nonnull|nullable|null_unspecified}0' conflicts with " - "existing specifier '%select{__|}3%select{nonnull|nullable|" - "null_unspecified}2'">; + "nullability specifier %0 conflicts with existing specifier %1">; } diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 803203c..7502194 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -426,6 +426,7 @@ def warn_redecl_library_builtin : Warning< InGroup<DiagGroup<"incompatible-library-redeclaration">>; def err_builtin_definition : Error<"definition of builtin function %0">; def err_arm_invalid_specialreg : Error<"invalid special register for builtin">; +def err_invalid_cpu_supports : Error<"invalid cpu feature string for builtin">; def warn_builtin_unknown : Warning<"use of unknown builtin %0">, InGroup<ImplicitFunctionDeclare>, DefaultError; def warn_dyn_class_memaccess : Warning< @@ -1050,6 +1051,7 @@ def ext_friend_tag_redecl_outside_namespace : ExtWarn< "unqualified friend declaration referring to type outside of the nearest " "enclosing namespace is a Microsoft extension; add a nested name specifier">, InGroup<Microsoft>; +def err_pure_friend : Error<"friend declaration cannot have a pure-specifier">; def err_invalid_member_in_interface : Error< "%select{data member |non-public member function |static member function |" @@ -1262,6 +1264,8 @@ def ext_mutable_reference : ExtWarn< def err_mutable_const : Error<"'mutable' and 'const' cannot be mixed">; def err_mutable_nonmember : Error< "'mutable' can only be applied to member variables">; +def err_virtual_in_union : Error< + "unions cannot have virtual functions">; def err_virtual_non_function : Error< "'virtual' can only appear on non-static member functions">; def err_virtual_out_of_class : Error< @@ -2081,12 +2085,16 @@ def err_attr_objc_ownership_redundant : Error< "the type %0 is already explicitly ownership-qualified">; def err_undeclared_nsnumber : Error< "NSNumber must be available to use Objective-C literals">; +def err_undeclared_nsvalue : Error< + "NSValue must be available to use Objective-C boxed expressions">; def err_invalid_nsnumber_type : Error< "%0 is not a valid literal type for NSNumber">; def err_undeclared_nsstring : Error< "cannot box a string value because NSString has not been declared">; def err_objc_illegal_boxed_expression_type : Error< "illegal type %0 used in a boxed expression">; +def err_objc_non_trivially_copyable_boxed_expression_type : Error< + "non-trivially copyable type %0 cannot be used in a boxed expression">; def err_objc_incomplete_boxed_expression_type : Error< "incomplete type %0 used in a boxed expression">; def err_undeclared_nsarray : Error< @@ -2190,7 +2198,7 @@ def err_attribute_invalid_on_stmt : Error< "%0 attribute cannot be applied to a statement">; def warn_declspec_attribute_ignored : Warning< "attribute %0 is ignored, place it after " - "\"%select{class|struct|union|interface|enum}1\" to apply attribute to " + "\"%select{class|struct|interface|union|enum}1\" to apply attribute to " "type declaration">, InGroup<IgnoredAttributes>; def warn_attribute_precede_definition : Warning< "attribute declaration must precede definition">, @@ -4690,13 +4698,15 @@ def ext_sizeof_alignof_void_type : Extension< "invalid application of '%select{sizeof|alignof|vec_step}0' to a void " "type">, InGroup<PointerArith>; def err_opencl_sizeof_alignof_type : Error< - "invalid application of '%select{sizeof|alignof|vec_step}0' to a void type">; + "invalid application of '%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align}0' to a void type">; def err_sizeof_alignof_incomplete_type : Error< - "invalid application of '%select{sizeof|alignof|vec_step}0' to an " + "invalid application of '%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align}0' to an " "incomplete type %1">; def err_sizeof_alignof_function_type : Error< - "invalid application of '%select{sizeof|alignof|vec_step}0' to a " + "invalid application of '%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align}0' to a " "function type">; +def err_openmp_default_simd_align_expr : Error< + "invalid application of '__builtin_omp_required_simd_align' to an expression, only type is allowed">; def err_sizeof_alignof_bitfield : Error< "invalid application of '%select{sizeof|alignof}0' to bit-field">; def err_alignof_member_of_incomplete_type : Error< @@ -6791,6 +6801,15 @@ def warn_format_non_standard_conversion_spec: Warning< def warn_printf_ignored_flag: Warning< "flag '%0' is ignored when flag '%1' is present">, InGroup<Format>; +def warn_printf_empty_objc_flag: Warning< + "missing object format flag">, + InGroup<Format>; +def warn_printf_ObjCflags_without_ObjCConversion: Warning< + "object format flags cannot be used with '%0' conversion specifier">, + InGroup<Format>; +def warn_printf_invalid_objc_flag: Warning< + "'%0' is not a valid object format flag">, + InGroup<Format>; def warn_scanf_scanlist_incomplete : Warning< "no closing ']' for '%%[' in scanf format string">, InGroup<Format>; @@ -7413,6 +7432,8 @@ def err_omp_unexpected_clause_value : Error< "expected %0 in OpenMP clause '%1'">; def err_omp_expected_var_name : Error< "expected variable name">; +def err_omp_expected_var_name_or_array_item : Error< + "expected variable name, array element or array section">; def note_omp_task_predetermined_firstprivate_here : Note< "predetermined as a firstprivate in a task construct here">; def err_omp_clause_ref_type_arg : Error< @@ -7601,6 +7622,12 @@ def err_omp_single_copyprivate_with_nowait : Error< "the 'copyprivate' clause must not be used with the 'nowait' clause">; def note_omp_nowait_clause_here : Note< "'nowait' clause is here">; +def err_omp_wrong_cancel_region : Error< + "one of 'for', 'parallel', 'sections' or 'taskgroup' is expected">; +def err_omp_parent_cancel_region_nowait : Error< + "parent region for 'omp %select{cancellation point/cancel}0' construct cannot be nowait">; +def err_omp_parent_cancel_region_ordered : Error< + "parent region for 'omp %select{cancellation point/cancel}0' construct cannot be ordered">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { @@ -7677,28 +7704,21 @@ def warn_profile_data_unprofiled : Warning< let CategoryName = "Nullability Issue" in { def warn_mismatched_nullability_attr : Warning< - "nullability specifier " - "'%select{__|}1%select{nonnull|nullable|null_unspecified}0' " - "conflicts with existing specifier " - "'%select{__|}3%select{nonnull|nullable|null_unspecified}2'">, + "nullability specifier %0 conflicts with existing specifier %1">, InGroup<Nullability>; def warn_nullability_declspec : Warning< - "nullability specifier " - "'%select{__nonnull|__nullable|__null_unspecified}0' cannot be applied " + "nullability specifier %0 cannot be applied " "to non-pointer type %1; did you mean to apply the specifier to the " "%select{pointer|block pointer|member pointer|function pointer|" "member function pointer}2?">, InGroup<NullabilityDeclSpec>, DefaultError; -def note_nullability_here : Note< - "'%select{__nonnull|__nullable|__null_unspecified}0' specified here">; +def note_nullability_here : Note<"%0 specified here">; def err_nullability_nonpointer : Error< - "nullability specifier " - "'%select{__|}1%select{nonnull|nullable|null_unspecified}0' cannot be applied " - "to non-pointer type %2">; + "nullability specifier %0 cannot be applied to non-pointer type %1">; def warn_nullability_lost : Warning< "implicit conversion from nullable pointer %0 to non-nullable pointer " @@ -7706,12 +7726,9 @@ def warn_nullability_lost : Warning< InGroup<NullableToNonNullConversion>, DefaultIgnore; def err_nullability_cs_multilevel : Error< - "nullability keyword " - "'%select{nonnull|nullable|null_unspecified}0' cannot be applied to " - "multi-level pointer type %1">; + "nullability keyword %0 cannot be applied to multi-level pointer type %1">; def note_nullability_type_specifier : Note< - "use nullability type specifier " - "'%select{__nonnull|__nullable|__null_unspecified}0' to affect the innermost " + "use nullability type specifier %0 to affect the innermost " "pointer type of %1">; def warn_null_resettable_setter : Warning< @@ -7720,7 +7737,7 @@ def warn_null_resettable_setter : Warning< def warn_nullability_missing : Warning< "%select{pointer|block pointer|member pointer}0 is missing a nullability " - "type specifier (__nonnull, __nullable, or __null_unspecified)">, + "type specifier (_Nonnull, _Nullable, or _Null_unspecified)">, InGroup<NullabilityCompleteness>; } diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index bc586e4..33a8b74 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -406,19 +406,6 @@ public: virtual IdentifierIterator *getIdentifiers(); }; -/// \brief An abstract class used to resolve numerical identifier -/// references (meaningful only to some external source) into -/// IdentifierInfo pointers. -class ExternalIdentifierLookup { -public: - virtual ~ExternalIdentifierLookup(); - - /// \brief Return the identifier associated with the given ID number. - /// - /// The ID 0 is associated with the NULL identifier. - virtual IdentifierInfo *GetIdentifier(unsigned ID) = 0; -}; - /// \brief Implements an efficient mapping from strings to IdentifierInfo nodes. /// /// This has no other purpose, but this is an extremely performance-critical diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index bef122f..b27605b 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -130,6 +130,7 @@ COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "require declaration of module us BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically import modules as needed when performing error recovery") BENIGN_LANGOPT(ImplicitModules, 1, 1, "build modules that are not specified via -fmodule-file") COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility") +COMPATIBLE_LANGOPT(ModulesHideInternalLinkage, 1, 1, "hiding non-visible internal linkage declarations from redeclaration lookup") COMPATIBLE_LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro") COMPATIBLE_LANGOPT(OptimizeSize , 1, 0, "__OPTIMIZE_SIZE__ predefined macro") LANGOPT(Static , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)") diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 84836eb..3c9d23e 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -102,6 +102,8 @@ public: /// \brief The names of any features to enable in module 'requires' decls /// in addition to the hard-coded list in Module.cpp and the target features. + /// + /// This list is sorted. std::vector<std::string> ModuleFeatures; /// \brief Options for parsing comments. diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index 7470610..1bc8925 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -66,6 +66,9 @@ public: /// \brief The umbrella header or directory. llvm::PointerUnion<const DirectoryEntry *, const FileEntry *> Umbrella; + /// \brief The module signature. + uint64_t Signature; + /// \brief The name of the umbrella entry, as written in the module map. std::string UmbrellaAsWritten; diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index b09f012..67a5068 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -69,6 +69,9 @@ #ifndef OPENMP_SCHEDULE_KIND #define OPENMP_SCHEDULE_KIND(Name) #endif +#ifndef OPENMP_DEPEND_KIND +#define OPENMP_DEPEND_KIND(Name) +#endif // OpenMP directives. OPENMP_DIRECTIVE(threadprivate) @@ -90,10 +93,12 @@ OPENMP_DIRECTIVE(ordered) OPENMP_DIRECTIVE(atomic) OPENMP_DIRECTIVE(target) OPENMP_DIRECTIVE(teams) +OPENMP_DIRECTIVE(cancel) OPENMP_DIRECTIVE_EXT(parallel_for, "parallel for") OPENMP_DIRECTIVE_EXT(parallel_for_simd, "parallel for simd") OPENMP_DIRECTIVE_EXT(parallel_sections, "parallel sections") OPENMP_DIRECTIVE_EXT(for_simd, "for simd") +OPENMP_DIRECTIVE_EXT(cancellation_point, "cancellation point") // OpenMP clauses. OPENMP_CLAUSE(if, OMPIfClause) @@ -123,6 +128,7 @@ OPENMP_CLAUSE(write, OMPWriteClause) OPENMP_CLAUSE(update, OMPUpdateClause) OPENMP_CLAUSE(capture, OMPCaptureClause) OPENMP_CLAUSE(seq_cst, OMPSeqCstClause) +OPENMP_CLAUSE(depend, OMPDependClause) // Clauses allowed for OpenMP directive 'parallel'. OPENMP_PARALLEL_CLAUSE(if) @@ -195,6 +201,11 @@ OPENMP_SCHEDULE_KIND(guided) OPENMP_SCHEDULE_KIND(auto) OPENMP_SCHEDULE_KIND(runtime) +// Static attributes for 'depend' clause. +OPENMP_DEPEND_KIND(in) +OPENMP_DEPEND_KIND(out) +OPENMP_DEPEND_KIND(inout) + // Clauses allowed for OpenMP directive 'parallel for'. OPENMP_PARALLEL_FOR_CLAUSE(if) OPENMP_PARALLEL_FOR_CLAUSE(num_threads) @@ -248,6 +259,7 @@ OPENMP_TASK_CLAUSE(firstprivate) OPENMP_TASK_CLAUSE(shared) OPENMP_TASK_CLAUSE(untied) OPENMP_TASK_CLAUSE(mergeable) +OPENMP_TASK_CLAUSE(depend) // Clauses allowed for OpenMP directive 'atomic'. OPENMP_ATOMIC_CLAUSE(read) @@ -268,6 +280,7 @@ OPENMP_TEAMS_CLAUSE(firstprivate) OPENMP_TEAMS_CLAUSE(shared) OPENMP_TEAMS_CLAUSE(reduction) +#undef OPENMP_DEPEND_KIND #undef OPENMP_SCHEDULE_KIND #undef OPENMP_PROC_BIND_KIND #undef OPENMP_DEFAULT_KIND diff --git a/include/clang/Basic/OpenMPKinds.h b/include/clang/Basic/OpenMPKinds.h index e2f1151..83939bb 100644 --- a/include/clang/Basic/OpenMPKinds.h +++ b/include/clang/Basic/OpenMPKinds.h @@ -62,6 +62,14 @@ enum OpenMPScheduleClauseKind { OMPC_SCHEDULE_unknown }; +/// \brief OpenMP attributes for 'depend' clause. +enum OpenMPDependClauseKind { +#define OPENMP_DEPEND_KIND(Name) \ + OMPC_DEPEND_##Name, +#include "clang/Basic/OpenMPKinds.def" + OMPC_DEPEND_unknown +}; + OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str); const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind); diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index 5ce56c0..d95a77f 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -257,7 +257,8 @@ namespace clang { }; /// Retrieve the spelling of the given nullability kind. - llvm::StringRef getNullabilitySpelling(NullabilityKind kind); + llvm::StringRef getNullabilitySpelling(NullabilityKind kind, + bool isContextSensitive = false); } // end namespace clang #endif // LLVM_CLANG_BASIC_SPECIFIERS_H diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td index 675e91d..9d7b6fb 100644 --- a/include/clang/Basic/StmtNodes.td +++ b/include/clang/Basic/StmtNodes.td @@ -205,3 +205,5 @@ def OMPOrderedDirective : DStmt<OMPExecutableDirective>; def OMPAtomicDirective : DStmt<OMPExecutableDirective>; def OMPTargetDirective : DStmt<OMPExecutableDirective>; def OMPTeamsDirective : DStmt<OMPExecutableDirective>; +def OMPCancellationPointDirective : DStmt<OMPExecutableDirective>; +def OMPCancelDirective : DStmt<OMPExecutableDirective>; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index e415733..a3bb535 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -70,6 +70,7 @@ protected: unsigned char MinGlobalAlign; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; unsigned short MaxVectorAlign; + unsigned short SimdDefaultAlign; const char *DescriptionString; const char *UserLabelPrefix; const char *MCountName; @@ -393,6 +394,10 @@ public: /// \brief Return the maximum vector alignment supported for the given target. unsigned getMaxVectorAlign() const { return MaxVectorAlign; } + /// \brief Return default simd alignment for the given target. Generally, this + /// value is type-specific, but this alignment can be used for most of the + /// types for the given target. + unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; } /// \brief Return the size of intmax_t and uintmax_t for this target, in bits. unsigned getIntMaxTWidth() const { @@ -611,6 +616,9 @@ public: } }; + // Validate the contents of the __builtin_cpu_supports(const char*) argument. + virtual bool validateCpuSupports(StringRef Name) const { return false; } + // validateOutputConstraint, validateInputConstraint - Checks that // a constraint is valid and provides information about it. // FIXME: These should return a real error instead of just true/false. diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index 67b9933..ed2aa82 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -503,6 +503,9 @@ ALIAS("read_write", __read_write , KEYOPENCL) KEYWORD(__builtin_astype , KEYOPENCL) KEYWORD(vec_step , KEYOPENCL|KEYALTIVEC) +// OpenMP Type Traits +KEYWORD(__builtin_omp_required_simd_align, KEYALL) + // Borland Extensions. KEYWORD(__pascal , KEYALL) @@ -549,9 +552,9 @@ ALIAS("__volatile" , volatile , KEYALL) ALIAS("__volatile__" , volatile , KEYALL) // Type nullability. -KEYWORD(__nonnull , KEYALL) -KEYWORD(__nullable , KEYALL) -KEYWORD(__null_unspecified , KEYALL) +KEYWORD(_Nonnull , KEYALL) +KEYWORD(_Nullable , KEYALL) +KEYWORD(_Null_unspecified , KEYALL) // Microsoft extensions which should be disabled in strict conformance mode KEYWORD(__ptr64 , KEYMS) diff --git a/include/clang/Basic/TypeTraits.h b/include/clang/Basic/TypeTraits.h index ef84d2b..765246b 100644 --- a/include/clang/Basic/TypeTraits.h +++ b/include/clang/Basic/TypeTraits.h @@ -92,7 +92,8 @@ namespace clang { enum UnaryExprOrTypeTrait { UETT_SizeOf, UETT_AlignOf, - UETT_VecStep + UETT_VecStep, + UETT_OpenMPRequiredSimdAlign, }; } diff --git a/include/clang/CodeGen/CodeGenABITypes.h b/include/clang/CodeGen/CodeGenABITypes.h index 97a9dc8..4e76cd4 100644 --- a/include/clang/CodeGen/CodeGenABITypes.h +++ b/include/clang/CodeGen/CodeGenABITypes.h @@ -37,9 +37,11 @@ namespace clang { class ASTContext; class CXXRecordDecl; class CodeGenOptions; +class CoverageSourceInfo; class DiagnosticsEngine; +class HeaderSearchOptions; class ObjCMethodDecl; -class CoverageSourceInfo; +class PreprocessorOptions; namespace CodeGen { class CGFunctionInfo; @@ -74,6 +76,8 @@ private: /// CodeGenModule and otherwise not used. More specifically, it is /// not used in ABI type generation, so none of the options matter. CodeGenOptions *CGO; + HeaderSearchOptions *HSO; + PreprocessorOptions *PPO; /// The CodeGenModule we use get to the CodeGenTypes object. CodeGen::CodeGenModule *CGM; diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h index 8facc3c..52497d9 100644 --- a/include/clang/CodeGen/ModuleBuilder.h +++ b/include/clang/CodeGen/ModuleBuilder.h @@ -26,6 +26,8 @@ namespace clang { class DiagnosticsEngine; class CoverageSourceInfo; class LangOptions; + class HeaderSearchOptions; + class PreprocessorOptions; class CodeGenOptions; class Decl; @@ -42,6 +44,8 @@ namespace clang { /// the allocated CodeGenerator instance. CodeGenerator *CreateLLVMCodeGen(DiagnosticsEngine &Diags, const std::string &ModuleName, + const HeaderSearchOptions &HeaderSearchOpts, + const PreprocessorOptions &PreprocessorOpts, const CodeGenOptions &CGO, llvm::LLVMContext& C, CoverageSourceInfo *CoverageInfo = nullptr); diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index f2ef71e..60cc6ec 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -369,6 +369,10 @@ def fmodules_local_submodule_visibility : Flag<["-"], "fmodules-local-submodule-visibility">, HelpText<"Enforce name visibility rules across submodules of the same " "top-level module.">; +def fno_modules_hide_internal_linkage : + Flag<["-"], "fno-modules-hide-internal-linkage">, + HelpText<"Make all declarations visible to redeclaration lookup, " + "even if they have internal linkage.">; def fconcepts_ts : Flag<["-"], "fconcepts-ts">, HelpText<"Enable C++ Extensions for Concepts.">; diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td index 01913be..cf6b76b 100644 --- a/include/clang/Driver/CLCompatOptions.td +++ b/include/clang/Driver/CLCompatOptions.td @@ -52,16 +52,18 @@ class CLRemainingArgs<string name> : Option<["/", "-"], name, // (We don't put any of these in cl_compile_Group as the options they alias are // already in the right group.) -def _SLASH_C : CLFlag<"C">, HelpText<"Don't discard comments when preprocessing">, - Alias<C>; +def _SLASH_C : CLFlag<"C">, + HelpText<"Don't discard comments when preprocessing">, Alias<C>; def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias<c>; def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, MetaVarName<"<macro[=value]>">, Alias<D>; def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias<E>; def _SLASH_fp_except : CLFlag<"fp:except">, HelpText<"">, Alias<ftrapping_math>; -def _SLASH_fp_except_ : CLFlag<"fp:except-">, HelpText<"">, Alias<fno_trapping_math>; +def _SLASH_fp_except_ : CLFlag<"fp:except-">, + HelpText<"">, Alias<fno_trapping_math>; def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, Alias<ffast_math>; -def _SLASH_fp_precise : CLFlag<"fp:precise">, HelpText<"">, Alias<fno_fast_math>; +def _SLASH_fp_precise : CLFlag<"fp:precise">, + HelpText<"">, Alias<fno_fast_math>; def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias<fno_fast_math>; def _SLASH_GA : CLFlag<"GA">, Alias<ftlsmodel_EQ>, AliasArgs<["local-exec"]>, HelpText<"Assume thread-local variables are defined in the executable">; @@ -73,11 +75,13 @@ def _SLASH_Gs : CLJoined<"Gs">, HelpText<"Set stack probe size">, Alias<mstack_probe_size>; def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">, Alias<ffunction_sections>; -def _SLASH_Gy_ : CLFlag<"Gy-">, HelpText<"Don't put each function in its own section">, +def _SLASH_Gy_ : CLFlag<"Gy-">, + HelpText<"Don't put each function in its own section">, Alias<fno_function_sections>; def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">, Alias<fdata_sections>; -def _SLASH_Gw_ : CLFlag<"Gw-">, HelpText<"Don't put each data item in its own section">, +def _SLASH_Gw_ : CLFlag<"Gw-">, + HelpText<"Don't put each data item in its own section">, Alias<fno_data_sections>; def _SLASH_help : CLFlag<"help">, Alias<help>, HelpText<"Display available options">; @@ -109,21 +113,15 @@ def _SLASH_Oy_ : CLFlag<"Oy-">, HelpText<"Disable frame pointer omission">, Alias<fno_omit_frame_pointer>; def _SLASH_QUESTION : CLFlag<"?">, Alias<help>, HelpText<"Display available options">; +def _SLASH_Qvec : CLFlag<"Qvec">, + HelpText<"Enable the loop vectorization passes">, Alias<fvectorize>; +def _SLASH_Qvec_ : CLFlag<"Qvec-">, + HelpText<"Disable the loop vectorization passes">, Alias<fno_vectorize>; def _SLASH_showIncludes : CLFlag<"showIncludes">, HelpText<"Print info about included files to stderr">, Alias<show_includes>; def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">, MetaVarName<"<macro>">, Alias<U>; -def _SLASH_vmb : CLFlag<"vmb">, - HelpText<"Use a best-case representation method for member pointers">; -def _SLASH_vmg : CLFlag<"vmg">, - HelpText<"Use a most-general representation for member pointers">; -def _SLASH_vms : CLFlag<"vms">, - HelpText<"Set the default most-general representation to single inheritance">; -def _SLASH_vmm : CLFlag<"vmm">, - HelpText<"Set the default most-general representation to multiple inheritance">; -def _SLASH_vmv : CLFlag<"vmv">, - HelpText<"Set the default most-general representation to virtual inheritance">; def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias<w>; def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias<Wall>; def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias<Wall>; @@ -181,7 +179,8 @@ def _SLASH_arch : CLCompileJoined<"arch:">, HelpText<"Set architecture for code generation">; def _SLASH_M_Group : OptionGroup<"</M group>">, Group<cl_compile_Group>; -def _SLASH_volatile_Group : OptionGroup<"</volatile group>">, Group<cl_compile_Group>; +def _SLASH_volatile_Group : OptionGroup<"</volatile group>">, + Group<cl_compile_Group>; def _SLASH_EH : CLJoined<"EH">, HelpText<"Exception handling model">; def _SLASH_EP : CLFlag<"EP">, @@ -220,22 +219,30 @@ def _SLASH_o : CLJoinedOrSeparate<"o">, HelpText<"Set output file or directory (ends in / or \\)">, MetaVarName<"<file or directory>">; def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">; -def _SLASH_Qvec : CLFlag<"Qvec">, - HelpText<"Enable the loop vectorization passes">, - Alias<fvectorize>; -def _SLASH_Qvec_ : CLFlag<"Qvec-">, - HelpText<"Disable the loop vectorization passes">, - Alias<fno_vectorize>; def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">, HelpText<"Specify a C source file">, MetaVarName<"<filename>">; def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">; def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">, HelpText<"Specify a C++ source file">, MetaVarName<"<filename>">; def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">; -def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, Group<_SLASH_volatile_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Volatile loads and stores have standard semantics">; -def _SLASH_volatile_ms : Option<["/", "-"], "volatile:ms", KIND_FLAG>, Group<_SLASH_volatile_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Volatile loads and stores have acquire and release semantics">; +def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, + Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, + HelpText<"Volatile loads and stores have standard semantics">; +def _SLASH_vmb : CLFlag<"vmb">, + HelpText<"Use a best-case representation method for member pointers">; +def _SLASH_vmg : CLFlag<"vmg">, + HelpText<"Use a most-general representation for member pointers">; +def _SLASH_vms : CLFlag<"vms">, + HelpText<"Set the default most-general representation to single inheritance">; +def _SLASH_vmm : CLFlag<"vmm">, + HelpText<"Set the default most-general representation to " + "multiple inheritance">; +def _SLASH_vmv : CLFlag<"vmv">, + HelpText<"Set the default most-general representation to " + "virtual inheritance">; +def _SLASH_volatile_ms : Option<["/", "-"], "volatile:ms", KIND_FLAG>, + Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, + HelpText<"Volatile loads and stores have acquire and release semantics">; // Ignored: diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h index 5574e2c..f0c1bed 100644 --- a/include/clang/Driver/Compilation.h +++ b/include/clang/Driver/Compilation.h @@ -169,8 +169,9 @@ public: /// /// \param FailingCommands - For non-zero results, this will be a vector of /// failing commands and their associated result code. - void ExecuteJob(const Job &J, - SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands) const; + void ExecuteJobs( + const JobList &Jobs, + SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const; /// initCompilationForDiagnostics - Remove stale state and suppress output /// so compilation can be reexecuted to generate additional diagnostic diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index d7bb1d2..15c194b 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -42,7 +42,7 @@ namespace driver { class Command; class Compilation; class InputInfo; - class Job; + class JobList; class JobAction; class SanitizerArgs; class ToolChain; @@ -195,7 +195,7 @@ private: llvm::opt::Arg **FinalPhaseArg = nullptr) const; // Before executing jobs, sets up response files for commands that need them. - void setUpResponseFiles(Compilation &C, Job &J); + void setUpResponseFiles(Compilation &C, Command &Cmd); void generatePrefixedToolNames(const char *Tool, const ToolChain &TC, SmallVectorImpl<std::string> &Names) const; @@ -262,7 +262,7 @@ public: /// ParseArgStrings - Parse the given list of strings into an /// ArgList. - llvm::opt::InputArgList *ParseArgStrings(ArrayRef<const char *> Args); + llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args); /// BuildInputs - Construct the list of inputs and their types from /// the given arguments. diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h index bc7e3ec..8fc2e8d 100644 --- a/include/clang/Driver/Job.h +++ b/include/clang/Driver/Job.h @@ -37,37 +37,9 @@ struct CrashReportInfo { : Filename(Filename), VFSPath(VFSPath) {} }; -class Job { -public: - enum JobClass { - CommandClass, - FallbackCommandClass, - JobListClass - }; - -private: - JobClass Kind; - -protected: - Job(JobClass _Kind) : Kind(_Kind) {} -public: - virtual ~Job(); - - JobClass getKind() const { return Kind; } - - /// Print - Print this Job in -### format. - /// - /// \param OS - The stream to print on. - /// \param Terminator - A string to print at the end of the line. - /// \param Quote - Should separate arguments be quoted. - /// \param CrashInfo - Details for inclusion in a crash report. - virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, - CrashReportInfo *CrashInfo = nullptr) const = 0; -}; - /// Command - An executable path/name and argument vector to /// execute. -class Command : public Job { +class Command { /// Source - The action which caused the creation of this job. const Action &Source; @@ -106,11 +78,12 @@ class Command : public Job { void writeResponseFile(raw_ostream &OS) const; public: - Command(const Action &_Source, const Tool &_Creator, const char *_Executable, - const llvm::opt::ArgStringList &_Arguments); + Command(const Action &Source, const Tool &Creator, const char *Executable, + const llvm::opt::ArgStringList &Arguments); + virtual ~Command() {} - void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, - CrashReportInfo *CrashInfo = nullptr) const override; + virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, + CrashReportInfo *CrashInfo = nullptr) const; virtual int Execute(const StringRef **Redirects, std::string *ErrMsg, bool *ExecutionFailed) const; @@ -133,11 +106,6 @@ public: const char *getExecutable() const { return Executable; } const llvm::opt::ArgStringList &getArguments() const { return Arguments; } - - static bool classof(const Job *J) { - return J->getKind() == CommandClass || - J->getKind() == FallbackCommandClass; - } }; /// Like Command, but with a fallback which is executed in case @@ -154,18 +122,14 @@ public: int Execute(const StringRef **Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override; - static bool classof(const Job *J) { - return J->getKind() == FallbackCommandClass; - } - private: std::unique_ptr<Command> Fallback; }; /// JobList - A sequence of jobs to perform. -class JobList : public Job { +class JobList { public: - typedef SmallVector<std::unique_ptr<Job>, 4> list_type; + typedef SmallVector<std::unique_ptr<Command>, 4> list_type; typedef list_type::size_type size_type; typedef llvm::pointee_iterator<list_type::iterator> iterator; typedef llvm::pointee_iterator<list_type::const_iterator> const_iterator; @@ -174,14 +138,11 @@ private: list_type Jobs; public: - JobList(); - ~JobList() override {} - void Print(llvm::raw_ostream &OS, const char *Terminator, - bool Quote, CrashReportInfo *CrashInfo = nullptr) const override; + bool Quote, CrashReportInfo *CrashInfo = nullptr) const; /// Add a job to the list (taking ownership). - void addJob(std::unique_ptr<Job> J) { Jobs.push_back(std::move(J)); } + void addJob(std::unique_ptr<Command> J) { Jobs.push_back(std::move(J)); } /// Clear the job list. void clear(); @@ -193,10 +154,6 @@ public: const_iterator begin() const { return Jobs.begin(); } iterator end() { return Jobs.end(); } const_iterator end() const { return Jobs.end(); } - - static bool classof(const Job *J) { - return J->getKind() == JobListClass; - } }; } // end namespace driver diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index aae3776..6a75b7c 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1153,6 +1153,11 @@ def march_EQ : Joined<["-"], "march=">, Group<m_Group>; def masm_EQ : Joined<["-"], "masm=">, Group<m_Group>, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>; def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group<clang_ignored_m_Group>; +def mconsole : Joined<["-"], "mconsole">, Group<m_Group>, Flags<[DriverOption]>; +def mwindows : Joined<["-"], "mwindows">, Group<m_Group>, Flags<[DriverOption]>; +def mdll : Joined<["-"], "mdll">, Group<m_Group>, Flags<[DriverOption]>; +def municode : Joined<["-"], "municode">, Group<m_Group>, Flags<[DriverOption]>; +def mthreads : Joined<["-"], "mthreads">, Group<m_Group>, Flags<[DriverOption]>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group<m_Group>; def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group<m_Group>; def mfix_and_continue : Flag<["-"], "mfix-and-continue">, Group<clang_ignored_m_Group>; @@ -1170,6 +1175,7 @@ def miphoneos_version_min_EQ : Joined<["-"], "miphoneos-version-min=">, Group<m_ def mios_version_min_EQ : Joined<["-"], "mios-version-min=">, Alias<miphoneos_version_min_EQ>, HelpText<"Set iOS deployment target">; def mios_simulator_version_min_EQ : Joined<["-"], "mios-simulator-version-min=">, Alias<miphoneos_version_min_EQ>; +def miphonesimulator_version_min_EQ : Joined<["-"], "miphonesimulator-version-min=">, Alias<miphoneos_version_min_EQ>; def mkernel : Flag<["-"], "mkernel">, Group<m_Group>; def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, Flags<[DriverOption]>; @@ -1742,6 +1748,7 @@ def _warn_ : Joined<["--"], "warn-">, Alias<W_Joined>; def _write_dependencies : Flag<["--"], "write-dependencies">, Alias<MD>; def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, Alias<MMD>; def _ : Joined<["--"], "">, Flags<[Unsupported]>; + def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">, Group<m_hexagon_Features_Group>; def mv1 : Flag<["-"], "mv1">, Group<m_hexagon_Features_Group>, Alias<march_EQ>, AliasArgs<["v1"]>; diff --git a/include/clang/Driver/SanitizerArgs.h b/include/clang/Driver/SanitizerArgs.h index ceba912..11bfd41 100644 --- a/include/clang/Driver/SanitizerArgs.h +++ b/include/clang/Driver/SanitizerArgs.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_DRIVER_SANITIZERARGS_H #include "clang/Basic/Sanitizers.h" +#include "clang/Driver/Types.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include <string> @@ -54,8 +55,8 @@ class SanitizerArgs { bool requiresPIE() const; bool needsUnwindTables() const; bool linkCXXRuntimes() const { return LinkCXXRuntimes; } - void addArgs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const; + void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const; private: void clear(); diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index ad87a05..6f9523c 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -40,168 +40,50 @@ std::error_code make_error_code(ParseError e); /// \brief The \c FormatStyle is used to configure the formatting to follow /// specific guidelines. struct FormatStyle { - /// \brief Supported languages. When stored in a configuration file, specifies - /// the language, that the configuration targets. When passed to the - /// reformat() function, enables syntax features specific to the language. - enum LanguageKind { - /// Do not use. - LK_None, - /// Should be used for C, C++, ObjectiveC, ObjectiveC++. - LK_Cpp, - /// Should be used for Java. - LK_Java, - /// Should be used for JavaScript. - LK_JavaScript, - /// Should be used for Protocol Buffers - /// (https://developers.google.com/protocol-buffers/). - LK_Proto - }; - - /// \brief Language, this format style is targeted at. - LanguageKind Language; - - /// \brief The column limit. - /// - /// A column limit of \c 0 means that there is no column limit. In this case, - /// clang-format will respect the input's line breaking decisions within - /// statements unless they contradict other rules. - unsigned ColumnLimit; - - /// \brief The maximum number of consecutive empty lines to keep. - unsigned MaxEmptyLinesToKeep; - - /// \brief If true, empty lines at the start of blocks are kept. - bool KeepEmptyLinesAtTheStartOfBlocks; - - /// \brief The penalty for each line break introduced inside a comment. - unsigned PenaltyBreakComment; - - /// \brief The penalty for each line break introduced inside a string literal. - unsigned PenaltyBreakString; - - /// \brief The penalty for each character outside of the column limit. - unsigned PenaltyExcessCharacter; - - /// \brief The penalty for breaking before the first \c <<. - unsigned PenaltyBreakFirstLessLess; - - /// \brief The penalty for breaking a function call after "call(". - unsigned PenaltyBreakBeforeFirstCallParameter; - - /// \brief The & and * alignment style. - enum PointerAlignmentStyle { - /// Align pointer to the left. - PAS_Left, - /// Align pointer to the right. - PAS_Right, - /// Align pointer in the middle. - PAS_Middle - }; - - /// Pointer and reference alignment style. - PointerAlignmentStyle PointerAlignment; - - /// \brief If \c true, analyze the formatted file for the most common - /// alignment of & and *. \c PointerAlignment is then used only as fallback. - bool DerivePointerAlignment; - /// \brief The extra indent or outdent of access modifiers, e.g. \c public:. int AccessModifierOffset; - /// \brief Supported language standards. - enum LanguageStandard { - /// Use C++03-compatible syntax. - LS_Cpp03, - /// Use features of C++11 (e.g. \c A<A<int>> instead of - /// <tt>A<A<int> ></tt>). - LS_Cpp11, - /// Automatic detection based on the input. - LS_Auto - }; - - /// \brief Format compatible with this standard, e.g. use - /// <tt>A<A<int> ></tt> instead of \c A<A<int>> for LS_Cpp03. - LanguageStandard Standard; - - /// \brief Indent case labels one level from the switch statement. + /// \brief If \c true, horizontally aligns arguments after an open bracket. /// - /// When \c false, use the same indentation level as for the switch statement. - /// Switch statement body is always indented one level more than case labels. - bool IndentCaseLabels; - - /// \brief Indent if a function definition or declaration is wrapped after the - /// type. - bool IndentWrappedFunctionNames; - - /// \brief Different ways to indent namespace contents. - enum NamespaceIndentationKind { - /// Don't indent in namespaces. - NI_None, - /// Indent only in inner namespaces (nested in other namespaces). - NI_Inner, - /// Indent in all namespaces. - NI_All - }; - - /// \brief The indentation used for namespaces. - NamespaceIndentationKind NamespaceIndentation; + /// This applies to round brackets (parentheses), angle brackets and square + /// brackets. This will result in formattings like + /// \code + /// someLongFunction(argument1, + /// argument2); + /// \endcode + bool AlignAfterOpenBracket; - /// \brief The number of spaces before trailing line comments - /// (\c // - comments). + /// \brief If \c true, aligns consecutive assignments. /// - /// This does not affect trailing block comments (\c /**/ - comments) as those - /// commonly have different usage patterns and a number of special cases. - unsigned SpacesBeforeTrailingComments; + /// This will align the assignment operators of consecutive lines. This + /// will result in formattings like + /// \code + /// int aaaa = 12; + /// int b = 23; + /// int ccc = 23; + /// \endcode + bool AlignConsecutiveAssignments; - /// \brief If \c false, a function declaration's or function definition's - /// parameters will either all be on the same line or will have one line each. - bool BinPackParameters; + /// \brief If \c true, aligns escaped newlines as far left as possible. + /// Otherwise puts them into the right-most column. + bool AlignEscapedNewlinesLeft; - /// \brief If \c false, a function call's arguments will either be all on the - /// same line or will have one line each. - bool BinPackArguments; + /// \brief If \c true, horizontally align operands of binary and ternary + /// expressions. + bool AlignOperands; - /// \brief If \c true, clang-format detects whether function calls and - /// definitions are formatted with one parameter per line. - /// - /// Each call can be bin-packed, one-per-line or inconclusive. If it is - /// inconclusive, e.g. completely on one line, but a decision needs to be - /// made, clang-format analyzes whether there are other bin-packed cases in - /// the input file and act accordingly. - /// - /// NOTE: This is an experimental flag, that might go away or be renamed. Do - /// not use this in config files, etc. Use at your own risk. - bool ExperimentalAutoDetectBinPacking; + /// \brief If \c true, aligns trailing comments. + bool AlignTrailingComments; /// \brief Allow putting all parameters of a function declaration onto /// the next line even if \c BinPackParameters is \c false. bool AllowAllParametersOfDeclarationOnNextLine; - /// \brief Penalty for putting the return type of a function onto its own - /// line. - unsigned PenaltyReturnTypeOnItsOwnLine; - - /// \brief If the constructor initializers don't fit on a line, put each - /// initializer on its own line. - bool ConstructorInitializerAllOnOneLineOrOnePerLine; - - /// \brief Always break constructor initializers before commas and align - /// the commas with the colon. - bool BreakConstructorInitializersBeforeComma; - /// \brief Allows contracting simple braced statements to a single line. /// /// E.g., this allows <tt>if (a) { return; }</tt> to be put on a single line. bool AllowShortBlocksOnASingleLine; - /// \brief If \c true, <tt>if (a) return;</tt> can be put on a single - /// line. - bool AllowShortIfStatementsOnASingleLine; - - /// \brief If \c true, <tt>while (true) continue;</tt> can be put on a - /// single line. - bool AllowShortLoopsOnASingleLine; - /// \brief If \c true, short case labels will be contracted to a single line. bool AllowShortCaseLabelsOnASingleLine; @@ -222,69 +104,27 @@ struct FormatStyle { /// on a single line. ShortFunctionStyle AllowShortFunctionsOnASingleLine; - /// \brief Add a space after \c @property in Objective-C, i.e. use - /// <tt>\@property (readonly)</tt> instead of <tt>\@property(readonly)</tt>. - bool ObjCSpaceAfterProperty; - - /// \brief Add a space in front of an Objective-C protocol list, i.e. use - /// <tt>Foo <Protocol></tt> instead of \c Foo<Protocol>. - bool ObjCSpaceBeforeProtocolList; - - /// \brief If \c true, horizontally aligns arguments after an open bracket. - /// - /// This applies to round brackets (parentheses), angle brackets and square - /// brackets. This will result in formattings like - /// \code - /// someLongFunction(argument1, - /// argument2); - /// \endcode - bool AlignAfterOpenBracket; - - /// \brief If \c true, horizontally align operands of binary and ternary - /// expressions. - bool AlignOperands; - - /// \brief If \c true, aligns trailing comments. - bool AlignTrailingComments; - - /// \brief If \c true, aligns consecutive assignments. - /// - /// This will align the assignment operators of consecutive lines. This - /// will result in formattings like - /// \code - /// int aaaa = 12; - /// int b = 23; - /// int ccc = 23; - /// \endcode - bool AlignConsecutiveAssignments; - - /// \brief If \c true, aligns escaped newlines as far left as possible. - /// Otherwise puts them into the right-most column. - bool AlignEscapedNewlinesLeft; - - /// \brief The number of columns to use for indentation. - unsigned IndentWidth; - - /// \brief The number of columns used for tab stops. - unsigned TabWidth; - - /// \brief The number of characters to use for indentation of constructor - /// initializer lists. - unsigned ConstructorInitializerIndentWidth; + /// \brief If \c true, <tt>if (a) return;</tt> can be put on a single + /// line. + bool AllowShortIfStatementsOnASingleLine; - /// \brief The number of characters to use for indentation of ObjC blocks. - unsigned ObjCBlockIndentWidth; + /// \brief If \c true, <tt>while (true) continue;</tt> can be put on a + /// single line. + bool AllowShortLoopsOnASingleLine; - /// \brief If \c true, always break after function definition return types. - /// - /// More truthfully called 'break before the identifier following the type - /// in a function definition'. PenaltyReturnTypeOnItsOwnLine becomes - /// irrelevant. - bool AlwaysBreakAfterDefinitionReturnType; + /// \brief Different ways to break after the function definition return type. + enum DefinitionReturnTypeBreakingStyle { + /// Break after return type automatically. + /// \c PenaltyReturnTypeOnItsOwnLine is taken into account. + DRTBS_None, + /// Always break after the return type. + DRTBS_All, + /// Always break after the return types of top level functions. + DRTBS_TopLevel, + }; - /// \brief If \c true, always break after the <tt>template<...></tt> of a - /// template declaration. - bool AlwaysBreakTemplateDeclarations; + /// \brief The function definition return type breaking style to use. + DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType; /// \brief If \c true, always break before multiline string literals. /// @@ -294,19 +134,17 @@ struct FormatStyle { /// \c ContinuationIndentWidth spaces from the start of the line. bool AlwaysBreakBeforeMultilineStrings; - /// \brief Different ways to use tab in formatting. - enum UseTabStyle { - /// Never use tab. - UT_Never, - /// Use tabs only for indentation. - UT_ForIndentation, - /// Use tabs whenever we need to fill whitespace that spans at least from - /// one tab stop to the next one. - UT_Always - }; + /// \brief If \c true, always break after the <tt>template<...></tt> of a + /// template declaration. + bool AlwaysBreakTemplateDeclarations; - /// \brief The way to use tab characters in the resulting file. - UseTabStyle UseTab; + /// \brief If \c false, a function call's arguments will either be all on the + /// same line or will have one line each. + bool BinPackArguments; + + /// \brief If \c false, a function declaration's or function definition's + /// parameters will either all be on the same line or will have one line each. + bool BinPackParameters; /// \brief The style of breaking before or after binary operators. enum BinaryOperatorStyle { @@ -321,9 +159,6 @@ struct FormatStyle { /// \brief The way to wrap binary operators. BinaryOperatorStyle BreakBeforeBinaryOperators; - /// \brief If \c true, ternary operators will be placed after line breaks. - bool BreakBeforeTernaryOperators; - /// \brief Different ways to attach braces to their surrounding context. enum BraceBreakingStyle { /// Always attach braces to surrounding context. @@ -344,6 +179,35 @@ struct FormatStyle { /// \brief The brace breaking style to use. BraceBreakingStyle BreakBeforeBraces; + /// \brief If \c true, ternary operators will be placed after line breaks. + bool BreakBeforeTernaryOperators; + + /// \brief Always break constructor initializers before commas and align + /// the commas with the colon. + bool BreakConstructorInitializersBeforeComma; + + /// \brief The column limit. + /// + /// A column limit of \c 0 means that there is no column limit. In this case, + /// clang-format will respect the input's line breaking decisions within + /// statements unless they contradict other rules. + unsigned ColumnLimit; + + /// \brief A regular expression that describes comments with special meaning, + /// which should not be split into lines or otherwise changed. + std::string CommentPragmas; + + /// \brief If the constructor initializers don't fit on a line, put each + /// initializer on its own line. + bool ConstructorInitializerAllOnOneLineOrOnePerLine; + + /// \brief The number of characters to use for indentation of constructor + /// initializer lists. + unsigned ConstructorInitializerIndentWidth; + + /// \brief Indent width for line continuations. + unsigned ContinuationIndentWidth; + /// \brief If \c true, format braced lists as best suited for C++11 braced /// lists. /// @@ -359,29 +223,138 @@ struct FormatStyle { /// a zero-length name is assumed. bool Cpp11BracedListStyle; - /// \brief If \c true, spaces will be inserted after '(' and before ')'. - bool SpacesInParentheses; + /// \brief If \c true, analyze the formatted file for the most common + /// alignment of & and *. \c PointerAlignment is then used only as fallback. + bool DerivePointerAlignment; - /// \brief If \c true, spaces will be inserted after '<' and before '>' in - /// template argument lists - bool SpacesInAngles; + /// \brief Disables formatting completely. + bool DisableFormat; - /// \brief If \c true, spaces will be inserted after '[' and before ']'. - bool SpacesInSquareBrackets; + /// \brief If \c true, clang-format detects whether function calls and + /// definitions are formatted with one parameter per line. + /// + /// Each call can be bin-packed, one-per-line or inconclusive. If it is + /// inconclusive, e.g. completely on one line, but a decision needs to be + /// made, clang-format analyzes whether there are other bin-packed cases in + /// the input file and act accordingly. + /// + /// NOTE: This is an experimental flag, that might go away or be renamed. Do + /// not use this in config files, etc. Use at your own risk. + bool ExperimentalAutoDetectBinPacking; - /// \brief If \c true, spaces may be inserted into '()'. - bool SpaceInEmptyParentheses; + /// \brief A vector of macros that should be interpreted as foreach loops + /// instead of as function calls. + /// + /// These are expected to be macros of the form: + /// \code + /// FOREACH(<variable-declaration>, ...) + /// <loop-body> + /// \endcode + /// + /// For example: BOOST_FOREACH. + std::vector<std::string> ForEachMacros; - /// \brief If \c true, spaces are inserted inside container literals (e.g. - /// ObjC and Javascript array and dict literals). - bool SpacesInContainerLiterals; + /// \brief Indent case labels one level from the switch statement. + /// + /// When \c false, use the same indentation level as for the switch statement. + /// Switch statement body is always indented one level more than case labels. + bool IndentCaseLabels; - /// \brief If \c true, spaces may be inserted into C style casts. - bool SpacesInCStyleCastParentheses; + /// \brief The number of columns to use for indentation. + unsigned IndentWidth; + + /// \brief Indent if a function definition or declaration is wrapped after the + /// type. + bool IndentWrappedFunctionNames; + + /// \brief If true, empty lines at the start of blocks are kept. + bool KeepEmptyLinesAtTheStartOfBlocks; + + /// \brief Supported languages. When stored in a configuration file, specifies + /// the language, that the configuration targets. When passed to the + /// reformat() function, enables syntax features specific to the language. + enum LanguageKind { + /// Do not use. + LK_None, + /// Should be used for C, C++, ObjectiveC, ObjectiveC++. + LK_Cpp, + /// Should be used for Java. + LK_Java, + /// Should be used for JavaScript. + LK_JavaScript, + /// Should be used for Protocol Buffers + /// (https://developers.google.com/protocol-buffers/). + LK_Proto + }; + + /// \brief Language, this format style is targeted at. + LanguageKind Language; + + /// \brief The maximum number of consecutive empty lines to keep. + unsigned MaxEmptyLinesToKeep; + + /// \brief Different ways to indent namespace contents. + enum NamespaceIndentationKind { + /// Don't indent in namespaces. + NI_None, + /// Indent only in inner namespaces (nested in other namespaces). + NI_Inner, + /// Indent in all namespaces. + NI_All + }; + + /// \brief The indentation used for namespaces. + NamespaceIndentationKind NamespaceIndentation; + + /// \brief The number of characters to use for indentation of ObjC blocks. + unsigned ObjCBlockIndentWidth; + + /// \brief Add a space after \c @property in Objective-C, i.e. use + /// <tt>\@property (readonly)</tt> instead of <tt>\@property(readonly)</tt>. + bool ObjCSpaceAfterProperty; + + /// \brief Add a space in front of an Objective-C protocol list, i.e. use + /// <tt>Foo <Protocol></tt> instead of \c Foo<Protocol>. + bool ObjCSpaceBeforeProtocolList; + + /// \brief The penalty for breaking a function call after "call(". + unsigned PenaltyBreakBeforeFirstCallParameter; + + /// \brief The penalty for each line break introduced inside a comment. + unsigned PenaltyBreakComment; + + /// \brief The penalty for breaking before the first \c <<. + unsigned PenaltyBreakFirstLessLess; + + /// \brief The penalty for each line break introduced inside a string literal. + unsigned PenaltyBreakString; + + /// \brief The penalty for each character outside of the column limit. + unsigned PenaltyExcessCharacter; + + /// \brief Penalty for putting the return type of a function onto its own + /// line. + unsigned PenaltyReturnTypeOnItsOwnLine; + + /// \brief The & and * alignment style. + enum PointerAlignmentStyle { + /// Align pointer to the left. + PAS_Left, + /// Align pointer to the right. + PAS_Right, + /// Align pointer in the middle. + PAS_Middle + }; + + /// Pointer and reference alignment style. + PointerAlignmentStyle PointerAlignment; /// \brief If \c true, a space may be inserted after C style casts. bool SpaceAfterCStyleCast; + /// \brief If \c false, spaces will be removed before assignment operators. + bool SpaceBeforeAssignmentOperators; + /// \brief Different ways to put a space before opening parentheses. enum SpaceBeforeParensOptions { /// Never put a space before opening parentheses. @@ -399,97 +372,139 @@ struct FormatStyle { /// \brief Defines in which cases to put a space before opening parentheses. SpaceBeforeParensOptions SpaceBeforeParens; - /// \brief If \c false, spaces will be removed before assignment operators. - bool SpaceBeforeAssignmentOperators; + /// \brief If \c true, spaces may be inserted into '()'. + bool SpaceInEmptyParentheses; - /// \brief Indent width for line continuations. - unsigned ContinuationIndentWidth; + /// \brief The number of spaces before trailing line comments + /// (\c // - comments). + /// + /// This does not affect trailing block comments (\c /**/ - comments) as those + /// commonly have different usage patterns and a number of special cases. + unsigned SpacesBeforeTrailingComments; - /// \brief A regular expression that describes comments with special meaning, - /// which should not be split into lines or otherwise changed. - std::string CommentPragmas; + /// \brief If \c true, spaces will be inserted after '<' and before '>' in + /// template argument lists + bool SpacesInAngles; - /// \brief Disables formatting at all. - bool DisableFormat; + /// \brief If \c true, spaces are inserted inside container literals (e.g. + /// ObjC and Javascript array and dict literals). + bool SpacesInContainerLiterals; - /// \brief A vector of macros that should be interpreted as foreach loops - /// instead of as function calls. - /// - /// These are expected to be macros of the form: - /// \code - /// FOREACH(<variable-declaration>, ...) - /// <loop-body> - /// \endcode - /// - /// For example: BOOST_FOREACH. - std::vector<std::string> ForEachMacros; + /// \brief If \c true, spaces may be inserted into C style casts. + bool SpacesInCStyleCastParentheses; + + /// \brief If \c true, spaces will be inserted after '(' and before ')'. + bool SpacesInParentheses; + + /// \brief If \c true, spaces will be inserted after '[' and before ']'. + bool SpacesInSquareBrackets; + + /// \brief Supported language standards. + enum LanguageStandard { + /// Use C++03-compatible syntax. + LS_Cpp03, + /// Use features of C++11 (e.g. \c A<A<int>> instead of + /// <tt>A<A<int> ></tt>). + LS_Cpp11, + /// Automatic detection based on the input. + LS_Auto + }; + + /// \brief Format compatible with this standard, e.g. use + /// <tt>A<A<int> ></tt> instead of \c A<A<int>> for LS_Cpp03. + LanguageStandard Standard; + + /// \brief The number of columns used for tab stops. + unsigned TabWidth; + + /// \brief Different ways to use tab in formatting. + enum UseTabStyle { + /// Never use tab. + UT_Never, + /// Use tabs only for indentation. + UT_ForIndentation, + /// Use tabs whenever we need to fill whitespace that spans at least from + /// one tab stop to the next one. + UT_Always + }; + + /// \brief The way to use tab characters in the resulting file. + UseTabStyle UseTab; bool operator==(const FormatStyle &R) const { return AccessModifierOffset == R.AccessModifierOffset && AlignAfterOpenBracket == R.AlignAfterOpenBracket && - AlignOperands == R.AlignOperands && + AlignConsecutiveAssignments == R.AlignConsecutiveAssignments && AlignEscapedNewlinesLeft == R.AlignEscapedNewlinesLeft && + AlignOperands == R.AlignOperands && AlignTrailingComments == R.AlignTrailingComments && AllowAllParametersOfDeclarationOnNextLine == R.AllowAllParametersOfDeclarationOnNextLine && + AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine && + AllowShortCaseLabelsOnASingleLine == + R.AllowShortCaseLabelsOnASingleLine && AllowShortFunctionsOnASingleLine == R.AllowShortFunctionsOnASingleLine && - AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine && AllowShortIfStatementsOnASingleLine == R.AllowShortIfStatementsOnASingleLine && AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine && AlwaysBreakAfterDefinitionReturnType == R.AlwaysBreakAfterDefinitionReturnType && - AlwaysBreakTemplateDeclarations == - R.AlwaysBreakTemplateDeclarations && AlwaysBreakBeforeMultilineStrings == R.AlwaysBreakBeforeMultilineStrings && - BinPackParameters == R.BinPackParameters && + AlwaysBreakTemplateDeclarations == + R.AlwaysBreakTemplateDeclarations && BinPackArguments == R.BinPackArguments && + BinPackParameters == R.BinPackParameters && BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators && - BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators && BreakBeforeBraces == R.BreakBeforeBraces && + BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators && BreakConstructorInitializersBeforeComma == R.BreakConstructorInitializersBeforeComma && ColumnLimit == R.ColumnLimit && + CommentPragmas == R.CommentPragmas && ConstructorInitializerAllOnOneLineOrOnePerLine == R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == R.ConstructorInitializerIndentWidth && + ContinuationIndentWidth == R.ContinuationIndentWidth && + Cpp11BracedListStyle == R.Cpp11BracedListStyle && DerivePointerAlignment == R.DerivePointerAlignment && + DisableFormat == R.DisableFormat && ExperimentalAutoDetectBinPacking == R.ExperimentalAutoDetectBinPacking && + ForEachMacros == R.ForEachMacros && IndentCaseLabels == R.IndentCaseLabels && - IndentWrappedFunctionNames == R.IndentWrappedFunctionNames && IndentWidth == R.IndentWidth && Language == R.Language && - MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && + IndentWrappedFunctionNames == R.IndentWrappedFunctionNames && KeepEmptyLinesAtTheStartOfBlocks == R.KeepEmptyLinesAtTheStartOfBlocks && + MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && NamespaceIndentation == R.NamespaceIndentation && ObjCBlockIndentWidth == R.ObjCBlockIndentWidth && ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty && ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList && + PenaltyBreakBeforeFirstCallParameter == + R.PenaltyBreakBeforeFirstCallParameter && PenaltyBreakComment == R.PenaltyBreakComment && PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess && PenaltyBreakString == R.PenaltyBreakString && PenaltyExcessCharacter == R.PenaltyExcessCharacter && PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine && PointerAlignment == R.PointerAlignment && + SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && + SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators && + SpaceBeforeParens == R.SpaceBeforeParens && + SpaceInEmptyParentheses == R.SpaceInEmptyParentheses && SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments && - Cpp11BracedListStyle == R.Cpp11BracedListStyle && - Standard == R.Standard && TabWidth == R.TabWidth && - UseTab == R.UseTab && SpacesInParentheses == R.SpacesInParentheses && - SpacesInSquareBrackets == R.SpacesInSquareBrackets && SpacesInAngles == R.SpacesInAngles && - SpaceInEmptyParentheses == R.SpaceInEmptyParentheses && SpacesInContainerLiterals == R.SpacesInContainerLiterals && SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses && - SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && - SpaceBeforeParens == R.SpaceBeforeParens && - SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators && - ContinuationIndentWidth == R.ContinuationIndentWidth && - CommentPragmas == R.CommentPragmas && - ForEachMacros == R.ForEachMacros; + SpacesInParentheses == R.SpacesInParentheses && + SpacesInSquareBrackets == R.SpacesInSquareBrackets && + Standard == R.Standard && + TabWidth == R.TabWidth && + UseTab == R.UseTab; } }; diff --git a/include/clang/Lex/ExternalPreprocessorSource.h b/include/clang/Lex/ExternalPreprocessorSource.h index 33e7a2d..adf8e71 100644 --- a/include/clang/Lex/ExternalPreprocessorSource.h +++ b/include/clang/Lex/ExternalPreprocessorSource.h @@ -23,7 +23,7 @@ class Module; /// information. /// /// This abstract class allows an external sources (such as the \c ASTReader) -/// to provide additional macro definitions. +/// to provide additional preprocessing information. class ExternalPreprocessorSource { public: virtual ~ExternalPreprocessorSource(); @@ -34,6 +34,11 @@ public: /// \brief Update an out-of-date identifier. virtual void updateOutOfDateIdentifier(IdentifierInfo &II) = 0; + /// \brief Return the identifier associated with the given ID number. + /// + /// The ID 0 is associated with the NULL identifier. + virtual IdentifierInfo *GetIdentifier(unsigned ID) = 0; + /// \brief Map a module ID to a module. virtual Module *getModule(unsigned ModuleID) = 0; }; diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 0406c6d..4c13380 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -27,7 +27,7 @@ namespace clang { class DiagnosticsEngine; -class ExternalIdentifierLookup; +class ExternalPreprocessorSource; class FileEntry; class FileManager; class HeaderSearchOptions; @@ -111,8 +111,9 @@ struct HeaderFileInfo { /// \brief Retrieve the controlling macro for this header file, if /// any. - const IdentifierInfo *getControllingMacro(ExternalIdentifierLookup *External); - + const IdentifierInfo * + getControllingMacro(ExternalPreprocessorSource *External); + /// \brief Determine whether this is a non-default header file info, e.g., /// it corresponds to an actual header we've included or tried to include. bool isNonDefault() const { @@ -242,8 +243,9 @@ class HeaderSearch { llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames; /// \brief Entity used to resolve the identifier IDs of controlling - /// macros into IdentifierInfo pointers, as needed. - ExternalIdentifierLookup *ExternalLookup; + /// macros into IdentifierInfo pointers, and keep the identifire up to date, + /// as needed. + ExternalPreprocessorSource *ExternalLookup; /// \brief Entity used to look up stored header file information. ExternalHeaderFileInfoSource *ExternalSource; @@ -345,11 +347,11 @@ public: FileInfo.clear(); } - void SetExternalLookup(ExternalIdentifierLookup *EIL) { - ExternalLookup = EIL; + void SetExternalLookup(ExternalPreprocessorSource *EPS) { + ExternalLookup = EPS; } - ExternalIdentifierLookup *getExternalLookup() const { + ExternalPreprocessorSource *getExternalLookup() const { return ExternalLookup; } @@ -421,7 +423,7 @@ public: /// \return false if \#including the file will have no effect or true /// if we should include it. bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File, - bool isImport); + bool isImport, Module *CorrespondingModule); /// \brief Return whether the specified file is a normal header, /// a system header, or a C++ friendly system header. diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 0bbcfac..2b18a7d 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -231,8 +231,7 @@ private: return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs)); } - Module *inferFrameworkModule(StringRef ModuleName, - const DirectoryEntry *FrameworkDir, + Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir, Attributes Attrs, Module *Parent); public: @@ -344,10 +343,9 @@ public: /// \brief Infer the contents of a framework module map from the given /// framework directory. - Module *inferFrameworkModule(StringRef ModuleName, - const DirectoryEntry *FrameworkDir, + Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir, bool IsSystem, Module *Parent); - + /// \brief Retrieve the module map file containing the definition of the given /// module. /// diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 439a280..bba0c38 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -394,7 +394,9 @@ class Preprocessor : public RefCountedBase<Preprocessor> { const IdentifierInfo *II) const { // FIXME: Find a spare bit on IdentifierInfo and store a // HasModuleMacros flag. - if (!II->hasMacroDefinition() || !PP.getLangOpts().Modules || + if (!II->hasMacroDefinition() || + (!PP.getLangOpts().Modules && + !PP.getLangOpts().ModulesLocalVisibility) || !PP.CurSubmoduleState->VisibleModules.getGeneration()) return nullptr; @@ -454,7 +456,9 @@ class Preprocessor : public RefCountedBase<Preprocessor> { MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc, SourceManager &SourceMgr) const { // FIXME: Incorporate module macros into the result of this. - return getLatest()->findDirectiveAtLoc(Loc, SourceMgr); + if (auto *Latest = getLatest()) + return Latest->findDirectiveAtLoc(Loc, SourceMgr); + return MacroDirective::DefInfo(); } void overrideActiveModuleMacros(Preprocessor &PP, IdentifierInfo *II) { diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 7042a1e..97a0aa4 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -303,7 +303,7 @@ public: return true; } - /// Retrieve the underscored keyword (__nonnull, __nullable) that corresponds + /// Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds /// to the given nullability kind. IdentifierInfo *getNullabilityKeyword(NullabilityKind nullability) { return Actions.getNullabilityKeyword(nullability); @@ -1182,7 +1182,7 @@ private: ParsingDeclarator &D, const ParsedTemplateInfo &TemplateInfo, const VirtSpecifiers& VS, - ExprResult& Init); + SourceLocation PureSpecLoc); void ParseCXXNonStaticMemberInitializer(Decl *VarD); void ParseLexedAttributes(ParsingClass &Class); void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D, @@ -1331,6 +1331,7 @@ public: ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast); ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast); + ExprResult ParseConstraintExpression(); // Expr that doesn't include commas. ExprResult ParseAssignmentExpression(TypeCastState isTypeCast = NotTypeCast); @@ -1704,6 +1705,7 @@ private: DSC_top_level, // top-level/namespace declaration context DSC_template_type_arg, // template type argument context DSC_objc_method_result, // ObjC method result context, enables 'instancetype' + DSC_condition // condition declaration context }; /// Is this a context in which we are parsing just a type-specifier (or @@ -1714,6 +1716,7 @@ private: case DSC_class: case DSC_top_level: case DSC_objc_method_result: + case DSC_condition: return false; case DSC_template_type_arg: diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 2ec3286..d375ec3 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -358,6 +358,9 @@ private: // constexpr-specifier unsigned Constexpr_specified : 1; + // concept-specifier + unsigned Concept_specified : 1; + union { UnionParsedType TypeRep; Decl *DeclRep; @@ -393,7 +396,7 @@ private: SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc; SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc; SourceLocation FS_forceinlineLoc; - SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc; + SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc, ConceptLoc; WrittenBuiltinSpecs writtenBS; void SaveWrittenBuiltinSpecs(); @@ -437,6 +440,7 @@ public: FS_noreturn_specified(false), Friend_specified(false), Constexpr_specified(false), + Concept_specified(false), Attrs(attrFactory), ProtocolQualifiers(nullptr), NumProtocolQualifiers(0), @@ -688,6 +692,8 @@ public: unsigned &DiagID); bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); + bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, + unsigned &DiagID); bool isFriendSpecified() const { return Friend_specified; } SourceLocation getFriendSpecLoc() const { return FriendLoc; } @@ -698,11 +704,19 @@ public: bool isConstexprSpecified() const { return Constexpr_specified; } SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } + bool isConceptSpecified() const { return Concept_specified; } + SourceLocation getConceptSpecLoc() const { return ConceptLoc; } + void ClearConstexprSpec() { Constexpr_specified = false; ConstexprLoc = SourceLocation(); } + void ClearConceptSpec() { + Concept_specified = false; + ConceptLoc = SourceLocation(); + } + AttributePool &getAttributePool() const { return Attrs.getPool(); } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index cb75b96..72a0e0b 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -277,7 +277,9 @@ class Sema { // it will keep having external linkage. If it has internal linkage, we // will not link it. Since it has no previous decls, it will remain // with internal linkage. - return isVisible(Old) || New->isExternallyVisible(); + if (getLangOpts().ModulesHideInternalLinkage) + return isVisible(Old) || New->isExternallyVisible(); + return true; } public: @@ -700,9 +702,15 @@ public: /// \brief The declaration of the Objective-C NSNumber class. ObjCInterfaceDecl *NSNumberDecl; + /// \brief The declaration of the Objective-C NSValue class. + ObjCInterfaceDecl *NSValueDecl; + /// \brief Pointer to NSNumber type (NSNumber *). QualType NSNumberPointer; + /// \brief Pointer to NSValue type (NSValue *). + QualType NSValuePointer; + /// \brief The Objective-C NSNumber methods used to create NSNumber literals. ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]; @@ -715,6 +723,9 @@ public: /// \brief The declaration of the stringWithUTF8String: method. ObjCMethodDecl *StringWithUTF8StringMethod; + /// \brief The declaration of the valueWithBytes:objCType: method. + ObjCMethodDecl *ValueWithBytesObjCTypeMethod; + /// \brief The declaration of the Objective-C NSArray class. ObjCInterfaceDecl *NSArrayDecl; @@ -1679,6 +1690,7 @@ public: bool TypeMayContainAuto); void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto); void ActOnInitializerError(Decl *Dcl); + void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc); void ActOnCXXForRangeDecl(Decl *D); StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, @@ -2976,7 +2988,7 @@ public: bool SynthesizeProperties); /// Diagnose any null-resettable synthesized setters. - void diagnoseNullResettableSynthesizedSetters(ObjCImplDecl *impDecl); + void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl); /// DefaultSynthesizeProperties - This routine default synthesizes all /// properties which must be synthesized in the class's \@implementation. @@ -5025,9 +5037,9 @@ public: /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the /// '@' prefixed parenthesized expression. The type of the expression will - /// either be "NSNumber *" or "NSString *" depending on the type of - /// ValueType, which is allowed to be a built-in numeric type or - /// "char *" or "const char *". + /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type + /// of ValueType, which is allowed to be a built-in numeric type, "char *", + /// "const char *" or C structure with attribute 'objc_boxable'. ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr); ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, @@ -7603,6 +7615,12 @@ private: bool IsOpenMPCapturedVar(VarDecl *VD); public: + /// \brief Check if the specified variable is used in one of the private + /// clauses in OpenMP constructs. + /// \param Level Relative level of nested OpenMP construct for that the check + /// is performed. + bool isOpenMPPrivateVar(VarDecl *VD, unsigned Level); + ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, Expr *Op); /// \brief Called on start of new data sharing attribute block. @@ -7610,9 +7628,9 @@ public: const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc); /// \brief Start analysis of clauses. - void StartOpenMPClauses(); + void StartOpenMPClause(OpenMPClauseKind K); /// \brief End analysis of clauses. - void EndOpenMPClauses(); + void EndOpenMPClause(); /// \brief Called on end of data sharing attribute block. void EndOpenMPDSABlock(Stmt *CurDirective); @@ -7646,12 +7664,10 @@ public: /// /// \returns Statement for finished OpenMP region. StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses); - StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, - const DeclarationNameInfo &DirName, - ArrayRef<OMPClause *> Clauses, - Stmt *AStmt, - SourceLocation StartLoc, - SourceLocation EndLoc); + StmtResult ActOnOpenMPExecutableDirective( + OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, + OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); /// \brief Called on well-formed '\#pragma omp parallel' after parsing /// of the associated statement. StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, @@ -7757,6 +7773,15 @@ public: StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp cancellation point'. + StmtResult + ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); + /// \brief Called on well-formed '\#pragma omp cancel'. + StmtResult ActOnOpenMPCancelDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + OpenMPDirectiveKind CancelRegion); OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, @@ -7851,13 +7876,13 @@ public: OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc); - OMPClause * - ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, - Expr *TailExpr, SourceLocation StartLoc, - SourceLocation LParenLoc, SourceLocation ColonLoc, - SourceLocation EndLoc, - CXXScopeSpec &ReductionIdScopeSpec, - const DeclarationNameInfo &ReductionId); + OMPClause *ActOnOpenMPVarListClause( + OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation ColonLoc, SourceLocation EndLoc, + CXXScopeSpec &ReductionIdScopeSpec, + const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind, + SourceLocation DepLoc); /// \brief Called on well-formed 'private' clause. OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, @@ -7914,6 +7939,12 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// \brief Called on well-formed 'depend' clause. + OMPClause * + ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc, + SourceLocation ColonLoc, ArrayRef<Expr *> VarList, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc); /// \brief The kind of conversion being performed. enum CheckedConversionKind { @@ -8711,6 +8742,7 @@ private: bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, int ArgNum, unsigned ExpectedFieldNum, bool AllowName); + bool SemaBuiltinCpuSupports(CallExpr *TheCall); public: enum FormatStringType { FST_Scanf, @@ -8840,9 +8872,9 @@ private: mutable IdentifierInfo *Ident___float128; /// Nullability type specifiers. - IdentifierInfo *Ident___nonnull = nullptr; - IdentifierInfo *Ident___nullable = nullptr; - IdentifierInfo *Ident___null_unspecified = nullptr; + IdentifierInfo *Ident__Nonnull = nullptr; + IdentifierInfo *Ident__Nullable = nullptr; + IdentifierInfo *Ident__Null_unspecified = nullptr; IdentifierInfo *Ident_NSError = nullptr; diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 83185a8..ee8e3f4 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -1397,6 +1397,8 @@ namespace clang { STMT_OMP_TARGET_DIRECTIVE, STMT_OMP_TEAMS_DIRECTIVE, STMT_OMP_TASKGROUP_DIRECTIVE, + STMT_OMP_CANCELLATION_POINT_DIRECTIVE, + STMT_OMP_CANCEL_DIRECTIVE, // ARC EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 429f00f..ef5b107 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -304,7 +304,6 @@ class ASTReader public ExternalHeaderFileInfoSource, public ExternalSemaSource, public IdentifierInfoLookup, - public ExternalIdentifierLookup, public ExternalSLocEntrySource { public: @@ -1846,6 +1845,11 @@ public: /// Note: overrides method in ExternalASTSource Module *getModule(unsigned ID) override; + /// \brief Return a descriptor for the corresponding module. + llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID) override; + /// \brief Return a descriptor for the module. + ASTSourceDescriptor getSourceDescriptor(const Module &M) override; + /// \brief Retrieve a selector from the given module with its local ID /// number. Selector getLocalSelector(ModuleFile &M, unsigned LocalID); diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index decd07a..c966d3e 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -42,6 +42,7 @@ namespace llvm { namespace clang { class ASTContext; +class Attr; class NestedNameSpecifier; class CXXBaseSpecifier; class CXXCtorInitializer; @@ -60,6 +61,7 @@ class Module; class PreprocessedEntity; class PreprocessingRecord; class Preprocessor; +class RecordDecl; class Sema; class SourceManager; struct StoredDeclsList; @@ -302,6 +304,7 @@ private: unsigned Loc; unsigned Val; Module *Mod; + const Attr *Attribute; }; public: @@ -315,6 +318,8 @@ private: : Kind(Kind), Val(Val) {} DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {} + DeclUpdate(unsigned Kind, const Attr *Attribute) + : Kind(Kind), Attribute(Attribute) {} unsigned getKind() const { return Kind; } const Decl *getDecl() const { return Dcl; } @@ -324,6 +329,7 @@ private: } unsigned getNumber() const { return Val; } Module *getModule() const { return Mod; } + const Attr *getAttr() const { return Attribute; } }; typedef SmallVector<DeclUpdate, 1> UpdateRecord; @@ -860,6 +866,8 @@ public: void DeclarationMarkedUsed(const Decl *D) override; void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override; void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override; + void AddedAttributeToRecord(const Attr *Attr, + const RecordDecl *Record) override; }; /// \brief AST and semantic-analysis consumer that generates a diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 5571d91..c98ced4 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -20,6 +20,7 @@ #include "clang/Serialization/ContinuousRangeMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/Bitcode/BitstreamReader.h" +#include "llvm/Support/Endian.h" #include <memory> #include <string> @@ -206,7 +207,7 @@ public: llvm::BitstreamCursor InputFilesCursor; /// \brief Offsets for all of the input file entries in the AST file. - const uint64_t *InputFileOffsets; + const llvm::support::unaligned_uint64_t *InputFileOffsets; /// \brief The input files that have been loaded from this AST file. std::vector<InputFile> InputFilesLoaded; diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 308ac83..57c73fd 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -464,7 +464,7 @@ public: /// The reports are usually generated by the checkers. Further, they are /// folded based on the profile value, which is done to coalesce similar /// reports. - void emitReport(BugReport *R); + void emitReport(std::unique_ptr<BugReport> R); void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker, StringRef BugName, StringRef BugCategory, diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index 68274f5..a4ff133 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -232,9 +232,9 @@ public: } /// \brief Emit the diagnostics report. - void emitReport(BugReport *R) { + void emitReport(std::unique_ptr<BugReport> R) { Changed = true; - Eng.getBugReporter().emitReport(R); + Eng.getBugReporter().emitReport(std::move(R)); } /// \brief Get the declaration of the called function (path-sensitive). diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h index 6a42df2..e7ec1f4 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h @@ -28,10 +28,9 @@ template <class T> bool containsStmt(const Stmt *S) { if (isa<T>(S)) return true; - for (Stmt::const_child_range I = S->children(); I; ++I) - if (const Stmt *child = *I) - if (containsStmt<T>(child)) - return true; + for (const Stmt *Child : S->children()) + if (Child && containsStmt<T>(Child)) + return true; return false; } |