Skip to content

Commit

Permalink
Choose a SourceLocation closer to which header the declaration might …
Browse files Browse the repository at this point in the history
…"belong" and check if it's part of a Clang module.

At least for the time being since Clang 3.6's Serialization/ doesn't always map correctly the files to decls. And currently it's even varying with how the header is included, for example with:

    #include <unistd.h>

getpagesize() is mapped by ASTReader to unistd.h, but with

    #include <OGRE/Ogre.h>

where there is another extern C {} enclosing the extern C {} of cdefs.h, Clang's ASTReader maps getpagesize() to cdefs.h.

This is obviously a bug and Clang 3.7 may improve things a bit, e.g:

llvm-mirror/clang@938847c

Modules may have to be disabled until then, now that loading the global namespace « _ » is possible (iirc).
  • Loading branch information
Syniurge committed Jul 18, 2015
1 parent 8fb388e commit 0d43a79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dmd2/cpp/cpptypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,8 @@ static clang::Module *GetClangModuleForDecl(const clang::Decl* D)
if (!MMap)
return nullptr;

auto DLoc = SrcMgr.getFileLoc(D->getLocation());
auto Loc = SrcMgr.getSpellingLoc(D->getLocStart());
auto DLoc = SrcMgr.getFileLoc(Loc);
if (!DLoc.isFileID())
return nullptr;

Expand Down

0 comments on commit 0d43a79

Please sign in to comment.