[PATCH] D59196: [NFC][clang][PCH] ASTStmtReader::VisitStmt(): fixup faulty assert.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 10 15:29:45 PDT 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: rsmith, rtrieu, riccibruno.
lebedev.ri added a project: clang.

While this is NFC - `NumStmtFields` **is** currently `0`, the assert is faulty.

It's not checking that `VisitStmt()` is called when `getIdx()` returns `NumStmtFields`.
It is checking that `VisitStmt()` is called *first*, when `getIdx()` returns `0`.

I have stumbled into this while changing `NumStmtFields` to `1`.


Repository:
  rC Clang

https://reviews.llvm.org/D59196

Files:
  lib/Serialization/ASTReaderStmt.cpp


Index: lib/Serialization/ASTReaderStmt.cpp
===================================================================
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -147,7 +147,7 @@
 }
 
 void ASTStmtReader::VisitStmt(Stmt *S) {
-  assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
+  assert(Record.getIdx() == 0 && "Incorrect statement field count");
 }
 
 void ASTStmtReader::VisitNullStmt(NullStmt *S) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59196.190028.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190310/ef37ac05/attachment.bin>


More information about the cfe-commits mailing list