Skip to content

Commit 9068713

Browse files
author
Julian Nagele
committed
Merge commit 'd3153ad66c53' from llvm.org/main into next
Conflicts: clang/lib/Parse/ParseDecl.cpp
2 parents 2776da7 + d3153ad commit 9068713

Some content is hidden

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

45 files changed

+399
-384
lines changed

clang-tools-extra/pp-trace/PPCallbacksTracker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) {
547547
if (I)
548548
SS << ", ";
549549
SS << "{"
550-
<< "Name: " << Value[I].first->getName() << ", "
551-
<< "Loc: " << getSourceLocationString(PP, Value[I].second) << "}";
550+
<< "Name: " << Value[I].getIdentifierInfo()->getName() << ", "
551+
<< "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}";
552552
}
553553
SS << "]";
554554
appendArgument(Name, SS.str());

clang/include/clang/AST/OpenACCClause.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ inline bool operator!=(const OpenACCBindClause &LHS,
258258
return !(LHS == RHS);
259259
}
260260

261-
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
261+
using DeviceTypeArgument = IdentifierLoc;
262262
/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
263263
/// an identifier. The 'asterisk' means 'the rest'.
264264
class OpenACCDeviceTypeClause final
@@ -280,16 +280,16 @@ class OpenACCDeviceTypeClause final
280280
"Invalid clause kind for device-type");
281281

282282
assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
283-
return Arg.second.isInvalid();
283+
return Arg.getLoc().isInvalid();
284284
}) && "Invalid SourceLocation for an argument");
285285

286-
assert(
287-
(Archs.size() == 1 || !llvm::any_of(Archs,
288-
[](const DeviceTypeArgument &Arg) {
289-
return Arg.first == nullptr;
290-
})) &&
291-
"Only a single asterisk version is permitted, and must be the "
292-
"only one");
286+
assert((Archs.size() == 1 ||
287+
!llvm::any_of(Archs,
288+
[](const DeviceTypeArgument &Arg) {
289+
return Arg.getIdentifierInfo() == nullptr;
290+
})) &&
291+
"Only a single asterisk version is permitted, and must be the "
292+
"only one");
293293

294294
std::uninitialized_copy(Archs.begin(), Archs.end(),
295295
getTrailingObjects<DeviceTypeArgument>());
@@ -302,7 +302,7 @@ class OpenACCDeviceTypeClause final
302302
}
303303
bool hasAsterisk() const {
304304
return getArchitectures().size() > 0 &&
305-
getArchitectures()[0].first == nullptr;
305+
getArchitectures()[0].getIdentifierInfo() == nullptr;
306306
}
307307

308308
ArrayRef<DeviceTypeArgument> getArchitectures() const {

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/Basic/Builtins.h"
1919
#include "clang/Basic/DiagnosticIDs.h"
2020
#include "clang/Basic/LLVM.h"
21+
#include "clang/Basic/SourceLocation.h"
2122
#include "clang/Basic/TokenKinds.h"
2223
#include "llvm/ADT/DenseMapInfo.h"
2324
#include "llvm/ADT/FoldingSet.h"
@@ -76,9 +77,6 @@ inline bool isReservedInAllContexts(ReservedIdentifierStatus Status) {
7677
Status != ReservedIdentifierStatus::StartsWithUnderscoreAndIsExternC;
7778
}
7879

79-
/// A simple pair of identifier info and location.
80-
using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
81-
8280
/// IdentifierInfo and other related classes are aligned to
8381
/// 8 bytes so that DeclarationName can use the lower 3 bits
8482
/// of a pointer to one of these classes.
@@ -1148,6 +1146,28 @@ class SelectorTable {
11481146
static std::string getPropertyNameFromSetterSelector(Selector Sel);
11491147
};
11501148

1149+
/// A simple pair of identifier info and location.
1150+
class IdentifierLoc {
1151+
SourceLocation Loc;
1152+
IdentifierInfo *II = nullptr;
1153+
1154+
public:
1155+
IdentifierLoc() = default;
1156+
IdentifierLoc(SourceLocation L, IdentifierInfo *Ident) : Loc(L), II(Ident) {}
1157+
1158+
void setLoc(SourceLocation L) { Loc = L; }
1159+
void setIdentifierInfo(IdentifierInfo *Ident) { II = Ident; }
1160+
SourceLocation getLoc() const { return Loc; }
1161+
IdentifierInfo *getIdentifierInfo() const { return II; }
1162+
1163+
bool operator==(const IdentifierLoc &X) const {
1164+
return Loc == X.Loc && II == X.II;
1165+
}
1166+
1167+
bool operator!=(const IdentifierLoc &X) const {
1168+
return Loc != X.Loc || II != X.II;
1169+
}
1170+
};
11511171
} // namespace clang
11521172

