To understand the link between doping and electronic properties in the high-temperature superconductors, we have performed first-principles calculations for several representatives of high T c compounds. In the single-layer cuprate HgBa2CuO4 the excess oxygen attracts electrons from the CuO2 plane leading to an increase of the hole concentration in this building block, where the maximum amount of holes is reached when the dopant oxygen shell is closed. The usage of supercells allows to study the inhomogeneous charge distribution as a function of doping, i.e. from the underdoped up to the overdoped regime. Comparison is made with other compounds like Ba-doped La2CuO4 and oxygen-deficient YBa2Cu3O7−x . The effects of our findings on superconductivity are discussed.