the pain you are describing is tendonitis in your rectus femoris, which is actually part of your quad, although it also acts as a hip flexor). It is caused by inactive, inhibited or weak glutes & hammies. The glute/hams might be inhibited or weak from a structural point of view, which requires specific activation strategies, but usually it's a technique problem more than anything.
The technique problem I'm talking about is described by Rippetoe in Starting Strength. Basically it's caused by not sitting back in a back squat. If you let you knees shoot forward at the bottom of the squat to hit depth, basically your hamstring is relaxing and loses control of the angle of the pelvis (hamstring attaches to both the hip and the knee). The combined loss of control at the knee and the hip means your rec fem gets tugged from the ASIS causing bad tendonitis.
If this is the problem stretching your hip flexor could make it worse not better, so just be careful not to overstretch. Treat it like any soft tissue injury. Rest, Ice, anti-inflamms if it's too painful (but they will make it heal slower).
Definitely foam roll rec fem (quads), even better use PVC pipe. You lie face down with the pipe under the centre of your quad. pull your feet to your buttocks to itensify the hit on rec fem (as it will put it on stretch).
Then fix your squat. Use a vertical block of wood 1" in front of your toes when you squat, which will force you to sit back (otherwise your knees will knock over the wood).