<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Mar 9, 2014 at 1:18 AM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2014-03-08 9:03 GMT+09:00 Richard Smith <<a href="mailto:richard-llvm@metafoo.co.uk">richard-llvm@metafoo.co.uk</a>>:<br>

<div><div class="h5">> Author: rsmith<br>
> Date: Fri Mar  7 18:03:56 2014<br>
> New Revision: 203317<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203317&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=203317&view=rev</a><br>
> Log:<br>
> Module [extern_c] attribute: inherit to submodules, don't write 'extern "C"'<br>
> blocks when building in C mode, and serialize and deserialize the attribute.<br>
><br>
> Added:<br>
>     cfe/trunk/test/Modules/Inputs/elsewhere/<br>
>     cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h<br>
>     cfe/trunk/test/Modules/Inputs/elsewhere/module.map<br>
> Modified:<br>
>     cfe/trunk/lib/Basic/Module.cpp<br>
>     cfe/trunk/lib/Frontend/FrontendActions.cpp<br>
>     cfe/trunk/lib/Serialization/ASTReader.cpp<br>
>     cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
>     cfe/trunk/test/Modules/Inputs/module.map<br>
>     cfe/trunk/test/Modules/extern_c.cpp<br>
>     cfe/trunk/unittests/AST/CMakeLists.txt<br>
><br>
> Modified: cfe/trunk/lib/Basic/Module.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Basic/Module.cpp (original)<br>
> +++ cfe/trunk/lib/Basic/Module.cpp Fri Mar  7 18:03:56 2014<br>
> @@ -37,6 +37,8 @@ Module::Module(StringRef Name, SourceLoc<br>
>        IsAvailable = false;<br>
>      if (Parent->IsSystem)<br>
>        IsSystem = true;<br>
> +    if (Parent->IsExternC)<br>
> +      IsExternC = true;<br>
><br>
>      Parent->SubModuleIndex[Name] = Parent->SubModules.size();<br>
>      Parent->SubModules.push_back(this);<br>
><br>
> Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)<br>
> +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Mar  7 18:03:56 2014<br>
> @@ -132,7 +132,7 @@ static void addHeaderInclude(StringRef H<br>
>                               SmallVectorImpl<char> &Includes,<br>
>                               const LangOptions &LangOpts,<br>
>                               bool IsExternC) {<br>
> -  if (IsExternC)<br>
> +  if (IsExternC && LangOpts.CPlusPlus)<br>
>      Includes += "extern \"C\" {\n";<br>
>    if (LangOpts.ObjC1)<br>
>      Includes += "#import \"";<br>
> @@ -140,7 +140,7 @@ static void addHeaderInclude(StringRef H<br>
>      Includes += "#include \"";<br>
>    Includes += HeaderName;<br>
>    Includes += "\"\n";<br>
> -  if (IsExternC)<br>
> +  if (IsExternC && LangOpts.CPlusPlus)<br>
>      Includes += "}\n";<br>
>  }<br>
><br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Mar  7 18:03:56 2014<br>
> @@ -3996,15 +3996,17 @@ bool ASTReader::ReadSubmoduleBlock(Modul<br>
>        }<br>
><br>
>        StringRef Name = Blob;<br>
> -      SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[0]);<br>
> -      SubmoduleID Parent = getGlobalSubmoduleID(F, Record[1]);<br>
> -      bool IsFramework = Record[2];<br>
> -      bool IsExplicit = Record[3];<br>
> -      bool IsSystem = Record[4];<br>
> -      bool InferSubmodules = Record[5];<br>
> -      bool InferExplicitSubmodules = Record[6];<br>
> -      bool InferExportWildcard = Record[7];<br>
> -      bool ConfigMacrosExhaustive = Record[8];<br>
> +      unsigned Idx = 0;<br>
> +      SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);<br>
> +      SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);<br>
> +      bool IsFramework = Record[Idx++];<br>
> +      bool IsExplicit = Record[Idx++];<br>
> +      bool IsSystem = Record[Idx++];<br>
> +      bool IsExternC = Record[Idx++];<br>
> +      bool InferSubmodules = Record[Idx++];<br>
> +      bool InferExplicitSubmodules = Record[Idx++];<br>
> +      bool InferExportWildcard = Record[Idx++];<br>
> +      bool ConfigMacrosExhaustive = Record[Idx++];<br>
<br>
</div></div>Richard, I saw a few tests crashed due to incompatibility of file format.<br>
<br>
Failing Tests (2):<br>
    Clang :: Index/retain-comments-from-system-headers.c<br>
    Clang Tools :: pp-trace/pp-trace-modules.cpp<br>
<br>
How to reproduce:<br>
  - rm -rf tools/clang/test/Index/Output<br>
  - Checkout r203316<br>
  - Build and run a test (Index/retain-comments-from-system-headers.c)<br>
  - Checkout r203318 (yours)<br>
  - Build and run a test w/o removing test tree.<br>
