Skip to content

Commit d168ced

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:c4e9e41199127bb288e84e9477da99f28941edb3 into amd-gfx:c5f22f9383e1
Local branch amd-gfx c5f22f9 Merged main:b5af667b01458e9083256f2614df175916c73e5a into amd-gfx:3ceb816dd24a Remote branch main c4e9e41 [Clang] Ensure ``if consteval`` consititute an immediate function context (llvm#91939)
2 parents c5f22f9 + c4e9e41 commit d168ced

File tree

183 files changed

+6112
-2524
lines changed

Some content is hidden

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

183 files changed

+6112
-2524
lines changed

.github/new-prs-labeler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ mlir:dlti:
239239
- mlir/**/DLTI/**
240240

241241
mlir:emitc:
242-
- mlir/**/EmitC/**
242+
- mlir/**/*EmitC*/**
243243
- mlir/lib/Target/Cpp/**
244244

245245
mlir:func:
@@ -306,7 +306,7 @@ mlir:tensor:
306306
- mlir/**/Tensor/**
307307

308308
mlir:tosa:
309-
- mlir/**/Tosa/**
309+
- mlir/**/*Tosa*/**
310310

311311
mlir:ub:
312312
- mlir/**/UB/**

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ std::error_code DataAggregator::parseMMapEvents() {
20002000
std::pair<StringRef, MMapInfo> FileMMapInfo = FileMMapInfoRes.get();
20012001
if (FileMMapInfo.second.PID == -1)
20022002
continue;
2003-
if (FileMMapInfo.first.equals("(deleted)"))
2003+
if (FileMMapInfo.first == "(deleted)")
20042004
continue;
20052005

20062006
// Consider only the first mapping of the file for any given PID

bolt/lib/Profile/DataReader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,7 @@ std::error_code DataReader::parse() {
12051205

12061206
// Add entry data for branches to another function or branches
12071207
// to entry points (including recursive calls)
1208-
if (BI.To.IsSymbol &&
1209-
(!BI.From.Name.equals(BI.To.Name) || BI.To.Offset == 0)) {
1208+
if (BI.To.IsSymbol && (BI.From.Name != BI.To.Name || BI.To.Offset == 0)) {
12101209
I = GetOrCreateFuncEntry(BI.To.Name);
12111210
I->second.EntryData.emplace_back(std::move(BI));
12121211
}

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder &DIEBlder,
15501550
for (const SectionRef &Section : Obj->sections()) {
15511551
StringRef Contents = cantFail(Section.getContents());
15521552
StringRef Name = cantFail(Section.getName());
1553-
if (Name.equals(".debug_types"))
1553+
if (Name == ".debug_types")
15541554
BC.registerOrUpdateNoteSection(".debug_types", copyByteArray(Contents),
15551555
Contents.size());
15561556
}
@@ -1633,10 +1633,10 @@ void DWARFRewriter::finalizeDebugSections(
16331633
for (const SectionRef &Secs : Obj->sections()) {
16341634
StringRef Contents = cantFail(Secs.getContents());
16351635
StringRef Name = cantFail(Secs.getName());
1636-
if (Name.equals(".debug_abbrev")) {
1636+
if (Name == ".debug_abbrev") {
16371637
BC.registerOrUpdateNoteSection(".debug_abbrev", copyByteArray(Contents),
16381638
Contents.size());
1639-
} else if (Name.equals(".debug_info")) {
1639+
} else if (Name == ".debug_info") {
16401640
BC.registerOrUpdateNoteSection(".debug_info", copyByteArray(Contents),
16411641
Contents.size());
16421642
}
@@ -1771,7 +1771,7 @@ std::optional<StringRef> updateDebugData(
17711771
};
17721772
switch (SectionIter->second.second) {
17731773
default: {
1774-
if (!SectionName.equals("debug_str.dwo"))
1774+
if (SectionName != "debug_str.dwo")
17751775
errs() << "BOLT-WARNING: unsupported debug section: " << SectionName
17761776
<< "\n";
17771777
return SectionContents;
@@ -1959,7 +1959,7 @@ void DWARFRewriter::updateDWP(DWARFUnit &CU,
19591959
continue;
19601960
}
19611961

1962-
if (SectionName.equals("debug_str.dwo")) {
1962+
if (SectionName == "debug_str.dwo") {
19631963
CurStrSection = OutData;
19641964
} else {
19651965
// Since handleDebugDataPatching returned true, we already know this is

bolt/lib/Rewrite/SDTRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void SDTRewriter::readSection() {
8787

8888
StringRef Name = DE.getCStr(&Offset);
8989

90-
if (!Name.equals("stapsdt"))
90+
if (Name != "stapsdt")
9191
errs() << "BOLT-WARNING: SDT note name \"" << Name
9292
<< "\" is not expected\n";
9393

clang-tools-extra/clang-query/Query.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Query.h"
10+
#include "QueryParser.h"
1011
#include "QuerySession.h"
1112
#include "clang/AST/ASTDumper.h"
1213
#include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -281,5 +282,26 @@ const QueryKind SetQueryKind<bool>::value;
281282
const QueryKind SetQueryKind<OutputKind>::value;
282283
#endif
283284

285+
bool FileQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
286+
auto Buffer = llvm::MemoryBuffer::getFile(StringRef{File}.trim());
287+
if (!Buffer) {
288+
if (Prefix.has_value())
289+
llvm::errs() << *Prefix << ": ";
290+
llvm::errs() << "cannot open " << File << ": "
291+
<< Buffer.getError().message() << "\n";
292+
return false;
293+
}
294+
295+
StringRef FileContentRef(Buffer.get()->getBuffer());
296+
297+
while (!FileContentRef.empty()) {
298+
QueryRef Q = QueryParser::parse(FileContentRef, QS);
299+
if (!Q->run(llvm::outs(), QS))
300+
return false;
301+
FileContentRef = Q->RemainingContent;
302+
}
303+
return true;
304+
}
305+
284306
} // namespace query
285307
} // namespace clang

clang-tools-extra/clang-query/Query.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ enum QueryKind {
3030
QK_SetTraversalKind,
3131
QK_EnableOutputKind,
3232
QK_DisableOutputKind,
33-
QK_Quit
33+
QK_Quit,
34+
QK_File
3435
};
3536

3637
class QuerySession;
@@ -188,6 +189,21 @@ struct DisableOutputQuery : SetNonExclusiveOutputQuery {
188189
}
189190
};
190191

192+
struct FileQuery : Query {
193+
FileQuery(StringRef File, StringRef Prefix = StringRef())
194+
: Query(QK_File), File(File),
195+
Prefix(!Prefix.empty() ? std::optional<std::string>(Prefix)
196+
: std::nullopt) {}
197+
198+
bool run(llvm::raw_ostream &OS, QuerySession &QS) const override;
199+
200+
static bool classof(const Query *Q) { return Q->Kind == QK_File; }
201+
202+
private:
203+
std::string File;
204+
std::optional<std::string> Prefix;
205+
};
206+
191207
} // namespace query
192208
} // namespace clang
193209

clang-tools-extra/clang-query/QueryParser.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ enum ParsedQueryKind {
183183
PQK_Unlet,
184184
PQK_Quit,
185185
PQK_Enable,
186-
PQK_Disable
186+
PQK_Disable,
187+
PQK_File
187188
};
188189

189190
enum ParsedQueryVariable {
@@ -222,12 +223,14 @@ QueryRef QueryParser::doParse() {
222223
.Case("let", PQK_Let)
223224
.Case("m", PQK_Match, /*IsCompletion=*/false)
224225
.Case("match", PQK_Match)
225-
.Case("q", PQK_Quit, /*IsCompletion=*/false)
226+
.Case("q", PQK_Quit, /*IsCompletion=*/false)
226227
.Case("quit", PQK_Quit)
227228
.Case("set", PQK_Set)
228229
.Case("enable", PQK_Enable)
229230
.Case("disable", PQK_Disable)
230231
.Case("unlet", PQK_Unlet)
232+
.Case("f", PQK_File, /*IsCompletion=*/false)
233+
.Case("file", PQK_File)
231234
.Default(PQK_Invalid);
232235

