Skip to content

Commit b021d35

Browse files
authored
fixed null pointer exceptions in C++ builds (#476)
* fixed null pointer exceptions in C++ builds
1 parent ae3b3a4 commit b021d35

16 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
- Fixed Java regexp issue in IndentationCheck ([#468](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/468))
2626
- Fixed empty lines between types with conditionals ([#469](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/469))
2727
- Fixed empty lines before comments with conditionals ([#472](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/472))
28-
- Fixed EFunction changes in Haxe 4rc4
28+
- Fixed EFunction changes in Haxe 4rc4 ([#474](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/474))
29+
- Fixed null pointer references for C++ ([#476](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/476))
2930
- Changed return block indentation [#453](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/453)
3031
- Changed applied formatter [#461](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/461)
3132
- Refactored coverage reporting [#462](https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/462)

src/checkstyle/checks/Check.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Check {
9090
}
9191

9292
function forEachField(cb:Field -> ParentType -> Void) {
93+
if (checker.ast == null) return;
9394
if (checker.ast.decls == null) return;
9495
for (td in checker.ast.decls) {
9596
var fields:Array<Field> = switch (td.decl) {
@@ -134,6 +135,7 @@ class Check {
134135
}
135136

136137
function isCharPosExtern(pos:Int):Bool {
138+
if (checker.ast == null) return false;
137139
if (checker.ast.decls == null) return false;
138140
for (td in checker.ast.decls) {
139141
switch (td.decl) {

src/checkstyle/checks/coding/AvoidInlineConditionalsCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class AvoidInlineConditionalsCheck extends Check {
1414
}
1515

1616
override function actualRun() {
17+
if (checker.ast == null) return;
1718
checker.ast.walkFile(function(e:Expr) {
1819
if (isPosSuppressed(e.pos)) return;
1920
switch (e.expr) {

src/checkstyle/checks/coding/DefaultComesLastCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DefaultComesLastCheck extends Check {
1919

2020
for (token in acceptableTokens) {
2121
var tokens:Array<TokenTree> = token.filter([Kwd(KwdCase), Kwd(KwdDefault)], FIRST);
22+
if (tokens.length <= 0) continue;
2223
if (tokens[tokens.length - 1].is(Kwd(KwdDefault))) continue;
2324

2425
for (i in 0...tokens.length) {

src/checkstyle/checks/literal/ArrayLiteralCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ArrayLiteralCheck extends Check {
1212
}
1313

1414
override function actualRun() {
15+
if (checker.ast == null) return;
1516
checker.ast.walkFile(function(e:Expr) {
1617
switch (e.expr) {
1718
case ENew({pack: [], name: "Array"}, _):

src/checkstyle/checks/literal/ERegLiteralCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ERegLiteralCheck extends Check {
1212
}
1313

1414
override function actualRun() {
15+
if (checker.ast == null) return;
1516
checker.ast.walkFile(function(e:Expr) {
1617
if (isPosSuppressed(e.pos)) return;
1718
switch (e.expr) {

src/checkstyle/checks/literal/HexadecimalLiteralCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class HexadecimalLiteralCheck extends Check {
2121
}
2222

2323
override function actualRun() {
24+
if (checker.ast == null) return;
2425
checker.ast.walkFile(function(e:Expr) {
2526
switch (e.expr) {
2627
case EConst(CInt(s)):

src/checkstyle/checks/naming/LocalVariableNameCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class LocalVariableNameCheck extends NameCheckBase<String> {
1313

1414
override function actualRun() {
1515
formatRE = new EReg(format, "");
16+
if (checker.ast == null) return;
1617
checker.ast.walkFile(function(e) {
1718
switch (e.expr) {
1819
case EVars(vars):

src/checkstyle/checks/naming/NameCheckBase.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class NameCheckBase<T> extends Check {
4040
}
4141

4242
function checkClassFields() {
43+
if (checker.ast == null) return;
4344
for (td in checker.ast.decls) {
4445
switch (td.decl) {
4546
case EClass(d):

src/checkstyle/checks/size/FileLengthCheck.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class FileLengthCheck extends Check {
2222
}
2323

2424
override function actualRun() {
25+
if (checker.ast == null) return;
2526
for (td in checker.ast.decls) {
2627
switch (td.decl) {
2728
case EClass(d):

0 commit comments

Comments
 (0)