No, Benadryl has not been (directly) linked to dementia, but it is classified as an anticholinergic drug, and those HAVE been linked to dementia. So not Benadryl, but the group it is classified under. That group of drugs also includes some extremely powerful antipsychotic medications (EDIT: sorry, anticholinergic drugs are often prescribed along side antipsychotic medications), so it’s kinda like lumping a Nerf gun in with assault rifles. As well, sleep deprivation has also been linked to dementia and people will take Benadryl as a sleep aid (as you know), so any connection there might be ancillary. Your doctor’s advice sounds like it is just precautionary, which is good, but may turn out to be unfounded. Bottom line is that it needs to be studied more as there currently isn’t enough solid data about the subject.
What distribution are you on?