Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
arichardson committed Nov 11, 2024
2 parents 9fe1912 + 947ddf5 commit f8044f3
Show file tree
Hide file tree
Showing 738 changed files with 17,463 additions and 8,467 deletions.
4 changes: 1 addition & 3 deletions bolt/include/bolt/Profile/YAMLProfileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class YAMLProfileReader : public ProfileReaderBase {
yaml::bolt::BinaryProfile YamlBP;

/// Map a function ID from a YAML profile to a BinaryFunction object.
std::vector<BinaryFunction *> YamlProfileToFunction;
DenseMap<uint32_t, BinaryFunction *> YamlProfileToFunction;

using FunctionSet = std::unordered_set<const BinaryFunction *>;
/// To keep track of functions that have a matched profile before the profile
Expand Down Expand Up @@ -162,8 +162,6 @@ class YAMLProfileReader : public ProfileReaderBase {
/// Update matched YAML -> BinaryFunction pair.
void matchProfileToFunction(yaml::bolt::BinaryFunctionProfile &YamlBF,
BinaryFunction &BF) {
if (YamlBF.Id >= YamlProfileToFunction.size())
YamlProfileToFunction.resize(YamlBF.Id + 1);
YamlProfileToFunction[YamlBF.Id] = &BF;
YamlBF.Used = true;

Expand Down
13 changes: 3 additions & 10 deletions bolt/lib/Profile/YAMLProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ bool YAMLProfileReader::parseFunctionProfile(
BB.setExecutionCount(YamlBB.ExecCount);

for (const yaml::bolt::CallSiteInfo &YamlCSI : YamlBB.CallSites) {
BinaryFunction *Callee = YamlCSI.DestId < YamlProfileToFunction.size()
? YamlProfileToFunction[YamlCSI.DestId]
: nullptr;
BinaryFunction *Callee = YamlProfileToFunction.lookup(YamlCSI.DestId);
bool IsFunction = Callee ? true : false;
MCSymbol *CalleeSymbol = nullptr;
if (IsFunction)
Expand Down Expand Up @@ -703,7 +701,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
break;
}
}
YamlProfileToFunction.resize(YamlBP.Functions.size() + 1);
YamlProfileToFunction.reserve(YamlBP.Functions.size());

// Computes hash for binary functions.
if (opts::MatchProfileWithFunctionHash) {
Expand Down Expand Up @@ -756,12 +754,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
NormalizeByCalls = usesEvent("branches");
uint64_t NumUnused = 0;
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
if (YamlBF.Id >= YamlProfileToFunction.size()) {
// Such profile was ignored.
++NumUnused;
continue;
}
if (BinaryFunction *BF = YamlProfileToFunction[YamlBF.Id])
if (BinaryFunction *BF = YamlProfileToFunction.lookup(YamlBF.Id))
parseFunctionProfile(*BF, YamlBF);
else
++NumUnused;
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Rewrite/PseudoProbeRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {

StringRef Contents = PseudoProbeDescSection->getContents();
if (!ProbeDecoder.buildGUID2FuncDescMap(
reinterpret_cast<const uint8_t *>(Contents.data()),
Contents.size())) {
reinterpret_cast<const uint8_t *>(Contents.data()), Contents.size(),
/*IsMMapped*/ true)) {
errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n";
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {

void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
auto CtorInitializerList =
cxxConstructorDecl(hasAnyConstructorInitializer(anything()));

Finder->addMatcher(
cxxConstructExpr(
hasType(cxxRecordDecl(
Expand All @@ -27,7 +24,7 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
allOf(hasAncestor(CtorInitializerList),
allOf(hasAncestor(cxxConstructorDecl()),
unless(hasAncestor(cxxCatchStmt()))))))
.bind("temporary-exception-not-thrown"),
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

#include "InitVariablesCheck.h"

#include "../utils/LexerUtils.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Type.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include <optional>

Expand Down Expand Up @@ -107,8 +108,9 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
<< MatchedDecl;
if (*InitializationString != nullptr)
Diagnostic << FixItHint::CreateInsertion(
MatchedDecl->getLocation().getLocWithOffset(
MatchedDecl->getName().size()),
utils::lexer::findNextTerminator(MatchedDecl->getLocation(),
*Result.SourceManager,
Result.Context->getLangOpts()),
*InitializationString);
if (AddMathInclude) {
Diagnostic << IncludeInserter.createIncludeInsertion(
Expand Down
14 changes: 11 additions & 3 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ Changes in existing checks
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
subtracting from a pointer directly or when used to scale a numeric value.

- Improved :doc:`bugprone-throw-keyword-missing
<clang-tidy/checks/bugprone/throw-keyword-missing>` by fixing a false positive
when using non-static member initializers and a constructor.

- Improved :doc:`bugprone-unchecked-optional-access
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
`bsl::optional` and `bdlb::NullableValue` from
Expand All @@ -190,6 +194,10 @@ Changes in existing checks
fix false positive that floating point variable is only used in increment
expression.

- Improved :doc:`cppcoreguidelines-init-variables
<clang-tidy/checks/cppcoreguidelines/init-variables>` check by fixing the
insertion location for function pointers.

- Improved :doc:`cppcoreguidelines-prefer-member-initializer
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
avoid false positive when member initialization depends on a structured
Expand All @@ -208,9 +216,9 @@ Changes in existing checks
false positive for C++23 deducing this.

- Improved :doc:`modernize-avoid-c-arrays
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using ``std::span``
as a replacement for parameters of incomplete C array type in C++20 and
``std::array`` or ``std::vector`` before C++20.
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
``std::span`` as a replacement for parameters of incomplete C array type in
C++20 and ``std::array`` or ``std::vector`` before C++20.

- Improved :doc:`modernize-loop-convert
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ CtorInitializerListTest::CtorInitializerListTest(float) try : exc(RegularExcepti
RegularException();
}

namespace GH115055 {
class CtorInitializerListTest2 {
public:
CtorInitializerListTest2() {}
private:
RegularException exc{};
};
} // namespace GH115055

RegularException funcReturningExceptionTest(int i) {
return RegularException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ void test_clang_diagnostic_error() {
// CHECK-MESSAGES: :[[@LINE-1]]:3: error: unknown type name 'UnknownType' [clang-diagnostic-error]
// CHECK-FIXES-NOT: {{^}} UnknownType b = 0;{{$}}
}

namespace gh112089 {
void foo(void*);
using FPtr = void(*)(void*);
void test() {
void(*a1)(void*);
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'a1' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: void(*a1)(void*) = nullptr;
FPtr a2;
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'a2' is not initialized [cppcoreguidelines-init-variables]
// CHECK-FIXES: FPtr a2 = nullptr;
}
} // namespace gh112089

4 changes: 2 additions & 2 deletions clang/docs/AMDGPUSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Predefined Macros
* - ``__AMDGCN_UNSAFE_FP_ATOMICS__``
- Defined if unsafe floating-point atomics are allowed.
* - ``__AMDGCN_WAVEFRONT_SIZE__``
- Defines the wavefront size. Allowed values are 32 and 64.
- Defines the wavefront size. Allowed values are 32 and 64 (deprecated).
* - ``__AMDGCN_WAVEFRONT_SIZE``
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__``. To be deprecated.
- Alias to ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated).
* - ``__HAS_FMAF__``
- Defined if FMAF instruction is available (deprecated).
* - ``__HAS_LDEXPF__``
Expand Down
2 changes: 1 addition & 1 deletion clang/docs/HIPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Predefined Macros

Note that some architecture specific AMDGPU macros will have default values when
used from the HIP host compilation. Other :doc:`AMDGPU macros <AMDGPUSupport>`
like ``__AMDGCN_WAVEFRONT_SIZE__`` will default to 64 for example.
like ``__AMDGCN_WAVEFRONT_SIZE__`` (deprecated) will default to 64 for example.

Compilation Modes
=================
Expand Down
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ Attribute Changes in Clang
- Fix a bug where clang doesn't automatically apply the ``[[gsl::Owner]]`` or
``[[gsl::Pointer]]`` to STL explicit template specialization decls. (#GH109442)

- Clang now supports ``[[clang::lifetime_capture_by(X)]]``. Similar to lifetimebound, this can be
used to specify when a reference to a function parameter is captured by another capturing entity ``X``.

Improvements to Clang's diagnostics
-----------------------------------

Expand Down Expand Up @@ -740,6 +743,7 @@ X86 Support
- Support ISA of ``AMX-FP8``.
- Support ISA of ``AMX-TRANSPOSE``.
- Support ISA of ``AMX-AVX512``.
- Support ISA of ``AMX-TF32``.

Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/docs/SafeBuffers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ A relatively fresh version of C++ is recommended. In particular, the very useful
standard view class ``std::span`` requires C++20.

Other implementations of the C++ standard library may provide different
flags to enable such hardening hardening.
flags to enable such hardening.

If you're using custom containers and views, they will need to be hardened
this way as well, but you don't necessarily need to do this ahead of time.
Expand Down
37 changes: 14 additions & 23 deletions clang/include/clang/AST/StmtOpenACC.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class OpenACCAssociatedStmtConstruct : public OpenACCConstructStmt {
}
};

class OpenACCLoopConstruct;
/// This class represents a compute construct, representing a 'Kind' of
/// `parallel', 'serial', or 'kernel'. These constructs are associated with a
/// 'structured block', defined as:
Expand Down Expand Up @@ -183,8 +182,7 @@ class OpenACCComputeConstruct final
static OpenACCComputeConstruct *
Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc,
SourceLocation DirectiveLoc, SourceLocation EndLoc,
ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock,
ArrayRef<OpenACCLoopConstruct *> AssociatedLoopConstructs);
ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock);

Stmt *getStructuredBlock() { return getAssociatedStmt(); }
const Stmt *getStructuredBlock() const {
Expand All @@ -198,12 +196,10 @@ class OpenACCLoopConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCLoopConstruct,
const OpenACCClause *> {
// The compute construct this loop is associated with, or nullptr if this is
// an orphaned loop construct, or if it hasn't been set yet. Because we
// construct the directives at the end of their statement, the 'parent'
// construct is not yet available at the time of construction, so this needs
// to be set 'later'.
const OpenACCComputeConstruct *ParentComputeConstruct = nullptr;
// The compute/combined construct kind this loop is associated with, or
// invalid if this is an orphaned loop construct.
OpenACCDirectiveKind ParentComputeConstructKind =
OpenACCDirectiveKind::Invalid;

friend class ASTStmtWriter;
friend class ASTStmtReader;
Expand All @@ -212,15 +208,9 @@ class OpenACCLoopConstruct final

OpenACCLoopConstruct(unsigned NumClauses);

OpenACCLoopConstruct(SourceLocation Start, SourceLocation DirLoc,
SourceLocation End,
OpenACCLoopConstruct(OpenACCDirectiveKind ParentKind, SourceLocation Start,
SourceLocation DirLoc, SourceLocation End,
ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop);
void setLoop(Stmt *Loop);

void setParentComputeConstruct(OpenACCComputeConstruct *CC) {
assert(!ParentComputeConstruct && "Parent already set?");
ParentComputeConstruct = CC;
}

public:
static bool classof(const Stmt *T) {
Expand All @@ -231,9 +221,9 @@ class OpenACCLoopConstruct final
unsigned NumClauses);

static OpenACCLoopConstruct *
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation DirLoc,
SourceLocation EndLoc, ArrayRef<const OpenACCClause *> Clauses,
Stmt *Loop);
Create(const ASTContext &C, OpenACCDirectiveKind ParentKind,
SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
ArrayRef<const OpenACCClause *> Clauses, Stmt *Loop);

Stmt *getLoop() { return getAssociatedStmt(); }
const Stmt *getLoop() const {
Expand All @@ -246,10 +236,11 @@ class OpenACCLoopConstruct final
/// loop construct is the nearest compute construct that lexically contains
/// the loop construct.
bool isOrphanedLoopConstruct() const {
return ParentComputeConstruct == nullptr;
return ParentComputeConstructKind == OpenACCDirectiveKind::Invalid;
}
const OpenACCComputeConstruct *getParentComputeConstruct() const {
return ParentComputeConstruct;

OpenACCDirectiveKind getParentComputeConstructKind() const {
return ParentComputeConstructKind;
}
};
} // namespace clang
Expand Down
33 changes: 33 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,39 @@ def LifetimeBound : DeclOrTypeAttr {
let SimpleHandler = 1;
}

def LifetimeCaptureBy : DeclOrTypeAttr {
let Spellings = [Clang<"lifetime_capture_by", 0>];
let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
let Args = [VariadicParamOrParamIdxArgument<"Params">];
let Documentation = [LifetimeCaptureByDocs];
let AdditionalMembers = [{
private:
SmallVector<IdentifierInfo*, 1> ArgIdents;
SmallVector<SourceLocation, 1> ArgLocs;

public:
static constexpr int THIS = 0;
static constexpr int INVALID = -1;
static constexpr int UNKNOWN = -2;
static constexpr int GLOBAL = -3;

void setArgs(SmallVector<IdentifierInfo*>&& Idents,
SmallVector<SourceLocation>&& Locs) {
assert(Idents.size() == Locs.size());
assert(Idents.size() == params_Size);
ArgIdents = std::move(Idents);
ArgLocs = std::move(Locs);
}

ArrayRef<IdentifierInfo*> getArgIdents() const { return ArgIdents; }
ArrayRef<SourceLocation> getArgLocs() const { return ArgLocs; }
void setParamIdx(size_t Idx, int Val) {
assert(Idx < params_Size);
params_[Idx] = Val;
}
}];
}

def TrivialABI : InheritableAttr {
// This attribute does not have a C [[]] spelling because it requires the
// CPlusPlus language option.
Expand Down
Loading

0 comments on commit f8044f3

Please sign in to comment.