Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (intel#59)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/docs/LanguageExtensions.rst
  • Loading branch information
bader committed Mar 30, 2020
2 parents d5b4c66 + 5bd0611 commit e4993fa
Show file tree
Hide file tree
Showing 199 changed files with 4,385 additions and 1,419 deletions.
27 changes: 19 additions & 8 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2129,21 +2129,32 @@ object that overloads ``operator&``.
``__builtin_operator_new`` and ``__builtin_operator_delete``
------------------------------------------------------------
``__builtin_operator_new`` allocates memory just like a non-placement non-class
*new-expression*. This is exactly like directly calling the normal
non-placement ``::operator new``, except that it allows certain optimizations
A call to ``__builtin_operator_new(args)`` is exactly the same as a call to
``::operator new(args)``, except that it allows certain optimizations
that the C++ standard does not permit for a direct function call to
``::operator new`` (in particular, removing ``new`` / ``delete`` pairs and
merging allocations).
merging allocations), and that the call is required to resolve to a
`replaceable global allocation function
<https://en.cppreference.com/w/cpp/memory/new/operator_new>`_.
Likewise, ``__builtin_operator_delete`` deallocates memory just like a
non-class *delete-expression*, and is exactly like directly calling the normal
``::operator delete``, except that it permits optimizations. Only the unsized
form of ``__builtin_operator_delete`` is currently available.
Likewise, ``__builtin_operator_delete`` is exactly the same as a call to
``::operator delete(args)``, except that it permits optimizations
and that the call is required to resolve to a
`replaceable global deallocation function
<https://en.cppreference.com/w/cpp/memory/new/operator_delete>`_.
These builtins are intended for use in the implementation of ``std::allocator``
and other similar allocation libraries, and are only available in C++.
Query for this feature with ``__has_builtin(__builtin_operator_new)`` or
``__has_builtin(__builtin_operator_delete)``:
* If the value is at least ``201802L``, the builtins behave as described above.
* If the value is non-zero, the builtins may not support calling arbitrary
replaceable global (de)allocation functions, but do support calling at least
``::operator new(size_t)`` and ``::operator delete(void*)``.
``__unique_stable_name``
------------------------
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ObjCPropertyDecl;
class ObjCPropertyImplDecl;
class ObjCProtocolDecl;
class ObjCTypeParamDecl;
class OMPTraitInfo;
struct ParsedTargetAttr;
class Preprocessor;
class Stmt;
Expand Down Expand Up @@ -2962,6 +2963,14 @@ OPT_LIST(V)
};

llvm::StringMap<SectionInfo> SectionInfos;

/// Return a new OMPTraitInfo object owned by this context.
OMPTraitInfo &getNewOMPTraitInfo();

private:
/// All OMPTraitInfo objects live in this collection, one per
/// `pragma omp [begin] declare variant` directive.
SmallVector<OMPTraitInfo *, 4> OMPTraitInfoVector;
};

/// Utility function for constructing a nullary selector.
Expand Down
122 changes: 113 additions & 9 deletions clang/include/clang/AST/OpenMPClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,12 @@ class OMPReductionClause final
friend OMPVarListClause;
friend TrailingObjects;

/// Reduction modifier.
OpenMPReductionClauseModifier Modifier = OMPC_REDUCTION_unknown;

/// Reduction modifier location.
SourceLocation ModifierLoc;

/// Location of ':'.
SourceLocation ColonLoc;

Expand All @@ -2716,18 +2722,22 @@ class OMPReductionClause final
///
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param EndLoc Ending location of the clause.
/// \param ModifierLoc Modifier location.
/// \param ColonLoc Location of ':'.
/// \param EndLoc Ending location of the clause.
/// \param N Number of the variables in the clause.
/// \param QualifierLoc The nested-name qualifier with location information
/// \param NameInfo The full name info for reduction identifier.
OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
SourceLocation ModifierLoc, SourceLocation ColonLoc,
SourceLocation EndLoc,
OpenMPReductionClauseModifier Modifier, unsigned N,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo)
: OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
LParenLoc, EndLoc, N),
OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
OMPClauseWithPostUpdate(this), Modifier(Modifier),
ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}

