Skip to content

Commit 6925c69

Browse files
author
Valery N Dmitriev
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp
2 parents a0fcd3a + 849d440 commit 6925c69

File tree

263 files changed

+4343
-2966
lines changed

Some content is hidden

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

263 files changed

+4343
-2966
lines changed

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class HighlightingsBuilder {
224224
// Create one token for each line in the skipped range, so it works
225225
// with line-based diffing.
226226
assert(R.start.line <= R.end.line);
227-
for (int Line = R.start.line; Line < R.end.line; ++Line) {
227+
for (int Line = R.start.line; Line <= R.end.line; ++Line) {
228228
// Don't bother computing the offset for the end of the line, just use
229229
// zero. The client will treat this highlighting kind specially, and
230230
// highlight the entire line visually (i.e. not just to where the text

clang/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ endif()
99
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
1010
project(Clang)
1111

12+
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
13+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
14+
set(CMAKE_CXX_EXTENSIONS NO)
15+
1216
# Rely on llvm-config.
1317
set(CONFIG_OUTPUT)
1418
if(LLVM_CONFIG)

clang/docs/UsersManual.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,7 @@ Global objects must be constructed before the first kernel using the global obje
31323132
is executed and destroyed just after the last kernel using the program objects is
31333133
executed. In OpenCL v2.0 drivers there is no specific API for invoking global
31343134
constructors. However, an easy workaround would be to enqueue a constructor
3135-
initialization kernel that has a name ``@_GLOBAL__sub_I_<compiled file name>``.
3135+
initialization kernel that has a name ``_GLOBAL__sub_I_<compiled file name>``.
31363136
This kernel is only present if there are any global objects to be initialized in
31373137
the compiled binary. One way to check this is by passing ``CL_PROGRAM_KERNEL_NAMES``
31383138
to ``clGetProgramInfo`` (OpenCL v2.0 s5.8.7).
@@ -3148,7 +3148,7 @@ before running any kernels in which the objects are used.
31483148
clang -cl-std=clc++ test.cl
31493149
31503150
If there are any global objects to be initialized, the final binary will contain
3151-
the ``@_GLOBAL__sub_I_test.cl`` kernel to be enqueued.
3151+
the ``_GLOBAL__sub_I_test.cl`` kernel to be enqueued.
31523152

31533153
Global destructors can not be invoked in OpenCL v2.0 drivers. However, all memory used
31543154
for program scope objects is released on ``clReleaseProgram``.

clang/include/clang/AST/Stmt.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,8 @@ class WhileStmt final : public Stmt,
22772277
enum { VarOffset = 0, BodyOffsetFromCond = 1 };
22782278
enum { NumMandatoryStmtPtr = 2 };
22792279

2280+
SourceLocation LParenLoc, RParenLoc;
2281+
22802282
unsigned varOffset() const { return VarOffset; }
22812283
unsigned condOffset() const { return VarOffset + hasVarStorage(); }
22822284
unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
@@ -2287,15 +2289,17 @@ class WhileStmt final : public Stmt,
22872289

22882290
/// Build a while statement.
22892291
WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body,
2290-
SourceLocation WL);
2292+
SourceLocation WL, SourceLocation LParenLoc,
2293+
SourceLocation RParenLoc);
22912294

22922295
/// Build an empty while statement.
22932296
explicit WhileStmt(EmptyShell Empty, bool HasVar);
22942297

22952298
public:
22962299
/// Create a while statement.
22972300
static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
2298-
Stmt *Body, SourceLocation WL);
2301+
Stmt *Body, SourceLocation WL,
2302+
SourceLocation LParenLoc, SourceLocation RParenLoc);
22992303

23002304
/// Create an empty while statement optionally with storage for
23012305
/// a condition variable.
@@ -2359,6 +2363,11 @@ class WhileStmt final : public Stmt,
23592363
SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; }
23602364
void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; }
23612365

