Skip to content

Commit e4993fa

Browse files
committed
Merge from 'master' to 'sycl-web' (intel#59)
CONFLICT (content): Merge conflict in clang/docs/LanguageExtensions.rst
2 parents d5b4c66 + 5bd0611 commit e4993fa

File tree

199 files changed

+4385
-1419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+4385
-1419
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,21 +2129,32 @@ object that overloads ``operator&``.
21292129
``__builtin_operator_new`` and ``__builtin_operator_delete``
21302130
------------------------------------------------------------
21312131
2132-
``__builtin_operator_new`` allocates memory just like a non-placement non-class
2133-
*new-expression*. This is exactly like directly calling the normal
2134-
non-placement ``::operator new``, except that it allows certain optimizations
2132+
A call to ``__builtin_operator_new(args)`` is exactly the same as a call to
2133+
``::operator new(args)``, except that it allows certain optimizations
21352134
that the C++ standard does not permit for a direct function call to
21362135
``::operator new`` (in particular, removing ``new`` / ``delete`` pairs and
2137-
merging allocations).
2136+
merging allocations), and that the call is required to resolve to a
2137+
`replaceable global allocation function
2138+
<https://en.cppreference.com/w/cpp/memory/new/operator_new>`_.
21382139
2139-
Likewise, ``__builtin_operator_delete`` deallocates memory just like a
2140-
non-class *delete-expression*, and is exactly like directly calling the normal
2141-
``::operator delete``, except that it permits optimizations. Only the unsized
2142-
form of ``__builtin_operator_delete`` is currently available.
2140+
Likewise, ``__builtin_operator_delete`` is exactly the same as a call to
2141+
``::operator delete(args)``, except that it permits optimizations
2142+
and that the call is required to resolve to a
2143+
`replaceable global deallocation function
2144+
<https://en.cppreference.com/w/cpp/memory/new/operator_delete>`_.
21432145
21442146
These builtins are intended for use in the implementation of ``std::allocator``
21452147
and other similar allocation libraries, and are only available in C++.
21462148
2149+
Query for this feature with ``__has_builtin(__builtin_operator_new)`` or
2150+
``__has_builtin(__builtin_operator_delete)``:
2151+
2152+
* If the value is at least ``201802L``, the builtins behave as described above.
2153+
2154+
* If the value is non-zero, the builtins may not support calling arbitrary
2155+
replaceable global (de)allocation functions, but do support calling at least
2156+
``::operator new(size_t)`` and ``::operator delete(void*)``.
2157+
21472158
``__unique_stable_name``
21482159
------------------------
21492160

clang/include/clang/AST/ASTContext.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ObjCPropertyDecl;
116116
class ObjCPropertyImplDecl;
117117
class ObjCProtocolDecl;
118118
class ObjCTypeParamDecl;
119+
class OMPTraitInfo;
119120
struct ParsedTargetAttr;
120121
class Preprocessor;
121122
class Stmt;
@@ -2962,6 +2963,14 @@ OPT_LIST(V)
29622963
};
29632964

29642965
llvm::StringMap<SectionInfo> SectionInfos;
2966+
2967+
/// Return a new OMPTraitInfo object owned by this context.
2968+
OMPTraitInfo &getNewOMPTraitInfo();
2969+
2970+
private:
2971+
/// All OMPTraitInfo objects live in this collection, one per
2972+
/// `pragma omp [begin] declare variant` directive.
2973+
SmallVector<OMPTraitInfo *, 4> OMPTraitInfoVector;
29652974
};
29662975

29672976
/// Utility function for constructing a nullary selector.

clang/include/clang/AST/OpenMPClause.h

Lines changed: 113 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,12 @@ class OMPReductionClause final
27032703
friend OMPVarListClause;
27042704
friend TrailingObjects;
27052705

2706+
/// Reduction modifier.
2707+
OpenMPReductionClauseModifier Modifier = OMPC_REDUCTION_unknown;
2708+
2709+
/// Reduction modifier location.
2710+
SourceLocation ModifierLoc;
2711+
27062712
/// Location of ':'.
27072713
SourceLocation ColonLoc;
27082714