/// Build an empty clause.
Expand All @@ -2739,6 +2749,12 @@ class OMPReductionClause final
N),
OMPClauseWithPostUpdate(this) {}

/// Sets reduction modifier.
void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }

/// Sets location of the modifier.
void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }

/// Sets location of ':' symbol in clause.
void setColonLoc(SourceLocation CL) { ColonLoc = CL; }

Expand Down Expand Up @@ -2808,6 +2824,7 @@ class OMPReductionClause final
///
/// \param StartLoc Starting location of the clause.
/// \param LParenLoc Location of '('.
/// \param ModifierLoc Modifier location.
/// \param ColonLoc Location of ':'.
/// \param EndLoc Ending location of the clause.
/// \param VL The variables in the clause.
Expand Down Expand Up @@ -2838,8 +2855,9 @@ class OMPReductionClause final
/// OpenMP region with this clause.
static OMPReductionClause *
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
NestedNameSpecifierLoc QualifierLoc,
SourceLocation ModifierLoc, SourceLocation ColonLoc,
SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
Expand All @@ -2850,6 +2868,12 @@ class OMPReductionClause final
/// \param N The number of variables.
static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);

/// Returns modifier.
OpenMPReductionClauseModifier getModifier() const { return Modifier; }

/// Returns modifier location.
SourceLocation getModifierLoc() const { return ModifierLoc; }

/// Gets location of ':' symbol in clause.
SourceLocation getColonLoc() const { return ColonLoc; }

Expand Down Expand Up @@ -6985,6 +7009,80 @@ class OMPInclusiveClause final
}
};

/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
///
/// \code
/// #pragma omp scan exclusive(a,b)
/// \endcode
/// In this example directive '#pragma omp scan' has clause 'exclusive'
/// with the variables 'a' and 'b'.
class OMPExclusiveClause final
: public OMPVarListClause<OMPExclusiveClause>,
private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
friend class OMPClauseReader;
friend OMPVarListClause;
friend TrailingObjects;

/// 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.
OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation EndLoc, unsigned N)
: OMPVarListClause<OMPExclusiveClause>(OMPC_exclusive, StartLoc,
LParenLoc, EndLoc, N) {}

/// Build an empty clause.
///
/// \param N Number of variables.
explicit OMPExclusiveClause(unsigned N)
: OMPVarListClause<OMPExclusiveClause>(OMPC_exclusive, SourceLocation(),
SourceLocation(), SourceLocation(),
N) {}

public:
/// 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 VL List of references to the original variables.
static OMPExclusiveClause *Create(const ASTContext &C,
SourceLocation StartLoc,
SourceLocation LParenLoc,
SourceLocation EndLoc, ArrayRef<Expr *> VL);

/// Creates an empty clause with the place for \a N variables.
///
/// \param C AST context.
/// \param N The number of variables.
static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);

child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
reinterpret_cast<Stmt **>(varlist_end()));
}

const_child_range children() const {
auto Children = const_cast<OMPExclusiveClause *>(this)->children();
return const_child_range(Children.begin(), Children.end());
}

child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}

static bool classof(const OMPClause *T) {
return T->getClauseKind() == OMPC_exclusive;
}
};

