Skip to content

Commit ca1acf9

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in llvm/test/CMakeLists.txt
2 parents 93dd9cf + d054c7e commit ca1acf9

File tree

472 files changed

+48119
-6433
lines changed

Some content is hidden

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

472 files changed

+48119
-6433
lines changed

clang-tools-extra/clangd/unittests/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ include_directories(
1313
${CLANGD_BINARY_DIR}
1414
)
1515

16+
if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
17+
add_compile_options("-Wno-suggest-override")
18+
endif()
19+
1620
if(CLANG_BUILT_STANDALONE)
1721
# LLVMTestingSupport library is needed for clangd tests.
1822
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support

clang-tools-extra/unittests/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ function(add_extra_unittest test_dirname)
55
add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
66
endfunction()
77

8+
if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
9+
add_compile_options("-Wno-suggest-override")
10+
endif()
11+
812
add_subdirectory(clang-apply-replacements)
913
add_subdirectory(clang-change-namespace)
1014
add_subdirectory(clang-doc)

clang/docs/LanguageExtensions.rst

+3
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,9 @@ This extension also works in C++ mode, as far as that goes, but does not apply
17191719
to the C++ ``std::complex``. (In C++11, list initialization allows the same
17201720
syntax to be used with ``std::complex`` with the same meaning.)
17211721
1722+
For GCC compatibility, ``__builtin_complex(re, im)`` can also be used to
1723+
construct a complex number from the given real and imaginary components.
1724+
17221725
Builtin Functions
17231726
=================
17241727

clang/include/clang/AST/ExternalASTSource.h

-4
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
161161
/// Retrieve the module that corresponds to the given module ID.
162162
virtual Module *getModule(unsigned ID) { return nullptr; }
163163

164-
/// Determine whether D comes from a PCH which was built with a corresponding
165-
/// object file.
166-
virtual bool DeclIsFromPCHWithObjectFile(const Decl *D) { return false; }
167-
168164
/// Return a descriptor for the corresponding module, if one exists.
169165
virtual llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID);
170166

clang/include/clang/Basic/Builtins.def

+3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ BUILTIN(__builtin_ctanh, "XdXd", "Fne")
395395
BUILTIN(__builtin_ctanhf, "XfXf", "Fne")
396396
BUILTIN(__builtin_ctanhl, "XLdXLd", "Fne")
397397

398+
// GCC-compatible C99 CMPLX implementation.
399+
BUILTIN(__builtin_complex, "v.", "nct")
400+
398401
// FP Comparisons.
399402
BUILTIN(__builtin_isgreater , "i.", "Fnct")
400403
BUILTIN(__builtin_isgreaterequal, "i.", "Fnct")

clang/include/clang/Basic/BuiltinsPPC.def

+7-7
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ BUILTIN(__builtin_altivec_vinswlx, "V4UiV4UiUiUi", "")
329329
BUILTIN(__builtin_altivec_vinswrx, "V4UiV4UiUiUi", "")
330330
BUILTIN(__builtin_altivec_vinsdlx, "V2ULLiV2ULLiULLiULLi", "")
331331
BUILTIN(__builtin_altivec_vinsdrx, "V2ULLiV2ULLiULLiULLi", "")
332-
BUILTIN(__builtin_altivec_vinsbvlx, "V16UcV16UcULLiV16Uc", "")
333-
BUILTIN(__builtin_altivec_vinsbvrx, "V16UcV16UcULLiV16Uc", "")
334-
BUILTIN(__builtin_altivec_vinshvlx, "V8UsV8UsULLiV8Us", "")
335-
BUILTIN(__builtin_altivec_vinshvrx, "V8UsV8UsULLiV8Us", "")
336-
BUILTIN(__builtin_altivec_vinswvlx, "V4UiV4UiULLiV4Ui", "")
337-
BUILTIN(__builtin_altivec_vinswvrx, "V4UiV4UiULLiV4Ui", "")
332+
BUILTIN(__builtin_altivec_vinsbvlx, "V16UcV16UcUiV16Uc", "")
333+
BUILTIN(__builtin_altivec_vinsbvrx, "V16UcV16UcUiV16Uc", "")
334+
BUILTIN(__builtin_altivec_vinshvlx, "V8UsV8UsUiV8Us", "")
335+
BUILTIN(__builtin_altivec_vinshvrx, "V8UsV8UsUiV8Us", "")
336+
BUILTIN(__builtin_altivec_vinswvlx, "V4UiV4UiUiV4Ui", "")
337+
BUILTIN(__builtin_altivec_vinswvrx, "V4UiV4UiUiV4Ui", "")
338338

339339
// VSX built-ins.
340340

@@ -467,7 +467,7 @@ BUILTIN(__builtin_vsx_xxsldwi, "v.", "t")
467467

