Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make tokstyle ready for the toxcore system PR. #236

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/Tokstyle/C/Linter/VoidCall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ linter :: AstActions (TravT Env Identity)
linter = astActions
{ doIdentDecl = \node act -> case node of
FunctionDef (FunDef (VarDecl (VarName fname _) _ (FunctionType (FunType _ ps _) _)) (CCompound _ body _) _)
| "os_" `isPrefixOf` idName fname -> return ()
| "sys_" `isPrefixOf` idName fname -> return ()
| otherwise -> checkFunction (voidPtrParams ps) body

Expand Down
10 changes: 10 additions & 0 deletions src/Tokstyle/C/Patterns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
{- HLINT ignore "Use camelCase" -}
module Tokstyle.C.Patterns where

import Language.C (CConstant (CIntConst),
CDeclaration (CDecl),
CDeclarationSpecifier (CTypeSpec),
CDeclarator (CDeclr),
CDerivedDeclarator (CPtrDeclr),
CExpression (CCast, CConst),
CInteger (CInteger),
CTypeSpecifier (CVoidType))
import Language.C.Analysis.SemRep (CompTypeRef (..), IntType (..),
Type (..), TypeDefRef (..),
TypeName (..))
Expand All @@ -25,6 +33,8 @@ pattern TY_sockaddr_in_ptr <- TY_struct_ptr "sockaddr_in"
pattern TY_sockaddr_in6_ptr <- TY_struct_ptr "sockaddr_in6"
pattern TY_canon_bool <- (canonicalType -> DirectType (TyIntegral TyBool) _ _)

pattern E_0 <- CConst (CIntConst (CInteger 0 _ _) _)
pattern E_nullptr <- CCast (CDecl [CTypeSpec (CVoidType _)] [(Just (CDeclr _ [CPtrDeclr [] _] _ _ _),_,_)] _) E_0 _

isEnum :: Type -> Bool
isEnum (canonicalType -> DirectType TyEnum{} _ _) = True
Expand Down
2 changes: 0 additions & 2 deletions src/Tokstyle/Linter/DeclsHaveDefns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Language.Cimple (AlexPosn (..), Lexeme (..),
import qualified Language.Cimple.Diagnostics as Diagnostics
import Language.Cimple.TraverseAst (AstActions, astActions, doNode,
traverseAst)
import System.FilePath (takeFileName)
import Text.EditDistance (defaultEditCosts,
levenshteinDistance)

Expand Down Expand Up @@ -77,7 +76,6 @@ analyse =
. Map.elems
. flip State.execState empty
. traverseAst collectPairs
. filter (not . (`elem` ["tox.h", "tox_private.h"]) . takeFileName . fst)
where
lacksDefn DeclDefn{decl, defn = Nothing} = decl
lacksDefn _ = Nothing
Expand Down