[clang] [clang-tools-extra] Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc`" (PR #135974)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 16 08:06:32 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Michael Buch (Michael137)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->135808
Example from the LLDB macOS CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/24084/execution/node/54/log/?consoleFull
```
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49: error: no viable conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'clang::ModuleIdPath' (aka 'ArrayRef<IdentifierLoc>')
clang::Module *top_level_module = DoGetModule(clang_path.front(), false);
^~~~~~~~~~~~~~~~~~
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'const llvm::ArrayRef<clang::IdentifierLoc> &' for 1st argument
class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
^
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'llvm::ArrayRef<clang::IdentifierLoc> &&' for 1st argument
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'std::nullopt_t' for 1st argument
/*implicit*/ ArrayRef(std::nullopt_t) {}
```
---
Patch is 107.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/135974.diff
45 Files Affected:
- (modified) clang-tools-extra/pp-trace/PPCallbacksTracker.cpp (+2-2)
- (modified) clang/include/clang/AST/OpenACCClause.h (+10-10)
- (modified) clang/include/clang/Basic/IdentifierTable.h (+3-23)
- (modified) clang/include/clang/Lex/ModuleLoader.h (+1-2)
- (modified) clang/include/clang/Lex/PPCallbacks.h (-1)
- (modified) clang/include/clang/Lex/Preprocessor.h (+5-4)
- (modified) clang/include/clang/Parse/LoopHint.h (+1-1)
- (modified) clang/include/clang/Parse/Parser.h (+8-5)
- (modified) clang/include/clang/Sema/ParsedAttr.h (+10)
- (modified) clang/include/clang/Sema/Sema.h (+1-1)
- (modified) clang/include/clang/Sema/SemaCodeCompletion.h (+2-1)
- (modified) clang/include/clang/Sema/SemaObjC.h (+2-2)
- (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1)
- (modified) clang/lib/AST/OpenACCClause.cpp (+2-2)
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2)
- (modified) clang/lib/Frontend/CompilerInstance.cpp (+25-28)
- (modified) clang/lib/Frontend/FrontendActions.cpp (+2-2)
- (modified) clang/lib/Lex/PPDirectives.cpp (+11-11)
- (modified) clang/lib/Lex/PPLexerChange.cpp (+3-3)
- (modified) clang/lib/Lex/Pragma.cpp (+38-35)
- (modified) clang/lib/Lex/Preprocessor.cpp (+8-8)
- (modified) clang/lib/Parse/ParseDecl.cpp (+14-14)
- (modified) clang/lib/Parse/ParseExpr.cpp (+3-4)
- (modified) clang/lib/Parse/ParseHLSL.cpp (+1-1)
- (modified) clang/lib/Parse/ParseObjc.cpp (+20-18)
- (modified) clang/lib/Parse/ParseOpenACC.cpp (+5-7)
- (modified) clang/lib/Parse/ParsePragma.cpp (+8-7)
- (modified) clang/lib/Parse/ParseStmt.cpp (+3-3)
- (modified) clang/lib/Parse/Parser.cpp (+10-9)
- (modified) clang/lib/Sema/ParsedAttr.cpp (+8)
- (modified) clang/lib/Sema/SemaARM.cpp (+1-1)
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-4)
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+59-65)
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+16-19)
- (modified) clang/lib/Sema/SemaHLSL.cpp (+6-6)
- (modified) clang/lib/Sema/SemaModule.cpp (+19-23)
- (modified) clang/lib/Sema/SemaObjC.cpp (+22-23)
- (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+5-6)
- (modified) clang/lib/Sema/SemaStmtAttr.cpp (+13-16)
- (modified) clang/lib/Sema/SemaSwift.cpp (+12-12)
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+5-5)
- (modified) clang/lib/Sema/SemaType.cpp (+7-6)
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1)
- (modified) clang/lib/Serialization/ASTWriter.cpp (+4-4)
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
index 4c916fa30685b..3bb30fd15b2e1 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
@@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) {
if (I)
SS << ", ";
SS << "{"
- << "Name: " << Value[I].getIdentifierInfo()->getName() << ", "
- << "Loc: " << getSourceLocationString(PP, Value[I].getLoc()) << "}";
+ << "Name: " << Value[I].first->getName() << ", "
+ << "Loc: " << getSourceLocationString(PP, Value[I].second) << "}";
}
SS << "]";
appendArgument(Name, SS.str());
diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index f18a6cf62f2c5..681567228cbb0 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -258,7 +258,7 @@ inline bool operator!=(const OpenACCBindClause &LHS,
return !(LHS == RHS);
}
-using DeviceTypeArgument = IdentifierLoc;
+using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
/// an identifier. The 'asterisk' means 'the rest'.
class OpenACCDeviceTypeClause final
@@ -280,16 +280,16 @@ class OpenACCDeviceTypeClause final
"Invalid clause kind for device-type");
assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
- return Arg.getLoc().isInvalid();
+ return Arg.second.isInvalid();
}) && "Invalid SourceLocation for an argument");
- assert((Archs.size() == 1 ||
- !llvm::any_of(Archs,
- [](const DeviceTypeArgument &Arg) {
- return Arg.getIdentifierInfo() == nullptr;
- })) &&
- "Only a single asterisk version is permitted, and must be the "
- "only one");
+ assert(
+ (Archs.size() == 1 || !llvm::any_of(Archs,
+ [](const DeviceTypeArgument &Arg) {
+ return Arg.first == nullptr;
+ })) &&
+ "Only a single asterisk version is permitted, and must be the "
+ "only one");
std::uninitialized_copy(Archs.begin(), Archs.end(),
getTrailingObjects<DeviceTypeArgument>());
@@ -302,7 +302,7 @@ class OpenACCDeviceTypeClause final
}
bool hasAsterisk() const {
return getArchitectures().size() > 0 &&
- getArchitectures()[0].getIdentifierInfo() == nullptr;
+ getArchitectures()[0].first == nullptr;
}
ArrayRef<DeviceTypeArgument> getArchitectures() const {
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h
index 1275b056227b5..0347880244a40 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -18,7 +18,6 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/FoldingSet.h"
@@ -77,6 +76,9 @@ inline bool isReservedInAllContexts(ReservedIdentifierStatus Status) {
Status != ReservedIdentifierStatus::StartsWithUnderscoreAndIsExternC;
}
+/// A simple pair of identifier info and location.
+using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
+
/// IdentifierInfo and other related classes are aligned to
/// 8 bytes so that DeclarationName can use the lower 3 bits
/// of a pointer to one of these classes.
@@ -1163,28 +1165,6 @@ class SelectorTable {
static std::string getPropertyNameFromSetterSelector(Selector Sel);
};
-/// A simple pair of identifier info and location.
-class IdentifierLoc {
- SourceLocation Loc;
- IdentifierInfo *II = nullptr;
-
-public:
- IdentifierLoc() = default;
- IdentifierLoc(SourceLocation L, IdentifierInfo *Ident) : Loc(L), II(Ident) {}
-
- void setLoc(SourceLocation L) { Loc = L; }
- void setIdentifierInfo(IdentifierInfo *Ident) { II = Ident; }
- SourceLocation getLoc() const { return Loc; }
- IdentifierInfo *getIdentifierInfo() const { return II; }
-
- bool operator==(const IdentifierLoc &X) const {
- return Loc == X.Loc && II == X.II;
- }
-
- bool operator!=(const IdentifierLoc &X) const {
- return Loc != X.Loc || II != X.II;
- }
-};
} // namespace clang
namespace llvm {
diff --git a/clang/include/clang/Lex/ModuleLoader.h b/clang/include/clang/Lex/ModuleLoader.h
index a58407200c41c..f880a9091a2ed 100644
--- a/clang/include/clang/Lex/ModuleLoader.h
+++ b/clang/include/clang/Lex/ModuleLoader.h
@@ -14,7 +14,6 @@
#ifndef LLVM_CLANG_LEX_MODULELOADER_H
#define LLVM_CLANG_LEX_MODULELOADER_H
-#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceLocation.h"
@@ -30,7 +29,7 @@ class IdentifierInfo;
/// A sequence of identifier/location pairs used to describe a particular
/// module or submodule, e.g., std.vector.
-using ModuleIdPath = ArrayRef<IdentifierLoc>;
+using ModuleIdPath = ArrayRef<std::pair<IdentifierInfo *, SourceLocation>>;
/// Describes the result of attempting to load a module.
class ModuleLoadResult {
diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h
index 313b730afbab8..46cc564086f1c 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -15,7 +15,6 @@
#define LLVM_CLANG_LEX_PPCALLBACKS_H
#include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/ModuleLoader.h"
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index f8f2f567f9171..24bb524783e93 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -327,7 +327,7 @@ class Preprocessor {
SourceLocation ModuleImportLoc;
/// The import path for named module that we're currently processing.
- SmallVector<IdentifierLoc, 2> NamedModuleImportPath;
+ SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> NamedModuleImportPath;
llvm::DenseMap<FileID, SmallVector<const char *>> CheckPoints;
unsigned CheckPointCounter = 0;
@@ -622,7 +622,7 @@ class Preprocessor {
/// The identifier and source location of the currently-active
/// \#pragma clang arc_cf_code_audited begin.
- IdentifierLoc PragmaARCCFCodeAuditedInfo;
+ std::pair<IdentifierInfo *, SourceLocation> PragmaARCCFCodeAuditedInfo;
/// The source location of the currently-active
/// \#pragma clang assume_nonnull begin.
@@ -1998,7 +1998,8 @@ class Preprocessor {
/// arc_cf_code_audited begin.
///
/// Returns an invalid location if there is no such pragma active.
- IdentifierLoc getPragmaARCCFCodeAuditedInfo() const {
+ std::pair<IdentifierInfo *, SourceLocation>
+ getPragmaARCCFCodeAuditedInfo() const {
return PragmaARCCFCodeAuditedInfo;
}
@@ -2006,7 +2007,7 @@ class Preprocessor {
/// arc_cf_code_audited begin. An invalid location ends the pragma.
void setPragmaARCCFCodeAuditedInfo(IdentifierInfo *Ident,
SourceLocation Loc) {
- PragmaARCCFCodeAuditedInfo = IdentifierLoc(Loc, Ident);
+ PragmaARCCFCodeAuditedInfo = {Ident, Loc};
}
/// The location of the currently-active \#pragma clang
diff --git a/clang/include/clang/Parse/LoopHint.h b/clang/include/clang/Parse/LoopHint.h
index 72be043d3c5a4..cec5605ea3615 100644
--- a/clang/include/clang/Parse/LoopHint.h
+++ b/clang/include/clang/Parse/LoopHint.h
@@ -9,12 +9,12 @@
#ifndef LLVM_CLANG_PARSE_LOOPHINT_H
#define LLVM_CLANG_PARSE_LOOPHINT_H
-#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
namespace clang {
class Expr;
+struct IdentifierLoc;
/// Loop optimization hint for loop and unroll pragmas.
struct LoopHint {
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 662f54d0e8d8a..9ebcf144ba59e 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1725,8 +1725,8 @@ class Parser : public CodeCompletionHandler {
ObjCTypeParamList *parseObjCTypeParamList();
ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
- SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
- bool mayBeProtocolList = true);
+ SmallVectorImpl<IdentifierLocPair> &protocolIdents,
+ SourceLocation &rAngleLoc, bool mayBeProtocolList = true);
void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
SourceLocation atLoc,
@@ -3818,7 +3818,8 @@ class Parser : public CodeCompletionHandler {
SourceLocation Loc,
llvm::SmallVectorImpl<Expr *> &IntExprs);
/// Parses the 'device-type-list', which is a list of identifiers.
- bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
+ bool ParseOpenACCDeviceTypeList(
+ llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>> &Archs);
/// Parses the 'async-argument', which is an integral value with two
/// 'special' values that are likely negative (but come from Macros).
OpenACCIntExprParseResult ParseOpenACCAsyncArgument(OpenACCDirectiveKind DK,
@@ -3950,8 +3951,10 @@ class Parser : public CodeCompletionHandler {
return false;
}
- bool ParseModuleName(SourceLocation UseLoc,
- SmallVectorImpl<IdentifierLoc> &Path, bool IsImport);
+ bool ParseModuleName(
+ SourceLocation UseLoc,
+ SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
+ bool IsImport);
//===--------------------------------------------------------------------===//
// C++11/G++: Type Traits [Type-Traits.html in the GCC manual]
diff --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h
index 428d3111de80d..b88b871dc8821 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -40,6 +40,7 @@ class LangOptions;
class Sema;
class Stmt;
class TargetInfo;
+struct IdentifierLoc;
/// Represents information about a change in availability for
/// an entity, which is part of the encoding of the 'availability'
@@ -98,6 +99,15 @@ struct PropertyData {
} // namespace detail
+/// Wraps an identifier and optional source location for the identifier.
+struct IdentifierLoc {
+ SourceLocation Loc;
+ IdentifierInfo *Ident;
+
+ static IdentifierLoc *create(ASTContext &Ctx, SourceLocation Loc,
+ IdentifierInfo *Ident);
+};
+
/// A union of the various pointer types that can be passed to an
/// ParsedAttr as an argument.
using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f23b754a69cb..fe37fd7701ce3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -143,7 +143,7 @@ enum class LangAS : unsigned int;
class LocalInstantiationScope;
class LookupResult;
class MangleNumberingContext;
-typedef ArrayRef<IdentifierLoc> ModuleIdPath;
+typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
class ModuleLoader;
class MultiLevelTemplateArgumentList;
struct NormalizedConstraint;
diff --git a/clang/include/clang/Sema/SemaCodeCompletion.h b/clang/include/clang/Sema/SemaCodeCompletion.h
index 3029e56e5cfe2..72159de3a6e72 100644
--- a/clang/include/clang/Sema/SemaCodeCompletion.h
+++ b/clang/include/clang/Sema/SemaCodeCompletion.h
@@ -193,7 +193,8 @@ class SemaCodeCompletion : public SemaBase {
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar);
void CodeCompleteObjCSelector(Scope *S,
ArrayRef<const IdentifierInfo *> SelIdents);
- void CodeCompleteObjCProtocolReferences(ArrayRef<IdentifierLoc> Protocols);
+ void
+ CodeCompleteObjCProtocolReferences(ArrayRef<IdentifierLocPair> Protocols);
void CodeCompleteObjCProtocolDecl(Scope *S);
void CodeCompleteObjCInterfaceDecl(Scope *S);
void CodeCompleteObjCClassForwardDecl(Scope *S);
diff --git a/clang/include/clang/Sema/SemaObjC.h b/clang/include/clang/Sema/SemaObjC.h
index 4cda41a82b61f..791a7f45b832f 100644
--- a/clang/include/clang/Sema/SemaObjC.h
+++ b/clang/include/clang/Sema/SemaObjC.h
@@ -307,11 +307,11 @@ class SemaObjC : public SemaBase {
DeclGroupPtrTy
ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
- ArrayRef<IdentifierLoc> IdentList,
+ ArrayRef<IdentifierLocPair> IdentList,
const ParsedAttributesView &attrList);
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
- ArrayRef<IdentifierLoc> ProtocolId,
+ ArrayRef<IdentifierLocPair> ProtocolId,
SmallVectorImpl<Decl *> &Protocols);
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,
diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h
index 8d31d46444c7e..4c3a13a3b044f 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -212,7 +212,7 @@ class SemaOpenACC : public SemaBase {
} LoopWithoutSeqInfo;
// Redeclaration of the version in OpenACCClause.h.
- using DeviceTypeArgument = IdentifierLoc;
+ using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
/// A type to represent all the data for an OpenACC Clause that has been
/// parsed, but not yet created/semantically analyzed. This is effectively a
diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp
index 2820d7b288658..d7cbb51335359 100644
--- a/clang/lib/AST/OpenACCClause.cpp
+++ b/clang/lib/AST/OpenACCClause.cpp
@@ -891,10 +891,10 @@ void OpenACCClausePrinter::VisitDeviceTypeClause(
OS << "(";
llvm::interleaveComma(C.getArchitectures(), OS,
[&](const DeviceTypeArgument &Arch) {
- if (Arch.getIdentifierInfo() == nullptr)
+ if (Arch.first == nullptr)
OS << "*";
else
- OS << Arch.getIdentifierInfo()->getName();
+ OS << Arch.first->getName();
});
OS << ")";
}
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 1bd94a3ac6431..c8b459ee78e6b 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -500,10 +500,10 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
llvm::interleaveComma(
cast<OpenACCDeviceTypeClause>(C)->getArchitectures(), OS,
[&](const DeviceTypeArgument &Arch) {
- if (Arch.getIdentifierInfo() == nullptr)
+ if (Arch.first == nullptr)
OS << "*";
else
- OS << Arch.getIdentifierInfo()->getName();
+ OS << Arch.first->getName();
});
OS << ")";
break;
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 93e4e31c2891d..243e0a3c15b05 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -35,7 +35,6 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/CodeCompleteConsumer.h"
-#include "clang/Sema/ParsedAttr.h"
#include "clang/Sema/Sema.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/GlobalModuleIndex.h"
@@ -2010,8 +2009,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
Module::NameVisibilityKind Visibility,
bool IsInclusionDirective) {
// Determine what file we're searching from.
- StringRef ModuleName = Path[0].getIdentifierInfo()->getName();
- SourceLocation ModuleNameLoc = Path[0].getLoc();
+ StringRef ModuleName = Path[0].first->getName();
+ SourceLocation ModuleNameLoc = Path[0].second;
// If we've already handled this import, just return the cached result.
// This one-element cache is important to eliminate redundant diagnostics
@@ -2027,7 +2026,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
// If we don't already have information on this module, load the module now.
Module *Module = nullptr;
ModuleMap &MM = getPreprocessor().getHeaderSearchInfo().getModuleMap();
- if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].getIdentifierInfo())) {
+ if (auto MaybeModule = MM.getCachedModuleLoad(*Path[0].first)) {
// Use the cached result, which may be nullptr.
Module = *MaybeModule;
// Config macros are already checked before building a module, but they need
@@ -2047,7 +2046,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
// * `Preprocessor::HandleHeaderIncludeOrImport` will never call this
// function as the `#include` or `#import` is textual.
- MM.cacheModuleLoad(*Path[0].getIdentifierInfo(), Module);
+ MM.cacheModuleLoad(*Path[0].first, Module);
} else {
ModuleLoadResult Result = findOrCompileModuleAndReadAST(
ModuleName, ImportLoc, ModuleNameLoc, IsInclusionDirective);
@@ -2056,7 +2055,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
if (!Result)
DisableGeneratingGlobalModuleIndex = true;
Module = Result;
- MM.cacheModuleLoad(*Path[0].getIdentifierInfo(), Module);
+ MM.cacheModuleLoad(*Path[0].first, Module);
}
// If we never found the module, fail. Otherwise, verify the module and link
@@ -2068,7 +2067,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
// a submodule.
bool MapPrivateSubModToTopLevel = false;
for (unsigned I = 1, N = Path.size(); I != N; ++I) {
- StringRef Name = Path[I].getIdentifierInfo()->getName();
+ StringRef Name = Path[I].first->getName();
clang::Module *Sub = Module->findSubmodule(Name);
// If the user is requesting Foo.Private and it doesn't exist, try to
@@ -2079,10 +2078,10 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
SmallString<128> PrivateModule(Module->Name);
PrivateModule.append("_Private");
- SmallVector<IdentifierLoc, 2> PrivPath;
+ SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> PrivPath;
auto &II = PP->getIdentifierTable().get(
PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
- PrivPath.emplace_back(Path[0].getLoc(), &II);
+ PrivPath.push_back(std::make_pair(&II, Path[0].second));
std::string FileName;
// If there is a modulemap module or prebuilt module, load it.
@@ -2096,12 +2095,11 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
PP->markClangModuleAsAffecting(Module);
if (!getDiagnostics().isIgnored(
diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
- getDiagnostics().Report(Path[I].getLoc(),
+ getDiagnostics().Report(Path[I].second,
diag::warn_no_priv_submodule_use_toplevel)
- << Path[I].getIdentifierInfo() << Module->getFullModuleName()
- << PrivateModule
- << SourceRange(Path[0].getLoc(), Path[I].getLoc())
- << FixItHint::CreateReplacement(SourceRange(Path[0].getLoc()),
+ << Path[I].first << Module->getFullModuleName() << PrivateModule
+ << SourceRange(Path[0].second, Path[I].second)
+ << FixItHint::CreateReplacement(SourceRange(Path[0].second),
PrivateModule);
getDiagnostics().Report(Sub->DefinitionLoc,
diag::note_private_top_level_defined);
@@ -2130,11 +2128,10 @@ Com...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/135974
More information about the cfe-commits
mailing list