468468
BUILTIN(__builtin_vsx_xxeval, "V2ULLiV2ULLiV2ULLiV2ULLiIi", "")
469469

470-
BUILTIN(__builtin_vsx_xvtlsbb, "iV16Ucb", "")
470+
BUILTIN(__builtin_vsx_xvtlsbb, "iV16UcUi", "")
471471

472472
// P10 Vector Permute Extended built-in.
473473
BUILTIN(__builtin_vsx_xxpermx, "V16UcV16UcV16UcV16UcIi", "")

clang/include/clang/Basic/DiagnosticSemaKinds.td

+4
Original file line numberDiff line numberDiff line change
@@ -8191,6 +8191,10 @@ def warn_cast_pointer_from_sel : Warning<
81918191
def warn_function_def_in_objc_container : Warning<
81928192
"function definition inside an Objective-C container is deprecated">,
81938193
InGroup<FunctionDefInObjCContainer>;
8194+
def err_typecheck_call_requires_real_fp : Error<
8195+
"argument type %0 is not a real floating point type">;
8196+
def err_typecheck_call_different_arg_types : Error<
8197+
"arguments are of different types%diff{ ($ vs $)|}0,1">;
81948198

81958199
def warn_cast_calling_conv : Warning<
81968200
"cast between incompatible calling conventions '%0' and '%1'; "

clang/include/clang/Driver/SanitizerArgs.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class SanitizerArgs {
7474
!Sanitizers.has(SanitizerKind::Address) &&
7575
!Sanitizers.has(SanitizerKind::HWAddress);
7676
}
77+
bool needsFuzzerInterceptors() const;
7778
bool needsUbsanRt() const;
7879
bool requiresMinimalRuntime() const { return MinimalRuntime; }
7980
bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }

clang/include/clang/Sema/MultiplexExternalSemaSource.h

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
153153
/// Retrieve the module that corresponds to the given module ID.
154154
Module *getModule(unsigned ID) override;
155155

156-
bool DeclIsFromPCHWithObjectFile(const Decl *D) override;
157-
158156
/// Perform layout on the given record.
159157
///
160158
/// This routine allows the external AST source to provide an specific

clang/include/clang/Sema/Sema.h

+1
Original file line numberDiff line numberDiff line change
@@ -12351,6 +12351,7 @@ class Sema final {
1235112351
bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
1235212352
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
1235312353
bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
12354+
bool SemaBuiltinComplex(CallExpr *TheCall);
1235412355
bool SemaBuiltinVSX(CallExpr *TheCall);
1235512356
bool SemaBuiltinOSLogFormat(CallExpr *TheCall);
1235612357

clang/include/clang/Serialization/ASTReader.h

-2
Original file line numberDiff line numberDiff line change
@@ -2085,8 +2085,6 @@ class ASTReader
20852085
/// Note: overrides method in ExternalASTSource
20862086
Module *getModule(unsigned ID) override;
20872087

2088-
bool DeclIsFromPCHWithObjectFile(const Decl *D) override;
2089-
20902088
/// Retrieve the module file with a given local ID within the specified
20912089
/// ModuleFile.
20922090
ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);

clang/include/clang/Serialization/ModuleFile.h

-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ class ModuleFile {
155155
/// Whether timestamps are included in this module file.
156156
bool HasTimestamps = false;
157157

158-
/// Whether the PCH has a corresponding object file.
159-
bool PCHHasObjectFile = false;
160-
161158
/// Whether the top-level module has been read from the AST file.
162159
bool DidReadTopLevelSubmodule = false;
163160

clang/lib/AST/ASTContext.cpp

-31
Original file line numberDiff line numberDiff line change
@@ -10502,37 +10502,6 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
1050210502
else
1050310503
return false;
1050410504

10505-
if (D->isFromASTFile() && !LangOpts.BuildingPCHWithObjectFile) {
10506-
assert(getExternalSource() && "It's from an AST file; must have a source.");
10507-
// On Windows, PCH files are built together with an object file. If this
10508-
// declaration comes from such a PCH and DeclMustBeEmitted would return
10509-
// true, it would have returned true and the decl would have been emitted
10510-
// into that object file, so it doesn't need to be emitted here.
10511-
// Note that decls are still emitted if they're referenced, as usual;
10512-
// DeclMustBeEmitted is used to decide whether a decl must be emitted even
10513-
// if it's not referenced.
10514-
//
10515-
// Explicit template instantiation definitions are tricky. If there was an
10516-
// explicit template instantiation decl in the PCH before, it will look like
10517-
// the definition comes from there, even if that was just the declaration.
10518-
// (Explicit instantiation defs of variable templates always get emitted.)
10519-
bool IsExpInstDef =
10520-
isa<FunctionDecl>(D) &&
10521-
cast<FunctionDecl>(D)->getTemplateSpecializationKind() ==
10522-
TSK_ExplicitInstantiationDefinition;
10523-
10524-
// Implicit member function definitions, such as operator= might not be
10525-
// marked as template specializations, since they're not coming from a
10526-
// template but synthesized directly on the class.
10527-
IsExpInstDef |=
10528-
isa<CXXMethodDecl>(D) &&
10529-
cast<CXXMethodDecl>(D)->getParent()->getTemplateSpecializationKind() ==
10530-
TSK_ExplicitInstantiationDefinition;
10531-
10532-
if (getExternalSource()->DeclIsFromPCHWithObjectFile(D) && !IsExpInstDef)
10533-
return false;
10534-
}
10535-
1053610505
// If this is a member of a class template, we do not need to emit it.
1053710506
if (D->getDeclContext()->isDependentContext())
1053810507
return false;

clang/lib/AST/ExprConstant.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -13286,6 +13286,7 @@ class ComplexExprEvaluator
1328613286
bool VisitBinaryOperator(const BinaryOperator *E);
1328713287
bool VisitUnaryOperator(const UnaryOperator *E);
1328813288
bool VisitInitListExpr(const InitListExpr *E);
13289+
bool VisitCallExpr(const CallExpr *E);
1328913290
};
1329013291
} // end anonymous namespace
1329113292