2366+
SourceLocation getLParenLoc() const { return LParenLoc; }
2367+
void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2368+
SourceLocation getRParenLoc() const { return RParenLoc; }
2369+
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2370+
23622371
SourceLocation getBeginLoc() const { return getWhileLoc(); }
23632372
SourceLocation getEndLoc() const LLVM_READONLY {
23642373
return getBody()->getEndLoc();

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def err_drv_no_cuda_libdevice : Error<
5656
"cannot find libdevice for %0. Provide path to different CUDA installation "
5757
"via --cuda-path, or pass -nocudalib to build without linking with libdevice.">;
5858

59-
def err_drv_no_rocm_installation : Error<
60-
"cannot find ROCm installation. Provide its path via --rocm-path, or pass "
61-
"-nogpulib and -nogpuinc to build without ROCm device library and HIP includes.">;
6259
def err_drv_no_rocm_device_lib : Error<
63-
"cannot find device library for %0. Provide path to different ROCm installation "
64-
"via --rocm-path, or pass -nogpulib to build without linking default libraries.">;
60+
"cannot find ROCm device library%select{| for %1}0. Provide its path via --rocm-path or "
61+
"--rocm-device-lib-path, or pass -nogpulib to build without ROCm device library.">;
62+
def err_drv_no_hip_runtime : Error<
63+
"cannot find HIP runtime. Provide its path via --rocm-path, or pass "
64+
"-nogpuinc to build without HIP runtime.">;
6565

6666
def err_drv_cuda_version_unsupported : Error<
6767
"GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5436,9 +5436,6 @@ def ext_typecheck_zero_array_size : Extension<
54365436
"zero size arrays are an extension">, InGroup<ZeroLengthArray>;
54375437
def err_typecheck_zero_array_size : Error<
54385438
"zero-length arrays are not permitted in C++">;
5439-
def warn_typecheck_zero_static_array_size : Warning<
5440-
"'static' has no effect on zero-length arrays">,
5441-
InGroup<ArrayBounds>;
54425439
def err_array_size_non_int : Error<"size of array has non-integer type %0">;
54435440
def err_init_element_not_constant : Error<
54445441
"initializer element is not a compile-time constant">;

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,19 @@ defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr",
656656
"Use 32-bit pointers for accessing const/local/shared address spaces">;
657657
def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group<i_Group>,
658658
HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">;
659-
def hip_device_lib_path_EQ : Joined<["--"], "hip-device-lib-path=">, Group<Link_Group>,
660-
HelpText<"HIP device library path. Alternative to rocm-path.">;
659+
def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group<Link_Group>,
660+
HelpText<"ROCm device library path. Alternative to rocm-path.">;
661+
def : Joined<["--"], "hip-device-lib-path=">, Alias<rocm_device_lib_path_EQ>;
661662
def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group<Link_Group>,
662663
HelpText<"HIP device library">;
664+
def hip_version_EQ : Joined<["--"], "hip-version=">,
665+
HelpText<"HIP version in the format of major.minor.patch">;
663666
def fhip_dump_offload_linker_script : Flag<["-"], "fhip-dump-offload-linker-script">,
664667
Group<f_Group>, Flags<[NoArgumentUnused, HelpHidden]>;
665668
defm hip_new_launch_api : OptInFFlag<"hip-new-launch-api",
666-
"Use new kernel launching API for HIP">;
667-
defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init", "Allow device side init function in HIP">;
669+
"Use", "Don't use", " new kernel launching API for HIP">;
670+
defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init",
671+
"Allow", "Don't allow", " device side init function in HIP">;
668672
def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">,
669673
Flags<[CC1Option]>,
670674
HelpText<"Default max threads per block for kernel launch bounds for HIP">;

clang/include/clang/Parse/Parser.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,8 +2071,9 @@ class Parser : public CodeCompletionHandler {
20712071
StmtResult ParseCompoundStatementBody(bool isStmtExpr = false);
20722072
bool ParseParenExprOrCondition(StmtResult *InitStmt,
20732073
Sema::ConditionResult &CondResult,
2074-
SourceLocation Loc,
2075-
Sema::ConditionKind CK);
2074+
SourceLocation Loc, Sema::ConditionKind CK,
2075+
SourceLocation *LParenLoc = nullptr,
2076+
SourceLocation *RParenLoc = nullptr);
20762077
StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
20772078
StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
20782079
StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4532,7 +4532,8 @@ class Sema final {
45324532
ConditionResult Cond);
45334533
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
45344534
Stmt *Switch, Stmt *Body);
4535-
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond,
4535+
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc,
4536+
ConditionResult Cond, SourceLocation RParenLoc,
45364537
Stmt *Body);
45374538
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
45384539
SourceLocation WhileLoc, SourceLocation CondLParen,

