[PATCH] D69937: [clangd] Use name of Macro to compute its SymbolID.
UTKARSH SAXENA via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 8 06:06:24 PST 2019
usaxena95 updated this revision to Diff 228431.
usaxena95 added a comment.
Hopefully reverting unintended changes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69937/new/
https://reviews.llvm.org/D69937
Files:
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===================================================================
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -377,7 +377,7 @@
Roles & static_cast<unsigned>(index::SymbolRole::Definition)))
return true;
- auto ID = getSymbolID(*Name, MI, SM);
+ auto ID = getSymbolID(Name->getName(), MI, SM);
if (!ID)
return true;
@@ -473,14 +473,14 @@
// First, drop header guards. We can't identify these until EOF.
for (const IdentifierInfo *II : IndexedMacros) {
if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
- if (auto ID = getSymbolID(*II, MI, PP->getSourceManager()))
+ if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager()))
if (MI->isUsedForHeaderGuard())
Symbols.erase(*ID);
}
// Now increment refcounts.
for (const IdentifierInfo *II : ReferencedMacros) {
if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
- if (auto ID = getSymbolID(*II, MI, PP->getSourceManager()))
+ if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager()))
IncRef(*ID);
}
}
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -492,7 +492,7 @@
return clang::clangd::getSymbolID(R.Declaration);
}
case CodeCompletionResult::RK_Macro:
- return clang::clangd::getSymbolID(*R.Macro, R.MacroDefInfo, SM);
+ return clang::clangd::getSymbolID(R.Macro->getName(), R.MacroDefInfo, SM);
case CodeCompletionResult::RK_Keyword:
return None;
}
Index: clang-tools-extra/clangd/AST.h
===================================================================
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -17,6 +17,7 @@
#include "clang/AST/Decl.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/MacroInfo.h"
+#include "llvm/ADT/StringRef.h"
namespace clang {
class SourceManager;
@@ -69,7 +70,7 @@
/// macro (e.g. a change in definition offset can result in a different USR). We
/// could change these semantics in the future by reimplementing this funcure
/// (e.g. avoid USR for macros).
-llvm::Optional<SymbolID> getSymbolID(const IdentifierInfo &II,
+llvm::Optional<SymbolID> getSymbolID(const llvm::StringRef MacroName,
const MacroInfo *MI,
const SourceManager &SM);
Index: clang-tools-extra/clangd/AST.cpp
===================================================================
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -203,13 +203,13 @@
return SymbolID(USR);
}
-llvm::Optional<SymbolID> getSymbolID(const IdentifierInfo &II,
+llvm::Optional<SymbolID> getSymbolID(const llvm::StringRef MacroName,
const MacroInfo *MI,
const SourceManager &SM) {
if (MI == nullptr)
return None;
llvm::SmallString<128> USR;
- if (index::generateUSRForMacro(II.getName(), MI->getDefinitionLoc(), SM, USR))
+ if (index::generateUSRForMacro(MacroName, MI->getDefinitionLoc(), SM, USR))
return None;
return SymbolID(USR);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69937.228431.patch
Type: text/x-patch
Size: 3427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191108/3a332da3/attachment-0001.bin>
More information about the cfe-commits
mailing list