11531173
namespace llvm {

clang/include/clang/Lex/ModuleLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_CLANG_LEX_MODULELOADER_H
1515
#define LLVM_CLANG_LEX_MODULELOADER_H
1616

17+
#include "clang/Basic/IdentifierTable.h"
1718
#include "clang/Basic/LLVM.h"
1819
#include "clang/Basic/Module.h"
1920
#include "clang/Basic/SourceLocation.h"
@@ -29,7 +30,7 @@ class IdentifierInfo;
2930

3031
/// A sequence of identifier/location pairs used to describe a particular
3132
/// module or submodule, e.g., std.vector.
32-
using ModuleIdPath = ArrayRef<std::pair<IdentifierInfo *, SourceLocation>>;
33+
using ModuleIdPath = ArrayRef<IdentifierLoc>;
3334

3435
/// Describes the result of attempting to load a module.
3536
class ModuleLoadResult {

clang/include/clang/Lex/PPCallbacks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_CLANG_LEX_PPCALLBACKS_H
1616

1717
#include "clang/Basic/DiagnosticIDs.h"
18+
#include "clang/Basic/IdentifierTable.h"
1819
#include "clang/Basic/SourceLocation.h"
1920
#include "clang/Basic/SourceManager.h"
2021
#include "clang/Lex/ModuleLoader.h"

clang/include/clang/Lex/Preprocessor.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class Preprocessor {
331331
SourceLocation ModuleImportLoc;
332332

333333
/// The import path for named module that we're currently processing.
334-
SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> NamedModuleImportPath;
334+
SmallVector<IdentifierLoc, 2> NamedModuleImportPath;
335335

336336
llvm::DenseMap<FileID, SmallVector<const char *>> CheckPoints;
337337
unsigned CheckPointCounter = 0;
@@ -626,7 +626,7 @@ class Preprocessor {
626626

627627
/// The identifier and source location of the currently-active
628628
/// \#pragma clang arc_cf_code_audited begin.
629-
std::pair<IdentifierInfo *, SourceLocation> PragmaARCCFCodeAuditedInfo;
629+
IdentifierLoc PragmaARCCFCodeAuditedInfo;
630630

631631
/// The source location of the currently-active
632632
/// \#pragma clang assume_nonnull begin.
@@ -2013,16 +2013,15 @@ class Preprocessor {
20132013
/// arc_cf_code_audited begin.
20142014
///
20152015
/// Returns an invalid location if there is no such pragma active.
2016-
std::pair<IdentifierInfo *, SourceLocation>
2017-
getPragmaARCCFCodeAuditedInfo() const {
2016+
IdentifierLoc getPragmaARCCFCodeAuditedInfo() const {
20182017
return PragmaARCCFCodeAuditedInfo;
20192018
}
20202019

20212020
/// Set the location of the currently-active \#pragma clang
20222021
/// arc_cf_code_audited begin. An invalid location ends the pragma.
20232022
void setPragmaARCCFCodeAuditedInfo(IdentifierInfo *Ident,
20242023
SourceLocation Loc) {
2025-
PragmaARCCFCodeAuditedInfo = {Ident, Loc};
2024+
PragmaARCCFCodeAuditedInfo = IdentifierLoc(Loc, Ident);
20262025
}
20272026

20282027
/// The location of the currently-active \#pragma clang

clang/include/clang/Parse/LoopHint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#ifndef LLVM_CLANG_PARSE_LOOPHINT_H
1010
#define LLVM_CLANG_PARSE_LOOPHINT_H
1111

12+
#include "clang/Basic/IdentifierTable.h"
1213
#include "clang/Basic/SourceLocation.h"
1314

1415
namespace clang {
1516

1617
class Expr;
17-
struct IdentifierLoc;
1818

1919
/// Loop optimization hint for loop and unroll pragmas.
2020
struct LoopHint {

clang/include/clang/Parse/Parser.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,8 @@ class Parser : public CodeCompletionHandler {
17291729
ObjCTypeParamList *parseObjCTypeParamList();
17301730
ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
17311731
ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1732-
SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1733-
SourceLocation &rAngleLoc, bool mayBeProtocolList = true);
1732+
SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
1733+
bool mayBeProtocolList = true);
17341734

17351735
void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
17361736
SourceLocation atLoc,
@@ -3886,8 +3886,7 @@ class Parser : public CodeCompletionHandler {
38863886
SourceLocation Loc,
38873887
llvm::SmallVectorImpl<Expr *> &IntExprs);
38883888
/// Parses the 'device-type-list', which is a list of identifiers.
3889-
bool ParseOpenACCDeviceTypeList(
3890-
llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs);
3889+
bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
38913890
/// Parses the 'async-argument', which is an integral value with two
38923891
/// 'special' values that are likely negative (but come from Macros).
38933892
OpenACCIntExprParseResult ParseOpenACCAsyncArgument(OpenACCDirectiveKind DK,
@@ -4019,10 +4018,8 @@ class Parser : public CodeCompletionHandler {
40194018
return false;
40204019
}
40214020

4022-
bool ParseModuleName(
4023-
SourceLocation UseLoc,
4024-
SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
4025-
bool IsImport);
4021+
bool ParseModuleName(SourceLocation UseLoc,
4022+
SmallVectorImpl<IdentifierLoc> &Path, bool IsImport);
40264023

40274024
//===--------------------------------------------------------------------===//
40284025
// C++11/G++: Type Traits [Type-Traits.html in the GCC manual]

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class LangOptions;
4040
class Sema;
4141
class Stmt;
4242
class TargetInfo;
43-
struct IdentifierLoc;
4443

4544
/// Represents information about a change in availability for
4645
/// an entity, which is part of the encoding of the 'availability'
@@ -99,15 +98,6 @@ struct PropertyData {
9998

10099
} // namespace detail
101100

102-
/// Wraps an identifier and optional source location for the identifier.
103-
struct IdentifierLoc {
104-
SourceLocation Loc;
105-
IdentifierInfo *Ident;
106-
107-
static IdentifierLoc *create(ASTContext &Ctx, SourceLocation Loc,
108-
IdentifierInfo *Ident);
109-
};
110-
111101
/// A union of the various pointer types that can be passed to an
112102
/// ParsedAttr as an argument.
113103
using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ enum class LangAS : unsigned int;
143143
class LocalInstantiationScope;
144144
class LookupResult;
145145
class MangleNumberingContext;
146-
typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
146+
typedef ArrayRef<IdentifierLoc> ModuleIdPath;
147147
class ModuleLoader;
148148
class MultiLevelTemplateArgumentList;
149149
struct NormalizedConstraint;

clang/include/clang/Sema/SemaCodeCompletion.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class SemaCodeCompletion : public SemaBase {
193193
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar);
194194
void CodeCompleteObjCSelector(Scope *S,
195195
ArrayRef<const IdentifierInfo *> SelIdents);
196-
void
197-
CodeCompleteObjCProtocolReferences(ArrayRef<IdentifierLocPair> Protocols);
196+
void CodeCompleteObjCProtocolReferences(ArrayRef<IdentifierLoc> Protocols);
198197
void CodeCompleteObjCProtocolDecl(Scope *S);
199198
void CodeCompleteObjCInterfaceDecl(Scope *S);
200199
void CodeCompleteObjCClassForwardDecl(Scope *S);

clang/include/clang/Sema/SemaObjC.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ class SemaObjC : public SemaBase {
307307

308308
DeclGroupPtrTy
309309
ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
310-
ArrayRef<IdentifierLocPair> IdentList,
310+
ArrayRef<IdentifierLoc> IdentList,
311311
const ParsedAttributesView &attrList);
312312

313313
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
314-
ArrayRef<IdentifierLocPair> ProtocolId,
314+
ArrayRef<IdentifierLoc> ProtocolId,
315315
SmallVectorImpl<Decl *> &Protocols);
316316

317317
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class SemaOpenACC : public SemaBase {
212212
} LoopWithoutSeqInfo;
213213

214214
// Redeclaration of the version in OpenACCClause.h.
215-
using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
215+
using DeviceTypeArgument = IdentifierLoc;
216216

217217
/// A type to represent all the data for an OpenACC Clause that has been
218218
/// parsed, but not yet created/semantically analyzed. This is effectively a

clang/lib/AST/OpenACCClause.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,10 @@ void OpenACCClausePrinter::VisitDeviceTypeClause(
891891
OS << "(";
892892
llvm::interleaveComma(C.getArchitectures(), OS,
893893
[&](const DeviceTypeArgument &Arch) {
894-
if (Arch.first == nullptr)
894+
if (Arch.getIdentifierInfo() == nullptr)
895895
OS << "*";
896896
else
897-
OS << Arch.first->getName();
897+
OS << Arch.getIdentifierInfo()->getName();
898898
});
899899
OS << ")";
900900
}

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,10 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
500500
llvm::interleaveComma(
501501
cast<OpenACCDeviceTypeClause>(C)->getArchitectures(), OS,
502502
[&](const DeviceTypeArgument &Arch) {
503-
if (Arch.first == nullptr)
503+
if (Arch.getIdentifierInfo() == nullptr)
504504
OS << "*";
505505
else
506-
OS << Arch.first->getName();
506+
OS << Arch.getIdentifierInfo()->getName();
507507
});
508508
OS << ")";
509509
break;

0 commit comments

Comments
 (0)