[cfe-commits] r139979 - in /cfe/trunk: lib/Lex/HeaderSearch.cpp test/Modules/Inputs/point.h test/Modules/header-import.m
Douglas Gregor
dgregor at apple.com
Fri Sep 16 22:35:19 PDT 2011
Author: dgregor
Date: Sat Sep 17 00:35:18 2011
New Revision: 139979
URL: http://llvm.org/viewvc/llvm-project?rev=139979&view=rev
Log:
When we load header file information from the external source (i.e.,
the AST reader), merge that header file information with whatever
header file information we already have. Otherwise, we might forget
something we already knew (e.g., that the header was #import'd already).
Added:
cfe/trunk/test/Modules/Inputs/point.h (with props)
cfe/trunk/test/Modules/header-import.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=139979&r1=139978&r2=139979&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Sat Sep 17 00:35:18 2011
@@ -580,7 +580,31 @@
// File Info Management.
//===----------------------------------------------------------------------===//
+/// \brief Merge the header file info provided by \p OtherHFI into the current
+/// header file info (\p HFI)
+static void mergeHeaderFileInfo(HeaderFileInfo &HFI,
+ const HeaderFileInfo &OtherHFI) {
+ HFI.isImport |= OtherHFI.isImport;
+ HFI.isPragmaOnce |= OtherHFI.isPragmaOnce;
+ HFI.NumIncludes += OtherHFI.NumIncludes;
+
+ if (!HFI.ControllingMacro && !HFI.ControllingMacroID) {
+ HFI.ControllingMacro = OtherHFI.ControllingMacro;
+ HFI.ControllingMacroID = OtherHFI.ControllingMacroID;
+ }
+
+ if (OtherHFI.External) {
+ HFI.DirInfo = OtherHFI.DirInfo;
+ HFI.External = OtherHFI.External;
+ HFI.IndexHeaderMapHeader = OtherHFI.IndexHeaderMapHeader;
+ }
+ if (HFI.Framework.empty())
+ HFI.Framework = OtherHFI.Framework;
+
+ HFI.Resolved = true;
+}
+
/// getFileInfo - Return the HeaderFileInfo structure for the specified
/// FileEntry.
HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
@@ -588,10 +612,8 @@
FileInfo.resize(FE->getUID()+1);
HeaderFileInfo &HFI = FileInfo[FE->getUID()];
- if (ExternalSource && !HFI.Resolved) {
- HFI = ExternalSource->GetHeaderFileInfo(FE);
- HFI.Resolved = true;
- }
+ if (ExternalSource && !HFI.Resolved)
+ mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(FE));
return HFI;
}
@@ -602,10 +624,8 @@
// Resolve header file info from the external source, if needed.
HeaderFileInfo &HFI = FileInfo[File->getUID()];
- if (ExternalSource && !HFI.Resolved) {
- HFI = ExternalSource->GetHeaderFileInfo(File);
- HFI.Resolved = true;
- }
+ if (ExternalSource && !HFI.Resolved)
+ mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(File));
return HFI.isPragmaOnce || HFI.ControllingMacro || HFI.ControllingMacroID;
}
Added: cfe/trunk/test/Modules/Inputs/point.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/point.h?rev=139979&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/point.h (added)
+++ cfe/trunk/test/Modules/Inputs/point.h Sat Sep 17 00:35:18 2011
@@ -0,0 +1,2 @@
+struct Point { int x, y; };
+
Propchange: cfe/trunk/test/Modules/Inputs/point.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/Modules/Inputs/point.h
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/Modules/Inputs/point.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cfe/trunk/test/Modules/header-import.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/header-import.m?rev=139979&view=auto
==============================================================================
--- cfe/trunk/test/Modules/header-import.m (added)
+++ cfe/trunk/test/Modules/header-import.m Sat Sep 17 00:35:18 2011
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+
+#import "point.h"
+__import_module__ Module;
+#import "point.h"
+
More information about the cfe-commits
mailing list