Skip to content

Commit a834ec3

Browse files
Merge branch 'main' into visit-no-direct-i128
2 parents b2646cd + 51b63bb commit a834ec3

File tree

217 files changed

+4181
-2356
lines changed

Some content is hidden

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

217 files changed

+4181
-2356
lines changed

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "MCTargetDesc/RISCVMCExpr.h"
13+
#include "MCTargetDesc/RISCVMCAsmInfo.h"
1414
#include "MCTargetDesc/RISCVMCTargetDesc.h"
1515
#include "bolt/Core/MCPlusBuilder.h"
1616
#include "llvm/BinaryFormat/ELF.h"
@@ -438,12 +438,12 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
438438
return RISCVMCExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx);
439439
case ELF::R_RISCV_PCREL_LO12_I:
440440
case ELF::R_RISCV_PCREL_LO12_S:
441-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_PCREL_LO, Ctx);
441+
return RISCVMCExpr::create(Expr, RISCV::S_PCREL_LO, Ctx);
442442
case ELF::R_RISCV_HI20:
443443
return RISCVMCExpr::create(Expr, ELF::R_RISCV_HI20, Ctx);
444444
case ELF::R_RISCV_LO12_I:
445445
case ELF::R_RISCV_LO12_S:
446-
return RISCVMCExpr::create(Expr, RISCVMCExpr::VK_LO, Ctx);
446+
return RISCVMCExpr::create(Expr, RISCV::S_LO, Ctx);
447447
case ELF::R_RISCV_CALL:
448448
return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx);
449449
case ELF::R_RISCV_CALL_PLT:

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ getNewFieldsOrder(const RecordDecl *Definition,
8686
static void
8787
addReplacement(SourceRange Old, SourceRange New, const ASTContext &Context,
8888
std::map<std::string, tooling::Replacements> &Replacements) {
89+
if (Old.getBegin().isMacroID())
90+
Old = Context.getSourceManager().getExpansionRange(Old).getAsRange();
91+
if (New.getBegin().isMacroID())
92+
New = Context.getSourceManager().getExpansionRange(New).getAsRange();
8993
StringRef NewText =
9094
Lexer::getSourceText(CharSourceRange::getTokenRange(New),
9195
Context.getSourceManager(), Context.getLangOpts());

clang-tools-extra/modularize/CoverageChecker.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,8 @@ bool CoverageChecker::collectFileSystemHeaders() {
329329
else {
330330
// Otherwise we only look at the sub-trees specified by the
331331
// include paths.
332-
for (std::vector<std::string>::const_iterator I = IncludePaths.begin(),
333-
E = IncludePaths.end();
334-
I != E; ++I) {
335-
if (!collectFileSystemHeaders(*I))
332+
for (const std::string &IncludePath : IncludePaths) {
333+
if (!collectFileSystemHeaders(IncludePath))
336334
return false;
337335
}
338336
}

clang-tools-extra/modularize/Modularize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ static std::string findInputFile(const CommandLineArguments &CLArgs) {
339339
llvm::opt::Visibility VisibilityMask(options::CC1Option);
340340
unsigned MissingArgIndex, MissingArgCount;
341341
SmallVector<const char *, 256> Argv;
342-
for (auto I = CLArgs.begin(), E = CLArgs.end(); I != E; ++I)
343-
Argv.push_back(I->c_str());
342+
for (const std::string &CLArg : CLArgs)
343+
Argv.push_back(CLArg.c_str());
344344
InputArgList Args = getDriverOptTable().ParseArgs(
345345
Argv, MissingArgIndex, MissingArgCount, VisibilityMask);
346346
std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ ModularizeUtilities *ModularizeUtilities::createModularizeUtilities(
6969
// Load all header lists and dependencies.
7070
std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies() {
7171
// For each input file.
72-
for (auto I = InputFilePaths.begin(), E = InputFilePaths.end(); I != E; ++I) {
73-
llvm::StringRef InputPath = *I;
72+
for (llvm::StringRef InputPath : InputFilePaths) {
7473
// If it's a module map.
7574
if (InputPath.ends_with(".modulemap")) {
7675
// Load the module map.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,y,x %s -- | FileCheck %s
2+
3+
namespace bar {
4+
5+
#define INT_DECL(NAME) int NAME // CHECK: {{^#define INT_DECL\(NAME\) int NAME}}
6+
#define MACRO_DECL int x; // CHECK-NEXT: {{^#define MACRO_DECL int x;}}
7+
8+
struct Foo {
9+
MACRO_DECL // CHECK: {{^ INT_DECL\(z\);}}
10+
int y; // CHECK-NEXT: {{^ int y;}}
11+
INT_DECL(z); // CHECK-NEXT: {{^ MACRO_DECL}}
12+
};
13+
14+
#define FOO 0 // CHECK: {{^#define FOO 0}}
15+
#define BAR 1 // CHECK-NEXT: {{^#define BAR 1}}
16+
#define BAZ 2 // CHECK-NEXT: {{^#define BAZ 2}}
17+
18+
struct Foo foo = {
19+
FOO, // CHECK: {{^ BAZ,}}
20+
BAR, // CHECK-NEXT: {{^ BAR,}}
21+
BAZ, // CHECK-NEXT: {{^ FOO,}}
22+
};
23+
24+
} // end namespace bar

clang/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ configure_file(
345345
# Add appropriate flags for GCC
346346
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
347347
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
348-
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
349-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
350-
endif ()
351348

352349
# Enable -pedantic for Clang even if it's not enabled for LLVM.
353350
if (NOT LLVM_ENABLE_PEDANTIC)

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
1515
#define LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
1616

17+
#include "clang/Basic/AttributeScopeInfo.h"
1718
#include "clang/Basic/SourceLocation.h"
1819
#include "clang/Basic/TokenKinds.h"
1920

@@ -61,6 +62,7 @@ class AttributeCommonInfo {
6162
/// implicitly.
6263
AS_Implicit
6364
};
65+
6466
enum Kind {
6567
#define PARSED_ATTR(NAME) AT_##NAME,
6668
#include "clang/Basic/AttrParsedAttrList.inc"
@@ -78,9 +80,9 @@ class AttributeCommonInfo {
7880

7981
private:
8082
const IdentifierInfo *AttrName = nullptr;
81-
const IdentifierInfo *ScopeName = nullptr;
83+
AttributeScopeInfo AttrScope;
8284
SourceRange AttrRange;
83-
const SourceLocation ScopeLoc;
85+
8486
// Corresponds to the Kind enum.
8587
LLVM_PREFERRED_TYPE(Kind)
8688
unsigned AttrKind : 16;
@@ -146,33 +148,31 @@ class AttributeCommonInfo {
146148
};
147149

148150
AttributeCommonInfo(const IdentifierInfo *AttrName,
149-
const IdentifierInfo *ScopeName, SourceRange AttrRange,
150-
SourceLocation ScopeLoc, Kind AttrKind, Form FormUsed)
151-
: AttrName(AttrName), ScopeName(ScopeName), AttrRange(AttrRange),
152-
ScopeLoc(ScopeLoc), AttrKind(AttrKind),
153-
SyntaxUsed(FormUsed.getSyntax()),
151+
AttributeScopeInfo AttrScope, SourceRange AttrRange,
152+
Kind AttrKind, Form FormUsed)
153+
: AttrName(AttrName), AttrScope(AttrScope), AttrRange(AttrRange),
154+
AttrKind(AttrKind), SyntaxUsed(FormUsed.getSyntax()),
154155
SpellingIndex(FormUsed.getSpellingIndex()),
155156
IsAlignas(FormUsed.isAlignas()),
156157
IsRegularKeywordAttribute(FormUsed.isRegularKeywordAttribute()) {
157158
assert(SyntaxUsed >= AS_GNU && SyntaxUsed <= AS_Implicit &&
158159
"Invalid syntax!");
159160
}
160161

161-
AttributeCommonInfo(const IdentifierInfo *AttrName,
162-
const IdentifierInfo *ScopeName, SourceRange AttrRange,
163-
SourceLocation ScopeLoc, Form FormUsed)
162+
AttributeCommonInfo(const IdentifierInfo *AttrName, AttributeScopeInfo Scope,
163+
SourceRange AttrRange, Form FormUsed)
164164
: AttributeCommonInfo(
165-
AttrName, ScopeName, AttrRange, ScopeLoc,
166-
getParsedKind(AttrName, ScopeName, FormUsed.getSyntax()),
165+
AttrName, Scope, AttrRange,
166+
getParsedKind(AttrName, Scope.getName(), FormUsed.getSyntax()),
167167
FormUsed) {}
168168

169169
AttributeCommonInfo(const IdentifierInfo *AttrName, SourceRange AttrRange,
170170
Form FormUsed)
171-
: AttributeCommonInfo(AttrName, nullptr, AttrRange, SourceLocation(),
171+
: AttributeCommonInfo(AttrName, AttributeScopeInfo(), AttrRange,
172172
FormUsed) {}
173173

174174
AttributeCommonInfo(SourceRange AttrRange, Kind K, Form FormUsed)
175-
: AttributeCommonInfo(nullptr, nullptr, AttrRange, SourceLocation(), K,
175+
: AttributeCommonInfo(nullptr, AttributeScopeInfo(), AttrRange, K,
176176
FormUsed) {}
177177

178178
AttributeCommonInfo(AttributeCommonInfo &&) = default;
@@ -190,17 +190,27 @@ class AttributeCommonInfo {
190190
SourceRange getRange() const { return AttrRange; }
191191
void setRange(SourceRange R) { AttrRange = R; }
192192

193-
bool hasScope() const { return ScopeName; }
194-
const IdentifierInfo *getScopeName() const { return ScopeName; }
195-
SourceLocation getScopeLoc() const { return ScopeLoc; }
193+
bool hasScope() const { return AttrScope.isValid(); }
194+
bool isExplicitScope() const { return AttrScope.isExplicit(); }
195+
196+
const IdentifierInfo *getScopeName() const { return AttrScope.getName(); }
197+
SourceLocation getScopeLoc() const { return AttrScope.getNameLoc(); }
196198

197199
/// Gets the normalized full name, which consists of both scope and name and
198200
/// with surrounding underscores removed as appropriate (e.g.
199201
/// __gnu__::__attr__ will be normalized to gnu::attr).
200202
std::string getNormalizedFullName() const;
201-
std::optional<std::string>
202-
getCorrectedFullName(const TargetInfo &Target,
203-
const LangOptions &LangOpts) const;
203+
std::string getNormalizedFullName(StringRef ScopeName,
204+
StringRef AttrName) const;
205+
StringRef getNormalizedScopeName() const;
206+
StringRef getNormalizedAttrName(StringRef ScopeName) const;
207+
208+
std::optional<StringRef> tryGetCorrectedScopeName(StringRef ScopeName) const;
209+
std::optional<StringRef>
210+
tryGetCorrectedAttrName(StringRef ScopeName, StringRef AttrName,
211+
const TargetInfo &Target,
212+
const LangOptions &LangOpts) const;
213+
204214
SourceRange getNormalizedRange() const;
205215

206216
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//==- AttributeScopeInfo.h - Base info about an Attribute Scope --*- C++ -*-==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file defines the AttributeScopeInfo type, which represents information
10+
// about the scope of an attribute.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef LLVM_CLANG_BASIC_ATTRIBUTESCOPEINFO_H
15+
#define LLVM_CLANG_BASIC_ATTRIBUTESCOPEINFO_H
16+
17+
#include "clang/Basic/SourceLocation.h"
18+
19+
namespace clang {
20+
21+
class IdentifierInfo;
22+
23+
class AttributeScopeInfo {
24+
public:
25+
AttributeScopeInfo() = default;
26+
27+
AttributeScopeInfo(const IdentifierInfo *Name, SourceLocation NameLoc)
28+
: Name(Name), NameLoc(NameLoc) {}
29+
30+
AttributeScopeInfo(const IdentifierInfo *Name, SourceLocation NameLoc,
31+
SourceLocation CommonScopeLoc)
32+
: Name(Name), NameLoc(NameLoc), CommonScopeLoc(CommonScopeLoc) {}
33+
34+
const IdentifierInfo *getName() const { return Name; }
35+
SourceLocation getNameLoc() const { return NameLoc; }
36+
37+
bool isValid() const { return Name != nullptr; }
38+
bool isExplicit() const { return CommonScopeLoc.isInvalid(); }
39+
40+
private:
41+
const IdentifierInfo *Name = nullptr;
42+
SourceLocation NameLoc;
43+
SourceLocation CommonScopeLoc;
44+
};
45+
46+
} // namespace clang
47+
48+
#endif // LLVM_CLANG_BASIC_ATTRIBUTESCOPEINFO_H

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ def note_unsatisfied_trait_reason
17791779
"%HasArcLifetime{has an ARC lifetime qualifier}|"
17801780
"%VLA{is a variably-modified type}|"
17811781
"%VBase{has a virtual base %1}|"
1782-
"%NotScalarOrClass{not %select{a|an array of objects of}1 scalar or "
1782+
"%NotScalarOrClass{is not %select{a|an array of objects of}1 scalar or "
17831783
"class type}|"
17841784
"%NTRBase{has a non-trivially-relocatable base %1}|"
17851785
"%NTRField{has a non-trivially-relocatable member %1 of type %2}|"

0 commit comments

Comments
 (0)