/// This class implements a simple visitor for OMPClause
/// subclasses.
template<class ImplClass, template <typename> class Ptr, typename RetTy>
Expand Down Expand Up @@ -7042,22 +7140,27 @@ class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
/// collection of selector sets, each with an associated kind and an ordered
/// collection of selectors. A selector has a kind, an optional score/condition,
/// and an ordered collection of properties.
struct OMPTraitInfo {
class OMPTraitInfo {
/// Private constructor accesible only by ASTContext.
OMPTraitInfo() {}
friend class ASTContext;

public:
struct OMPTraitProperty {
llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
};
struct OMPTraitSelector {
Expr *ScoreOrCondition = nullptr;
llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
llvm::SmallVector<OMPTraitProperty, 4> Properties;
llvm::SmallVector<OMPTraitProperty, 1> Properties;
};
struct OMPTraitSet {
llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
llvm::SmallVector<OMPTraitSelector, 4> Selectors;
llvm::SmallVector<OMPTraitSelector, 2> Selectors;
};

/// The outermost level of selector sets.
llvm::SmallVector<OMPTraitSet, 4> Sets;
llvm::SmallVector<OMPTraitSet, 2> Sets;

bool anyScoreOrCondition(
llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
Expand All @@ -7083,6 +7186,7 @@ struct OMPTraitInfo {
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);

} // namespace clang

Expand Down
7 changes: 7 additions & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3190,6 +3190,13 @@ bool RecursiveASTVisitor<Derived>::VisitOMPInclusiveClause(
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPExclusiveClause(
OMPExclusiveClause *C) {
TRY_TO(VisitOMPClauseList(C));
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
TRY_TO(VisitOMPClauseList(C));
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -3763,7 +3763,7 @@ def OMPDeclareVariant : InheritableAttr {
OMPTraitInfoArgument<"TraitInfos">,
];
let AdditionalMembers = [{
OMPTraitInfo &getTraitInfo() { return traitInfos; }
OMPTraitInfo &getTraitInfo() { return *traitInfos; }
void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
const;
}];
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ def err_id_after_template_in_nested_name_spec : Error<
"expected template name after 'template' keyword in nested name specifier">;
def err_unexpected_template_in_unqualified_id : Error<
"'template' keyword not permitted here">;
def err_unexpected_template_in_destructor_name : Error<
"'template' keyword not permitted in destructor name">;
def err_unexpected_template_after_using : Error<
"'template' keyword not permitted after 'using' keyword">;
def err_two_right_angle_brackets_need_space : Error<
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/Basic/OpenMPKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@
#ifndef OPENMP_SCAN_CLAUSE
#define OPENMP_SCAN_CLAUSE(Name)
#endif
#ifndef OPENMP_REDUCTION_MODIFIER
#define OPENMP_REDUCTION_MODIFIER(Name)
#endif

// OpenMP clauses.
OPENMP_CLAUSE(allocator, OMPAllocatorClause)
Expand Down Expand Up @@ -285,9 +288,11 @@ OPENMP_CLAUSE(depobj, OMPDepobjClause)
OPENMP_CLAUSE(destroy, OMPDestroyClause)
OPENMP_CLAUSE(detach, OMPDetachClause)
OPENMP_CLAUSE(inclusive, OMPInclusiveClause)
OPENMP_CLAUSE(exclusive, OMPExclusiveClause)

// Clauses allowed for OpenMP directive 'scan'.
OPENMP_SCAN_CLAUSE(inclusive)
OPENMP_SCAN_CLAUSE(exclusive)

// Clauses allowed for OpenMP directive 'parallel'.
OPENMP_PARALLEL_CLAUSE(if)
Expand Down Expand Up @@ -1105,6 +1110,10 @@ OPENMP_DEPOBJ_CLAUSE(depend)
OPENMP_DEPOBJ_CLAUSE(destroy)
OPENMP_DEPOBJ_CLAUSE(update)

// Modifiers for 'reduction' clause.
OPENMP_REDUCTION_MODIFIER(default)

#undef OPENMP_REDUCTION_MODIFIER
#undef OPENMP_SCAN_CLAUSE
#undef OPENMP_DEVICE_MODIFIER
#undef OPENMP_DEPOBJ_CLAUSE
Expand Down
7 changes: 7 additions & 0 deletions clang/include/clang/Basic/OpenMPKinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ struct OpenMPScheduleTy final {
OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
};

/// OpenMP modifiers for 'reduction' clause.
enum OpenMPReductionClauseModifier {
#define OPENMP_REDUCTION_MODIFIER(Name) OMPC_REDUCTION_##Name,
#include "clang/Basic/OpenMPKinds.def"
OMPC_REDUCTION_unknown,
};

OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
const char *getOpenMPClauseName(OpenMPClauseKind Kind);

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,7 @@ class Parser : public CodeCompletionHandler {
SmallVector<SourceLocation, OMPMapClause::NumberOfModifiers>
MapTypeModifiersLoc;
bool IsMapTypeImplicit = false;
SourceLocation DepLinMapLastLoc;
SourceLocation ExtraModifierLoc;
};

/// Parses clauses with list.
Expand Down
Loading

0 comments on commit e4993fa

Please sign in to comment.