clang/include/clang/Tooling/Syntax/Nodes.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ enum class NodeKind : uint16_t {
5050
StringLiteralExpression,
5151
BoolLiteralExpression,
5252
CxxNullPtrExpression,
53+
IntegerUserDefinedLiteralExpression,
54+
FloatUserDefinedLiteralExpression,
55+
CharUserDefinedLiteralExpression,
56+
StringUserDefinedLiteralExpression,
5357
IdExpression,
5458

5559
// Statements.
@@ -325,6 +329,72 @@ class CxxNullPtrExpression final : public Expression {
325329
syntax::Leaf *nullPtrKeyword();
326330
};
327331

332+
/// Expression for user-defined literal. C++ [lex.ext]
333+
/// user-defined-literal:
334+
/// user-defined-integer-literal
335+
/// user-defined-floating-point-literal
336+
/// user-defined-string-literal
337+
/// user-defined-character-literal
338+
class UserDefinedLiteralExpression : public Expression {
339+
public:
340+
UserDefinedLiteralExpression(NodeKind K) : Expression(K) {}
341+
static bool classof(const Node *N) {
342+
return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression ||
343+
N->kind() == NodeKind::FloatUserDefinedLiteralExpression ||
344+
N->kind() == NodeKind::CharUserDefinedLiteralExpression ||
345+
N->kind() == NodeKind::StringUserDefinedLiteralExpression;
346+
}
347+
syntax::Leaf *literalToken();
348+
};
349+
350+
/// Expression for user-defined-integer-literal. C++ [lex.ext]
351+
class IntegerUserDefinedLiteralExpression final
352+
: public UserDefinedLiteralExpression {
353+
public:
354+
IntegerUserDefinedLiteralExpression()
355+
: UserDefinedLiteralExpression(
356+
NodeKind::IntegerUserDefinedLiteralExpression) {}
357+
static bool classof(const Node *N) {
358+
return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression;
359+
}
360+
};
361+
362+
/// Expression for user-defined-floating-point-literal. C++ [lex.ext]
363+
class FloatUserDefinedLiteralExpression final
364+
: public UserDefinedLiteralExpression {
365+
public:
366+
FloatUserDefinedLiteralExpression()
367+
: UserDefinedLiteralExpression(
368+
NodeKind::FloatUserDefinedLiteralExpression) {}
369+
static bool classof(const Node *N) {
370+
return N->kind() == NodeKind::FloatUserDefinedLiteralExpression;
371+
}
372+
};
373+
374+
/// Expression for user-defined-character-literal. C++ [lex.ext]
375+
class CharUserDefinedLiteralExpression final
376+
: public UserDefinedLiteralExpression {
377+
public:
378+
CharUserDefinedLiteralExpression()
379+
: UserDefinedLiteralExpression(
380+
NodeKind::CharUserDefinedLiteralExpression) {}
381+
static bool classof(const Node *N) {
382+
return N->kind() == NodeKind::CharUserDefinedLiteralExpression;
383+
}
384+
};
385+
386+
/// Expression for user-defined-string-literal. C++ [lex.ext]
387+
class StringUserDefinedLiteralExpression final
388+
: public UserDefinedLiteralExpression {
389+
public:
390+
StringUserDefinedLiteralExpression()
391+
: UserDefinedLiteralExpression(
392+
NodeKind::StringUserDefinedLiteralExpression) {}
393+
static bool classof(const Node *N) {
394+
return N->kind() == NodeKind::StringUserDefinedLiteralExpression;
395+
}
396+
};
397+
328398
/// An abstract class for prefix and postfix unary operators.
329399
class UnaryOperatorExpression : public Expression {
330400
public:

clang/lib/AST/ASTImporter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6123,11 +6123,13 @@ ExpectedStmt ASTNodeImporter::VisitWhileStmt(WhileStmt *S) {
61236123
auto ToCond = importChecked(Err, S->getCond());
61246124
auto ToBody = importChecked(Err, S->getBody());
61256125
auto ToWhileLoc = importChecked(Err, S->getWhileLoc());
6126+
auto ToLParenLoc = importChecked(Err, S->getLParenLoc());
6127+
auto ToRParenLoc = importChecked(Err, S->getRParenLoc());
61266128
if (Err)
61276129
return std::move(Err);
61286130

61296131
return WhileStmt::Create(Importer.getToContext(), ToConditionVariable, ToCond,
6130-
ToBody, ToWhileLoc);
6132+
ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
61316133
}
61326134

61336135
ExpectedStmt ASTNodeImporter::VisitDoStmt(DoStmt *S) {

clang/lib/AST/DeclPrinter.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,15 +1380,24 @@ void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
13801380
}
13811381

13821382
void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
1383-
Out << "@implementation " << *PID->getClassInterface() << '(' << *PID <<")\n";
1383+
Out << "@implementation ";
1384+
if (const auto *CID = PID->getClassInterface())
1385+
Out << *CID;
1386+
else
1387+
Out << "<<error-type>>";
1388+
Out << '(' << *PID << ")\n";
13841389

13851390
VisitDeclContext(PID, false);
13861391
Out << "@end";
13871392
// FIXME: implement the rest...
13881393
}
13891394

13901395
void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) {
1391-
Out << "@interface " << *PID->getClassInterface();
1396+
Out << "@interface ";
1397+
if (const auto *CID = PID->getClassInterface())
1398+
Out << *CID;
1399+
else
1400+
Out << "<<error-type>>";
13921401
if (auto TypeParams = PID->getTypeParamList()) {
13931402
PrintObjCTypeParams(TypeParams);
13941403
}

clang/lib/AST/FormatString.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
419419
QualType pointeeTy = PT->getPointeeType();
420420
if (const BuiltinType *BT = pointeeTy->getAs<BuiltinType>())
421421
switch (BT->getKind()) {
422-
case BuiltinType::Void:
423422
case BuiltinType::Char_U:
424423
case BuiltinType::UChar:
425424
case BuiltinType::Char_S:

clang/lib/AST/Stmt.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,8 @@ void SwitchStmt::setConditionVariable(const ASTContext &Ctx, VarDecl *V) {
10121012
}
10131013

10141014
WhileStmt::WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
1015-
Stmt *Body, SourceLocation WL)
1015+
Stmt *Body, SourceLocation WL, SourceLocation LParenLoc,
1016+
SourceLocation RParenLoc)
10161017
: Stmt(WhileStmtClass) {
10171018
bool HasVar = Var != nullptr;
10181019
WhileStmtBits.HasVar = HasVar;
@@ -1023,6 +1024,8 @@ WhileStmt::WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
10231024
setConditionVariable(Ctx, Var);
10241025

10251026
setWhileLoc(WL);
1027+
setLParenLoc(LParenLoc);
1028+
setRParenLoc(RParenLoc);
10261029
}
10271030

