aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-08 20:15:42 +0000
committerChris Lattner <sabre@nondot.org>2009-04-08 20:15:42 +0000
commitb31ac22ed75e6b0095f92f32bc5592a61211846b (patch)
tree47b50b98791d3ea34e936b8c2e2632a1ddd10e27
parentfbb22988150b98a3332a06e957154ac2bd6e4a35 (diff)
According to the GCC man page, all -imacros are included before any -include's.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68633 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/clang-cc/clang-cc.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index ee90147e60..3260a750a2 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -1100,12 +1100,15 @@ static bool InitializePreprocessor(Preprocessor &PP,
DefineBuiltinMacro(PredefineBuffer, U_macros[u++].c_str(), "#undef ");
}
- // FIXME: Read any files specified by -imacros.
+ // If -imacros are specified, include them now. These are processed before
+ // any -include directives.
+
+ for (unsigned i = 0, e = ImplicitMacroIncludes.size(); i != e; ++i)
+ AddImplicitIncludeMacros(PredefineBuffer, ImplicitMacroIncludes[i]);
- if (!ImplicitIncludePTH.empty() || !ImplicitIncludes.empty() ||
- !ImplicitMacroIncludes.empty()) {
- // We want to add these paths to the predefines buffer in order, make a temporary
- // vector to sort by their occurrence.
+ if (!ImplicitIncludePTH.empty() || !ImplicitIncludes.empty()) {
+ // We want to add these paths to the predefines buffer in order, make a
+ // temporary vector to sort by their occurrence.
llvm::SmallVector<std::pair<unsigned, std::string*>, 8> OrderedPaths;
if (!ImplicitIncludePTH.empty())
@@ -1114,10 +1117,6 @@ static bool InitializePreprocessor(Preprocessor &PP,
for (unsigned i = 0, e = ImplicitIncludes.size(); i != e; ++i)
OrderedPaths.push_back(std::make_pair(ImplicitIncludes.getPosition(i),
&ImplicitIncludes[i]));
- for (unsigned i = 0, e = ImplicitMacroIncludes.size(); i != e; ++i)
- OrderedPaths.push_back(std::make_pair(ImplicitMacroIncludes
- .getPosition(i),
- &ImplicitMacroIncludes[i]));
llvm::array_pod_sort(OrderedPaths.begin(), OrderedPaths.end());
// Now that they are ordered by position, add to the predefines buffer.
@@ -1127,13 +1126,9 @@ static bool InitializePreprocessor(Preprocessor &PP,
Ptr >= &ImplicitIncludes[0] &&
Ptr <= &ImplicitIncludes[ImplicitIncludes.size()-1]) {
AddImplicitInclude(PredefineBuffer, *Ptr);
- } else if (Ptr == &ImplicitIncludePTH) {
- AddImplicitIncludePTH(PredefineBuffer, PP);
} else {
- assert(Ptr >= &ImplicitMacroIncludes[0] &&
- Ptr <= &ImplicitMacroIncludes[ImplicitMacroIncludes.size()-1] &&
- "String must have been in -imacros?");
- AddImplicitIncludeMacros(PredefineBuffer, *Ptr);
+ assert(Ptr == &ImplicitIncludePTH);
+ AddImplicitIncludePTH(PredefineBuffer, PP);
}
}
}