Merge pull request #854 from WebFreak001/upgrade-libdparse
Upgrade to latest libdparse
This commit is contained in:
commit
93f614ae49
2
dsymbol
2
dsymbol
|
@ -1 +1 @@
|
||||||
Subproject commit 666aed31f6224af737199374cbe7c8c9416c6d80
|
Subproject commit 7e5aaa2c6c9bec226e51bcce2e0364ea3fd6a01d
|
4
dub.json
4
dub.json
|
@ -12,8 +12,8 @@
|
||||||
"StdLoggerDisableWarning"
|
"StdLoggerDisableWarning"
|
||||||
],
|
],
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"libdparse": ">=0.17.0 <1.0.0",
|
"libdparse": ">=0.19.0 <1.0.0",
|
||||||
"dsymbol" : ">=0.11.3 <0.12.0",
|
"dsymbol" : ">=0.13.0 <1.0.0",
|
||||||
"inifiled" : "~>1.3.1",
|
"inifiled" : "~>1.3.1",
|
||||||
"emsi_containers" : "~>0.8.0",
|
"emsi_containers" : "~>0.8.0",
|
||||||
"libddoc" : "~>0.8.0",
|
"libddoc" : "~>0.8.0",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7112880dae3f25553d96dae53a445c16261de7f9
|
Subproject commit 205fa27ff39e46d7f2acea0a0f7c9deee0076231
|
|
@ -46,6 +46,8 @@ final class IncorrectInfiniteRangeCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
if (fb.specifiedFunctionBody && fb.specifiedFunctionBody.blockStatement !is null)
|
if (fb.specifiedFunctionBody && fb.specifiedFunctionBody.blockStatement !is null)
|
||||||
visit(fb.specifiedFunctionBody.blockStatement);
|
visit(fb.specifiedFunctionBody.blockStatement);
|
||||||
|
else if (fb.shortenedFunctionBody && fb.shortenedFunctionBody.expression !is null)
|
||||||
|
visitReturnExpression(fb.shortenedFunctionBody.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const BlockStatement bs)
|
override void visit(const BlockStatement bs)
|
||||||
|
@ -63,9 +65,14 @@ final class IncorrectInfiniteRangeCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
if (inStruct == 0 || line == size_t.max) // not within a struct yet
|
if (inStruct == 0 || line == size_t.max) // not within a struct yet
|
||||||
return;
|
return;
|
||||||
if (!rs.expression || rs.expression.items.length != 1)
|
visitReturnExpression(rs.expression);
|
||||||
|
}
|
||||||
|
|
||||||
|
void visitReturnExpression(const Expression expression)
|
||||||
|
{
|
||||||
|
if (!expression || expression.items.length != 1)
|
||||||
return;
|
return;
|
||||||
UnaryExpression unary = cast(UnaryExpression) rs.expression.items[0];
|
UnaryExpression unary = cast(UnaryExpression) expression.items[0];
|
||||||
if (unary is null)
|
if (unary is null)
|
||||||
return;
|
return;
|
||||||
if (unary.primaryExpression is null)
|
if (unary.primaryExpression is null)
|
||||||
|
@ -119,6 +126,22 @@ unittest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InfiniteRange
|
||||||
|
{
|
||||||
|
bool empty() => false; // [warn]: %1$s
|
||||||
|
bool stuff() => false;
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=18409
|
||||||
|
struct Foo
|
||||||
|
{
|
||||||
|
~this() nothrow @nogc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool empty() { return false; }
|
bool empty() { return false; }
|
||||||
class C { bool empty() { return false; } } // [warn]: %1$s
|
class C { bool empty() { return false; } } // [warn]: %1$s
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
|
||||||
|
|
||||||
override void visit(const UnaryExpression decl)
|
override void visit(const UnaryExpression decl)
|
||||||
{
|
{
|
||||||
|
import std.algorithm.searching : canFind;
|
||||||
|
|
||||||
const IdentifierOrTemplateInstance iot = safeAccess(decl)
|
const IdentifierOrTemplateInstance iot = safeAccess(decl)
|
||||||
.functionCallExpression.unaryExpression.primaryExpression
|
.functionCallExpression.unaryExpression.primaryExpression
|
||||||
.identifierOrTemplateInstance;
|
.identifierOrTemplateInstance;
|
||||||
|
@ -69,6 +71,12 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inThrowExpression && decl.newExpression && decl.newExpression.type &&
|
||||||
|
!thrown.canFind!(a => a == decl.newExpression.type))
|
||||||
|
{
|
||||||
|
thrown ~= decl.newExpression.type;
|
||||||
|
}
|
||||||
|
|
||||||
// enforce(condition);
|
// enforce(condition);
|
||||||
if (iot && iot.identifier.text == "enforce")
|
if (iot && iot.identifier.text == "enforce")
|
||||||
{
|
{
|
||||||
|
@ -182,12 +190,13 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
|
||||||
import std.array : Appender;
|
import std.array : Appender;
|
||||||
|
|
||||||
// ignore header declaration for now
|
// ignore header declaration for now
|
||||||
if (!decl.functionBody || !decl.functionBody.specifiedFunctionBody)
|
if (!decl.functionBody || (!decl.functionBody.specifiedFunctionBody
|
||||||
|
&& !decl.functionBody.shortenedFunctionBody))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (nestedFuncs == 1)
|
if (nestedFuncs == 1)
|
||||||
thrown.length = 0;
|
thrown.length = 0;
|
||||||
// detect ThrowStatement only if not nothrow
|
// detect ThrowExpression only if not nothrow
|
||||||
if (!decl.attributes.any!(a => a.attribute.text == "nothrow"))
|
if (!decl.attributes.any!(a => a.attribute.text == "nothrow"))
|
||||||
{
|
{
|
||||||
decl.accept(this);
|
decl.accept(this);
|
||||||
|
@ -228,20 +237,14 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
|
||||||
.array;
|
.array;
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const ThrowStatement ts)
|
override void visit(const ThrowExpression ts)
|
||||||
{
|
{
|
||||||
import std.algorithm.searching : canFind;
|
const wasInThrowExpression = inThrowExpression;
|
||||||
|
inThrowExpression = true;
|
||||||
|
scope (exit)
|
||||||
|
inThrowExpression = wasInThrowExpression;
|
||||||
ts.accept(this);
|
ts.accept(this);
|
||||||
if (ts.expression && ts.expression.items.length == 1)
|
inThrowExpression = false;
|
||||||
if (const UnaryExpression ue = cast(UnaryExpression) ts.expression.items[0])
|
|
||||||
{
|
|
||||||
if (ue.newExpression && ue.newExpression.type &&
|
|
||||||
!thrown.canFind!(a => a == ue.newExpression.type))
|
|
||||||
{
|
|
||||||
thrown ~= ue.newExpression.type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alias visit = BaseAnalyzer.visit;
|
alias visit = BaseAnalyzer.visit;
|
||||||
|
@ -260,6 +263,7 @@ private:
|
||||||
}
|
}
|
||||||
Function lastSeenFun;
|
Function lastSeenFun;
|
||||||
|
|
||||||
|
bool inThrowExpression;
|
||||||
const(Type)[] thrown;
|
const(Type)[] thrown;
|
||||||
|
|
||||||
// find invalid ddoc parameters (i.e. they don't occur in a function declaration)
|
// find invalid ddoc parameters (i.e. they don't occur in a function declaration)
|
||||||
|
@ -656,6 +660,20 @@ int foo(int k){} // [warn]: %s
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
|
* Description.
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* A long description.
|
||||||
|
*/
|
||||||
|
int foo(int k) => k; // [warn]: %s
|
||||||
|
}c.format(
|
||||||
|
ProperlyDocumentedPublicFunctions.MISSING_PARAMS_MESSAGE.format("k")
|
||||||
|
), sac);
|
||||||
|
|
||||||
|
assertAnalyzerWarnings(q{
|
||||||
|
/**
|
||||||
Description.
|
Description.
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
|
|
|
@ -347,5 +347,15 @@ unittest
|
||||||
deprecated auto func()(){}
|
deprecated auto func()(){}
|
||||||
}, sac);
|
}, sac);
|
||||||
|
|
||||||
|
assertAnalyzerWarnings(q{
|
||||||
|
class C{} /// a
|
||||||
|
interface I{} /// b
|
||||||
|
enum e = 0; /// c
|
||||||
|
void f(){} /// d
|
||||||
|
struct S{} /// e
|
||||||
|
template T(){} /// f
|
||||||
|
union U{} /// g
|
||||||
|
}, sac);
|
||||||
|
|
||||||
stderr.writeln("Unittest for UndocumentedDeclarationCheck passed.");
|
stderr.writeln("Unittest for UndocumentedDeclarationCheck passed.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ abstract class UnusedIdentifierCheck : BaseAnalyzer
|
||||||
override void visit(const FunctionDeclaration functionDec)
|
override void visit(const FunctionDeclaration functionDec)
|
||||||
{
|
{
|
||||||
pushScope();
|
pushScope();
|
||||||
if (functionDec.functionBody && functionDec.functionBody.specifiedFunctionBody)
|
if (functionDec.functionBody
|
||||||
|
&& (functionDec.functionBody.specifiedFunctionBody
|
||||||
|
|| functionDec.functionBody.shortenedFunctionBody))
|
||||||
{
|
{
|
||||||
immutable bool ias = inAggregateScope;
|
immutable bool ias = inAggregateScope;
|
||||||
inAggregateScope = false;
|
inAggregateScope = false;
|
||||||
|
@ -74,7 +76,7 @@ abstract class UnusedIdentifierCheck : BaseAnalyzer
|
||||||
mixin PartsUseVariables!StaticIfCondition;
|
mixin PartsUseVariables!StaticIfCondition;
|
||||||
mixin PartsUseVariables!StructDeclaration;
|
mixin PartsUseVariables!StructDeclaration;
|
||||||
mixin PartsUseVariables!TemplateArgumentList;
|
mixin PartsUseVariables!TemplateArgumentList;
|
||||||
mixin PartsUseVariables!ThrowStatement;
|
mixin PartsUseVariables!ThrowExpression;
|
||||||
mixin PartsUseVariables!CastExpression;
|
mixin PartsUseVariables!CastExpression;
|
||||||
|
|
||||||
override void visit(const SwitchStatement switchStatement)
|
override void visit(const SwitchStatement switchStatement)
|
||||||
|
|
|
@ -53,8 +53,6 @@ final class UnusedLabelCheck : BaseAnalyzer
|
||||||
}
|
}
|
||||||
if (functionBody.missingFunctionBody && functionBody.missingFunctionBody.functionContracts)
|
if (functionBody.missingFunctionBody && functionBody.missingFunctionBody.functionContracts)
|
||||||
functionBody.missingFunctionBody.functionContracts.each!((a){pushScope(); a.accept(this); popScope();});
|
functionBody.missingFunctionBody.functionContracts.each!((a){pushScope(); a.accept(this); popScope();});
|
||||||
if (functionBody.specifiedFunctionBody && functionBody.specifiedFunctionBody.functionContracts)
|
|
||||||
functionBody.specifiedFunctionBody.functionContracts.each!((a){pushScope(); a.accept(this); popScope();});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const LabeledStatement labeledStatement)
|
override void visit(const LabeledStatement labeledStatement)
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ class XMLPrinter : ASTVisitor
|
||||||
override void visit(const TemplateValueParameter templateValueParameter) { mixin (tagAndAccept!"templateValueParameter"); }
|
override void visit(const TemplateValueParameter templateValueParameter) { mixin (tagAndAccept!"templateValueParameter"); }
|
||||||
override void visit(const TernaryExpression ternaryExpression) { mixin (tagAndAccept!"ternaryExpression"); }
|
override void visit(const TernaryExpression ternaryExpression) { mixin (tagAndAccept!"ternaryExpression"); }
|
||||||
override void visit(const TypeIdentifierPart typeIdentifierPart) { mixin (tagAndAccept!"typeIdentifierPart"); }
|
override void visit(const TypeIdentifierPart typeIdentifierPart) { mixin (tagAndAccept!"typeIdentifierPart"); }
|
||||||
override void visit(const ThrowStatement throwStatement) { mixin (tagAndAccept!"throwStatement"); }
|
override void visit(const ThrowExpression throwExpression) { mixin (tagAndAccept!"throwExpression"); }
|
||||||
override void visit(const TryStatement tryStatement) { mixin (tagAndAccept!"tryStatement"); } override void visit(const TemplateInstance templateInstance) { mixin (tagAndAccept!"templateInstance"); }
|
override void visit(const TryStatement tryStatement) { mixin (tagAndAccept!"tryStatement"); } override void visit(const TemplateInstance templateInstance) { mixin (tagAndAccept!"templateInstance"); }
|
||||||
override void visit(const TypeofExpression typeofExpression) { mixin (tagAndAccept!"typeofExpression"); } override void visit(const TypeSpecialization typeSpecialization) { mixin (tagAndAccept!"typeSpecialization"); } override void visit(const TraitsExpression traitsExpression) { mixin (tagAndAccept!"traitsExpression"); }
|
override void visit(const TypeofExpression typeofExpression) { mixin (tagAndAccept!"typeofExpression"); } override void visit(const TypeSpecialization typeSpecialization) { mixin (tagAndAccept!"typeSpecialization"); } override void visit(const TraitsExpression traitsExpression) { mixin (tagAndAccept!"traitsExpression"); }
|
||||||
override void visit(const Vector vector) { mixin (tagAndAccept!"vector"); }
|
override void visit(const Vector vector) { mixin (tagAndAccept!"vector"); }
|
||||||
|
|
Loading…
Reference in New Issue