Skip to content

Commit

Permalink
Add null terminator to string pointers (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladiwostok authored Nov 1, 2023
1 parent 8360dab commit 8c50b17
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Sublime Text 2
*.sublime-workspace

# Idea stuff
.idea/

# Subversion
.svn/

Expand Down
8 changes: 4 additions & 4 deletions src/dscanner/analysis/helpers.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b

global.params.useUnitTests = true;
global.path = new Strings();
global.path.push((dmdParentDir ~ "/dmd").ptr);
global.path.push((dmdParentDir ~ "/dmd/druntime/src").ptr);
global.path.push((dmdParentDir ~ "/dmd" ~ "\0").ptr);
global.path.push((dmdParentDir ~ "/dmd/druntime/src" ~ "\0").ptr);

initDMD();

auto input = cast(char[]) code;
input ~= '\0';
auto t = dmd.frontend.parseModule(cast(const(char)[]) file, cast(const (char)[]) input);
auto t = dmd.frontend.parseModule(cast(const(char)[]) file, cast(const (char)[]) input);
if (semantic)
t.module_.fullSemantic();

Expand Down Expand Up @@ -258,4 +258,4 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b
immutable string message = "Unexpected warnings:\n" ~ unexpectedWarnings.join("\n");
throw new AssertError(message, file, line);
}
}
}
24 changes: 12 additions & 12 deletions src/dscanner/analysis/run.d
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ bool analyze(string[] fileNames, const StaticAnalysisConfig config, string error

global.params.useUnitTests = true;
global.path = new Strings();
global.path.push((dmdParentDir ~ "/dmd").ptr);
global.path.push((dmdParentDir ~ "/dmd/druntime/src").ptr);
global.path.push((dmdParentDir ~ "/dmd" ~ "\0").ptr);
global.path.push((dmdParentDir ~ "/dmd/druntime/src" ~ "\0").ptr);

initDMD();

Expand Down Expand Up @@ -596,7 +596,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN

if (moduleName.shouldRunDmd!(FinalAttributeChecker!ASTCodegen)(config))
visitors ~= new FinalAttributeChecker!ASTCodegen(fileName);

if (moduleName.shouldRunDmd!(ImportSortednessCheck!ASTCodegen)(config))
visitors ~= new ImportSortednessCheck!ASTCodegen(fileName);

Expand All @@ -605,10 +605,10 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN

if (moduleName.shouldRunDmd!(RedundantAttributesCheck!ASTCodegen)(config))
visitors ~= new RedundantAttributesCheck!ASTCodegen(fileName);

if (moduleName.shouldRunDmd!(LengthSubtractionCheck!ASTCodegen)(config))
visitors ~= new LengthSubtractionCheck!ASTCodegen(fileName);

if (moduleName.shouldRunDmd!(AliasSyntaxCheck!ASTCodegen)(config))
visitors ~= new AliasSyntaxCheck!ASTCodegen(fileName);

Expand All @@ -617,7 +617,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN

if (moduleName.shouldRunDmd!(ConstructorCheck!ASTCodegen)(config))
visitors ~= new ConstructorCheck!ASTCodegen(fileName);

if (moduleName.shouldRunDmd!(AssertWithoutMessageCheck!ASTCodegen)(config))
visitors ~= new AssertWithoutMessageCheck!ASTCodegen(
fileName,
Expand All @@ -638,22 +638,22 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN
fileName,
config.trust_too_much == Check.skipTests && !ut
);

if (moduleName.shouldRunDmd!(AutoRefAssignmentCheck!ASTCodegen)(config))
visitors ~= new AutoRefAssignmentCheck!ASTCodegen(fileName);

if (moduleName.shouldRunDmd!(LogicPrecedenceCheck!ASTCodegen)(config))
visitors ~= new LogicPrecedenceCheck!ASTCodegen(
fileName,
config.logical_precedence_check == Check.skipTests && !ut
);

if (moduleName.shouldRunDmd!(UnusedLabelCheck!ASTCodegen)(config))
visitors ~= new UnusedLabelCheck!ASTCodegen(
fileName,
config.unused_label_check == Check.skipTests && !ut
);

if (moduleName.shouldRunDmd!(BuiltinPropertyNameCheck!ASTCodegen)(config))
visitors ~= new BuiltinPropertyNameCheck!ASTCodegen(fileName);

Expand Down Expand Up @@ -686,7 +686,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN
fileName,
config.static_if_else_check == Check.skipTests && !ut
);

if (moduleName.shouldRunDmd!(UselessAssertCheck!ASTCodegen)(config))
visitors ~= new UselessAssertCheck!ASTCodegen(
fileName,
Expand All @@ -696,7 +696,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN
foreach (visitor; visitors)
{
m.accept(visitor);

foreach (message; visitor.messages)
set.insert(message);
}
Expand Down

0 comments on commit 8c50b17

Please sign in to comment.