git: 52e4ee64c25f - stable/13 - Merge llvm-project main llvmorg-18-init-16864-g3b3ee1f53424
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Apr 2024 10:34:25 UTC
The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=52e4ee64c25fe0837e9cf783a63e8c214b3180cf commit 52e4ee64c25fe0837e9cf783a63e8c214b3180cf Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-01-11 18:29:01 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-04-19 21:24:43 +0000 Merge llvm-project main llvmorg-18-init-16864-g3b3ee1f53424 This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvm-project main llvmorg-18-init-16864-g3b3ee1f53424. PR: 276104 MFC after: 1 month (cherry picked from commit 297eecfb02bb25902531dbb5c3b9a88caf8adf29) --- .../clang/include/clang/AST/DeclBase.h | 10 + .../llvm-project/clang/include/clang/AST/DeclCXX.h | 3 + .../llvm-project/clang/include/clang/AST/Stmt.h | 6 +- .../llvm-project/clang/include/clang/AST/Type.h | 3 + .../llvm-project/clang/include/clang/Basic/Attr.td | 18 + .../clang/include/clang/Basic/AttrDocs.td | 78 +++ .../include/clang/Basic/DiagnosticFrontendKinds.td | 2 +- .../include/clang/Basic/DiagnosticSemaKinds.td | 15 + .../clang/include/clang/Basic/LangOptions.def | 1 + .../clang/include/clang/Basic/TargetInfo.h | 1 + .../clang/include/clang/Basic/arm_sve.td | 22 +- .../clang/include/clang/Driver/Options.td | 18 +- .../clang/include/clang/Format/Format.h | 20 +- .../clang/include/clang/Parse/Parser.h | 24 +- .../llvm-project/clang/include/clang/Sema/Sema.h | 3 + .../clang/include/clang/Sema/TypoCorrection.h | 12 +- contrib/llvm-project/clang/lib/AST/ASTContext.cpp | 7 + contrib/llvm-project/clang/lib/AST/ASTImporter.cpp | 37 +- contrib/llvm-project/clang/lib/AST/DeclBase.cpp | 74 ++- contrib/llvm-project/clang/lib/AST/DeclCXX.cpp | 13 + contrib/llvm-project/clang/lib/AST/Expr.cpp | 83 +--- .../clang/lib/AST/Interp/ByteCodeExprGen.cpp | 7 + .../clang/lib/AST/Interp/Descriptor.cpp | 6 +- .../llvm-project/clang/lib/AST/Interp/Descriptor.h | 7 +- .../llvm-project/clang/lib/AST/Interp/Interp.cpp | 12 + .../clang/lib/AST/Interp/InterpBuiltin.cpp | 33 +- .../llvm-project/clang/lib/AST/Interp/Program.cpp | 16 +- contrib/llvm-project/clang/lib/AST/Type.cpp | 34 +- .../clang/lib/Analysis/ExprMutationAnalyzer.cpp | 355 +++++++------- .../clang/lib/Basic/Targets/AArch64.cpp | 7 + .../llvm-project/clang/lib/Basic/Targets/RISCV.cpp | 5 +- .../llvm-project/clang/lib/CodeGen/CGBuiltin.cpp | 244 +++++++++- contrib/llvm-project/clang/lib/CodeGen/CGCall.cpp | 2 + .../llvm-project/clang/lib/CodeGen/CGException.cpp | 7 +- contrib/llvm-project/clang/lib/CodeGen/CGExpr.cpp | 340 +++++++++++++- .../llvm-project/clang/lib/CodeGen/CGObjCGNU.cpp | 35 +- .../clang/lib/CodeGen/CodeGenFunction.h | 22 + .../clang/lib/CodeGen/CodeGenModule.cpp | 2 + .../clang/lib/CodeGen/CoverageMappingGen.cpp | 13 +- .../clang/lib/CodeGen/Targets/AArch64.cpp | 2 + .../clang/lib/Driver/ToolChains/Clang.cpp | 6 +- .../clang/lib/Driver/ToolChains/Flang.cpp | 57 ++- .../clang/lib/Driver/ToolChains/Flang.h | 7 + .../clang/lib/Driver/ToolChains/Gnu.cpp | 8 +- .../clang/lib/Driver/ToolChains/Linux.cpp | 8 +- contrib/llvm-project/clang/lib/Format/Format.cpp | 30 +- .../llvm-project/clang/lib/Format/FormatToken.cpp | 4 +- .../llvm-project/clang/lib/Format/FormatToken.h | 25 +- .../clang/lib/Format/TokenAnnotator.cpp | 14 +- .../clang/lib/Format/UnwrappedLineFormatter.cpp | 10 +- .../clang/lib/Format/UnwrappedLineParser.cpp | 4 +- .../clang/lib/Format/WhitespaceManager.cpp | 9 +- .../clang/lib/Format/WhitespaceManager.h | 1 + .../lib/Frontend/VerifyDiagnosticConsumer.cpp | 15 +- .../llvm-project/clang/lib/Headers/ia32intrin.h | 376 +++++++-------- .../clang/lib/Interpreter/Interpreter.cpp | 1 + contrib/llvm-project/clang/lib/Parse/ParseDecl.cpp | 8 +- contrib/llvm-project/clang/lib/Parse/ParseExpr.cpp | 26 +- .../llvm-project/clang/lib/Parse/ParseOpenACC.cpp | 65 +-- contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp | 6 + .../llvm-project/clang/lib/Sema/SemaDeclAttr.cpp | 133 ++++++ contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp | 16 +- .../llvm-project/clang/lib/Sema/SemaExprMember.cpp | 3 +- .../llvm-project/clang/lib/Sema/SemaOverload.cpp | 10 + contrib/llvm-project/clang/lib/Sema/SemaStmt.cpp | 2 +- .../llvm-project/clang/lib/Sema/TreeTransform.h | 20 +- .../Checkers/StdLibraryFunctionsChecker.cpp | 21 +- .../lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 59 ++- .../clang/tools/clang-format/ClangFormat.cpp | 65 ++- .../compiler-rt/include/profile/InstrProfData.inc | 2 + .../lib/profile/InstrProfilingPlatformLinux.c | 9 - .../lib/sanitizer_common/sanitizer_flags.inc | 3 + .../sanitizer_symbolizer_report.cpp | 36 +- .../sanitizer_thread_arg_retval.cpp | 23 +- .../sanitizer_common/sanitizer_thread_arg_retval.h | 1 + .../lib/scudo/standalone/condition_variable.h | 2 +- contrib/llvm-project/libcxx/include/__config | 5 - .../libcxx/include/__memory/shared_ptr.h | 4 +- contrib/llvm-project/libcxx/include/cstdio | 2 +- contrib/llvm-project/libcxx/include/regex | 3 + contrib/llvm-project/libcxx/include/tuple | 2 +- contrib/llvm-project/lld/ELF/Arch/AArch64.cpp | 3 + contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp | 110 ++--- contrib/llvm-project/lld/ELF/Arch/RISCV.cpp | 7 +- contrib/llvm-project/lld/ELF/InputSection.cpp | 10 +- contrib/llvm-project/lld/ELF/Target.h | 2 +- .../llvm-project/lldb/include/lldb/Core/Module.h | 6 + .../llvm-project/lldb/include/lldb/Symbol/Type.h | 4 + .../lldb/include/lldb/Utility/StreamString.h | 2 +- contrib/llvm-project/lldb/source/Core/Module.cpp | 17 + .../ExpressionParser/Clang/ClangASTImporter.cpp | 51 +- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 35 ++ .../source/Plugins/Language/CPlusPlus/LibCxx.cpp | 57 +++ .../source/Plugins/Language/CPlusPlus/LibCxx.h | 8 + .../source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 44 +- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 11 +- .../intel-pt/CommandObjectTraceStartIntelPT.cpp | 4 +- .../Plugins/Trace/intel-pt/DecodedThread.cpp | 32 +- .../source/Plugins/Trace/intel-pt/DecodedThread.h | 26 +- .../Plugins/Trace/intel-pt/LibiptDecoder.cpp | 4 +- .../Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp | 4 +- .../Trace/intel-pt/TraceIntelPTBundleLoader.cpp | 13 +- contrib/llvm-project/lldb/source/Symbol/Type.cpp | 4 + .../lldb/source/Target/ProcessTrace.cpp | 2 + .../lldb/source/Utility/StreamString.cpp | 2 +- .../llvm-project/llvm/include/llvm/ADT/STLExtras.h | 29 +- .../llvm-project/llvm/include/llvm/ADT/StringRef.h | 4 +- .../llvm/include/llvm/Analysis/VecFuncs.def | 190 ++++---- .../llvm/BinaryFormat/ELFRelocs/AArch64.def | 1 + .../include/llvm/BinaryFormat/ELFRelocs/RISCV.def | 3 +- .../llvm/CodeGen/AssignmentTrackingAnalysis.h | 29 +- .../llvm/include/llvm/CodeGen/CodeGenPassBuilder.h | 1 + .../llvm/CodeGen/GlobalISel/CombinerHelper.h | 3 + .../llvm/CodeGen/GlobalISel/GenericMachineInstrs.h | 18 + .../include/llvm/CodeGen/GlobalISel/Localizer.h | 7 +- .../llvm/include/llvm/CodeGen/SelectionDAGISel.h | 16 + .../llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 7 + .../Parallel => include/llvm/DWARFLinker}/Utils.h | 36 +- .../llvm/include/llvm/Frontend/OpenACC/ACC.td | 66 +-- .../llvm/include/llvm/IR/IntrinsicsAArch64.td | 6 +- .../llvm/include/llvm/IR/IntrinsicsNVVM.td | 10 + .../llvm/include/llvm/IR/ModuleSummaryIndex.h | 6 + .../llvm/include/llvm/IR/PatternMatch.h | 36 ++ .../llvm/include/llvm/ProfileData/InstrProf.h | 3 +- .../include/llvm/ProfileData/InstrProfData.inc | 2 + .../llvm/include/llvm/Support/RISCVISAInfo.h | 22 +- .../llvm/include/llvm/Support/TargetOpcodes.def | 3 + .../llvm/include/llvm/Target/GenericOpcodes.td | 21 + .../llvm/Target/GlobalISel/SelectionDAGCompat.td | 3 + .../llvm/include/llvm/Target/TargetPfmCounters.td | 21 + .../llvm/TargetParser/ARMTargetParserCommon.h | 1 + .../llvm/lib/Analysis/LazyValueInfo.cpp | 8 +- .../llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 17 +- .../lib/CodeGen/AssignmentTrackingAnalysis.cpp | 34 ++ .../llvm/lib/CodeGen/BranchFolding.cpp | 17 + .../llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 84 ++++ .../llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 12 + .../lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 10 + .../llvm/lib/CodeGen/GlobalISel/Localizer.cpp | 55 ++- .../CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 9 +- .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 74 +-- .../CodeGen/SelectionDAG/LegalizeVectorTypes.cpp | 2 +- .../llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 +- .../lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 48 +- .../lib/CodeGen/SelectionDAG/TargetLowering.cpp | 5 +- .../lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 11 +- .../llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 15 +- .../Parallel/AcceleratorRecordsSaver.cpp | 2 +- .../Parallel/DWARFLinkerCompileUnit.cpp | 23 +- .../lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- .../DWARFLinker/Parallel/DebugLineSectionEmitter.h | 38 +- .../llvm-project/llvm/lib/DWARFLinker/Utils.cpp | 2 + contrib/llvm-project/llvm/lib/IR/Verifier.cpp | 11 + .../llvm/lib/MC/MCParser/ELFAsmParser.cpp | 6 +- contrib/llvm-project/llvm/lib/MC/MCSectionELF.cpp | 18 +- .../llvm-project/llvm/lib/Passes/PassBuilder.cpp | 1 + .../llvm-project/llvm/lib/Passes/PassRegistry.def | 4 +- .../llvm-project/llvm/lib/Support/RISCVISAInfo.cpp | 331 +++++++------ contrib/llvm-project/llvm/lib/TableGen/Record.cpp | 15 +- .../llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 5 + .../lib/Target/AArch64/AArch64ISelDAGToDAG.cpp | 4 +- .../lib/Target/AArch64/AArch64ISelLowering.cpp | 3 +- .../llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 3 + .../Target/AArch64/AArch64LoadStoreOptimizer.cpp | 64 ++- .../Target/AArch64/AArch64LoopIdiomTransform.cpp | 2 +- .../llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td | 18 +- .../Target/AArch64/AArch64TargetTransformInfo.cpp | 98 ++-- .../Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 3 +- .../MCTargetDesc/AArch64ELFObjectWriter.cpp | 8 +- .../llvm/lib/Target/AArch64/SMEInstrFormats.td | 2 +- .../llvm/lib/Target/AMDGPU/AMDGPUCombine.td | 2 +- .../llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp | 12 +- .../lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp | 52 ++ .../Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp | 46 +- .../Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 43 +- .../llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp | 17 +- .../llvm/lib/Target/AMDGPU/GCNSubtarget.h | 2 + .../Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp | 1 - .../llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 8 +- .../llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 5 +- .../llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 33 +- .../llvm/lib/Target/AMDGPU/SIInstrInfo.td | 33 +- .../llvm/lib/Target/AMDGPU/VOP1Instructions.td | 55 ++- .../llvm/lib/Target/AMDGPU/VOP2Instructions.td | 14 +- .../llvm/lib/Target/AMDGPU/VOPInstructions.td | 13 +- .../llvm/lib/Target/ARM/ARMISelLowering.cpp | 9 +- .../llvm/lib/Target/MSP430/MSP430ISelLowering.cpp | 13 +- .../llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | 6 +- .../llvm/lib/Target/NVPTX/NVPTXInstrInfo.td | 3 + .../llvm/lib/Target/NVPTX/NVPTXIntrinsics.td | 13 + .../llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 2 +- .../llvm/lib/Target/PowerPC/PPCInstrInfo.td | 2 +- .../lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 77 ++- .../RISCV/Disassembler/RISCVDisassembler.cpp | 6 +- .../lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp | 40 ++ .../RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp | 2 + .../Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | 7 + .../lib/Target/RISCV/RISCVExpandPseudoInsts.cpp | 12 +- .../llvm/lib/Target/RISCV/RISCVFeatures.td | 1 + .../llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 46 +- .../llvm/lib/Target/RISCV/RISCVISelLowering.h | 6 +- .../llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp | 37 +- .../llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 17 +- .../llvm/lib/Target/RISCV/RISCVInstrInfoA.td | 140 +++--- .../llvm/lib/Target/RISCV/RISCVInstrInfoD.td | 16 +- .../lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td | 33 +- .../lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td | 38 +- .../llvm/lib/Target/RISCV/RISCVInstrInfoZa.td | 98 +++- .../llvm/lib/Target/RISCV/RISCVRegisterInfo.td | 45 +- .../lib/Target/SystemZ/SystemZISelDAGToDAG.cpp | 2 +- .../lib/Target/SystemZ/SystemZISelLowering.cpp | 7 + .../lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 4 +- .../llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 16 + .../llvm/lib/Target/X86/X86FlagsCopyLowering.cpp | 1 + .../llvm/lib/Target/X86/X86ISelLowering.cpp | 53 ++- .../llvm/lib/Target/X86/X86InstrArithmetic.td | 110 +++-- .../llvm/lib/Target/X86/X86InstrCompiler.td | 380 ++++++++------- .../llvm/lib/Target/X86/X86InstrMisc.td | 12 +- .../llvm/lib/Target/X86/X86PfmCounters.td | 18 + .../lib/TargetParser/ARMTargetParserCommon.cpp | 7 +- .../llvm/lib/TextAPI/InterfaceFile.cpp | 8 + .../IPO/MemProfContextDisambiguation.cpp | 521 ++++++++++++++++++--- .../Transforms/InstCombine/InstCombineAddSub.cpp | 24 + .../Transforms/InstCombine/InstCombineAndOrXor.cpp | 114 +++-- .../Transforms/InstCombine/InstCombineCalls.cpp | 4 + .../Transforms/InstCombine/InstCombineSelect.cpp | 4 +- .../Instrumentation/AddressSanitizer.cpp | 2 +- .../Instrumentation/PGOInstrumentation.cpp | 12 +- .../llvm/lib/Transforms/Scalar/LoopFlatten.cpp | 79 ++-- .../Transforms/Scalar/RewriteStatepointsForGC.cpp | 23 +- .../Scalar/SeparateConstOffsetFromGEP.cpp | 58 +-- .../Scalar/StraightLineStrengthReduce.cpp | 55 +-- .../llvm/lib/Transforms/Utils/Local.cpp | 3 +- .../llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 13 +- .../lib/Transforms/Vectorize/LoopVectorize.cpp | 6 +- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 69 ++- .../llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 2 +- .../llvm/utils/TableGen/DAGISelMatcherEmitter.cpp | 81 +++- .../llvm/utils/TableGen/ExegesisEmitter.cpp | 52 +- .../utils/TableGen/GlobalISelCombinerEmitter.cpp | 2 +- .../openmp/runtime/src/z_Linux_util.cpp | 2 +- lib/clang/include/VCSVersion.inc | 6 +- lib/clang/include/lld/Common/Version.inc | 2 +- lib/clang/include/llvm/Support/VCSRevision.h | 2 +- lib/clang/libllvm/Makefile | 32 +- lib/libc++/Makefile | 40 +- lib/libc++/module.modulemap | 4 +- 247 files changed, 5252 insertions(+), 2361 deletions(-) diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h index 10dcbdb262d8..5b1038582bc6 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h @@ -19,6 +19,7 @@ #include "clang/AST/SelectorLocationsKind.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" +#include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" #include "llvm/ADT/ArrayRef.h" @@ -488,6 +489,15 @@ public: // Return true if this is a FileContext Decl. bool isFileContextDecl() const; + /// Whether it resembles a flexible array member. This is a static member + /// because we want to be able to call it with a nullptr. That allows us to + /// perform non-Decl specific checks based on the object's type and strict + /// flex array level. + static bool isFlexibleArrayMemberLike( + ASTContext &Context, const Decl *D, QualType Ty, + LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, + bool IgnoreTemplateOrMacroSubstitution); + ASTContext &getASTContext() const LLVM_READONLY; /// Helper to get the language options from the ASTContext. diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h index 984a4d8bab5e..648f5f946408 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h @@ -1425,6 +1425,9 @@ public: /// (C++11 [class]p6). bool isTriviallyCopyable() const; + /// Determine whether this class is considered trivially copyable per + bool isTriviallyCopyConstructible() const; + /// Determine whether this class is considered trivial. /// /// C++11 [class]p6: diff --git a/contrib/llvm-project/clang/include/clang/AST/Stmt.h b/contrib/llvm-project/clang/include/clang/AST/Stmt.h index da7b37ce0e12..e1fde24e6477 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Stmt.h +++ b/contrib/llvm-project/clang/include/clang/AST/Stmt.h @@ -1631,8 +1631,10 @@ public: SourceLocation RB); // Build an empty compound statement with a location. - explicit CompoundStmt(SourceLocation Loc) - : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(Loc) { + explicit CompoundStmt(SourceLocation Loc) : CompoundStmt(Loc, Loc) {} + + CompoundStmt(SourceLocation Loc, SourceLocation EndLoc) + : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(EndLoc) { CompoundStmtBits.NumStmts = 0; CompoundStmtBits.HasFPFeatures = 0; } diff --git a/contrib/llvm-project/clang/include/clang/AST/Type.h b/contrib/llvm-project/clang/include/clang/AST/Type.h index 9e9f896ebef7..d4e5310fb3ab 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Type.h +++ b/contrib/llvm-project/clang/include/clang/AST/Type.h @@ -917,6 +917,9 @@ public: /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext &Context) const; + /// Return true if this is a trivially copyable type + bool isTriviallyCopyConstructibleType(const ASTContext &Context) const; + /// Return true if this is a trivially relocatable type. bool isTriviallyRelocatableType(const ASTContext &Context) const; diff --git a/contrib/llvm-project/clang/include/clang/Basic/Attr.td b/contrib/llvm-project/clang/include/clang/Basic/Attr.td index d5eabaad4889..a03b0e44e15f 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Attr.td +++ b/contrib/llvm-project/clang/include/clang/Basic/Attr.td @@ -4372,3 +4372,21 @@ def CodeAlign: StmtAttr { static constexpr int MaximumAlignment = 4096; }]; } + +def CountedBy : InheritableAttr { + let Spellings = [Clang<"counted_by">]; + let Subjects = SubjectList<[Field]>; + let Args = [IdentifierArgument<"CountedByField">]; + let Documentation = [CountedByDocs]; + let LangOpts = [COnly]; + // FIXME: This is ugly. Let using a DeclArgument would be nice, but a Decl + // isn't yet available due to the fact that we're still parsing the + // structure. Maybe that code could be changed sometime in the future. + code AdditionalMembers = [{ + private: + SourceRange CountedByFieldLoc; + public: + SourceRange getCountedByFieldLoc() const { return CountedByFieldLoc; } + void setCountedByFieldLoc(SourceRange Loc) { CountedByFieldLoc = Loc; } + }]; +} diff --git a/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td b/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td index 5416a0cbdd07..2e8d7752c975 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td +++ b/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td @@ -7749,3 +7749,81 @@ but do not pass them to the underlying coroutine or pass them by value. .. _`CRT`: https://clang.llvm.org/docs/AttributeReference.html#coro-return-type }]; } + +def CountedByDocs : Documentation { + let Category = DocCatField; + let Content = [{ +Clang supports the ``counted_by`` attribute on the flexible array member of a +structure in C. The argument for the attribute is the name of a field member +holding the count of elements in the flexible array. This information can be +used to improve the results of the array bound sanitizer and the +``__builtin_dynamic_object_size`` builtin. The ``count`` field member must be +within the same non-anonymous, enclosing struct as the flexible array member. + +This example specifies that the flexible array member ``array`` has the number +of elements allocated for it in ``count``: + +.. code-block:: c + + struct bar; + + struct foo { + size_t count; + char other; + struct bar *array[] __attribute__((counted_by(count))); + }; + +This establishes a relationship between ``array`` and ``count``. Specifically, +``array`` must have at least ``count`` number of elements available. It's the +user's responsibility to ensure that this relationship is maintained through +changes to the structure. + +In the following example, the allocated array erroneously has fewer elements +than what's specified by ``p->count``. This would result in an out-of-bounds +access not being detected. + +.. code-block:: c + + #define SIZE_INCR 42 + + struct foo *p; + + void foo_alloc(size_t count) { + p = malloc(MAX(sizeof(struct foo), + offsetof(struct foo, array[0]) + count * sizeof(struct bar *))); + p->count = count + SIZE_INCR; + } + +The next example updates ``p->count``, but breaks the relationship requirement +that ``p->array`` must have at least ``p->count`` number of elements available: + +.. code-block:: c + + #define SIZE_INCR 42 + + struct foo *p; + + void foo_alloc(size_t count) { + p = malloc(MAX(sizeof(struct foo), + offsetof(struct foo, array[0]) + count * sizeof(struct bar *))); + p->count = count; + } + + void use_foo(int index, int val) { + p->count += SIZE_INCR + 1; /* 'count' is now larger than the number of elements of 'array'. */ + p->array[index] = val; /* The sanitizer can't properly check this access. */ + } + +In this example, an update to ``p->count`` maintains the relationship +requirement: + +.. code-block:: c + + void use_foo(int index, int val) { + if (p->count == 0) + return; + --p->count; + p->array[index] = val; + } + }]; +} diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 568000106a84..85ecfdf9de62 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -167,7 +167,7 @@ def err_verify_no_such_marker : Error< def err_verify_missing_start : Error< "cannot find start ('{{') of expected %0">; def err_verify_missing_end : Error< - "cannot find end ('}}') of expected %0">; + "cannot find end ('%1') of expected %0">; def err_verify_invalid_content : Error< "invalid expected %0: %1">; def err_verify_missing_regex : Error< diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td index e81d1a4fc288..e46779349475 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2253,6 +2253,8 @@ def warn_cxx17_compat_aggregate_init_paren_list : Warning< def err_reference_bind_to_bitfield : Error< "%select{non-const|volatile}0 reference cannot bind to " "bit-field%select{| %1}2">; +def err_reference_bind_to_bitfield_in_cce : Error< + "reference cannot bind to bit-field in converted constant expression">; def err_reference_bind_to_vector_element : Error< "%select{non-const|volatile}0 reference cannot bind to vector element">; def err_reference_bind_to_matrix_element : Error< @@ -6439,6 +6441,19 @@ def warn_superclass_variable_sized_type_not_at_end : Warning< "field %0 can overwrite instance variable %1 with variable sized type %2" " in superclass %3">, InGroup<ObjCFlexibleArray>; +def err_flexible_array_count_not_in_same_struct : Error< + "'counted_by' field %0 isn't within the same struct as the flexible array">; +def err_counted_by_attr_not_on_flexible_array_member : Error< + "'counted_by' only applies to C99 flexible array members">; +def err_counted_by_attr_refers_to_flexible_array : Error< + "'counted_by' cannot refer to the flexible array %0">; +def err_counted_by_must_be_in_structure : Error< + "field %0 in 'counted_by' not inside structure">; +def err_flexible_array_counted_by_attr_field_not_integer : Error< + "field %0 in 'counted_by' must be a non-boolean integer type">; +def note_flexible_array_counted_by_attr_field : Note< + "field %0 declared here">; + let CategoryName = "ARC Semantic Issue" in { // ARC-mode diagnostics. diff --git a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def index 21abc346cf17..0428b70c6020 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def +++ b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def @@ -457,6 +457,7 @@ ENUM_LANGOPT(SignReturnAddressKey, SignReturnAddressKeyKind, 1, SignReturnAddres "Key used for return address signing") LANGOPT(BranchTargetEnforcement, 1, 0, "Branch-target enforcement enabled") LANGOPT(BranchProtectionPAuthLR, 1, 0, "Use PC as a diversifier using PAuthLR NOP instructions.") +LANGOPT(GuardedControlStack, 1, 0, "Guarded control stack enabled") LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled") diff --git a/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h b/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h index ac3c324c6c29..3eb23ebdacf0 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h +++ b/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h @@ -1373,6 +1373,7 @@ public: LangOptions::SignReturnAddressKeyKind::AKey; bool BranchTargetEnforcement = false; bool BranchProtectionPAuthLR = false; + bool GuardedControlStack = false; }; /// Determine if the Architecture in this TargetInfo supports branch diff --git a/contrib/llvm-project/clang/include/clang/Basic/arm_sve.td b/contrib/llvm-project/clang/include/clang/Basic/arm_sve.td index 7f80fb0386cc..6f35e25617ad 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/arm_sve.td +++ b/contrib/llvm-project/clang/include/clang/Basic/arm_sve.td @@ -454,11 +454,11 @@ let TargetGuard = "sve,bf16" in { let TargetGuard = "sve2p1" in { // Contiguous truncating store from quadword (single vector). - def SVST1UWQ : MInst<"svst1uwq[_{d}]", "vPcd", "iUif", [IsStore], MemEltTyInt32, "aarch64_sve_st1uwq">; - def SVST1UWQ_VNUM : MInst<"svst1uwq_vnum[_{d}]", "vPcld", "iUif", [IsStore], MemEltTyInt32, "aarch64_sve_st1uwq">; + def SVST1UWQ : MInst<"svst1wq[_{d}]", "vPcd", "iUif", [IsStore], MemEltTyInt32, "aarch64_sve_st1wq">; + def SVST1UWQ_VNUM : MInst<"svst1wq_vnum[_{d}]", "vPcld", "iUif", [IsStore], MemEltTyInt32, "aarch64_sve_st1wq">; - def SVST1UDQ : MInst<"svst1udq[_{d}]", "vPcd", "lUld", [IsStore], MemEltTyInt64, "aarch64_sve_st1udq">; - def SVST1UDQ_VNUM : MInst<"svst1udq_vnum[_{d}]", "vPcld", "lUld", [IsStore], MemEltTyInt64, "aarch64_sve_st1udq">; + def SVST1UDQ : MInst<"svst1dq[_{d}]", "vPcd", "lUld", [IsStore], MemEltTyInt64, "aarch64_sve_st1dq">; + def SVST1UDQ_VNUM : MInst<"svst1dq_vnum[_{d}]", "vPcld", "lUld", [IsStore], MemEltTyInt64, "aarch64_sve_st1dq">; // Store one vector (vector base + scalar offset) def SVST1Q_SCATTER_U64BASE_OFFSET : MInst<"svst1q_scatter[_{2}base]_offset[_{d}]", "vPgld", "cUcsUsiUilUlfhdb", [IsScatterStore, IsByteIndexed], MemEltTyDefault, "aarch64_sve_st1q_scatter_scalar_offset">; @@ -2040,12 +2040,12 @@ let TargetGuard = "sve2p1|sme2" in { } let TargetGuard = "sve2p1" in { -def SVDOT_X2_S : SInst<"svdot[_{d}_{2}_{3}]", "ddhh", "i", MergeNone, "aarch64_sve_sdot_x2", [], []>; -def SVDOT_X2_U : SInst<"svdot[_{d}_{2}_{3}]", "ddhh", "Ui", MergeNone, "aarch64_sve_udot_x2", [], []>; -def SVDOT_X2_F : SInst<"svdot[_{d}_{2}_{3}]", "ddhh", "f", MergeNone, "aarch64_sve_fdot_x2", [], []>; -def SVDOT_LANE_X2_S : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "i", MergeNone, "aarch64_sve_sdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; -def SVDOT_LANE_X2_U : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "Ui", MergeNone, "aarch64_sve_udot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; -def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}_{3}]", "ddhhi", "f", MergeNone, "aarch64_sve_fdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; +def SVDOT_X2_S : SInst<"svdot[_{d}_{2}]", "ddhh", "i", MergeNone, "aarch64_sve_sdot_x2", [], []>; +def SVDOT_X2_U : SInst<"svdot[_{d}_{2}]", "ddhh", "Ui", MergeNone, "aarch64_sve_udot_x2", [], []>; +def SVDOT_X2_F : SInst<"svdot[_{d}_{2}]", "ddhh", "f", MergeNone, "aarch64_sve_fdot_x2", [], []>; +def SVDOT_LANE_X2_S : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "i", MergeNone, "aarch64_sve_sdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; +def SVDOT_LANE_X2_U : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "Ui", MergeNone, "aarch64_sve_udot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; +def SVDOT_LANE_X2_F : SInst<"svdot_lane[_{d}_{2}]", "ddhhi", "f", MergeNone, "aarch64_sve_fdot_lane_x2", [], [ImmCheck<3, ImmCheck0_3>]>; } let TargetGuard = "sve2p1|sme2" in { @@ -2208,7 +2208,7 @@ let TargetGuard = "sve2p1" in { def SVTBLQ : SInst<"svtblq[_{d}]", "ddu", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_tblq">; def SVTBXQ : SInst<"svtbxq[_{d}]", "dddu", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_tbxq">; // EXTQ - def EXTQ : SInst<"svextq_lane[_{d}]", "dddk", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_extq_lane", [], [ImmCheck<2, ImmCheck0_15>]>; + def EXTQ : SInst<"svextq[_{d}]", "dddk", "cUcsUsiUilUlbhfd", MergeNone, "aarch64_sve_extq", [], [ImmCheck<2, ImmCheck0_15>]>; // PMOV // Move to Pred multiclass PMOV_TO_PRED<string name, string types, string intrinsic, list<FlagType> flags=[], ImmCheckType immCh > { diff --git a/contrib/llvm-project/clang/include/clang/Driver/Options.td b/contrib/llvm-project/clang/include/clang/Driver/Options.td index 84648c6d5500..7f97d6b6faa3 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Options.td +++ b/contrib/llvm-project/clang/include/clang/Driver/Options.td @@ -4267,7 +4267,7 @@ def iquote : JoinedOrSeparate<["-"], "iquote">, Group<clang_i_Group>, Visibility<[ClangOption, CC1Option]>, HelpText<"Add directory to QUOTE include search path">, MetaVarName<"<directory>">; def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group<clang_i_Group>, - Visibility<[ClangOption, CC1Option]>, + Visibility<[ClangOption, CC1Option, FlangOption]>, HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">, MarshallingInfoString<HeaderSearchOpts<"Sysroot">, [{"/"}]>; def isystem : JoinedOrSeparate<["-"], "isystem">, Group<clang_i_Group>, @@ -4585,11 +4585,13 @@ let Flags = [TargetSpecific] in { def menable_experimental_extensions : Flag<["-"], "menable-experimental-extensions">, Group<m_Group>, HelpText<"Enable use of experimental RISC-V extensions.">; def mrvv_vector_bits_EQ : Joined<["-"], "mrvv-vector-bits=">, Group<m_Group>, - HelpText<"Specify the size in bits of an RVV vector register. Defaults to " - "the vector length agnostic value of \"scalable\". Accepts power of " - "2 values between 64 and 65536. Also accepts \"zvl\" " - "to use the value implied by -march/-mcpu. Value will be reflected " - "in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">; + Visibility<[ClangOption, FlangOption]>, + HelpText<"Specify the size in bits of an RVV vector register">, + DocBrief<"Defaults to the vector length agnostic value of \"scalable\". " + "Accepts power of 2 values between 64 and 65536. Also accepts " + "\"zvl\" to use the value implied by -march/-mcpu. On Clang, value " + "will be reflected in __riscv_v_fixed_vlen preprocessor define " + "(RISC-V only)">; def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_Group>, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64/LoongArch/RISC-V only)">; @@ -5197,7 +5199,7 @@ def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, Group<IncludePath_Group>, HelpText<"Do not include the default HIP wrapper headers and include paths">; def : Flag<["-"], "nocudainc">, Alias<nogpuinc>; def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>, - Visibility<[ClangOption, CC1Option]>, + Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, HelpText<"Do not link device library for CUDA/HIP device compilation">; def : Flag<["-"], "nocudalib">, Alias<nogpulib>; def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, @@ -7010,6 +7012,8 @@ def mbranch_target_enforce : Flag<["-"], "mbranch-target-enforce">, MarshallingInfoFlag<LangOpts<"BranchTargetEnforcement">>; def mbranch_protection_pauth_lr : Flag<["-"], "mbranch-protection-pauth-lr">, MarshallingInfoFlag<LangOpts<"BranchProtectionPAuthLR">>; +def mguarded_control_stack : Flag<["-"], "mguarded-control-stack">, + MarshallingInfoFlag<LangOpts<"GuardedControlStack">>; def fno_dllexport_inlines : Flag<["-"], "fno-dllexport-inlines">, MarshallingInfoNegativeFlag<LangOpts<"DllExportInlines">>; def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">, diff --git a/contrib/llvm-project/clang/include/clang/Format/Format.h b/contrib/llvm-project/clang/include/clang/Format/Format.h index 8604dea689f9..59b645ecab71 100755 --- a/contrib/llvm-project/clang/include/clang/Format/Format.h +++ b/contrib/llvm-project/clang/include/clang/Format/Format.h @@ -225,6 +225,22 @@ struct FormatStyle { /// bbb = 2; /// \endcode bool AlignCompound; + /// Only for ``AlignConsecutiveDeclarations``. Whether function pointers are + /// aligned. + /// \code + /// true: + /// unsigned i; + /// int &r; + /// int *p; + /// int (*f)(); + /// + /// false: + /// unsigned i; + /// int &r; + /// int *p; + /// int (*f)(); + /// \endcode + bool AlignFunctionPointers; /// Only for ``AlignConsecutiveAssignments``. Whether short assignment /// operators are left-padded to the same length as long ones in order to /// put all assignment operators to the right of the left hand side. @@ -247,7 +263,9 @@ struct FormatStyle { bool operator==(const AlignConsecutiveStyle &R) const { return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines && AcrossComments == R.AcrossComments && - AlignCompound == R.AlignCompound && PadOperators == R.PadOperators; + AlignCompound == R.AlignCompound && + AlignFunctionPointers == R.AlignFunctionPointers && + PadOperators == R.PadOperators; } bool operator!=(const AlignConsecutiveStyle &R) const { return !(*this == R); diff --git a/contrib/llvm-project/clang/include/clang/Parse/Parser.h b/contrib/llvm-project/clang/include/clang/Parse/Parser.h index 2dbe090bd093..186dbb770858 100644 --- a/contrib/llvm-project/clang/include/clang/Parse/Parser.h +++ b/contrib/llvm-project/clang/include/clang/Parse/Parser.h @@ -234,6 +234,26 @@ class Parser : public CodeCompletionHandler { /// Parsing OpenACC directive mode. bool OpenACCDirectiveParsing = false; + /// Currently parsing a situation where an OpenACC array section could be + /// legal, such as a 'var-list'. + bool AllowOpenACCArraySections = false; + + /// RAII object to set reset OpenACC parsing a context where Array Sections + /// are allowed. + class OpenACCArraySectionRAII { + Parser &P; + + public: + OpenACCArraySectionRAII(Parser &P) : P(P) { + assert(!P.AllowOpenACCArraySections); + P.AllowOpenACCArraySections = true; + } + ~OpenACCArraySectionRAII() { + assert(P.AllowOpenACCArraySections); + P.AllowOpenACCArraySections = false; + } + }; + /// When true, we are directly inside an Objective-C message /// send expression. /// @@ -3546,8 +3566,8 @@ private: ExprResult ParseOpenACCIDExpression(); /// Parses the variable list for the `cache` construct. void ParseOpenACCCacheVarList(); - /// Parses a single variable in a variable list for the 'cache' construct. - bool ParseOpenACCCacheVar(); + /// Parses a single variable in a variable list for OpenACC. + bool ParseOpenACCVar(); bool ParseOpenACCWaitArgument(); private: diff --git a/contrib/llvm-project/clang/include/clang/Sema/Sema.h b/contrib/llvm-project/clang/include/clang/Sema/Sema.h index edaee4c4b66d..cf2d4fbe6d3b 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Sema.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Sema.h @@ -4799,6 +4799,8 @@ public: bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A); + bool CheckCountedByAttr(Scope *Scope, const FieldDecl *FD); + /// Adjust the calling convention of a method to be the ABI default if it /// wasn't specified explicitly. This handles method types formed from /// function type typedefs and typename template arguments. @@ -5642,6 +5644,7 @@ public: CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, ArrayRef<Expr *> Args = std::nullopt, + DeclContext *LookupCtx = nullptr, TypoExpr **Out = nullptr); DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, diff --git a/contrib/llvm-project/clang/include/clang/Sema/TypoCorrection.h b/contrib/llvm-project/clang/include/clang/Sema/TypoCorrection.h index e0f8d152dbe5..09de164297e7 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/TypoCorrection.h +++ b/contrib/llvm-project/clang/include/clang/Sema/TypoCorrection.h @@ -282,7 +282,7 @@ class CorrectionCandidateCallback { public: static const unsigned InvalidDistance = TypoCorrection::InvalidDistance; - explicit CorrectionCandidateCallback(IdentifierInfo *Typo = nullptr, + explicit CorrectionCandidateCallback(const IdentifierInfo *Typo = nullptr, NestedNameSpecifier *TypoNNS = nullptr) : Typo(Typo), TypoNNS(TypoNNS) {} @@ -319,7 +319,7 @@ public: /// this method. virtual std::unique_ptr<CorrectionCandidateCallback> clone() = 0; - void setTypoName(IdentifierInfo *II) { Typo = II; } + void setTypoName(const IdentifierInfo *II) { Typo = II; } void setTypoNNS(NestedNameSpecifier *NNS) { TypoNNS = NNS; } // Flags for context-dependent keywords. WantFunctionLikeCasts is only @@ -345,13 +345,13 @@ protected: candidate.getCorrectionSpecifier() == TypoNNS; } - IdentifierInfo *Typo; + const IdentifierInfo *Typo; NestedNameSpecifier *TypoNNS; }; class DefaultFilterCCC final : public CorrectionCandidateCallback { public: - explicit DefaultFilterCCC(IdentifierInfo *Typo = nullptr, + explicit DefaultFilterCCC(const IdentifierInfo *Typo = nullptr, NestedNameSpecifier *TypoNNS = nullptr) : CorrectionCandidateCallback(Typo, TypoNNS) {} @@ -365,6 +365,10 @@ public: template <class C> class DeclFilterCCC final : public CorrectionCandidateCallback { public: + explicit DeclFilterCCC(const IdentifierInfo *Typo = nullptr, + NestedNameSpecifier *TypoNNS = nullptr) + : CorrectionCandidateCallback(Typo, TypoNNS) {} + bool ValidateCandidate(const TypoCorrection &candidate) override { return candidate.getCorrectionDeclAs<C>(); } diff --git a/contrib/llvm-project/clang/lib/AST/ASTContext.cpp b/contrib/llvm-project/clang/lib/AST/ASTContext.cpp index b60dcfaabfd1..d9cefcaa84d7 100644 --- a/contrib/llvm-project/clang/lib/AST/ASTContext.cpp +++ b/contrib/llvm-project/clang/lib/AST/ASTContext.cpp @@ -1318,6 +1318,13 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, InitBuiltinType(OMPArrayShapingTy, BuiltinType::OMPArrayShaping); InitBuiltinType(OMPIteratorTy, BuiltinType::OMPIterator); } + // Placeholder type for OpenACC array sections. + if (LangOpts.OpenACC) { + // FIXME: Once we implement OpenACC array sections in Sema, this will either + // be combined with the OpenMP type, or given its own type. In the meantime, + // just use the OpenMP type so that parsing can work. + InitBuiltinType(OMPArraySectionTy, BuiltinType::OMPArraySection); + } if (LangOpts.MatrixTypes) InitBuiltinType(IncompleteMatrixIdxTy, BuiltinType::IncompleteMatrixIdx); diff --git a/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp b/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp index 5e5570bb42a1..b762d6a4cd38 100644 --- a/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp +++ b/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp @@ -5929,15 +5929,22 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (ToD) return ToD; - bool IsFriendTemplate = D->getFriendObjectKind() != Decl::FOK_None; - bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext() - : DC->isDependentContext(); - bool DependentFriend = IsFriendTemplate && IsDependentContext; + // Should check if a declaration is friend in a dependent context. + // Such templates are not linked together in a declaration chain. + // The ASTImporter strategy is to map existing forward declarations to + // imported ones only if strictly necessary, otherwise import these as new + // forward declarations. In case of the "dependent friend" declarations, new + // declarations are created, but not linked in a declaration chain. + auto IsDependentFriend = [](ClassTemplateDecl *TD) { + return TD->getFriendObjectKind() != Decl::FOK_None && + TD->getLexicalDeclContext()->isDependentContext(); + }; + bool DependentFriend = IsDependentFriend(D); ClassTemplateDecl *FoundByLookup = nullptr; // We may already have a template of the same name; try to find and match it. - if (!DependentFriend && !DC->isFunctionOrMethod()) { + if (!DC->isFunctionOrMethod()) { SmallVector<NamedDecl *, 4> ConflictingDecls; auto FoundDecls = Importer.findDeclsInToCtx(DC, Name); for (auto *FoundDecl : FoundDecls) { @@ -5953,10 +5960,13 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { // FIXME: sufficient conditon for 'IgnoreTemplateParmDepth'? bool IgnoreTemplateParmDepth = - FoundTemplate->getFriendObjectKind() != Decl::FOK_None && - !D->specializations().empty(); + (FoundTemplate->getFriendObjectKind() != Decl::FOK_None) != + (D->getFriendObjectKind() != Decl::FOK_None); if (IsStructuralMatch(D, FoundTemplate, /*Complain=*/true, IgnoreTemplateParmDepth)) { + if (DependentFriend || IsDependentFriend(FoundTemplate)) + continue; + ClassTemplateDecl *TemplateWithDef = getTemplateDefinition(FoundTemplate); if (D->isThisDeclarationADefinition() && TemplateWithDef) @@ -9030,6 +9040,10 @@ class AttrImporter { public: AttrImporter(ASTImporter &I) : Importer(I), NImporter(I) {} + // Useful for accessing the imported attribute. + template <typename T> T *castAttrAs() { return cast<T>(ToAttr); } + template <typename T> const T *castAttrAs() const { return cast<T>(ToAttr); } + // Create an "importer" for an attribute parameter. // Result of the 'value()' of that object is to be passed to the function // 'importAttr', in the order that is expected by the attribute class. @@ -9243,6 +9257,15 @@ Expected<Attr *> ASTImporter::Import(const Attr *FromAttr) { From->args_size()); break; } + case attr::CountedBy: { + AI.cloneAttr(FromAttr); + const auto *CBA = cast<CountedByAttr>(FromAttr); + Expected<SourceRange> SR = Import(CBA->getCountedByFieldLoc()).get(); + if (!SR) + return SR.takeError(); + AI.castAttrAs<CountedByAttr>()->setCountedByFieldLoc(SR.get()); + break; + } default: { // The default branch works for attributes that have no arguments to import. diff --git a/contrib/llvm-project/clang/lib/AST/DeclBase.cpp b/contrib/llvm-project/clang/lib/AST/DeclBase.cpp index b1733c2d052a..8163f9bdaf8d 100644 --- a/contrib/llvm-project/clang/lib/AST/DeclBase.cpp +++ b/contrib/llvm-project/clang/lib/AST/DeclBase.cpp @@ -29,7 +29,6 @@ #include "clang/AST/Type.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" -#include "clang/Basic/LangOptions.h" #include "clang/Basic/Module.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/PartialDiagnostic.h" @@ -411,6 +410,79 @@ bool Decl::isFileContextDecl() const { return DC && DC->isFileContext(); } +bool Decl::isFlexibleArrayMemberLike( + ASTContext &Ctx, const Decl *D, QualType Ty, + LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, + bool IgnoreTemplateOrMacroSubstitution) { + // For compatibility with existing code, we treat arrays of length 0 or + // 1 as flexible array members. + const auto *CAT = Ctx.getAsConstantArrayType(Ty); + if (CAT) { + using FAMKind = LangOptions::StrictFlexArraysLevelKind; + + llvm::APInt Size = CAT->getSize(); + if (StrictFlexArraysLevel == FAMKind::IncompleteOnly) + return false; + + // GCC extension, only allowed to represent a FAM. + if (Size.isZero()) + return true; + + if (StrictFlexArraysLevel == FAMKind::ZeroOrIncomplete && Size.uge(1)) + return false; + + if (StrictFlexArraysLevel == FAMKind::OneZeroOrIncomplete && Size.uge(2)) + return false; + } else if (!Ctx.getAsIncompleteArrayType(Ty)) { + return false; + } + + if (const auto *OID = dyn_cast_if_present<ObjCIvarDecl>(D)) + return OID->getNextIvar() == nullptr; + + const auto *FD = dyn_cast_if_present<FieldDecl>(D); + if (!FD) + return false; + + if (CAT) { + // GCC treats an array memeber of a union as an FAM if the size is one or + // zero. + llvm::APInt Size = CAT->getSize(); + if (FD->getParent()->isUnion() && (Size.isZero() || Size.isOne())) + return true; + } + + // Don't consider sizes resulting from macro expansions or template argument + // substitution to form C89 tail-padded arrays. + if (IgnoreTemplateOrMacroSubstitution) { + TypeSourceInfo *TInfo = FD->getTypeSourceInfo(); + while (TInfo) { + TypeLoc TL = TInfo->getTypeLoc(); + + // Look through typedefs. + if (TypedefTypeLoc TTL = TL.getAsAdjusted<TypedefTypeLoc>()) { + const TypedefNameDecl *TDL = TTL.getTypedefNameDecl(); + TInfo = TDL->getTypeSourceInfo(); + continue; + } + + if (auto CTL = TL.getAs<ConstantArrayTypeLoc>()) { + if (const Expr *SizeExpr = + dyn_cast_if_present<IntegerLiteral>(CTL.getSizeExpr()); + !SizeExpr || SizeExpr->getExprLoc().isMacroID()) + return false; + } + + break; + } + } + + // Test that the field is the last in the structure. + RecordDecl::field_iterator FI( + DeclContext::decl_iterator(const_cast<FieldDecl *>(FD))); + return ++FI == FD->getParent()->field_end(); +} + TranslationUnitDecl *Decl::getTranslationUnitDecl() { if (auto *TUD = dyn_cast<TranslationUnitDecl>(this)) return TUD; diff --git a/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp b/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp index c944862fcefe..98b0a6dc28ea 100644 --- a/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp +++ b/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp @@ -587,6 +587,19 @@ bool CXXRecordDecl::isTriviallyCopyable() const { return true; } +bool CXXRecordDecl::isTriviallyCopyConstructible() const { + + // A trivially copy constructible class is a class that: + // -- has no non-trivial copy constructors, + if (hasNonTrivialCopyConstructor()) + return false; + // -- has a trivial destructor. + if (!hasTrivialDestructor()) + return false; + + return true; +} + void CXXRecordDecl::markedVirtualFunctionPure() { // C++ [class.abstract]p2: // A class is abstract if it has at least one pure virtual function. diff --git a/contrib/llvm-project/clang/lib/AST/Expr.cpp b/contrib/llvm-project/clang/lib/AST/Expr.cpp index a90f92d07f86..b125fc676da8 100644 --- a/contrib/llvm-project/clang/lib/AST/Expr.cpp +++ b/contrib/llvm-project/clang/lib/AST/Expr.cpp @@ -205,85 +205,22 @@ bool Expr::isKnownToHaveBooleanValue(bool Semantic) const { *** 13055 LINES SKIPPED ***