aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2008-08-29 17:02:23 +0000
committerNico Weber <nicolasweber@gmx.de>2008-08-29 17:02:23 +0000
commit491be73282d5483c2f799289ed90cc0011fde4bd (patch)
tree98bdcfe31a8672e95a82c62b5f926ace58f176d6
parentd19e21bcd347542bd1fa9ec767f14d91ef593d34 (diff)
minor cleanup
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55538 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/SourceManager.h3
-rw-r--r--lib/Sema/SemaDecl.cpp19
2 files changed, 5 insertions, 17 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 7cc4087db8..770ac803ae 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -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.
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c6f8c22b08..599f0ba61b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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);