Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/Serialization/ASTReaderDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
// after everything else is read.

FD->setStorageClass(static_cast<StorageClass>(Record.readInt()));
FD->setCheckedSpecifier(static_cast<CheckedScopeSpecifier>(Record.readInt()));
FD->setWrittenCheckedSpecifier(static_cast<CheckedScopeSpecifier>(Record.readInt()));
FD->setInlineSpecified(Record.readInt());
FD->setImplicitlyInline(Record.readInt());
FD->setExplicitSpecified(Record.readInt());
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ASTReaderStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
SmallVector<Stmt *, 16> Stmts;
unsigned NumStmts = Record.readInt();
S->setCheckedSpecifiers((CheckedScopeSpecifier)Record.readInt());
S->setWrittenCheckedSpecifiers((CheckedScopeSpecifier)Record.readInt());
S->setCheckedSpecifiers(static_cast<CheckedScopeSpecifier>(Record.readInt()));
S->setWrittenCheckedSpecifiers(static_cast<CheckedScopeSpecifier>(Record.readInt()));
while (NumStmts--)
Stmts.push_back(Record.readSubStmt());
S->setStmts(Stmts);
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Serialization/ASTWriterDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
// FunctionDecl's body is handled last at ASTWriterDecl::Visit,
// after everything else is written.
Record.push_back(static_cast<int>(D->getStorageClass())); // FIXME: stable encoding
Record.push_back(D->getCheckedSpecifier());
Record.push_back(D->getWrittenCheckedSpecifier());
Record.push_back(D->isInlineSpecified());
Record.push_back(D->isInlined());
Record.push_back(D->isExplicitSpecified());
Expand Down Expand Up @@ -2130,6 +2132,8 @@ void ASTWriter::WriteDeclAbbrevs() {
// FunctionDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // StorageClass
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // CheckedScopeSpecifier
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // WrittenCheckedScopeSpecifier
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Inline
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InlineSpecified
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitSpecified
Expand Down
24 changes: 23 additions & 1 deletion clang/test/CheckedC/ast-dump-pch.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,26 @@
// CHECK: _Unchecked
// CHECK-NOT {{checking-state}}

// TODO: GitHub issue #704: add function declarations with checked scope specifiers
// CHECK-NEXT: FunctionDecl
// CHECK: f5
// CHECK: checked
// CHECK-NEXT: CompoundStmt
// CHECK: checking-state bounds-and-types

// CHECK-NEXT: FunctionDecl
// CHECK: f6
// CHECK: checked bounds_only
// CHECK-NEXT: CompoundStmt
// CHECK: checking-state bounds

// CHECK-NEXT: FunctionDecl
// CHECK: f7
// CHECK: unchecked
// CHECK-NEXT: CompoundStmt
// CHECK-NOT: {{_Checked|_Unchecked|checking-state}}

// CHECK-NEXT: FunctionDecl
// CHECK: f8
// CHECK: checked
// CHECK-NEXT: CompoundStmt
// CHECK: checking-state bounds
8 changes: 7 additions & 1 deletion clang/test/CheckedC/ast-dump-pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ void f3(void) _Checked _Bounds_only {}

void f4(void) _Unchecked {}

// TODO: GitHub issue #704: add function declarations with checked scope specifiers
_Checked void f5(void) {}

_Checked _Bounds_only void f6(void) {}

_Unchecked void f7(void) {}

_Checked void f8(void) _Checked _Bounds_only {}