If a franchisor declares bankruptcy, what happens to the franchisees?
The first is that when any company goes into bankruptcy, the first claim to its assets goes to the company's creditors. That class does not usually include franchisees. Since things like the restaurant brand name and proprietary recipes or other trade secrets are assets of the franchise company, the court may very well end up deciding what should happen to them based on the considerations of the creditors--not the franchisees--and that could leave you in a position that is not at all in your favor.
The second issue, which is particularly serious in a Chapter 11 bankruptcy reorganization, is that most contracts of the bankrupt company must be reaffirmed or else they can be voided by the court.
In other words, you could have a contract like a franchise agreement and that contract could end up being voided without what you might feel is fair or reasonable consideration for your interests.
The bottom line: If you think there is any reasonable chance that a franchise company may go bankrupt then stay miles away from it unless you want some "interesting" experiences in your life!