Skip to content

Commit daa1881

Browse files
authored
merge main into amd-staging (llvm#3458)
2 parents a2d2a67 + e93baa9 commit daa1881

File tree

59 files changed

+1397
-212
lines changed

Some content is hidden

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

59 files changed

+1397
-212
lines changed

clang-tools-extra/include-cleaner/lib/Record.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "clang/Basic/FileEntry.h"
1515
#include "clang/Basic/FileManager.h"
1616
#include "clang/Basic/LLVM.h"
17+
#include "clang/Basic/LangOptions.h"
1718
#include "clang/Basic/SourceLocation.h"
1819
#include "clang/Basic/SourceManager.h"
1920
#include "clang/Basic/Specifiers.h"
@@ -179,8 +180,10 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
179180
RecordPragma(const CompilerInstance &CI, PragmaIncludes *Out)
180181
: RecordPragma(CI.getPreprocessor(), Out) {}
181182
RecordPragma(const Preprocessor &P, PragmaIncludes *Out)
182-
: SM(P.getSourceManager()), HeaderInfo(P.getHeaderSearchInfo()), Out(Out),
183-
Arena(std::make_shared<llvm::BumpPtrAllocator>()),
183+
: SM(P.getSourceManager()), HeaderInfo(P.getHeaderSearchInfo()),
184+
L(P.getLangOpts().CPlusPlus ? tooling::stdlib::Lang::CXX
185+
: tooling::stdlib::Lang::C),
186+
Out(Out), Arena(std::make_shared<llvm::BumpPtrAllocator>()),
184187
UniqueStrings(*Arena),
185188
MainFileStem(llvm::sys::path::stem(
186189
SM.getNonBuiltinFilenameForID(SM.getMainFileID()).value_or(""))) {}
@@ -224,7 +227,7 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
224227
std::optional<Header> IncludedHeader;
225228
if (IsAngled)
226229
if (auto StandardHeader =
227-
tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
230+
tooling::stdlib::Header::named("<" + FileName.str() + ">", L)) {
228231
IncludedHeader = *StandardHeader;
229232
}
230233
if (!IncludedHeader && File)
@@ -363,6 +366,7 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler {
363366
bool InMainFile = false;
364367
const SourceManager &SM;
365368
const HeaderSearch &HeaderInfo;
369+
const tooling::stdlib::Lang L;
366370
PragmaIncludes *Out;
367371
std::shared_ptr<llvm::BumpPtrAllocator> Arena;
368372
/// Intern table for strings. Contents are on the arena.

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/Frontend/FrontendActions.h"
1919
#include "clang/Frontend/FrontendOptions.h"
2020
#include "clang/Serialization/PCHContainerOperations.h"
21+
#include "clang/Testing/CommandLineArgs.h"
2122
#include "clang/Testing/TestAST.h"
2223
#include "clang/Tooling/Inclusions/StandardLibrary.h"
2324
#include "llvm/ADT/ArrayRef.h"
@@ -514,6 +515,26 @@ TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
514515
testing::UnorderedElementsAre(FileNamed("export.h")));
515516
}
516517

