The init expression of a VarDecl is overwritten in the "To" context if we
import a VarDecl without an init expression (and with a definition). Please
refer to the added tests, especially InitAndDefinitionAreInDifferentTUs. This
patch fixes the malfunction by importing the whole Decl chain similarly as we
did that in case of FunctionDecls. We handle the init expression similarly to
a definition, alas only one init expression will be in the merged ast.
Details
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 22529 Build 22529: arc lint + arc unit
Event Timeline
unittests/AST/ASTImporterTest.cpp | ||
---|---|---|
3763 | This hunk has nothing to do with this change, but previously we forgot to instantiate these test cases :( |
Hi Gabor,
The change looks mostly fine but the difference with ASTReader approach disturbs me a bit.
lib/AST/ASTImporter.cpp | ||
---|---|---|
1441 | I see that this is only a code move but I realized that ASTReader and ASTImporter handle this case differently. ASTReader code says: if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3 EvaluatedStmt *Eval = VD->ensureEvaluatedStmt(); Eval->CheckedICE = true; Eval->IsICE = Val == 3; } but ASTimporter sets these bits only if isInitKnownICE() is true. This looks strange. | |
3190 | have (same below) | |
unittests/AST/ASTImporterTest.cpp | ||
3312 | Formatting of comma is broken. Same below. |
lib/AST/ASTImporter.cpp | ||
---|---|---|
1441 | The comment in ASTReader seems to be wrong and misleading. Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2)); Thus, the comment in ASTReader should be: if (Val > 1) { // IsInitNOTKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3 So, Val > 1 means that the original init expression written by the ASTWriter had the ICE-ness already determined. |
lib/AST/ASTImporter.cpp | ||
---|---|---|
1441 | Thank you for checking this! |
I see that this is only a code move but I realized that ASTReader and ASTImporter handle this case differently. ASTReader code says:
but ASTimporter sets these bits only if isInitKnownICE() is true. This looks strange.