@@ -2716,18 +2722,22 @@ class OMPReductionClause final
27162722
///
27172723
/// \param StartLoc Starting location of the clause.
27182724
/// \param LParenLoc Location of '('.
2719-
/// \param EndLoc Ending location of the clause.
2725+
/// \param ModifierLoc Modifier location.
27202726
/// \param ColonLoc Location of ':'.
2727+
/// \param EndLoc Ending location of the clause.
27212728
/// \param N Number of the variables in the clause.
27222729
/// \param QualifierLoc The nested-name qualifier with location information
27232730
/// \param NameInfo The full name info for reduction identifier.
27242731
OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
2725-
SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N,
2732+
SourceLocation ModifierLoc, SourceLocation ColonLoc,
2733+
SourceLocation EndLoc,
2734+
OpenMPReductionClauseModifier Modifier, unsigned N,
27262735
NestedNameSpecifierLoc QualifierLoc,
27272736
const DeclarationNameInfo &NameInfo)
27282737
: OMPVarListClause<OMPReductionClause>(OMPC_reduction, StartLoc,
27292738
LParenLoc, EndLoc, N),
2730-
OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
2739+
OMPClauseWithPostUpdate(this), Modifier(Modifier),
2740+
ModifierLoc(ModifierLoc), ColonLoc(ColonLoc),
27312741
QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
27322742

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

2752+
/// Sets reduction modifier.
2753+
void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; }
2754+
2755+
/// Sets location of the modifier.
2756+
void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; }
2757+
27422758
/// Sets location of ':' symbol in clause.
27432759
void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
27442760

@@ -2808,6 +2824,7 @@ class OMPReductionClause final
28082824
///
28092825
/// \param StartLoc Starting location of the clause.
28102826
/// \param LParenLoc Location of '('.
2827+
/// \param ModifierLoc Modifier location.
28112828
/// \param ColonLoc Location of ':'.
28122829
/// \param EndLoc Ending location of the clause.
28132830
/// \param VL The variables in the clause.
@@ -2838,8 +2855,9 @@ class OMPReductionClause final
28382855
/// OpenMP region with this clause.
28392856
static OMPReductionClause *
28402857
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
2841-
SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
2842-
NestedNameSpecifierLoc QualifierLoc,
2858+
SourceLocation ModifierLoc, SourceLocation ColonLoc,
2859+
SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier,
2860+
ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc,
28432861
const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates,
28442862
ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
28452863
ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate);
@@ -2850,6 +2868,12 @@ class OMPReductionClause final
28502868
/// \param N The number of variables.
28512869
static OMPReductionClause *CreateEmpty(const ASTContext &C, unsigned N);
28522870

2871+
/// Returns modifier.
2872+
OpenMPReductionClauseModifier getModifier() const { return Modifier; }
2873+
2874+
/// Returns modifier location.
2875+
SourceLocation getModifierLoc() const { return ModifierLoc; }
2876+
28532877
/// Gets location of ':' symbol in clause.
28542878
SourceLocation getColonLoc() const { return ColonLoc; }
28552879

@@ -6985,6 +7009,80 @@ class OMPInclusiveClause final
69857009
}
69867010
};
69877011