518+
TEST_F(PragmaIncludeTest, IWYUExportForStandardHeadersRespectsLang) {
519+
Inputs.Code = R"cpp(
520+
#include "export.h"
521+
)cpp";
522+
Inputs.Language = TestLanguage::Lang_C99;
523+
Inputs.ExtraFiles["export.h"] = R"cpp(
524+
#include <stdlib.h> // IWYU pragma: export
525+
)cpp";
526+
Inputs.ExtraFiles["stdlib.h"] = "";
527+
Inputs.ExtraArgs = {"-isystem."};
528+
TestAST Processed = build();
529+
auto &FM = Processed.fileManager();
530+
EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(
531+
"<stdlib.h>", tooling::stdlib::Lang::C),
532+
FM),
533+
testing::UnorderedElementsAre(FileNamed("export.h")));
534+
EXPECT_THAT(PI.getExporters(llvm::cantFail(FM.getFileRef("stdlib.h")), FM),
535+
testing::UnorderedElementsAre(FileNamed("export.h")));
536+
}
537+
517538
TEST_F(PragmaIncludeTest, IWYUExportBlock) {
518539
Inputs.Code = R"cpp(// Line 1
519540
#include "normal.h"

clang/docs/ClangRepl.rst

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,29 @@ Lamdas:
159159
clang-repl> welcome();
160160
Welcome to REPL
161161
162-
Using Dynamic Library:
163-
======================
162+
Comments:
163+
=========
164+
165+
.. code-block:: text
166+
167+
clang-repl> // Comments in Clang-Repl
168+
clang-repl> /* Comments in Clang-Repl */
169+
170+
Built in Commands:
171+
==================
172+
clang-repl has some special commands that are of the form ``%<something>``. To list all these commands, use the ``%help`` command:
173+
174+
Help:
175+
-----
176+
The ``%help`` command lists all built in clang-repl commands.
177+
178+
.. code-block:: text
179+
180+
clang-repl> %help
181+
182+
Using Dynamic Libraries:
183+
------------------------
184+
The ``%lib`` command links a dynamic library.
164185

165186
.. code-block:: text
166187
@@ -189,21 +210,30 @@ Using Dynamic Library:
189210
clang++-17 -c -o print.o print.cpp
190211
clang-17 -shared print.o -o print.so
191212
192-
Comments:
193-
=========
213+
Undo:
214+
-----
215+
The ``%undo`` command undoes the previous input.
194216

195217
.. code-block:: text
196218
197-
clang-repl> // Comments in Clang-Repl
198-
clang-repl> /* Comments in Clang-Repl */
219+
clang-repl> int a = 1; a
220+
(int) 1
221+
clang-repl> %undo
222+
clang-repl> a
223+
In file included from <<< inputs >>>:1:
224+
input_line_2:1:1: error: use of undeclared identifier 'a'
225+
1 | a
226+
* | ^
227+
error: Parsing failed.
199228
200-
201-
Closure or Termination:
202-
=======================
229+
Quit:
230+
-----
231+
The ``%quit`` command terminates clang-repl.
203232

204233
.. code-block:: text
205234
206-
clang-repl>%quit
235+
clang-repl> %quit
236+
207237
208238
209239
Just like Clang, Clang-Repl can be integrated in existing applications as a library

clang/include/clang/AST/ASTContext.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,9 +2394,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
23942394
/// Retrieve the implicitly-predeclared 'struct type_info' declaration.
23952395
TagDecl *getMSTypeInfoTagDecl() const {
23962396
// Lazily create this type on demand - it's only needed for MS builds.
2397-
if (!MSTypeInfoTagDecl) {
2398-
MSTypeInfoTagDecl = buildImplicitRecord("type_info");
2399-
}
2397+
if (!MSTypeInfoTagDecl)
2398+
MSTypeInfoTagDecl = buildImplicitRecord("type_info", TagTypeKind::Class);
24002399
return MSTypeInfoTagDecl;
24012400
}
24022401

clang/lib/Basic/Targets/SPIR.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
438438

439439
ArrayRef<const char *> getGCCRegNames() const override;
440440

441+
BuiltinVaListKind getBuiltinVaListKind() const override {
442+
return TargetInfo::CharPtrBuiltinVaList;
443+
}
444+
441445
bool initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
442446
StringRef,
443447
const std::vector<std::string> &) const override;

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,7 @@ static bool isDefinedInClangModule(const RecordDecl *RD) {
29342934
if (!Explicit && CXXDecl->getEnclosingNamespaceContext())
29352935
return false;
29362936
// This is a template, check the origin of the first member.
2937-
if (CXXDecl->field_begin() == CXXDecl->field_end())
2937+
if (CXXDecl->fields().empty())
29382938
return TemplateKind == TSK_ExplicitInstantiationDeclaration;
29392939
if (!CXXDecl->field_begin()->isFromASTFile())
29402940
return false;

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(
373373
bool UseVirtualCall = CanUseVirtualCall && !DevirtualizedMethod;
374374

375375
if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(CalleeDecl)) {
376-
assert(CE->arg_begin() == CE->arg_end() &&
376+
assert(CE->arguments().empty() &&
377377
"Destructor shouldn't have explicit parameters");
378378
assert(ReturnValue.isNull() && "Destructor shouldn't have return value");
379379
if (UseVirtualCall) {

clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
17501750
// struct objc_method_list *methods
17511751
// FIXME: Almost identical code is copied and pasted below for the
17521752
// class, but refactoring it cleanly requires C++14 generic lambdas.
1753-
if (OID->classmeth_begin() == OID->classmeth_end())
1753+
if (OID->class_methods().empty())
17541754
metaclassFields.addNullPointer(PtrTy);
17551755
else {
17561756
SmallVector<ObjCMethodDecl*, 16> ClassMethods;

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ CodeGenTBAA::CollectFields(uint64_t BaseOffset,
438438

439439
// TODO: Handle C++ base classes.
440440
if (const CXXRecordDecl *Decl = dyn_cast<CXXRecordDecl>(RD))
441-
if (Decl->bases_begin() != Decl->bases_end())
441+
if (!Decl->bases().empty())
442442
return false;
443443

444444
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ llvm::Value *ItaniumCXXABI::EmitVirtualDestructorCall(
22622262
auto *CE = dyn_cast<const CXXMemberCallExpr *>(E);
22632263
auto *D = dyn_cast<const CXXDeleteExpr *>(E);
22642264
assert((CE != nullptr) ^ (D != nullptr));
2265-
assert(CE == nullptr || CE->arg_begin() == CE->arg_end());
2265+
assert(CE == nullptr || CE->arguments().empty());
22662266
assert(DtorType == Dtor_Deleting || DtorType == Dtor_Complete);
22672267

22682268
GlobalDecl GD(Dtor, DtorType);

0 commit comments

Comments
 (0)