Skip to content

Commit 00f60cf

Browse files
authored
Merge branch 'main' into lldrpath
2 parents ce79202 + 1aed6ad commit 00f60cf

File tree

949 files changed

+12612
-73496
lines changed

Some content is hidden

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

949 files changed

+12612
-73496
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 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)
@@ -385,6 +386,10 @@ Bug Fixes to Attribute Support
385386
or too few attribute argument indicies for the specified callback function.
386387
(#GH47451)
387388

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+
388393
Bug Fixes to C++ Support
389394
^^^^^^^^^^^^^^^^^^^^^^^^
390395

clang/include/clang/AST/OpenACCClause.h

Lines changed: 1 addition & 0 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

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; }

clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace dependencies {
3333

3434
class DependencyActionController;
3535
class DependencyConsumer;
36+
class PrebuiltModuleASTAttrs;
3637

3738
/// Modular dependency that has already been built prior to the dependency scan.
3839
struct PrebuiltModuleDep {
@@ -46,6 +47,47 @@ struct PrebuiltModuleDep {
4647
ModuleMapFile(M->PresumedModuleMapFile) {}
4748
};
4849

50+
/// Attributes loaded from AST files of prebuilt modules collected prior to
51+
/// ModuleDepCollector creation.
52+
using PrebuiltModulesAttrsMap = llvm::StringMap<PrebuiltModuleASTAttrs>;
53+
class PrebuiltModuleASTAttrs {
54+
public:
55+
/// When a module is discovered to not be in stable directories, traverse &
56+
/// update all modules that depend on it.
57+
void
58+
updateDependentsNotInStableDirs(PrebuiltModulesAttrsMap &PrebuiltModulesMap);
59+
60+
/// Read-only access to whether the module is made up of dependencies in
61+
/// stable directories.
62+
bool isInStableDir() const { return IsInStableDirs; }
63+
64+
/// Read-only access to vfs map files.
65+
const llvm::StringSet<> &getVFS() const { return VFSMap; }
66+
67+
/// Update the VFSMap to the one discovered from serializing the AST file.
68+
void setVFS(llvm::StringSet<> &&VFS) { VFSMap = std::move(VFS); }
69+
70+
/// Add a direct dependent module file, so it can be updated if the current
71+
/// module is from stable directores.
72+
void addDependent(StringRef ModuleFile) {
73+
ModuleFileDependents.insert(ModuleFile);
74+
}
75+
76+
/// Update whether the prebuilt module resolves entirely in a stable
77+
/// directories.
78+
void setInStableDir(bool V = false) {
79+
// Cannot reset attribute once it's false.
80+
if (!IsInStableDirs)
81+
return;
82+
IsInStableDirs = V;
83+
}
84+
85+
private:
86+
llvm::StringSet<> VFSMap;
87+
bool IsInStableDirs = true;
88+
std::set<StringRef> ModuleFileDependents;
89+
};
90+
4991
/// This is used to identify a specific module.
5092
struct ModuleID {
5193
/// The name of the module. This may include `:` for C++20 module partitions,
@@ -171,8 +213,6 @@ struct ModuleDeps {
171213
BuildInfo;
172214
};
173215

174-
using PrebuiltModuleVFSMapT = llvm::StringMap<llvm::StringSet<>>;
175-
176216
class ModuleDepCollector;
177217

178218
/// Callback that records textual includes and direct modular includes/imports
@@ -242,7 +282,7 @@ class ModuleDepCollector final : public DependencyCollector {
242282
CompilerInstance &ScanInstance, DependencyConsumer &C,
243283
DependencyActionController &Controller,
244284
CompilerInvocation OriginalCI,
245-
PrebuiltModuleVFSMapT PrebuiltModuleVFSMap);
285+
const PrebuiltModulesAttrsMap PrebuiltModulesASTMap);
246286

247287
void attachToPreprocessor(Preprocessor &PP) override;
248288
void attachToASTReader(ASTReader &R) override;
@@ -262,8 +302,9 @@ class ModuleDepCollector final : public DependencyCollector {
262302
DependencyConsumer &Consumer;
263303
/// Callbacks for computing dependency information.
264304
DependencyActionController &Controller;
265-
/// Mapping from prebuilt AST files to their sorted list of VFS overlay files.
266-
PrebuiltModuleVFSMapT PrebuiltModuleVFSMap;
305+
/// Mapping from prebuilt AST filepaths to their attributes referenced during
306+
/// dependency collecting.
307+
const PrebuiltModulesAttrsMap PrebuiltModulesASTMap;
267308
/// Path to the main source file.
268309
std::string MainFile;
269310
/// Hash identifying the compilation conditions of the current TU.
@@ -339,6 +380,14 @@ void resetBenignCodeGenOptions(frontend::ActionKind ProgramAction,
339380
bool isPathInStableDir(const ArrayRef<StringRef> Directories,
340381
const StringRef Input);
341382

383+
/// Determine if options collected from a module's
384+
/// compilation can safely be considered as stable.
385+
///
386+
/// \param Directories Paths known to be in a stable location. e.g. Sysroot.
387+
/// \param HSOpts Header search options derived from the compiler invocation.
388+
bool areOptionsInStableDir(const ArrayRef<StringRef> Directories,
389+
const HeaderSearchOptions &HSOpts);
390+
342391
} // end namespace dependencies
343392
} // end namespace tooling
344393
} // end namespace clang

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6823,7 +6823,7 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
68236823
return true;
68246824
}
68256825

6826-
if (size_t N = Desc->getNumElems()) {
6826+
if (unsigned N = Desc->getNumElems()) {
68276827
for (ssize_t I = N - 1; I >= 0; --I) {
68286828
if (!this->emitConstUint64(I, Loc))
68296829
return false;

clang/lib/Basic/Targets/SPIR.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,20 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64TargetInfo : public BaseSPIRVTargetInfo {
374374
const llvm::omp::GV &getGridValue() const override {
375375
return llvm::omp::SPIRVGridValues;
376376
}
377+
378+
std::optional<LangAS> getConstantAddressSpace() const override {
379+
return ConstantAS;
380+
}
381+
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override {
382+
BaseSPIRVTargetInfo::adjust(Diags, Opts);
383+
// opencl_constant will map to UniformConstant in SPIR-V
384+
if (Opts.OpenCL)
385+
ConstantAS = LangAS::opencl_constant;
386+
}
387+
388+
private:
389+
// opencl_global will map to CrossWorkgroup in SPIR-V
390+
LangAS ConstantAS = LangAS::opencl_global;
377391
};
378392

379393
class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final

0 commit comments

Comments
 (0)