Skip to content

Commit 4c2e494

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-replace-rdxdesc-with-recurkind
2 parents dca0d4b + cf06047 commit 4c2e494

File tree

1,041 files changed

+22188
-12354
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,041 files changed

+22188
-12354
lines changed

.github/workflows/libclang-python-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ on:
1010
- 'main'
1111
paths:
1212
- 'clang/bindings/python/**'
13-
- 'clang/test/bindings/python/**'
1413
- 'clang/tools/libclang/**'
14+
- 'clang/CMakeList.txt'
1515
- '.github/workflows/libclang-python-tests.yml'
1616
- '.github/workflows/llvm-project-tests.yml'
1717
pull_request:
1818
paths:
1919
- 'clang/bindings/python/**'
20-
- 'clang/test/bindings/python/**'
2120
- 'clang/tools/libclang/**'
21+
- 'clang/CMakeList.txt'
2222
- '.github/workflows/libclang-python-tests.yml'
2323
- '.github/workflows/llvm-project-tests.yml'
2424

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "bolt/Core/MCPlusBuilder.h"
2323
#include "llvm/BinaryFormat/ELF.h"
2424
#include "llvm/MC/MCContext.h"
25-
#include "llvm/MC/MCFixupKindInfo.h"
2625
#include "llvm/MC/MCInstBuilder.h"
2726
#include "llvm/MC/MCInstrInfo.h"
2827
#include "llvm/MC/MCRegister.h"
@@ -2557,7 +2556,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
25572556
else if (Fixup.getKind() ==
25582557
MCFixupKind(AArch64::fixup_aarch64_pcrel_branch26))
25592558
RelType = ELF::R_AARCH64_JUMP26;
2560-
else if (FKI.Flags & MCFixupKindInfo::FKF_IsPCRel) {
2559+
else if (Fixup.isPCRel()) {
25612560
switch (FKI.TargetSize) {
25622561
default:
25632562
return std::nullopt;

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "bolt/Core/MCPlusBuilder.h"
1919
#include "llvm/BinaryFormat/ELF.h"
2020
#include "llvm/MC/MCContext.h"
21-
#include "llvm/MC/MCFixupKindInfo.h"
2221
#include "llvm/MC/MCInst.h"
2322
#include "llvm/MC/MCInstBuilder.h"
2423
#include "llvm/MC/MCInstrInfo.h"
@@ -2444,7 +2443,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24442443
const uint64_t RelOffset = Fixup.getOffset();
24452444

24462445
uint32_t RelType;
2447-
if (FKI.Flags & MCFixupKindInfo::FKF_IsPCRel) {
2446+
if (Fixup.isPCRel()) {
24482447
switch (FKI.TargetSize) {
24492448
default:
24502449
return std::nullopt;

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ static llvm::Error addReference(T I, Reference &&R, FieldId F) {
569569
"invalid type cannot contain Reference");
570570
}
571571

572+
template <> llvm::Error addReference(VarInfo *I, Reference &&R, FieldId F) {
573+
switch (F) {
574+
case FieldId::F_namespace:
575+
I->Namespace.emplace_back(std::move(R));
576+
return llvm::Error::success();
577+
default:
578+
return llvm::createStringError(llvm::inconvertibleErrorCode(),
579+
"VarInfo cannot contain this Reference");
580+
}
581+
}
582+
572583
template <> llvm::Error addReference(TypeInfo *I, Reference &&R, FieldId F) {
573584
switch (F) {
574585
case FieldId::F_type:

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,27 @@ getFixIt(const tooling::Diagnostic &Diagnostic, bool AnyFix) {
358358

359359
} // namespace clang::tidy
360360

361+
void ClangTidyDiagnosticConsumer::BeginSourceFile(const LangOptions &LangOpts,
362+
const Preprocessor *PP) {
363+
DiagnosticConsumer::BeginSourceFile(LangOpts, PP);
364+
365+
assert(!InSourceFile);
366+
InSourceFile = true;
367+
}
368+
369+
void ClangTidyDiagnosticConsumer::EndSourceFile() {
370+
assert(InSourceFile);
371+
InSourceFile = false;
372+
373+
DiagnosticConsumer::EndSourceFile();
374+
}
375+
361376
void ClangTidyDiagnosticConsumer::HandleDiagnostic(
362377
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
378+
// A diagnostic should not be reported outside of a
379+
// BeginSourceFile()/EndSourceFile() pair if it has a source location.
380+
assert(InSourceFile || Info.getLocation().isInvalid());
381+
363382
if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
364383
return;
365384

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
292292
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
293293
const Diagnostic &Info) override;
294294

295+
void BeginSourceFile(const LangOptions &LangOpts,
296+
const Preprocessor *PP = nullptr) override;
297+
298+
void EndSourceFile() override;
299+
295300
// Retrieve the diagnostics that were captured.
296301
std::vector<ClangTidyError> take();
297302

@@ -326,6 +331,11 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
326331
bool LastErrorRelatesToUserCode = false;
327332
bool LastErrorPassesLineFilter = false;
328333
bool LastErrorWasIgnored = false;
334+
/// Tracks whether we're currently inside a
335+
/// `BeginSourceFile()/EndSourceFile()` pair. Outside of a source file, we
336+
/// should only receive diagnostics that have to source location, such as
337+
/// command-line warnings.
338+
bool InSourceFile = false;
329339
};
330340

331341
} // end namespace tidy

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,26 @@ using namespace clang::ast_matchers;
1515
namespace clang::tidy::cppcoreguidelines {
1616

1717
void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
18-
if (!getLangOpts().CPlusPlus)
19-
return;
20-
2118
const auto AllPointerTypes =
22-
anyOf(hasType(pointerType()),
19+
anyOf(hasType(hasUnqualifiedDesugaredType(pointerType())),
2320
hasType(autoType(
2421
hasDeducedType(hasUnqualifiedDesugaredType(pointerType())))),
2522
hasType(decltypeType(hasUnderlyingType(pointerType()))));
2623

27-
// Flag all operators +, -, +=, -=, ++, -- that result in a pointer
24+
// Flag all operators +, -, +=, -= that result in a pointer
2825
Finder->addMatcher(
2926
binaryOperator(
3027
hasAnyOperatorName("+", "-", "+=", "-="), AllPointerTypes,
3128
unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))))))
3229
.bind("expr"),
3330
this);
3431

32+
// Flag all operators ++, -- that result in a pointer
3533
Finder->addMatcher(
36-
unaryOperator(hasAnyOperatorName("++", "--"), hasType(pointerType()))
34+
unaryOperator(hasAnyOperatorName("++", "--"),
35+
hasType(hasUnqualifiedDesugaredType(pointerType())),
36+
unless(hasUnaryOperand(
37+
ignoringImpCasts(declRefExpr(to(isImplicit()))))))
3738
.bind("expr"),
3839
this);
3940

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ProBoundsPointerArithmeticCheck : public ClangTidyCheck {
2323
public:
2424
ProBoundsPointerArithmeticCheck(StringRef Name, ClangTidyContext *Context)
2525
: ClangTidyCheck(Name, Context) {}
26+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
27+
return LangOpts.CPlusPlus;
28+
}
2629
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
2730
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2831
};

clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ void UnconventionalAssignOperatorCheck::registerMatchers(
6666
hasArgument(0, cxxThisExpr())),
6767
cxxOperatorCallExpr(
6868
hasOverloadedOperatorName("="),
69-
hasArgument(
70-
0, unaryOperator(hasOperatorName("*"),
69+
hasArgument(0, unaryOperator(hasOperatorName("*"),
70+
hasUnaryOperand(cxxThisExpr())))),
71+
binaryOperator(
72+
hasOperatorName("="),
73+
hasLHS(unaryOperator(hasOperatorName("*"),
7174
hasUnaryOperand(cxxThisExpr())))))))));
7275
const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
7376

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "llvm/ADT/StringExtras.h"
3434
#include "llvm/ADT/StringRef.h"
3535
#include "llvm/ADT/Twine.h"
36-
#include "llvm/ADT/identity.h"
3736
#include "llvm/Support/Casting.h"
3837
#include "llvm/Support/ErrorHandling.h"
3938
#include "llvm/Support/FormatVariadic.h"
@@ -339,53 +338,6 @@ QualType maybeDesugar(ASTContext &AST, QualType QT) {
339338
return QT;
340339
}
341340

