minor cleanup

llvm-svn: 55538
This commit is contained in:
Nico Weber 2008-08-29 17:02:23 +00:00
parent 4c23963de8
commit fa5856a936
2 changed files with 5 additions and 17 deletions

View File

@ -432,8 +432,7 @@ public:
/// isInSystemHeader - Returns if a SourceLocation is in a system header.
bool isInSystemHeader(SourceLocation Loc) const {
assert (Loc.isFileID() && "method only valid for file ids");
return getFIDInfo(Loc.getFileID())->isSystemHeader();
return getFIDInfo(getPhysicalLoc(Loc).getFileID())->isSystemHeader();
}
/// PrintStats - Print statistics to stderr.

View File

@ -264,21 +264,10 @@ TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
// this adhoc compatibility rule. FIXME: The following code will not
// work properly when compiling ".i" files (containing preprocessed output).
SourceManager &SrcMgr = Context.getSourceManager();
HeaderSearch &HdrInfo = PP.getHeaderSearchInfo();
const FileEntry *OldDeclFile = SrcMgr.getFileEntryForLoc(Old->getLocation());
if (OldDeclFile) {
DirectoryLookup::DirType OldDirType = HdrInfo.getFileDirFlavor(OldDeclFile);
// Allow reclarations in both SystemHeaderDir and ExternCSystemHeaderDir.
if (OldDirType != DirectoryLookup::NormalHeaderDir)
return New;
}
const FileEntry *NewDeclFile = SrcMgr.getFileEntryForLoc(New->getLocation());
if (NewDeclFile) {
DirectoryLookup::DirType NewDirType = HdrInfo.getFileDirFlavor(NewDeclFile);
// Allow reclarations in both SystemHeaderDir and ExternCSystemHeaderDir.
if (NewDirType != DirectoryLookup::NormalHeaderDir)
return New;
}
if (SrcMgr.isInSystemHeader(Old->getLocation()))
return New;
if (SrcMgr.isInSystemHeader(New->getLocation()))
return New;
Diag(New->getLocation(), diag::err_redefinition, New->getName());
Diag(Old->getLocation(), diag::err_previous_definition);