7012+
/// This represents clause 'exclusive' in the '#pragma omp scan' directive.
7013+
///
7014+
/// \code
7015+
/// #pragma omp scan exclusive(a,b)
7016+
/// \endcode
7017+
/// In this example directive '#pragma omp scan' has clause 'exclusive'
7018+
/// with the variables 'a' and 'b'.
7019+
class OMPExclusiveClause final
7020+
: public OMPVarListClause<OMPExclusiveClause>,
7021+
private llvm::TrailingObjects<OMPExclusiveClause, Expr *> {
7022+
friend class OMPClauseReader;
7023+
friend OMPVarListClause;
7024+
friend TrailingObjects;
7025+
7026+
/// Build clause with number of variables \a N.
7027+
///
7028+
/// \param StartLoc Starting location of the clause.
7029+
/// \param LParenLoc Location of '('.
7030+
/// \param EndLoc Ending location of the clause.
7031+
/// \param N Number of the variables in the clause.
7032+
OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc,
7033+
SourceLocation EndLoc, unsigned N)
7034+
: OMPVarListClause<OMPExclusiveClause>(OMPC_exclusive, StartLoc,
7035+
LParenLoc, EndLoc, N) {}
7036+
7037+
/// Build an empty clause.
7038+
///
7039+
/// \param N Number of variables.
7040+
explicit OMPExclusiveClause(unsigned N)
7041+
: OMPVarListClause<OMPExclusiveClause>(OMPC_exclusive, SourceLocation(),
7042+
SourceLocation(), SourceLocation(),
7043+
N) {}
7044+
7045+
public:
7046+
/// Creates clause with a list of variables \a VL.
7047+
///
7048+
/// \param C AST context.
7049+
/// \param StartLoc Starting location of the clause.
7050+
/// \param LParenLoc Location of '('.
7051+
/// \param EndLoc Ending location of the clause.
7052+
/// \param VL List of references to the original variables.
7053+
static OMPExclusiveClause *Create(const ASTContext &C,
7054+
SourceLocation StartLoc,
7055+
SourceLocation LParenLoc,
7056+
SourceLocation EndLoc, ArrayRef<Expr *> VL);
7057+
7058+
/// Creates an empty clause with the place for \a N variables.
7059+
///
7060+
/// \param C AST context.
7061+
/// \param N The number of variables.
7062+
static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N);
7063+
7064+
child_range children() {
7065+
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
7066+
reinterpret_cast<Stmt **>(varlist_end()));
7067+
}
7068+
7069+
const_child_range children() const {
7070+
auto Children = const_cast<OMPExclusiveClause *>(this)->children();
7071+
return const_child_range(Children.begin(), Children.end());
7072+
}
7073+
7074+
child_range used_children() {
7075+
return child_range(child_iterator(), child_iterator());
7076+
}
7077+
const_child_range used_children() const {
7078+
return const_child_range(const_child_iterator(), const_child_iterator());
7079+
}
7080+
7081+
static bool classof(const OMPClause *T) {
7082+
return T->getClauseKind() == OMPC_exclusive;
7083+
}
7084+
};
7085+
69887086
/// This class implements a simple visitor for OMPClause
69897087
/// subclasses.
69907088
template<class ImplClass, template <typename> class Ptr, typename RetTy>
@@ -7042,22 +7140,27 @@ class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
70427140
/// collection of selector sets, each with an associated kind and an ordered
70437141
/// collection of selectors. A selector has a kind, an optional score/condition,
70447142
/// and an ordered collection of properties.
7045-
struct OMPTraitInfo {
7143+
class OMPTraitInfo {
7144+
/// Private constructor accesible only by ASTContext.
7145+
OMPTraitInfo() {}
7146+
friend class ASTContext;
7147+
7148+
public:
70467149
struct OMPTraitProperty {
70477150
llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
70487151
};
70497152
struct OMPTraitSelector {
70507153
Expr *ScoreOrCondition = nullptr;
70517154
llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
7052-
llvm::SmallVector<OMPTraitProperty, 4> Properties;
7155+
llvm::SmallVector<OMPTraitProperty, 1> Properties;
70537156
};
70547157
struct OMPTraitSet {
70557158
llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
7056-
llvm::SmallVector<OMPTraitSelector, 4> Selectors;
7159+
llvm::SmallVector<OMPTraitSelector, 2> Selectors;
70577160
};
70587161

70597162
/// The outermost level of selector sets.
7060-
llvm::SmallVector<OMPTraitSet, 4> Sets;
7163+
llvm::SmallVector<OMPTraitSet, 2> Sets;
70617164

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

70877191
} // namespace clang
70887192

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,6 +3190,13 @@ bool RecursiveASTVisitor<Derived>::VisitOMPInclusiveClause(
31903190
return true;
31913191
}
31923192

3193+
template <typename Derived>
3194+
bool RecursiveASTVisitor<Derived>::VisitOMPExclusiveClause(
3195+
OMPExclusiveClause *C) {
3196+
TRY_TO(VisitOMPClauseList(C));
3197+
return true;
3198+
}
3199+
31933200
template <typename Derived>
31943201
bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
31953202
TRY_TO(VisitOMPClauseList(C));

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3763,7 +3763,7 @@ def OMPDeclareVariant : InheritableAttr {
37633763
OMPTraitInfoArgument<"TraitInfos">,
37643764
];
37653765
let AdditionalMembers = [{
3766-
OMPTraitInfo &getTraitInfo() { return traitInfos; }
3766+
OMPTraitInfo &getTraitInfo() { return *traitInfos; }
37673767
void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
37683768
const;
37693769
}];

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ def err_id_after_template_in_nested_name_spec : Error<
706706
"expected template name after 'template' keyword in nested name specifier">;
707707
def err_unexpected_template_in_unqualified_id : Error<
708708
"'template' keyword not permitted here">;
709+
def err_unexpected_template_in_destructor_name : Error<
710+
"'template' keyword not permitted in destructor name">;
709711
def err_unexpected_template_after_using : Error<
710712
"'template' keyword not permitted after 'using' keyword">;
711713
def err_two_right_angle_brackets_need_space : Error<

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@
218218
#ifndef OPENMP_SCAN_CLAUSE
219219
#define OPENMP_SCAN_CLAUSE(Name)
220220
#endif
221+
#ifndef OPENMP_REDUCTION_MODIFIER
222+
#define OPENMP_REDUCTION_MODIFIER(Name)
223+
#endif
221224

222225
// OpenMP clauses.
223226
OPENMP_CLAUSE(allocator, OMPAllocatorClause)
@@ -285,9 +288,11 @@ OPENMP_CLAUSE(depobj, OMPDepobjClause)
285288
OPENMP_CLAUSE(destroy, OMPDestroyClause)
286289
OPENMP_CLAUSE(detach, OMPDetachClause)
287290
OPENMP_CLAUSE(inclusive, OMPInclusiveClause)
291+
OPENMP_CLAUSE(exclusive, OMPExclusiveClause)
288292

289293
// Clauses allowed for OpenMP directive 'scan'.
290294
OPENMP_SCAN_CLAUSE(inclusive)
295+
OPENMP_SCAN_CLAUSE(exclusive)
291296

292297
// Clauses allowed for OpenMP directive 'parallel'.
293298
OPENMP_PARALLEL_CLAUSE(if)
@@ -1105,6 +1110,10 @@ OPENMP_DEPOBJ_CLAUSE(depend)
11051110
OPENMP_DEPOBJ_CLAUSE(destroy)
11061111
OPENMP_DEPOBJ_CLAUSE(update)
11071112

1113+
// Modifiers for 'reduction' clause.
1114+
OPENMP_REDUCTION_MODIFIER(default)
1115+
1116+
#undef OPENMP_REDUCTION_MODIFIER
11081117
#undef OPENMP_SCAN_CLAUSE
11091118
#undef OPENMP_DEVICE_MODIFIER
11101119
#undef OPENMP_DEPOBJ_CLAUSE

clang/include/clang/Basic/OpenMPKinds.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ struct OpenMPScheduleTy final {
168168
OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
169169
};
170170

171+
/// OpenMP modifiers for 'reduction' clause.
172+
enum OpenMPReductionClauseModifier {
173+
#define OPENMP_REDUCTION_MODIFIER(Name) OMPC_REDUCTION_##Name,
174+
#include "clang/Basic/OpenMPKinds.def"
175+
OMPC_REDUCTION_unknown,
176+
};
177+
171178
OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
172179
const char *getOpenMPClauseName(OpenMPClauseKind Kind);
173180

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3086,7 +3086,7 @@ class Parser : public CodeCompletionHandler {
30863086
SmallVector<SourceLocation, OMPMapClause::NumberOfModifiers>
30873087
MapTypeModifiersLoc;
30883088
bool IsMapTypeImplicit = false;
3089-
SourceLocation DepLinMapLastLoc;
3089+
SourceLocation ExtraModifierLoc;
30903090
};
30913091

30923092
/// Parses clauses with list.

0 commit comments

Comments
 (0)