Skip to content

Commit 5fa1409

Browse files
Merge branch 'llvm:main' into hostnm-c
2 parents 528710b + 0fd81e5 commit 5fa1409

File tree

1,126 files changed

+16400
-76169
lines changed

Some content is hidden

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

1,126 files changed

+16400
-76169
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ Improvements to Clang's diagnostics
321321

322322
- ``-Wc++98-compat`` no longer diagnoses use of ``__auto_type`` or
323323
``decltype(auto)`` as though it was the extension for ``auto``. (#GH47900)
324+
- Clang now issues a warning for missing return in ``main`` in C89 mode. (#GH21650)
324325

325326
- Now correctly diagnose a tentative definition of an array with static
326327
storage duration in pedantic mode in C. (#GH50661)
@@ -354,6 +355,14 @@ Bug Fixes in This Version
354355
- Defining an integer literal suffix (e.g., ``LL``) before including
355356
``<stdint.h>`` in a freestanding build no longer causes invalid token pasting
356357
when using the ``INTn_C`` macros. (#GH85995)
358+
- Clang no longer accepts invalid integer constants which are too large to fit
359+
into any (standard or extended) integer type when the constant is unevaluated.
360+
Merely forming the token is sufficient to render the program invalid. Code
361+
like this was previously accepted and is now rejected (#GH134658):
362+
.. code-block:: c
363+
364+
#if 1 ? 1 : 999999999999999999999
365+
#endif
357366
358367
Bug Fixes to Compiler Builtins
359368
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -377,6 +386,10 @@ Bug Fixes to Attribute Support
377386
or too few attribute argument indicies for the specified callback function.
378387
(#GH47451)
379388

389+
- No longer crashing on ``__attribute__((align_value(N)))`` during template
390+
instantiation when the function parameter type is not a pointer or reference.
391+
(#GH26612)
392+
380393
Bug Fixes to C++ Support
381394
^^^^^^^^^^^^^^^^^^^^^^^^
382395

clang/include/clang/AST/DeclCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4166,7 +4166,7 @@ class StaticAssertDecl : public Decl {
41664166
/// DecompositionDecl of type 'int (&)[3]'.
41674167
class BindingDecl : public ValueDecl {
41684168
/// The declaration that this binding binds to part of.
4169-
ValueDecl *Decomp;
4169+
ValueDecl *Decomp = nullptr;
41704170
/// The binding represented by this declaration. References to this
41714171
/// declaration are effectively equivalent to this expression (except
41724172
/// that it is only evaluated once at the point of declaration of the

clang/include/clang/AST/OpenACCClause.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class OpenACCClause {
3838
OpenACCClauseKind getClauseKind() const { return Kind; }
3939
SourceLocation getBeginLoc() const { return Location.getBegin(); }
4040
SourceLocation getEndLoc() const { return Location.getEnd(); }
41+
SourceRange getSourceRange() const { return Location; }
4142

4243
static bool classof(const OpenACCClause *) { return true; }
4344

@@ -1315,11 +1316,13 @@ template <class Impl> class OpenACCClauseVisitor {
13151316
switch (C->getClauseKind()) {
13161317
#define VISIT_CLAUSE(CLAUSE_NAME) \
13171318
case OpenACCClauseKind::CLAUSE_NAME: \
1318-
Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1319+
getDerived().Visit##CLAUSE_NAME##Clause( \
1320+
*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
13191321
return;
13201322
#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
13211323
case OpenACCClauseKind::ALIAS_NAME: \
1322-
Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1324+
getDerived().Visit##CLAUSE_NAME##Clause( \
1325+
*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
13231326
return;
13241327
#include "clang/Basic/OpenACCClauses.def"
13251328

@@ -1332,7 +1335,7 @@ template <class Impl> class OpenACCClauseVisitor {
13321335
#define VISIT_CLAUSE(CLAUSE_NAME) \
13331336
void Visit##CLAUSE_NAME##Clause( \
13341337
const OpenACC##CLAUSE_NAME##Clause &Clause) { \
1335-
return getDerived().Visit##CLAUSE_NAME##Clause(Clause); \
1338+
return getDerived().VisitClause(Clause); \
13361339
}
13371340

13381341
#include "clang/Basic/OpenACCClauses.def"

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,13 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> {
17091709
def AllocSize : InheritableAttr {
17101710
let Spellings = [GCC<"alloc_size">];
17111711
let Subjects = SubjectList<[HasFunctionProto]>;
1712+
// The parameter names here are a bit misleading.
1713+
// When used with a single argument, the first argument is obviously the
1714+
// allocation size; but when used with two arguments, the first argument is
1715+
// usually the number of elements, while the second argument is usually the
1716+
// element size - the reverse of how they are named here.
1717+
// The documentation of both GCC and clang does not describe any semantic
1718+
// difference between the first and second argument.
17121719
let Args = [ParamIdxArgument<"ElemSizeParam">,
17131720
ParamIdxArgument<"NumElemsParam", /*opt*/ 1>];
17141721
let TemplateDependent = 1;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,9 @@ def err_mainlike_template_decl : Error<"%0 cannot be a template">;
10311031
def err_main_returns_nonint : Error<"'main' must return 'int'">;
10321032
def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">,
10331033
InGroup<MainReturnType>;
1034+
def ext_main_no_return : Extension<
1035+
"implicit '0' return value from 'main' is a C99 extension">,
1036+
InGroup<MainReturnType>;
10341037
def note_main_change_return_type : Note<"change return type to 'int'">;
10351038
def err_main_surplus_args : Error<"too many parameters (%0) for 'main': "
10361039
"must be 0, 2, or 3">;

clang/include/clang/CIR/Dialect/IR/CIRDialect.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class SameFirstOperandAndResultType
6060
using BuilderCallbackRef =
6161
llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>;
6262

63+
namespace cir {
64+
void buildTerminatedBody(mlir::OpBuilder &builder, mlir::Location loc);
65+
} // namespace cir
66+
6367
// TableGen'erated files for MLIR dialects require that a macro be defined when
6468
// they are included. GET_OP_CLASSES tells the file to define the classes for
6569
// the operations of that dialect.

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ def StoreOp : CIR_Op<"store", [
472472
// ReturnOp
473473
//===----------------------------------------------------------------------===//
474474

475-
def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "DoWhileOp",
476-
"WhileOp", "ForOp"]>,
475+
def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "IfOp",
476+
"DoWhileOp", "WhileOp", "ForOp"]>,
477477
Terminator]> {
478478
let summary = "Return from function";
479479
let description = [{
@@ -510,6 +510,58 @@ def ReturnOp : CIR_Op<"return", [ParentOneOf<["FuncOp", "ScopeOp", "DoWhileOp",
510510
let hasVerifier = 1;
511511
}
512512

513+
//===----------------------------------------------------------------------===//
514+
// IfOp
515+
//===----------------------------------------------------------------------===//
516+
517+
def IfOp : CIR_Op<"if",
518+
[DeclareOpInterfaceMethods<RegionBranchOpInterface>,
519+
RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments]>{
520+
521+
let summary = "the if-then-else operation";
522+
let description = [{
523+
The `cir.if` operation represents an if-then-else construct for
524+
conditionally executing two regions of code. The operand is a `cir.bool`
525+
type.
526+
527+
Examples:
528+
529+
```mlir
530+
cir.if %cond {
531+
...
532+
} else {
533+
...
534+
}
535+
536+
cir.if %cond {
537+
...
538+
}
539+
540+
cir.if %cond {
541+
...
542+
cir.br ^a
543+
^a:
544+
cir.yield
545+
}
546+
```
547+
548+
`cir.if` defines no values and the 'else' can be omitted. The if/else
549+
regions must be terminated. If the region has only one block, the terminator
550+
can be left out, and `cir.yield` terminator will be inserted implictly.
551+
Otherwise, the region must be explicitly terminated.
552+
}];
553+
let arguments = (ins CIR_BoolType:$condition);
554+
let regions = (region AnyRegion:$thenRegion, AnyRegion:$elseRegion);
555+
let hasCustomAssemblyFormat=1;
556+
let hasVerifier=1;
557+
let skipDefaultBuilders=1;
558+
let builders = [
559+
OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion,
560+
CArg<"BuilderCallbackRef", "buildTerminatedBody">:$thenBuilder,
561+
CArg<"BuilderCallbackRef", "nullptr">:$elseBuilder)>
562+
];
563+
}
564+
513565
//===----------------------------------------------------------------------===//
514566
// ConditionOp
515567
//===----------------------------------------------------------------------===//
@@ -560,8 +612,8 @@ def ConditionOp : CIR_Op<"condition", [
560612
//===----------------------------------------------------------------------===//
561613

562614
def YieldOp : CIR_Op<"yield", [ReturnLike, Terminator,
563-
ParentOneOf<["ScopeOp", "WhileOp", "ForOp",
564-
"DoWhileOp"]>]> {
615+
ParentOneOf<["IfOp", "ScopeOp", "WhileOp",
616+
"ForOp", "DoWhileOp"]>]> {
565617
let summary = "Represents the default branching behaviour of a region";
566618
let description = [{
567619
The `cir.yield` operation terminates regions on different CIR operations,

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct MissingFeatures {
8080

8181
// Clang early optimizations or things defered to LLVM lowering.
8282
static bool mayHaveIntegerOverflow() { return false; }
83+
static bool shouldReverseUnaryCondOnBoolExpr() { return false; }
8384

8485
// Misc
8586
static bool cxxABI() { return false; }
@@ -110,6 +111,8 @@ struct MissingFeatures {
110111
static bool lvalueBaseInfo() { return false; }
111112
static bool alignCXXRecordDecl() { return false; }
112113
static bool setNonGC() { return false; }
114+
static bool incrementProfileCounter() { return false; }
115+
static bool insertBuiltinUnpredictable() { return false; }
113116

114117
// Missing types
115118
static bool dataMemberType() { return false; }

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4510,7 +4510,7 @@ class Sema final : public SemaBase {
45104510
getAttrLoc(const AttrInfo &AL) {
45114511
return AL.getLocation();
45124512
}
4513-
SourceLocation getAttrLoc(const ParsedAttr &AL);
4513+
SourceLocation getAttrLoc(const AttributeCommonInfo &CI);
45144514

45154515
/// If Expr is a valid integer constant, get the value of the integer
45164516
/// expression and return success or failure. May output an error.

clang/include/clang/Serialization/ASTReader.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ class ASTReaderListener {
237237
return true;
238238
}
239239

240+
/// Overloaded member function of \c visitInputFile that should
241+
/// be defined when there is a distinction between
242+
/// the file name and name-as-requested. For example, when deserializing input
243+
/// files from precompiled AST files.
244+
///
245+
/// \returns true to continue receiving the next input file, false to stop.
246+
virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
247+
bool isSystem, bool isOverridden,
248+
bool isExplicitModule) {
249+
return true;
250+
}
251+
240252
/// Returns true if this \c ASTReaderListener wants to receive the
241253
/// imports of the AST file via \c visitImport, false otherwise.
242254
virtual bool needsImportVisitation() const { return false; }

0 commit comments

Comments
 (0)