@@ -13754,6 +13755,23 @@ bool ComplexExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
1375413755
return ExprEvaluatorBaseTy::VisitInitListExpr(E);
1375513756
}
1375613757

13758+
bool ComplexExprEvaluator::VisitCallExpr(const CallExpr *E) {
13759+
switch (E->getBuiltinCallee()) {
13760+
case Builtin::BI__builtin_complex:
13761+
Result.makeComplexFloat();
13762+
if (!EvaluateFloat(E->getArg(0), Result.FloatReal, Info))
13763+
return false;
13764+
if (!EvaluateFloat(E->getArg(1), Result.FloatImag, Info))
13765+
return false;
13766+
return true;
13767+
13768+
default:
13769+
break;
13770+
}
13771+
13772+
return ExprEvaluatorBaseTy::VisitCallExpr(E);
13773+
}
13774+
1375713775
//===----------------------------------------------------------------------===//
1375813776
// Atomic expression evaluation, essentially just handling the NonAtomicToAtomic
1375913777
// implicit conversion.

clang/lib/CodeGen/CGBuiltin.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
19781978
Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");
19791979
return RValue::get(Result);
19801980
}
1981+
case Builtin::BI__builtin_complex: {
1982+
Value *Real = EmitScalarExpr(E->getArg(0));
1983+
Value *Imag = EmitScalarExpr(E->getArg(1));
1984+
return RValue::getComplex({Real, Imag});
1985+
}
19811986
case Builtin::BI__builtin_conj:
19821987
case Builtin::BI__builtin_conjf:
19831988
case Builtin::BI__builtin_conjl:

clang/lib/Driver/SanitizerArgs.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
240240
return TrappingKinds;
241241
}
242242

243+
bool SanitizerArgs::needsFuzzerInterceptors() const {
244+
return needsFuzzer() && !needsAsanRt() && !needsTsanRt() && !needsMsanRt();
245+
}
246+
243247
bool SanitizerArgs::needsUbsanRt() const {
244248
// All of these include ubsan.
245249
if (needsAsanRt() || needsMsanRt() || needsHwasanRt() || needsTsanRt() ||

clang/lib/Driver/ToolChains/CommonArgs.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
792792
!Args.hasArg(options::OPT_shared)) {
793793

794794
addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
795+
if (SanArgs.needsFuzzerInterceptors())
796+
addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer_interceptors", false,
797+
true);
795798
if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
796799
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
797800
}