342-
// Given a callee expression `Fn`, if the call is through a function pointer,
343-
// try to find the declaration of the corresponding function pointer type,
344-
// so that we can recover argument names from it.
345-
// FIXME: This function is mostly duplicated in SemaCodeComplete.cpp; unify.
346-
static FunctionProtoTypeLoc getPrototypeLoc(Expr *Fn) {
347-
TypeLoc Target;
348-
Expr *NakedFn = Fn->IgnoreParenCasts();
349-
if (const auto *T = NakedFn->getType().getTypePtr()->getAs<TypedefType>()) {
350-
Target = T->getDecl()->getTypeSourceInfo()->getTypeLoc();
351-
} else if (const auto *DR = dyn_cast<DeclRefExpr>(NakedFn)) {
352-
const auto *D = DR->getDecl();
353-
if (const auto *const VD = dyn_cast<VarDecl>(D)) {
354-
Target = VD->getTypeSourceInfo()->getTypeLoc();
355-
}
356-
}
357-
358-
if (!Target)
359-
return {};
360-
361-
// Unwrap types that may be wrapping the function type
362-
while (true) {
363-
if (auto P = Target.getAs<PointerTypeLoc>()) {
364-
Target = P.getPointeeLoc();
365-
continue;
366-
}
367-
if (auto A = Target.getAs<AttributedTypeLoc>()) {
368-
Target = A.getModifiedLoc();
369-
continue;
370-
}
371-
if (auto P = Target.getAs<ParenTypeLoc>()) {
372-
Target = P.getInnerLoc();
373-
continue;
374-
}
375-
break;
376-
}
377-
378-
if (auto F = Target.getAs<FunctionProtoTypeLoc>()) {
379-
// In some edge cases the AST can contain a "trivial" FunctionProtoTypeLoc
380-
// which has null parameters. Avoid these as they don't contain useful
381-
// information.
382-
if (llvm::all_of(F.getParams(), llvm::identity<ParmVarDecl *>()))
383-
return F;
384-
}
385-
386-
return {};
387-
}
388-
389341
ArrayRef<const ParmVarDecl *>
390342
maybeDropCxxExplicitObjectParameters(ArrayRef<const ParmVarDecl *> Params) {
391343
if (!Params.empty() && Params.front()->isExplicitObjectParameter())
@@ -514,7 +466,8 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
514466
Callee.Decl = FD;
515467
else if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(CalleeDecls[0]))
516468
Callee.Decl = FTD->getTemplatedDecl();
517-
else if (FunctionProtoTypeLoc Loc = getPrototypeLoc(E->getCallee()))
469+
else if (FunctionProtoTypeLoc Loc =
470+
Resolver->getFunctionProtoTypeLoc(E->getCallee()))
518471
Callee.Loc = Loc;
519472
else
520473
return true;

0 commit comments

Comments
 (0)