Skip to content

Commit b989e9a

Browse files
committed
Fixed building on MSVC (#415)
1 parent 4a55bec commit b989e9a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/common/clang/usr/llvm-19/USRGeneration.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ static bool printLoc(llvm::raw_ostream &OS, SourceLocation Loc,
5454
static StringRef GetExternalSourceContainer(const NamedDecl *D) {
5555
if (!D)
5656
return StringRef();
57+
58+
#if !defined(_MSC_VER)
5759
if (auto *attr = D->getExternalSourceSymbolAttr()) {
5860
return attr->getDefinedIn();
5961
}
62+
#endif
63+
6064
return StringRef();
6165
}
6266

@@ -255,8 +259,12 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) {
255259
D->getDeclName().print(Out, Policy);
256260

257261
ASTContext &Ctx = *Context;
258-
if ((!Ctx.getLangOpts().CPlusPlus || D->isExternC()) &&
259-
!D->hasAttr<OverloadableAttr>())
262+
if ((!Ctx.getLangOpts().CPlusPlus || D->isExternC())
263+
#if !defined(_MSC_VER)
264+
&&
265+
!D->hasAttr<OverloadableAttr>()
266+
#endif
267+
)
260268
return;
261269

262270
if (D->isFunctionTemplateSpecialization()) {
@@ -1215,6 +1223,7 @@ bool common::index::generateUSRForDecl(const Decl *D,
12151223
// C++'s operator new function, can have invalid locations but it is fine to
12161224
// create USRs that can identify them.
12171225

1226+
#if !defined(_MSC_VER)
12181227
// Check if the declaration has explicit external USR specified.
12191228
auto *CD = D->getCanonicalDecl();
12201229
if (auto *ExternalSymAttr = CD->getAttr<ExternalSourceSymbolAttr>()) {
@@ -1224,6 +1233,8 @@ bool common::index::generateUSRForDecl(const Decl *D,
12241233
return false;
12251234
}
12261235
}
1236+
#endif
1237+
12271238
USRGenerator UG(&D->getASTContext(), Buf);
12281239
UG.Visit(D);
12291240
return UG.ignoreResults();

src/common/clang/usr/llvm-20/USRGeneration.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ static StringRef GetExternalSourceContainer(const NamedDecl *D)
5858
{
5959
if (!D)
6060
return StringRef();
61+
62+
#if !defined(_MSC_VER)
6163
if (auto *attr = D->getExternalSourceSymbolAttr()) {
6264
return attr->getDefinedIn();
6365
}
66+
#endif
67+
6468
return StringRef();
6569
}
6670

@@ -273,8 +277,12 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D)
273277
Policy.SuppressTemplateArgsInCXXConstructors = true;
274278
D->getDeclName().print(Out, Policy);
275279

276-
if ((!LangOpts.CPlusPlus || D->isExternC()) &&
277-
!D->hasAttr<OverloadableAttr>())
280+
if ((!LangOpts.CPlusPlus || D->isExternC())
281+
#if !defined(_MSC_VER)
282+
&&
283+
!D->hasAttr<OverloadableAttr>()
284+
#endif
285+
)
278286
return;
279287

280288
if (D->isFunctionTemplateSpecialization()) {
@@ -1362,6 +1370,7 @@ bool common::index::generateUSRForDecl(
13621370
// C++'s operator new function, can have invalid locations but it is fine to
13631371
// create USRs that can identify them.
13641372

1373+
#if !defined(_MSC_VER)
13651374
// Check if the declaration has explicit external USR specified.
13661375
auto *CD = D->getCanonicalDecl();
13671376
if (auto *ExternalSymAttr = CD->getAttr<ExternalSourceSymbolAttr>()) {
@@ -1371,6 +1380,8 @@ bool common::index::generateUSRForDecl(
13711380
return false;
13721381
}
13731382
}
1383+
#endif
1384+
13741385
USRGenerator UG(&D->getASTContext(), Buf, LangOpts);
13751386
UG.Visit(D);
13761387
return UG.ignoreResults();

0 commit comments

Comments
 (0)