Currently when we see a built-in we try and import the include location. Instead what we do now is find the buffer like we do for the invalid case and copy that over to the to context.
Details
- Reviewers
martong a.sidorin teemperor aaron.ballman balazske - Commits
- rG9adbbcb7cd06: [ASTImporter] Handle built-in when importing SourceLocation and FileID
rC355332: [ASTImporter] Handle built-in when importing SourceLocation and FileID
rL355332: [ASTImporter] Handle built-in when importing SourceLocation and FileID
Diff Detail
Event Timeline
Shafik, this looks good to me, once teemperor's comments are addressed.
Note, I added @balazske as a reviewer, he recently worked with importing the FileIDs, he may have some comments.
include/clang/AST/ASTImporter.h | ||
---|---|---|
342 | IsBuiltin = false should be the correct formatting. | |
lib/AST/ASTImporter.cpp | ||
8249–8250 | The new parameter should be added here too. | |
8284 | The Cache can be moved into this block and the block to else if. | |
8301 | Is it possible that in the isBuiltin true case this part of the code does run (always) without assertion or other error and the result is always an invalid ToID? (If yes the whole change is not needed, so I want to know what was the reason for this change, was there any crash or bug.) |
Addressed comments on formatting and missing changes to the Import_New version of the code.
This origin of this fix is the LLDB expression parsing issue. We were not able to reduce to a test we could put in ASTImpoterTest.cpp but we have a LLDB test that exercises this issue and will pass once this fix is in place.
See this differential https://reviews.llvm.org/D58790
lib/AST/ASTImporter.cpp | ||
---|---|---|
8284 | I am not sure I understand what you are asking. Do you mean just duplicate the const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache(); in both blocks? | |
8301 | This change was the result of a assert where evaluating an expression resulted in the built-in being imported and it would assert in SourceManager when when Import(SourceLocation....) attempted getDecomposedLoc at the next step. AFAICT the The Preprocessor sets it up the buffer here and then creates the FileID for in the SourceManager and copying over the buffer should be the correct thing to do since that seems to be sufficient. I also while testing verified that the BufferIndetifer() did indeed equal "<built-in>" similar to this check in SourceManager. |
Import_New should probably also get the new paramater.