[PATCH] Implement MSVC header search algorithm in MicrosoftMode

Reid Kleckner rnk at google.com
Sat Dec 14 12:10:21 PST 2013


Looks pretty good, but I think the include order is slightly off.  It looks
like we push the last includer, and then the include stack from outermost
to innermost rather than innermost to outermost.  Can you add a test to
make sure we get it right?

This is the case I'm thinking of:
t.cpp #include "a/foo.h"
a/foo.h #include "b/foo.h"
a/b/foo.h #include "c/foo.h"
a/b/c/foo.h #include "bar.h"
a/b/bar.h // Should find me
a/bar.h #error "not me"

+  // If the header lookup mechanism may be relative to the current
inclusion
+  // stack,
+  // record the parent #includes.

This comment can be reflowed.  clang-format doesn't yet know how to reflow
comments in the right place.

You can also request commit access if you want, or keep sending patches.
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


On Sat, Dec 14, 2013 at 5:44 AM, Will Wilson <will at indefiant.com> wrote:

> Hi All,
>
> Here's a patch to implement the MSVC header search algorithm for quoted
> #includes. MSVC doesn't just search the #includer's directory (the existing
> clang/GCC behaviour) but also searches the directories of all parent
> includers before falling back on the standard search paths. I implemented
> this after being bitten a few times by clang including different files to
> MSVC within existing MSVC targeted codebases.
>
> This MSVC algoritihm is outlined here:
> http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx
>
> The patch has been clang-formatted and I've also included a test case for
> validation of the algorithm. I've attempted to minimize the size of the
> change and tried to ensure that only MicrosoftMode will pay any performance
> penalty (and even then only a small one).
>
> Review away!
>
> Cheers,
> Will.
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131214/59c10180/attachment.html>


More information about the cfe-commits mailing list