clang/lib/Sema/DeclSpec.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
12791279
S.Diag(TSTLoc, diag::ext_integer_complex);
12801280
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double &&
12811281
TypeSpecType != TST_float128) {
1282+
// FIXME: _Float16, __fp16?
12821283
S.Diag(TSCLoc, diag::err_invalid_complex_spec)
12831284
<< getSpecifierName((TST)TypeSpecType, Policy);
12841285
TypeSpecComplex = TSC_unspecified;

clang/lib/Sema/MultiplexExternalSemaSource.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@ Module *MultiplexExternalSemaSource::getModule(unsigned ID) {
172172
return nullptr;
173173
}
174174

175-
bool MultiplexExternalSemaSource::DeclIsFromPCHWithObjectFile(const Decl *D) {
176-
for (auto *S : Sources)
177-
if (S->DeclIsFromPCHWithObjectFile(D))
178-
return true;
179-
return false;
180-
}
181-
182175
bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record,
183176
uint64_t &Size,
184177
uint64_t &Alignment,

clang/lib/Sema/SemaChecking.cpp

+59
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,10 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
15821582
if (checkArgCount(*this, TheCall, 1)) return true;
15831583
TheCall->setType(Context.IntTy);
15841584
break;
1585+
case Builtin::BI__builtin_complex:
1586+
if (SemaBuiltinComplex(TheCall))
1587+
return ExprError();
1588+
break;
15851589
case Builtin::BI__builtin_constant_p: {
15861590
if (checkArgCount(*this, TheCall, 1)) return true;
15871591
ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
@@ -5922,6 +5926,61 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
59225926
return false;
59235927
}
59245928

5929+
/// Perform semantic analysis for a call to __builtin_complex.
5930+
bool Sema::SemaBuiltinComplex(CallExpr *TheCall) {
5931+
if (checkArgCount(*this, TheCall, 2))
5932+
return true;
5933+
5934+
bool Dependent = false;
5935+
for (unsigned I = 0; I != 2; ++I) {
5936+
Expr *Arg = TheCall->getArg(I);
5937+
QualType T = Arg->getType();
5938+
if (T->isDependentType()) {
5939+
Dependent = true;
5940+
continue;
5941+
}
5942+
5943+
// Despite supporting _Complex int, GCC requires a real floating point type
5944+
// for the operands of __builtin_complex.
5945+
if (!T->isRealFloatingType()) {
5946+
return Diag(Arg->getBeginLoc(), diag::err_typecheck_call_requires_real_fp)
5947+
<< Arg->getType() << Arg->getSourceRange();
5948+
}
5949+
5950+
ExprResult Converted = DefaultLvalueConversion(Arg);
5951+
if (Converted.isInvalid())
5952+
return true;
5953+
TheCall->setArg(I, Converted.get());
5954+
}
5955+
5956+
if (Dependent) {
5957+
TheCall->setType(Context.DependentTy);
5958+
return false;
5959+
}
5960+
5961+
Expr *Real = TheCall->getArg(0);
5962+
Expr *Imag = TheCall->getArg(1);
5963+
if (!Context.hasSameType(Real->getType(), Imag->getType())) {
5964+
return Diag(Real->getBeginLoc(),
5965+
diag::err_typecheck_call_different_arg_types)
5966+
<< Real->getType() << Imag->getType()
5967+
<< Real->getSourceRange() << Imag->getSourceRange();
5968+
}
5969+
5970+
// We don't allow _Complex _Float16 nor _Complex __fp16 as type specifiers;
5971+
// don't allow this builtin to form those types either.
5972+
// FIXME: Should we allow these types?
5973+
if (Real->getType()->isFloat16Type())
5974+
return Diag(TheCall->getBeginLoc(), diag::err_invalid_complex_spec)
5975+
<< "_Float16";
5976+
if (Real->getType()->isHalfType())
5977+
return Diag(TheCall->getBeginLoc(), diag::err_invalid_complex_spec)
5978+
<< "half";
5979+
5980+
TheCall->setType(Context.getComplexType(Real->getType()));
5981+
return false;
5982+
}
5983+
59255984
// Customized Sema Checking for VSX builtins that have the following signature:
59265985
// vector [...] builtinName(vector [...], vector [...], const int);
59275986
// Which takes the same type of vectors (any legal vector type) for the first

clang/lib/Serialization/ASTReader.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
27472747
return VersionMismatch;
27482748
}
27492749

2750-
bool hasErrors = Record[7];
2750+
bool hasErrors = Record[6];
27512751
if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
27522752
Diag(diag::err_pch_with_compiler_errors);
27532753
return HadErrors;
@@ -2765,8 +2765,6 @@ ASTReader::ReadControlBlock(ModuleFile &F,
27652765

27662766
F.HasTimestamps = Record[5];
27672767

2768-
F.PCHHasObjectFile = Record[6];
2769-
27702768
const std::string &CurBranch = getClangFullRepositoryVersion();
27712769
StringRef ASTBranch = Blob;
27722770
if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
@@ -8597,11 +8595,6 @@ Module *ASTReader::getModule(unsigned ID) {
85978595
return getSubmodule(ID);
85988596
}
85998597

8600-
bool ASTReader::DeclIsFromPCHWithObjectFile(const Decl *D) {
8601-
ModuleFile *MF = getOwningModuleFile(D);
8602-
return MF && MF->PCHHasObjectFile;
8603-
}
8604-
86058598
ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &F, unsigned ID) {
86068599
if (ID & 1) {
86078600
// It's a module, look it up by submodule ID.

0 commit comments

Comments
 (0)