Skip to content
Open
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
4 changes: 2 additions & 2 deletions glean.cabal.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ common fb-haskell
ghc-options: -O2

common fb-cpp
cxx-options: -std=c++17 -Wno-nullability-completeness -fno-omit-frame-pointer
cxx-options: -std=c++20 -Wno-nullability-completeness -fno-omit-frame-pointer
if !flag(clang)
cxx-options: -fcoroutines
if flag(asan)
Expand Down Expand Up @@ -202,7 +202,7 @@ common deps
hinotify ^>= 0.4.1

common hsc2hs-cpp
hsc2hs-options: --cc=g++ --lflag=-lstdc++ --cflag=-D__HSC2HS__=1 --cflag=-std=c++17
hsc2hs-options: --cc=g++ --lflag=-lstdc++ --cflag=-D__HSC2HS__=1 --cflag=-std=c++20

common thrift-server
if flag(fbthrift)
Expand Down
4 changes: 3 additions & 1 deletion glean/db/Glean/Query/Reorder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,9 @@ toCgStatement stmt = case stmt of
lhs' <- fixVars IsPat lhs
return [CgStatement lhs' gen']
FlatAllStatement v e g -> do
cg <- withScopeFor (scopeVars g <> vars e) $ do
-- withinNegation enforces that bindings within the all are local
-- to this scope and not visible outside.
cg <- withinNegation $ withScopeFor (scopeVars g <> vars e) $ do
stmts <- reorderGroup g
e' <- fixVars IsExpr e
return [CgAllStatement v e' stmts]
Expand Down
32 changes: 16 additions & 16 deletions glean/db/Glean/Query/Vars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Data.IntSet (IntSet)
import qualified Data.IntMap as IntMap
import Data.IntMap (IntMap)
import Data.List.NonEmpty (NonEmpty)
import Data.Maybe

import Glean.Display
import Glean.Query.Codegen.Types
Expand Down Expand Up @@ -185,29 +186,28 @@ reWildGenerator used gen = case gen of
PrimCall op args ty ->
PrimCall op (map (reWild used) args) ty

reWildStatement :: VarMap -> CgStatement -> CgStatement
reWildStatement :: VarMap -> CgStatement -> Maybe CgStatement
reWildStatement used (CgStatement lhs rhs) =
CgStatement (reWild used lhs) (reWildGenerator used rhs)
reWildStatement used s@(CgAllStatement (Var ty n x) expr stmts) =
Just $ CgStatement (reWild used lhs) (reWildGenerator used rhs)
reWildStatement used (CgAllStatement (Var ty n x) expr stmts) =
case IntMap.lookup n used of
Nothing -> error $
"reWildStatement: var " <> show n <>
" not in scope in " <> show (displayVerbose s) <>
"\nVarMap: " <> show used
Nothing ->
-- the variable isn't used, so the statement has no effect
Nothing
Just new ->
CgAllStatement
Just $ CgAllStatement
(Var ty new x) (reWild used expr)
(map (reWildStatement used) stmts)
(mapMaybe (reWildStatement used) stmts)
reWildStatement used (CgNegation stmts) =
CgNegation (map (reWildStatement used) stmts)
Just $ CgNegation (mapMaybe (reWildStatement used) stmts)
reWildStatement used (CgDisjunction stmtss) =
CgDisjunction (map (map (reWildStatement used)) stmtss)
Just $ CgDisjunction (map (mapMaybe (reWildStatement used)) stmtss)
reWildStatement used (CgConditional cond then_ else_) =
CgConditional
(map (reWildStatement used) cond)
(map (reWildStatement used) then_)
(map (reWildStatement used) else_)
Just $ CgConditional
(mapMaybe (reWildStatement used) cond)
(mapMaybe (reWildStatement used) then_)
(mapMaybe (reWildStatement used) else_)

reWildQuery :: VarMap -> CgQuery -> CgQuery
reWildQuery used (CgQuery head stmts) =
CgQuery (reWild used head) (map (reWildStatement used) stmts)
CgQuery (reWild used head) (mapMaybe (reWildStatement used) stmts)
8 changes: 2 additions & 6 deletions glean/lang/clang/glean-clang.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ common fb-haskell
ghc-options: -O2

common fb-cpp
cxx-options: -DOSS=1 -std=c++17 -Wno-nullability-completeness
cxx-options: -DOSS=1 -std=c++20 -Wno-nullability-completeness
if arch(x86_64)
cxx-options: -DGLEAN_X86_64 -march=haswell
if flag(opt)
Expand Down Expand Up @@ -142,11 +142,7 @@ executable clang-index
gflags,
atomic,
re2
cxx-options: -fexceptions -DOSS=1 -std=c++17
if arch(x86_64)
cxx-options: -DGLEAN_X86_64 -march=haswell
if flag(opt)
cxx-options: -O3
cxx-options: -fexceptions

executable clang-derive
import: fb-haskell, fb-cpp, deps, exe
Expand Down
11 changes: 10 additions & 1 deletion glean/test/tests/Angle/SetTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Glean.Typed.Binary
import Glean.Types

import qualified Data.HashMap.Strict as HashMap
import Data.Set
import Data.Set as Set

import Test.HUnit
import TestRunner
Expand Down Expand Up @@ -157,6 +157,15 @@ setSemanticsTest dbTestCase = TestList
[set] <- runQuery_ env repo $ angleData @(Set Glean.Test.Predicate)
[s| all (glean.test.Predicate _) |]
assertEqual "angle - set matching" 4 (size set)
, TestLabel "unused all" $ dbTestCase $ \env repo -> do
r <- runQuery_ env repo $ angleData @Nat
[s| X where _ = all (X = 1); X = 0 |]
assertEqual "unused all" r [Nat 0]
, TestLabel "local constraint" $ dbTestCase $ \env repo -> do
r <- runQuery_ env repo $ angleData @(Set Nat)
[s| all (X where X = 1) where X = 1|2 |]
assertEqual "local constraint"
(sort r) [Set.empty, Set.fromList [Nat 1]]
]

setLimitTest :: Test
Expand Down
Loading