shared: refactor gcc_version_formula.
shared: refactor gcc_version_formula.

Avoid throwing unnecessary exceptions by checking for paths existing and
creating formulae as late as possible. Additionally use instance
variables for some caching.

rwhogg/brew,staticfloat/brew,nandub/brew,MikeMcQuaid/brew,konqui/brew,bfontaine/brew,reitermarkus/brew,claui/brew,amar-laksh/brew_sudo,EricFromCanada/brew,vitorgalvao/brew,jmsundar/brew,jmsundar/brew,muellermartin/dist,JCount/brew,Linuxbrew/brew,alyssais/brew,Linuxbrew/brew,gregory-nisbet/brew,mahori/brew,alyssais/brew,palxex/brew,maxim-belkin/brew,mahori/brew,JCount/brew,zmwangx/brew,muellermartin/dist,mahori/brew,tonyg/homebrew,reitermarkus/brew,hanxue/linuxbrew,konqui/brew,nandub/brew,DomT4/brew,AnastasiaSulyagina/brew,EricFromCanada/brew,claui/brew,konqui/brew,gordonmcshane/homebrew,EricFromCanada/brew,MikeMcQuaid/brew,bfontaine/brew,pseudocody/brew,toonetown/homebrew,toonetown/homebrew,MikeMcQuaid/brew,staticfloat/brew,vitorgalvao/brew,ilovezfs/brew,amar-laksh/brew_sudo,pseudocody/brew,mgrimes/brew,staticfloat/brew,Homebrew/brew,mistydemeo/homebrew,reelsense/brew,tonyg/homebrew,palxex/brew,ilovezfs/brew,mahori/brew,DomT4/brew,mistydemeo/homebrew,mistydemeo/homebrew,EricFromCanada/brew,JCount/brew,ilovezfs/brew,aw1621107/brew,JCount/brew,gregory-nisbet/brew,muellermartin/dist,konqui/brew,sjackman/homebrew,toonetown/homebrew,sjackman/homebrew,maxim-belkin/brew,gordonmcshane/homebrew,alyssais/brew,vitorgalvao/brew,zmwangx/brew,gordonmcshane/homebrew,claui/brew,AnastasiaSulyagina/brew,jmsundar/brew,Linuxbrew/brew,rwhogg/brew,hanxue/linuxbrew,nandub/brew,aw1621107/brew,AnastasiaSulyagina/brew,reitermarkus/brew,Homebrew/brew,mgrimes/brew,bfontaine/brew,tonyg/homebrew,pseudocody/brew,vitorgalvao/brew,amar-laksh/brew_sudo,aw1621107/brew,sjackman/homebrew,DomT4/brew,zmwangx/brew,reelsense/brew,DomT4/brew,sjackman/homebrew,hanxue/linuxbrew,claui/brew,nandub/brew,reitermarkus/brew,mgrimes/brew,Homebrew/brew,MikeMcQuaid/brew,reelsense/brew,gregory-nisbet/brew,Linuxbrew/brew,palxex/brew,rwhogg/brew,maxim-belkin/brew,Homebrew/brew