Valuation of Floating Rate bond

Let say, I have some floating rate bond where the coupon depends on 6-month Libor with semi-annual payments.

In a typical text-book, the way this bond is priced (dirty-price) is that, replace expected future Libor rate as Forward 6-month Libor rates and then discount those cash-flows with Libor rate again, using same Libor term-structure as seen today.

I feel this makes sense based on the T-forward measure.

Now let say, this Bond is Corporate bond. In this case, how does it make sense to discount it using Libor? Should not we use different term-structure of Yield based on the Credit-Rating? But in that case, how to mathematical basis of using T-forward measure would still hold?

Or, we should still use the Libor as discounting and then make Credit-value adjustment after I get the risk-free pricing using Libor? In that case, how should I calculate the Credit-value adjustment for this case?

Really appreciate for any help to understand the mathematical basis for risky floating rate bond pricing.

If a floating coupon bond is risky, then for one thing the coupon is probably not flat libor, but rather libor + some spread. (In some markets they use gearing here, but that has other problems.)

To take into account the riskiness of the bond (fixd or floating coupon, does not matter), you can take an approach similar to pricing a credit default swap. It is described in more detail in Thomas Bielecki's paper as well as in Duffie, Singleton Modeling Term Structure of Defaultable Bonds.

Suppose that you know the probability of default at each point in time, and the recovery assumption (what the bond will be worth after default). The way bankrupcy laws work in most civilized countries, if a bond defaults, then the accrued coupon is wiped out, and any remaining principal is accelerated and payable immediately.

The mark to market of each of the bond's cash flows is:

discount factor based on the cost of funding, times:

the cash flow amount (interest (doesn't matter whether the bond pays fixed or floating coupon) and principal) times (1 - default probability on cash flow date)

plus

the probability of default provided there was no default until period start times recovery times remaining principal