233236
switch (QKind) {
@@ -351,6 +354,9 @@ QueryRef QueryParser::doParse() {
351354
return endQuery(new LetQuery(Name, VariantValue()));
352355
}
353356

357+
case PQK_File:
358+
return new FileQuery(Line);
359+
354360
case PQK_Invalid:
355361
return new InvalidQuery("unknown command: " + CommandStr);
356362
}

clang-tools-extra/clang-query/tool/ClangQuery.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,8 @@ static cl::opt<std::string> PreloadFile(
7474

7575
bool runCommandsInFile(const char *ExeName, std::string const &FileName,
7676
QuerySession &QS) {
77-
auto Buffer = llvm::MemoryBuffer::getFile(FileName);
78-
if (!Buffer) {
79-
llvm::errs() << ExeName << ": cannot open " << FileName << ": "
80-
<< Buffer.getError().message() << "\n";
81-
return true;
82-
}
83-
84-
StringRef FileContentRef(Buffer.get()->getBuffer());
85-
86-
while (!FileContentRef.empty()) {
87-
QueryRef Q = QueryParser::parse(FileContentRef, QS);
88-
if (!Q->run(llvm::outs(), QS))
89-
return true;
90-
FileContentRef = Q->RemainingContent;
91-
}
92-
return false;
77+
FileQuery Query(FileName, ExeName);
78+
return !Query.run(llvm::errs(), QS);
9379
}
9480

9581
int main(int argc, const char **argv) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
171171
if (IgnoreCase) {
172172
if (Value.equals_insensitive(NameAndEnum.second))
173173
return NameAndEnum.first;
174-
} else if (Value.equals(NameAndEnum.second)) {
174+
} else if (Value == NameAndEnum.second) {
175175
return NameAndEnum.first;
176176
} else if (Value.equals_insensitive(NameAndEnum.second)) {
177177
Closest = NameAndEnum.second;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ AST_MATCHER(QualType, isEnableIf) {
2525
const NamedDecl *TypeDecl =
2626
Spec->getTemplateName().getAsTemplateDecl()->getTemplatedDecl();
2727
return TypeDecl->isInStdNamespace() &&
28-
(TypeDecl->getName().equals("enable_if") ||
29-
TypeDecl->getName().equals("enable_if_t"));
28+
(TypeDecl->getName() == "enable_if" ||
29+
TypeDecl->getName() == "enable_if_t");
3030
};
3131
const Type *BaseType = Node.getTypePtr();
3232
// Case: pointer or reference to enable_if.

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ getContainerFromBeginEndCall(const Expr *Init, bool IsBegin, bool *IsArrow,
421421
return {};
422422
if (IsReverse && !Call->Name.consume_back("r"))
423423
return {};
424-
if (!Call->Name.empty() && !Call->Name.equals("c"))
424+
if (!Call->Name.empty() && Call->Name != "c")
425425
return {};
426426
return std::make_pair(Call->Container, Call->CallKind);
427427
}

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ IdentifierNamingCheck::getFailureInfo(
13581358
std::replace(KindName.begin(), KindName.end(), '_', ' ');
13591359

13601360
std::string Fixup = fixupWithStyle(Type, Name, Style, HNOption, ND);
1361-
if (StringRef(Fixup).equals(Name)) {
1361+
if (StringRef(Fixup) == Name) {
13621362
if (!IgnoreFailedSplit) {
13631363
LLVM_DEBUG(Location.print(llvm::dbgs(), SM);
13641364
llvm::dbgs()

clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ static bool applyAbbreviationHeuristic(
138138
const llvm::StringMap<std::string> &AbbreviationDictionary, StringRef Arg,
139139
StringRef Param) {
140140
if (AbbreviationDictionary.contains(Arg) &&
141-
Param.equals(AbbreviationDictionary.lookup(Arg)))
141+
Param == AbbreviationDictionary.lookup(Arg))
142142
return true;
143143

144144
if (AbbreviationDictionary.contains(Param) &&
145-
Arg.equals(AbbreviationDictionary.lookup(Param)))
145+
Arg == AbbreviationDictionary.lookup(Param))
146146
return true;
147147

148148
return false;

clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ determineIncludeKind(StringRef CanonicalFile, StringRef IncludeFile,
8888
if (FileCopy.consume_front(Parts.first) &&
8989
FileCopy.consume_back(Parts.second)) {
9090
// Determine the kind of this inclusion.
91-
if (FileCopy.equals("/internal/") ||
92-
FileCopy.equals("/proto/")) {
91+
if (FileCopy == "/internal/" || FileCopy == "/proto/") {
9392
return IncludeSorter::IK_MainTUInclude;
9493
}
9594
}

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static const NamedDecl *findDecl(const RecordDecl &RecDecl,
8686
StringRef DeclName) {
8787
for (const Decl *D : RecDecl.decls()) {
8888
if (const auto *ND = dyn_cast<NamedDecl>(D)) {
89-
if (ND->getDeclName().isIdentifier() && ND->getName().equals(DeclName))
89+
if (ND->getDeclName().isIdentifier() && ND->getName() == DeclName)
9090
return ND;
9191
}
9292
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ Improvements to clang-doc
9090
Improvements to clang-query
9191
---------------------------
9292

93-
The improvements are...
93+
- Added the `file` command to dynamically load a list of commands and matchers
94+
from an external file, allowing the cost of reading the compilation database
95+
and building the AST to be imposed just once for faster prototyping.
9496

9597
Improvements to clang-rename
9698
----------------------------
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file intentionally has no queries
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f DIRECTORY/runtime_file.script
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set bind-root false
2+
3+
l func functionDecl(hasName("bar"))
4+
m func.bind("f")
5+
m varDecl().bind("v")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// RUN: not clang-query -c foo -c bar %s -- | FileCheck %s
22
// RUN: not clang-query -f %S/Inputs/foo.script %s -- | FileCheck %s
33
// RUN: not clang-query -f %S/Inputs/nonexistent.script %s -- 2>&1 | FileCheck --check-prefix=CHECK-NONEXISTENT %s
4+
// RUN: not clang-query -c 'file %S/Inputs/nonexistent.script' %s -- 2>&1 | FileCheck --check-prefix=CHECK-NONEXISTENT-FILEQUERY %s
45
// RUN: not clang-query -c foo -f foo %s -- 2>&1 | FileCheck --check-prefix=CHECK-BOTH %s
56

67
// CHECK: unknown command: foo
78
// CHECK-NOT: unknown command: bar
89

910
// CHECK-NONEXISTENT: cannot open {{.*}}nonexistent.script
11+
// CHECK-NONEXISTENT-FILEQUERY: cannot open {{.*}}nonexistent.script
1012
// CHECK-BOTH: cannot specify both -c and -f
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RUN: clang-query -c 'file %S/Inputs/empty.script' %s --
2+
// COM: no output expected; nothing to CHECK
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: rm -rf %/t
2+
// RUN: mkdir %/t
3+
// RUN: cp %/S/Inputs/file.script %/t/file.script
4+
// RUN: cp %/S/Inputs/runtime_file.script %/t/runtime_file.script
5+
// Need to embed the correct temp path in the actual JSON-RPC requests.
6+
// RUN: sed -e "s|DIRECTORY|%/t|" %/t/file.script > %/t/file.script.temp
7+
8+
// RUN: clang-query -c 'file %/t/file.script.temp' %s -- | FileCheck %s
9+
10+
// CHECK: file-query.c:11:1: note: "f" binds here
11+
void bar(void) {}
12+
13+
// CHECK: file-query.c:14:1: note: "v" binds here
14+
int baz{1};

clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ TEST_F(QueryParserTest, Comment) {
197197
TEST_F(QueryParserTest, Complete) {
198198
std::vector<llvm::LineEditor::Completion> Comps =
199199
QueryParser::complete("", 0, QS);
200-
ASSERT_EQ(8u, Comps.size());
200+
ASSERT_EQ(9u, Comps.size());
201201
EXPECT_EQ("help ", Comps[0].TypedText);
202202
EXPECT_EQ("help", Comps[0].DisplayText);
203203
EXPECT_EQ("let ", Comps[1].TypedText);
@@ -214,6 +214,8 @@ TEST_F(QueryParserTest, Complete) {
214214
EXPECT_EQ("disable", Comps[6].DisplayText);
215215
EXPECT_EQ("unlet ", Comps[7].TypedText);
216216
EXPECT_EQ("unlet", Comps[7].DisplayText);
217+
EXPECT_EQ("file ", Comps[8].TypedText);
218+
EXPECT_EQ("file", Comps[8].DisplayText);
217219

218220
Comps = QueryParser::complete("set o", 5, QS);
219221
ASSERT_EQ(1u, Comps.size());

clang/docs/Block-ABI-Apple.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The following flags bits are in use thusly for a possible ABI.2010.3.16:
8080
In 10.6.ABI the (1<<29) was usually set and was always ignored by the runtime -
8181
it had been a transitional marker that did not get deleted after the
8282
transition. This bit is now paired with (1<<30), and represented as the pair
83-
(3<<30), for the following combinations of valid bit settings, and their
83+
(3<<29), for the following combinations of valid bit settings, and their
8484
meanings:
8585

8686
.. code-block:: c

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ Bug Fixes to C++ Support
707707
initialized, rather than evaluating them as a part of the larger manifestly constant evaluated
708708
expression.
709709
- Fix a bug in access control checking due to dealyed checking of friend declaration. Fixes (#GH12361).
710+
- Correctly treat the compound statement of an ``if consteval`` as an immediate context. Fixes (#GH91509).
710711

711712
Bug Fixes to AST Handling
712713
^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)