Skip to content

Commit 1ff694a

Browse files
committed
Limit AST ID to FunctionDecl objects.
This should address the regression reported by @Machiry and discovered by @hasantouma, and resolve #18.
1 parent 14c3447 commit 1ff694a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/checked-c-convert/PersistentSourceLoc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ using namespace llvm;
1919
PersistentSourceLoc
2020
PersistentSourceLoc::mkPSL(const Decl *D, ASTContext &C) {
2121
SourceLocation SL = D->getLocation();
22+
int64_t funcID = -1;
2223

23-
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
24+
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2425
SL = C.getSourceManager().getSpellingLoc(FD->getLocation());
26+
funcID = D->getID(); // Only incorporate AST IDs to distinguish functions.
27+
}
2528
else if (const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D))
2629
SL = C.getSourceManager().getSpellingLoc(PV->getLocation());
2730
else if (const VarDecl *V = dyn_cast<VarDecl>(D))
2831
SL = C.getSourceManager().getExpansionLoc(V->getLocation());
2932

30-
return mkPSL(D->getSourceRange(), SL, D->getID(), C);
33+
return mkPSL(D->getSourceRange(), SL, funcID, C);
3134
}
3235

3336

0 commit comments

Comments
 (0)