Skip to content

Commit b88a40f

Browse files
authored
Rename BOUNDS_CHECKED pragma to CHECKED_SCOPE. (#485)
- Rename pragma and associated methods within the compiler. - Update tests - There are corresponding commits to the Checked C and the Checked C LNT also. Testing: - Passed local testing on Windows and automated testing on Linux.
1 parent 9f9ccfc commit b88a40f

File tree

11 files changed

+31
-31
lines changed

11 files changed

+31
-31
lines changed

include/clang/Basic/TokenKinds.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ ANNOTATION(pragma_fp)
814814
// Annotation for the attribute pragma directives - #pragma clang attribute ...
815815
ANNOTATION(pragma_attribute)
816816

817-
// Annotations for BOUNDS_CHECKED pragma directives for checkedc
817+
// Annotations for CHECKED_SCOPE pragma directives for checkedc
818818
// The lexer produces these so that they only take effect when the parser
819-
// handles #pragma BOUNDS_CHECKED ... directives.
820-
ANNOTATION(pragma_bounds_checked)
819+
// handles #pragma CHECKED_SCOPE ... directives.
820+
ANNOTATION(pragma_checked_scope)
821821

822822
// Annotations for module import translated from #include etc.
823823
ANNOTATION(module_include)

include/clang/Parse/Parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ class Parser : public CodeCompletionHandler {
640640
void HandlePragmaAttribute();
641641

642642
/// \brief Handle the annotation token produced for
643-
/// #pragma BOUNDS_CHECKED [on-off-switch]
644-
void HandlePragmaBoundsChecked();
643+
/// #pragma CHECKED_SCOPE [on-off-switch]
644+
void HandlePragmaCheckedScope();
645645

646646
/// GetLookAheadToken - This peeks ahead N tokens and returns that token
647647
/// without consuming any tokens. LookAhead(0) returns 'Tok', LookAhead(1)

include/clang/Sema/Sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,8 +4657,8 @@ class Sema {
46574657
/// \brief Add default bounds/interop type expressions to Annots, if appropriate.
46584658
void InferBoundsAnnots(QualType Ty, BoundsAnnotations &Annots, bool IsParam);
46594659

4660-
// \#pragma BOUNDS_CHECKED.
4661-
void ActOnPragmaBoundsChecked(Scope *S, tok::OnOffSwitch OOS);
4660+
// \#pragma CHECKED_SCOPE.
4661+
void ActOnPragmaCheckedScope(Scope *S, tok::OnOffSwitch OOS);
46624662

46634663
// Represents the context where an expression must be non-modifying.
46644664
enum NonModifyingContext {

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,8 +4100,8 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc, unsigned TagType,
41004100
continue;
41014101
}
41024102

4103-
if (Tok.is(tok::annot_pragma_bounds_checked)) {
4104-
HandlePragmaBoundsChecked();
4103+
if (Tok.is(tok::annot_pragma_checked_scope)) {
4104+
HandlePragmaCheckedScope();
41054105
continue;
41064106
}
41074107

lib/Parse/ParsePragma.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct PragmaForceCUDAHostDeviceHandler : public PragmaHandler {
192192
};
193193

194194
struct PragmaCheckedScopeHandler : public PragmaHandler {
195-
PragmaCheckedScopeHandler() : PragmaHandler("BOUNDS_CHECKED") {}
195+
PragmaCheckedScopeHandler() : PragmaHandler("CHECKED_SCOPE") {}
196196
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
197197
Token &FirstToken) override;
198198
};
@@ -1431,13 +1431,13 @@ void Parser::HandlePragmaAttribute() {
14311431
std::move(SubjectMatchRules));
14321432
}
14331433

1434-
// #pragma BOUNDS_CHECKED [on-off-switch]
1435-
void Parser::HandlePragmaBoundsChecked() {
1436-
assert(Tok.is(tok::annot_pragma_bounds_checked));
1434+
// #pragma CHECKED_SCOPE [on-off-switch]
1435+
void Parser::HandlePragmaCheckedScope() {
1436+
assert(Tok.is(tok::annot_pragma_checked_scope));
14371437
tok::OnOffSwitch OOS =
14381438
static_cast<tok::OnOffSwitch>(
14391439
reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
1440-
Actions.ActOnPragmaBoundsChecked(Actions.getCurScope(), OOS);
1440+
Actions.ActOnPragmaCheckedScope(Actions.getCurScope(), OOS);
14411441
ConsumeAnnotationToken(); // The annotation token.
14421442
}
14431443

@@ -3019,7 +3019,7 @@ void PragmaAttributeHandler::HandlePragma(Preprocessor &PP,
30193019
}
30203020

30213021
// Handle the checked-c top level scope checked property.
3022-
// #pragma BOUNDS_CHECKED [on-off-switch]
3022+
// #pragma CHECKED_SCOPE [on-off-switch]
30233023
// To handle precise scope property, annotation token is better
30243024
void PragmaCheckedScopeHandler::HandlePragma(Preprocessor &PP,
30253025
PragmaIntroducerKind Introducer,
@@ -3031,7 +3031,7 @@ void PragmaCheckedScopeHandler::HandlePragma(Preprocessor &PP,
30313031
MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(1),
30323032
1);
30333033
Toks[0].startToken();
3034-
Toks[0].setKind(tok::annot_pragma_bounds_checked);
3034+
Toks[0].setKind(tok::annot_pragma_checked_scope);
30353035
Toks[0].setLocation(Tok.getLocation());
30363036
Toks[0].setAnnotationEndLoc(Tok.getLocation());
30373037
Toks[0].setAnnotationValue(

lib/Parse/ParseStmt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ Parser::ParseStatementOrDeclarationAfterAttributes(StmtVector &Stmts,
394394
HandlePragmaAttribute();
395395
return StmtEmpty();
396396

397-
case tok::annot_pragma_bounds_checked:
398-
HandlePragmaBoundsChecked();
397+
case tok::annot_pragma_checked_scope:
398+
HandlePragmaCheckedScope();
399399
return StmtEmpty();
400400
}
401401

@@ -966,8 +966,8 @@ void Parser::ParseCompoundStatementLeadingPragmas() {
966966
case tok::annot_pragma_dump:
967967
HandlePragmaDump();
968968
break;
969-
case tok::annot_pragma_bounds_checked:
970-
HandlePragmaBoundsChecked();
969+
case tok::annot_pragma_checked_scope:
970+
HandlePragmaCheckedScope();
971971
break;
972972
default:
973973
checkForPragmas = false;

lib/Parse/Parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
585585
HandlePragmaUnused();
586586
return false;
587587

588-
case tok::annot_pragma_bounds_checked:
589-
HandlePragmaBoundsChecked();
588+
case tok::annot_pragma_checked_scope:
589+
HandlePragmaCheckedScope();
590590
return false;
591591

592592
case tok::kw_import:

lib/Sema/SemaAttr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ void Sema::ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc) {
685685
OptimizeOffPragmaLocation = PragmaLoc;
686686
}
687687

688-
// Checked C - #pragma BOUNDS_CHECKED action, adjust top level scope flags.
689-
// Adjust checked property of scope where '#pragma BOUNDS_CHECKED' is set.
690-
void Sema::ActOnPragmaBoundsChecked(Scope *S, tok::OnOffSwitch OOS) {
688+
// Checked C - #pragma CHECKED_SCOPE action, adjust top level scope flags.
689+
// Adjust checked property of scope where '#pragma CHECKED_SCOPE' is set.
690+
void Sema::ActOnPragmaCheckedScope(Scope *S, tok::OnOffSwitch OOS) {
691691
unsigned ScopeFlags = S->getFlags();
692692
switch (OOS) {
693693
case tok::OOS_ON:

test/CheckedC/checked-scope/error-messages.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ extern void f4(void) _Checked {
2020
int *p = 0; // expected-error {{local variable in a checked scope must have a checked type}}
2121
}
2222

23-
#pragma BOUNDS_CHECKED ON
23+
#pragma CHECKED_SCOPE ON
2424
extern int *gp1; // expected-error {{global variable in a checked scope must have a checked type or a bounds-safe interface}}
2525

2626
struct S1 {
2727
int *f; // expected-error {{member in a checked scope must have a checked type or a bounds-safe interface}}
2828
};
29-
#pragma BOUNDS_CHECKED OFF
29+
#pragma CHECKED_SCOPE OFF
3030

3131
//=========================================================================================
3232
// Error messages for uses of variables and members with unchecked types in checked scopes.
@@ -106,10 +106,10 @@ extern void f25(void) {
106106
}
107107
}
108108

109-
#pragma BOUNDS_CHECKED ON
109+
#pragma CHECKED_SCOPE ON
110110
extern ty gp3; // expected-error {{global variable in a checked scope must have a checked type or a bounds-safe interface}} \
111111
// expected-note {{'ty' (aka 'int *') is not allowed in a checked scope}}
112-
#pragma BOUNDS_CHECKED OFF
112+
#pragma CHECKED_SCOPE OFF
113113

114114
struct S3 {
115115
ty f; // expected-note {{member declared here}}

test/CheckedC/static-checking/bounds-decl-checking-bsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int f2(_Ptr<void> p) {
2424
return 0;
2525
}
2626

27-
#pragma BOUNDS_CHECKED ON
27+
#pragma CHECKED_SCOPE ON
2828

2929
extern void test_f3(const void* p_ptr : byte_count(1));
3030

test/CheckedC/static-checking/bounds-decl-checking-cs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// RUN: %clang -cc1 -fcheckedc-extension -verify %s
66

7-
#pragma BOUNDS_CHECKED ON
7+
#pragma CHECKED_SCOPE ON
88

99
#include "bounds-decl-checking.c"
1010

0 commit comments

Comments
 (0)