[cfe-commits] r55538 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Sema/SemaDecl.cpp

Nico Weber nicolasweber at gmx.de
Fri Aug 29 10:02:24 PDT 2008


Author: nico
Date: Fri Aug 29 12:02:23 2008
New Revision: 55538

URL: http://llvm.org/viewvc/llvm-project?rev=55538&view=rev
Log:
minor cleanup

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=55538&r1=55537&r2=55538&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Fri Aug 29 12:02:23 2008
@@ -432,8 +432,7 @@
 
   /// 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.

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=55538&r1=55537&r2=55538&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 29 12:02:23 2008
@@ -264,21 +264,10 @@
   // 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);





More information about the cfe-commits mailing list