Skip to content

Commit c44d533

Browse files
committed
[clang] Move IdentifierLoc to IdentifierTable.h and fix assertion build errors
Signed-off-by: yronglin <[email protected]>
1 parent 50be107 commit c44d533

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

clang/include/clang/AST/OpenACCClause.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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>());

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 24 additions & 0 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"
@@ -1162,6 +1163,29 @@ class SelectorTable {
11621163
static std::string getPropertyNameFromSetterSelector(Selector Sel);
11631164
};
11641165

1166+
/// A simple pair of identifier info and location.
1167+
class IdentifierLoc {
1168+
SourceLocation Loc;
1169+
IdentifierInfo *II = nullptr;
1170+
1171+
public:
1172+
IdentifierLoc() = default;
1173+
IdentifierLoc(SourceLocation L, IdentifierInfo *Ident) : Loc(L), II(Ident) {}
1174+
1175+
void setLoc(SourceLocation L) { Loc = L; }
1176+
void setIdentifierInfo(IdentifierInfo *Ident) { II = Ident; }
1177+
SourceLocation getLoc() const { return Loc; }
1178+
IdentifierInfo *getIdentifierInfo() const { return II; }
1179+
1180+
bool operator==(const IdentifierLoc &X) const {
1181+
return Loc == X.Loc && II == X.II;
1182+
}
1183+
1184+
bool operator!=(const IdentifierLoc &X) const {
1185+
return Loc != X.Loc || II != X.II;
1186+
}
1187+
};
1188+
11651189
} // namespace clang
11661190

11671191
namespace llvm {

clang/include/clang/Basic/SourceLocation.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -467,29 +467,6 @@ class FullSourceLoc : public SourceLocation {
467467
}
468468
};
469469

470-
/// A simple pair of identifier info and location.
471-
class IdentifierLoc {
472-
SourceLocation Loc;
473-
IdentifierInfo *II = nullptr;
474-
475-
public:
476-
IdentifierLoc() = default;
477-
IdentifierLoc(SourceLocation L, IdentifierInfo *Ident) : Loc(L), II(Ident) {}
478-
479-
void setLoc(SourceLocation L) { Loc = L; }
480-
void setIdentifierInfo(IdentifierInfo *Ident) { II = Ident; }
481-
SourceLocation getLoc() const { return Loc; }
482-
IdentifierInfo *getIdentifierInfo() const { return II; }
483-
484-
bool operator==(const IdentifierLoc &X) const {
485-
return Loc == X.Loc && II == X.II;
486-
}
487-
488-
bool operator!=(const IdentifierLoc &X) const {
489-
return Loc != X.Loc || II != X.II;
490-
}
491-
};
492-
493470
} // namespace clang
494471

495472
namespace llvm {

clang/include/clang/Lex/ModuleLoader.h

Lines changed: 1 addition & 0 deletions
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"

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/Parse/LoopHint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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 {

0 commit comments

Comments
 (0)