<br>
Lit might be required to sweep Output(s) in test directories, or<br>
ASTReader might be responsible to check micro-version.<br>
<br>
Any idea?</blockquote><div><br></div><div>IIUC, building at a different revision should cause us to generate a different hash and put the files in a different place. Is it possible that your bot is not picking up the SVN revision number when it builds? I'm surprised these tests didn't fail when I made the change locally.</div>
<div><br></div><div>In any case, these tests should be cleaning out the cache themselves (for stability).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
>        Module *ParentModule = 0;<br>
>        if (Parent)<br>
> @@ -4040,6 +4042,7 @@ bool ASTReader::ReadSubmoduleBlock(Modul<br>
><br>
>        CurrentModule->IsFromModuleFile = true;<br>
>        CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;<br>
> +      CurrentModule->IsExternC = IsExternC;<br>
>        CurrentModule->InferSubmodules = InferSubmodules;<br>
>        CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;<br>
>        CurrentModule->InferExportWildcard = InferExportWildcard;<br>
><br>
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Mar  7 18:03:56 2014<br>
> @@ -2225,7 +2225,8 @@ void ASTWriter::WriteSubmodules(Module *<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit<br>
> -  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem<br>
> +  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem<br>
> +  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExternC<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferSubmodules...<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExplicit...<br>
>    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExportWild...<br>
> @@ -2313,6 +2314,7 @@ void ASTWriter::WriteSubmodules(Module *<br>
>      Record.push_back(Mod->IsFramework);<br>
>      Record.push_back(Mod->IsExplicit);<br>
>      Record.push_back(Mod->IsSystem);<br>
> +    Record.push_back(Mod->IsExternC);<br>
>      Record.push_back(Mod->InferSubmodules);<br>
>      Record.push_back(Mod->InferExplicitSubmodules);<br>
>      Record.push_back(Mod->InferExportWildcard);<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h?rev=203317&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h?rev=203317&view=auto</a><br>

> ==============================================================================<br>
> --- cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/elsewhere/c-header-indirect.h Fri Mar  7 18:03:56 2014<br>
> @@ -0,0 +1 @@<br>
> +#include "c-header.h"<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/elsewhere/module.map<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elsewhere/module.map?rev=203317&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elsewhere/module.map?rev=203317&view=auto</a><br>

> ==============================================================================<br>
> --- cfe/trunk/test/Modules/Inputs/elsewhere/module.map (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/elsewhere/module.map Fri Mar  7 18:03:56 2014<br>
> @@ -0,0 +1 @@<br>
> +module c_library_indirect { header "c-header-indirect.h" }<br>
><br>
> Modified: cfe/trunk/test/Modules/Inputs/module.map<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/test/Modules/Inputs/module.map (original)<br>
> +++ cfe/trunk/test/Modules/Inputs/module.map Fri Mar  7 18:03:56 2014<br>
> @@ -1,4 +1,4 @@<br>
> -module c_library [extern_c] { header "c-header.h" }<br>
> +module c_library [extern_c] { module inner { header "c-header.h" } }<br>
>  module cxx_library { header "cxx-header.h" requires cplusplus }<br>
>  module c_library_bad [extern_c] { header "c-header-bad.h" }<br>
>  module diamond_top { header "diamond_top.h" }<br>
><br>
> Modified: cfe/trunk/test/Modules/extern_c.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/extern_c.cpp?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/extern_c.cpp?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/test/Modules/extern_c.cpp (original)<br>
> +++ cfe/trunk/test/Modules/extern_c.cpp Fri Mar  7 18:03:56 2014<br>
> @@ -9,6 +9,12 @@<br>
>  // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_CXX<br>
>  // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DEXTERN_CXX<br>
>  // RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DNAMESPACE<br>
> +// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs -x c %s<br>
> +// RUN: %clang_cc1 -fmodules -verify -fmodules-cache-path=%t -I %S/Inputs/elsewhere -I %S/Inputs %s -DEXTERN_C -DINDIRECT<br>
> +<br>
> +#ifdef INDIRECT<br>
> +#include "c-header-indirect.h"<br>
> +#endif<br>
><br>
>  #ifdef NAMESPACE<br>
>  namespace M {<br>
> @@ -34,7 +40,7 @@ extern "C++" {<br>
>  // expected-error@-3 {{import of C++ module 'cxx_library' appears within extern "C" language linkage specification}}<br>
>  // expected-note@-17 {{extern "C" language linkage specification begins here}}<br>
>  #elif defined(NAMESPACE)<br>
> -// expected-error-re@-6 {{import of module '{{c_library|cxx_library}}' appears within namespace 'M'}}<br>
> +// expected-error-re@-6 {{import of module '{{c_library.inner|cxx_library}}' appears within namespace 'M'}}<br>
>  // expected-note@-24 {{namespace 'M' begins here}}<br>
>  #endif<br>
><br>
> @@ -51,16 +57,25 @@ extern "C++" {<br>
>  using namespace M;<br>
>  #endif<br>
><br>
> +#ifdef __cplusplus<br>
>  namespace N {<br>
> -  int k = f();<br>
> +#endif<br>
> +  void g() {<br>
> +    int k = f();<br>
> +  }<br>
><br>
> +#ifdef __cplusplus<br>
>    extern "C" {<br>
> +#endif<br>
>      int f;<br>
>  #if !defined(CXX_HEADER)<br>
>      // expected-error@-2 {{redefinition of 'f' as different kind of symbol}}<br>
>      // expected-note@c-header.h:1 {{previous}}<br>
>  #endif<br>
> +<br>
> +#ifdef __cplusplus<br>
>    }<br>
>  }<br>
> +#endif<br>
><br>
> -suppress_expected_no_diagnostics_error; // expected-error {{}}<br>
> +suppress_expected_no_diagnostics_error error_here; // expected-error {{}}<br>
><br>
> Modified: cfe/trunk/unittests/AST/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CMakeLists.txt?rev=203317&r1=203316&r2=203317&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CMakeLists.txt?rev=203317&r1=203316&r2=203317&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/unittests/AST/CMakeLists.txt (original)<br>
> +++ cfe/trunk/unittests/AST/CMakeLists.txt Fri Mar  7 18:03:56 2014<br>
> @@ -10,6 +10,7 @@ add_clang_unittest(ASTTests<br>
>    CommentParser.cpp<br>
>    DeclPrinterTest.cpp<br>
>    DeclTest.cpp<br>
> +  ExternalASTSourceTest.cpp<br>
>    SourceLocationTest.cpp<br>
>    StmtPrinterTest.cpp<br>
>    )<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>