Skip to content

Commit 3db2977

Browse files
authored
merge main into amd-staging (llvm#4244)
2 parents 8e59330 + 8facc51 commit 3db2977

File tree

186 files changed

+61841
-46621
lines changed

Some content is hidden

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

186 files changed

+61841
-46621
lines changed

bolt/lib/Target/AArch64/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ add_llvm_library(LLVMBOLTTargetAArch64
2828
AArch64CommonTableGen
2929
)
3030

31-
target_link_libraries(LLVMBOLTTargetAArch64 PRIVATE LLVMBOLTCore)
31+
target_link_libraries(LLVMBOLTTargetAArch64 PRIVATE LLVMBOLTCore LLVMBOLTUtils)
3232

3333
include_directories(
3434
${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64

clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
2020
hasType(cxxRecordDecl(anyOf(
2121
matchesName("[Ee]xception|EXCEPTION"),
2222
hasAnyBase(hasType(hasCanonicalType(recordType(hasDeclaration(
23-
cxxRecordDecl(matchesName("[Ee]xception|EXCEPTION")))))))))),
23+
cxxRecordDecl(matchesName("[Ee]xception|EXCEPTION"))
24+
.bind("base"))))))))),
2425
unless(anyOf(
2526
hasAncestor(
2627
stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
@@ -39,6 +40,11 @@ void ThrowKeywordMissingCheck::check(const MatchFinder::MatchResult &Result) {
3940
diag(TemporaryExpr->getBeginLoc(), "suspicious exception object created but "
4041
"not thrown; did you mean 'throw %0'?")
4142
<< TemporaryExpr->getType().getBaseTypeIdentifier()->getName();
43+
44+
if (const auto *BaseDecl = Result.Nodes.getNodeAs<Decl>("base"))
45+
diag(BaseDecl->getLocation(),
46+
"object type inherits from base class declared here",
47+
DiagnosticIDs::Note);
4248
}
4349

4450
} // namespace clang::tidy::bugprone

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ Changes in existing checks
272272

273273
- Improved :doc:`bugprone-throw-keyword-missing
274274
<clang-tidy/checks/bugprone/throw-keyword-missing>` check by only considering
275-
the canonical types of base classes as written.
275+
the canonical types of base classes as written and adding a note on the base
276+
class that triggered the warning.
276277

277278
- Improved :doc:`bugprone-unchecked-optional-access
278279
<clang-tidy/checks/bugprone/unchecked-optional-access>` check by supporting

clang-tools-extra/test/clang-tidy/checkers/bugprone/throw-keyword-missing.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef basic_string<char> string;
2020
typedef basic_string<wchar_t> wstring;
2121

2222
// std::exception and std::runtime_error declaration.
23+
// CHECK-MESSAGES-DAG: [[#EXCEPTION_LINE:@LINE + 1]]:8
2324
struct exception {
2425
exception();
2526
exception(const exception &other);
@@ -50,12 +51,13 @@ struct RegularException {
5051

5152
void stdExceptionNotTrownTest(int i) {
5253
if (i < 0)
53-
// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception object created but not thrown; did you mean 'throw {{.*}}'? [bugprone-throw-keyword-missing]
54+
// CHECK-MESSAGES-DAG: :[[@LINE+1]]:5: warning: suspicious exception object created but not thrown; did you mean 'throw {{.*}}'? [bugprone-throw-keyword-missing]
5455
std::exception();
5556

5657
if (i > 0)
57-
// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: suspicious exception
58+
// CHECK-MESSAGES-DAG: :[[@LINE+1]]:5: warning: suspicious exception
5859
std::runtime_error("Unexpected argument");
60+
// CHECK-MESSAGES: note: object type inherits from base class declared here
5961
}
6062

6163
void stdExceptionThrownTest(int i) {
@@ -181,6 +183,7 @@ class RegularError : public ERROR_BASE {};
181183
void typedefTest() {
182184
// CHECK-MESSAGES: :[[@LINE+1]]:3: warning: suspicious exception
183185
RegularError();
186+
// CHECK-MESSAGES: :[[#EXCEPTION_LINE]]:8: note: object type inherits from base class declared here
184187
}
185188

186189
struct ExceptionRAII {

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ Crash and bug fixes
820820
- Fixed a crash in the static analyzer that when the expression in an
821821
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
822822
- Fixed a crash when parsing ``#embed`` parameters with unmatched closing brackets. (#GH152829)
823+
- Fixed a crash when compiling ``__real__`` or ``__imag__`` unary operator on scalar value with type promotion. (#GH160583)
823824

824825
Improvements
825826
^^^^^^^^^^^^

clang/include/clang/CodeGen/BackendUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
4949
llvm::MemoryBufferRef Buf);
5050

5151
void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
52-
DiagnosticsEngine &Diags);
52+
llvm::vfs::FileSystem &VFS, DiagnosticsEngine &Diags);
5353
} // namespace clang
5454

5555
#endif

clang/include/clang/Frontend/Utils.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ class ModuleDependencyCollector : public DependencyCollector {
143143
std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
144144

145145
public:
146-
ModuleDependencyCollector(std::string DestDir)
147-
: DestDir(std::move(DestDir)) {}
146+
ModuleDependencyCollector(std::string DestDir,
147+
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
148+
: DestDir(std::move(DestDir)), Canonicalizer(std::move(VFS)) {}
148149
~ModuleDependencyCollector() override { writeFileMap(); }
149150

150151
StringRef getDest() { return DestDir; }

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,7 @@ static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
11691169
const InterpFrame *Frame,
11701170
const CallExpr *Call,
11711171
unsigned BuiltinOp) {
1172-
PrimType AlignmentT = *S.Ctx.classify(Call->getArg(1));
1173-
const APSInt &Alignment = popToAPSInt(S.Stk, AlignmentT);
1172+
const APSInt &Alignment = popToAPSInt(S, Call->getArg(1));
11741173

11751174
if (Alignment < 0 || !Alignment.isPowerOf2()) {
11761175
S.FFDiag(Call, diag::note_constexpr_invalid_alignment) << Alignment;
@@ -1184,8 +1183,7 @@ static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
11841183
return false;
11851184
}
11861185

1187-
// The first parameter is either an integer or a pointer (but not a function
1188-
// pointer).
1186+
// The first parameter is either an integer or a pointer.
11891187
PrimType FirstArgT = *S.Ctx.classify(Call->getArg(0));
11901188

11911189
if (isIntegralType(FirstArgT)) {
@@ -1204,12 +1202,12 @@ static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
12041202
}
12051203
return true;
12061204
}
1207-
12081205
assert(FirstArgT == PT_Ptr);
12091206
const Pointer &Ptr = S.Stk.pop<Pointer>();
1207+
if (!Ptr.isBlockPointer())
1208+
return false;
12101209

1211-
unsigned PtrOffset = Ptr.getByteOffset();
1212-
PtrOffset = Ptr.getIndex();
1210+
unsigned PtrOffset = Ptr.getIndex();
12131211
CharUnits BaseAlignment =
12141212
S.getASTContext().getDeclAlign(Ptr.getDeclDesc()->asValueDecl());
12151213
CharUnits PtrAlign =

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,13 @@ void clang::EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
14761476
}
14771477

14781478
void clang::EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
1479-
DiagnosticsEngine &Diags) {
1479+
llvm::vfs::FileSystem &VFS, DiagnosticsEngine &Diags) {
14801480
if (CGOpts.OffloadObjects.empty())
14811481
return;
14821482

14831483
for (StringRef OffloadObject : CGOpts.OffloadObjects) {
14841484
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ObjectOrErr =
1485-
llvm::MemoryBuffer::getFileOrSTDIN(OffloadObject);
1485+
VFS.getBufferForFile(OffloadObject);
14861486
if (ObjectOrErr.getError()) {
14871487
auto DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
14881488
"could not open '%0' for embedding");

clang/lib/CodeGen/CGAtomic.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest,
734734
CGF.emitAtomicRMWInst(llvm::AtomicRMWInst::Xchg, Ptr,
735735
CGF.Builder.getInt8(1), Order, Scope, E);
736736
RMWI->setVolatile(E->isVolatile());
737-
llvm::Value *Result = CGF.Builder.CreateIsNotNull(RMWI, "tobool");
737+
llvm::Value *Result = CGF.EmitToMemory(
738+
CGF.Builder.CreateIsNotNull(RMWI, "tobool"), E->getType());
738739
auto *I = CGF.Builder.CreateStore(Result, Dest);
739740
CGF.addInstToCurrentSourceAtom(I, Result);
740741
return;

0 commit comments

Comments
 (0)