[PATCH] D82532: [libclang] Get rid of relience on SourceManager member signature
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 03:13:01 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5d3abea228b: [libclang] Get rid of relience on SourceManager member signature (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82532/new/
https://reviews.llvm.org/D82532
Files:
clang/tools/libclang/CIndexInclusionStack.cpp
Index: clang/tools/libclang/CIndexInclusionStack.cpp
===================================================================
--- clang/tools/libclang/CIndexInclusionStack.cpp
+++ clang/tools/libclang/CIndexInclusionStack.cpp
@@ -18,10 +18,9 @@
#include "clang/Frontend/ASTUnit.h"
using namespace clang;
-static void getInclusions(const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
- CXTranslationUnit TU, CXInclusionVisitor CB,
- CXClientData clientData)
-{
+namespace {
+void getInclusions(bool IsLocal, unsigned n, CXTranslationUnit TU,
+ CXInclusionVisitor CB, CXClientData clientData) {
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
SourceManager &SM = CXXUnit->getSourceManager();
ASTContext &Ctx = CXXUnit->getASTContext();
@@ -30,8 +29,8 @@
for (unsigned i = 0 ; i < n ; ++i) {
bool Invalid = false;
- const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+ const SrcMgr::SLocEntry &SL =
+ IsLocal ? SM.getLocalSLocEntry(i) : SM.getLoadedSLocEntry(i, &Invalid);
if (!SL.isFile() || Invalid)
continue;
@@ -61,11 +60,11 @@
// Callback to the client.
// FIXME: We should have a function to construct CXFiles.
CB(static_cast<CXFile>(
- const_cast<FileEntry *>(FI.getContentCache()->OrigEntry)),
+ const_cast<FileEntry *>(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
}
}
-
+} // namespace
void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
CXClientData clientData) {
@@ -83,14 +82,13 @@
// a AST/PCH file, but this file has a pre-compiled preamble, we also need
// to look in that file.
if (n == 1 || SM.getPreambleFileID().isValid()) {
- getInclusions(&SourceManager::getLoadedSLocEntry,
- SM.loaded_sloc_entry_size(), TU, CB, clientData);
+ getInclusions(/*IsLocal=*/false, SM.loaded_sloc_entry_size(), TU, CB,
+ clientData);
}
// Not a PCH/AST file. Note, if there is a preamble, it could still be that
// there are #includes in this file (e.g. for any include after the first
// declaration).
if (n != 1)
- getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
-
+ getInclusions(/*IsLocal=*/true, n, TU, CB, clientData);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82532.273283.patch
Type: text/x-patch
Size: 2412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200625/1eca1750/attachment-0001.bin>
More information about the cfe-commits
mailing list