Skip to content

Commit 6c0867c

Browse files
authored
Merge pull request #13 from well-typed/edsko/fix-userprovided
Fix bug in `UserProvided`
2 parents 41f7087 + 33a5891 commit 6c0867c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Clang/HighLevel/UserProvided.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ clang_getCursorSpelling cursor =
7676
--
7777
-- where @__builtin_va_list@ is a \"predefined typedef\".
7878
-- See <https://clang.llvm.org/docs/LanguageExtensions.html#variadic-function-builtins>.
79-
| isNullPtr (fileOf expansion) ->
79+
| isNullPtr (fileOf expansion) -> do
8080
return $ ClangBuiltin nameSpelling
8181

8282
-- If the expansion location and the spelling location /of the name/
8383
-- are different, this means that the name is constructed using a
8484
-- macro. This must therefore have been done by the user.
85-
| locationOf expansion /= locationOf spelling ->
85+
--
86+
-- NOTE: It's critical that we compare the file here too, in order
87+
-- for the line/column (and offset) information to be meaningful.
88+
| expansion /= spelling -> do
8689
return $ UserProvided nameSpelling
8790

8891
-- Otherwise, check the token at the expansion location. If it
@@ -96,6 +99,3 @@ clang_getCursorSpelling cursor =
9699

97100
fileOf :: (CXFile, CUInt, CUInt, CUInt) -> CXFile
98101
fileOf (file, _col, _line, _offset) = file
99-
100-
locationOf :: (CXFile, CUInt, CUInt, CUInt) -> (CUInt, CUInt)
101-
locationOf (_file, col, line, _offset) = (col, line)

src/Clang/LowLevel/Core/Pointers.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import Foreign
1111

1212
-- | A particular source file that is part of a translation unit.
1313
--
14+
-- NOTE: Equality on 'CXFile' is /pointer/ equality.
15+
--
1416
-- <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html#gacfcea9c1239c916597e2e5b3e109215a>
1517
newtype CXFile = CXFile (Ptr ())
16-
deriving stock (Show)
18+
deriving stock (Show, Eq)
1719
deriving newtype (Storable)
1820

1921
{-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)