I have used this function now
function! LLVMFolds()
let thisline = getline(v:lnum)
let nextline = getline(v:lnum + 1)
" match start of global var block
if match(thisline, '^@') == 0 && foldlevel(v:lnum - 1) <= 0
return ">1"
" match start of global struct block
elseif match(thisline, '^%') == 0 && foldlevel(v:lnum - 1) <= 0
return ">1"
" matches lables
elseif match(thisline, '^[-a-zA-Z$._][-a-zA-Z$._0-9]*:') >= 0
return ">2"
" keep closing brace outside l2 fold
elseif match(nextline, '^\}$') >= 0
return "<2"
" keep closing brace in l1 fold
elseif match(thisline, '^\}$') >= 0
return "<1"
" open new l1 fold for open brace
elseif match(thisline, '{$') >= 0
return ">1"
" for the next line being empty, close the fold for the var and struct blocks
elseif match(nextline, '^$') >= 0
if match(thisline, '^@') == 0 && foldlevel(v:lnum - 1) == 1
return "<1"
elseif match(thisline, '^%') >= 0 && foldlevel(v:lnum - 1) == 1
return "<1"
else
return "="
endif
else
return "="
endif
endfunction
Which excludes the closing brace from the level 2 fold, and folds the initial lists of global structs and variables.