10281031
WhileStmt::WhileStmt(EmptyShell Empty, bool HasVar)
@@ -1031,12 +1034,14 @@ WhileStmt::WhileStmt(EmptyShell Empty, bool HasVar)
10311034
}
10321035

10331036
WhileStmt *WhileStmt::Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
1034-
Stmt *Body, SourceLocation WL) {
1037+
Stmt *Body, SourceLocation WL,
1038+
SourceLocation LParenLoc,
1039+
SourceLocation RParenLoc) {
10351040
bool HasVar = Var != nullptr;
10361041
void *Mem =
10371042
Ctx.Allocate(totalSizeToAlloc<Stmt *>(NumMandatoryStmtPtr + HasVar),
10381043
alignof(WhileStmt));
1039-
return new (Mem) WhileStmt(Ctx, Var, Cond, Body, WL);
1044+
return new (Mem) WhileStmt(Ctx, Var, Cond, Body, WL, LParenLoc, RParenLoc);
10401045
}
10411046

10421047
WhileStmt *WhileStmt::CreateEmpty(const ASTContext &Ctx, bool HasVar) {

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
242242
EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl});
243243
if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
244244
CudaFeature::CUDA_USES_NEW_LAUNCH) ||
245-
CGF.getLangOpts().HIPUseNewLaunchAPI)
245+
(CGF.getLangOpts().HIP && CGF.getLangOpts().HIPUseNewLaunchAPI))
246246
emitDeviceStubBodyNew(CGF, Args);
247247
else
248248
emitDeviceStubBodyLegacy(CGF, Args);

clang/lib/CodeGen/CGCXXABI.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ void CGCXXABI::setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr) {
156156

157157
void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF,
158158
RValue RV, QualType ResultType) {
159+
assert(!CGF.hasAggregateEvaluationKind(ResultType) &&
160+
"cannot handle aggregates");
159161
CGF.EmitReturnOfRValue(RV, ResultType);
160162
}
161163

clang/lib/CodeGen/CGCall.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,9 +2510,11 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
25102510
ArrSize) {
25112511
llvm::AttrBuilder Attrs;
25122512
Attrs.addDereferenceableAttr(
2513-
getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize);
2513+
getContext().getTypeSizeInChars(ETy).getQuantity() *
2514+
ArrSize);
25142515
AI->addAttrs(Attrs);
2515-
} else if (getContext().getTargetAddressSpace(ETy) == 0 &&
2516+
} else if (getContext().getTargetInfo().getNullPointerValue(
2517+
ETy.getAddressSpace()) == 0 &&
25162518
!CGM.getCodeGenOpts().NullPointerIsValid) {
25172519
AI->addAttr(llvm::Attribute::NonNull);
25182520
}

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
363363
: FPT->getReturnType();
364364
ReturnValueSlot Slot;
365365
if (!ResultType->isVoidType() &&
366-
CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
366+
(CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect ||
367+
hasAggregateEvaluationKind(ResultType)))
367368
Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(),
368369
/*IsUnused=*/false, /*IsExternallyDestructed=*/true);
369370

0 commit comments

Comments
 (0)