r340117 - Revert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"

2018-08-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Aug 17 20:22:11 2018
New Revision: 340117

URL: http://llvm.org/viewvc/llvm-project?rev=340117&view=rev
Log:
Revert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"

This reverts commit a786521fa66c72edd308baff0c08961b6d964fb1.

Bots haven't caught up yet, but broke modules build with:

../tools/clang/include/clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h:18:10:
fatal error: cyclic dependency in module 'Clang_StaticAnalyzer_Core':
Clang_StaticAnalyzer_Core -> Clang_Analysis ->
Clang_StaticAnalyzer_Checkers -> Clang_StaticAnalyzer_Core
 ^

Added:
cfe/trunk/include/clang/Analysis/ObjCRetainCount.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp
  - copied, changed from r340114, 
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.h
  - copied, changed from r340114, 
cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h
  - copied, changed from r340114, 
cfe/trunk/include/clang/StaticAnalyzer/Checkers/SelectorExtras.h
Removed:
cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
cfe/trunk/include/clang/StaticAnalyzer/Checkers/SelectorExtras.h
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
Modified:
cfe/trunk/lib/ARCMigrate/CMakeLists.txt
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp

Added: cfe/trunk/include/clang/Analysis/ObjCRetainCount.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ObjCRetainCount.h?rev=340117&view=auto
==
--- cfe/trunk/include/clang/Analysis/ObjCRetainCount.h (added)
+++ cfe/trunk/include/clang/Analysis/ObjCRetainCount.h Fri Aug 17 20:22:11 2018
@@ -0,0 +1,231 @@
+//==-- ObjCRetainCount.h - Retain count summaries for Cocoa ---*- C++ 
-*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the core data structures for retain count "summaries"
+//  for Objective-C and Core Foundation APIs.  These summaries are used
+//  by the static analyzer to summarize the retain/release effects of
+//  function and method calls.  This drives a path-sensitive typestate
+//  analysis in the static analyzer, but can also potentially be used by
+//  other clients.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_OBJCRETAINCOUNT_H
+#define LLVM_CLANG_STATICANALYZER_CHECKERS_OBJCRETAINCOUNT_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+class FunctionDecl;
+class ObjCMethodDecl;
+
+namespace ento { namespace objc_retain {
+
+/// An ArgEffect summarizes the retain count behavior on an argument or 
receiver
+/// to a function or method.
+enum ArgEffect {
+  /// There is no effect.
+  DoNothing,
+
+  /// The argument is treated as if an -autorelease message had been sent to
+  /// the referenced object.
+  Autorelease,
+
+  /// The argument is treated as if an -dealloc message had been sent to
+  /// the referenced object.
+  Dealloc,
+
+  /// The argument has its reference count decreased by 1.  This is as
+  /// if CFRelease has been called on the argument.
+  DecRef,
+
+  /// The argument has its reference count decreased by 1.  This is as
+  /// if a -release message has been sent to the argument.  This differs
+  /// in behavior from DecRef when GC is enabled.
+  DecRefMsg,
+
+  /// The argument has its reference count decreased by 1 to model
+  /// a transferred bridge cast under ARC.
+  DecRefBridgedTransferred,
+
+  /// The argument has its reference count increased by 1.  This is as
+  /// if a -retain message has been sent to the argument.  This differs
+  /// in behavior from IncRef when GC is enabled.
+  IncRefMsg,
+
+  /// The argument has its reference count increased by 1.  This is as
+  /// if CFRetain has been called on the argument.
+  IncRef,
+
+  /// Used to mark an argument as collectible in GC mode, currently a noop.
+  MakeCollectable,
+
+  /// The argument is a poin

Re: r340114 - [analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker

2018-08-17 Thread Bruno Cardoso Lopes via cfe-commits
Hi George,

This broke the modules build, reverted in r340117 for now. I can help
you figure out any module map change if necessary next week.

Thanks,
On Fri, Aug 17, 2018 at 6:46 PM George Karpenkov via cfe-commits
 wrote:
>
> Author: george.karpenkov
> Date: Fri Aug 17 18:45:50 2018
> New Revision: 340114
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340114&view=rev
> Log:
> [analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker
>
> ARCMigrator is using code from RetainCountChecker, which is a layering
> violation (and it also does it badly, by using a different header, and
> then relying on implementation being present in a header file).
>
> This change splits up RetainSummaryManager into a separate library in
> lib/Analysis, which can be used independently of a checker.
>
> Differential Revision: https://reviews.llvm.org/D50934
>
> Added:
> cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
> cfe/trunk/include/clang/StaticAnalyzer/Checkers/SelectorExtras.h
> cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
> Removed:
> cfe/trunk/include/clang/Analysis/ObjCRetainCount.h
> 
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp
> 
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.h
> cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h
> Modified:
> cfe/trunk/lib/ARCMigrate/CMakeLists.txt
> cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
> cfe/trunk/lib/Analysis/CMakeLists.txt
> cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
> cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
> 
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
> 
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
> 
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
> cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp
>
> Removed: cfe/trunk/include/clang/Analysis/ObjCRetainCount.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ObjCRetainCount.h?rev=340113&view=auto
> ==
> --- cfe/trunk/include/clang/Analysis/ObjCRetainCount.h (original)
> +++ cfe/trunk/include/clang/Analysis/ObjCRetainCount.h (removed)
> @@ -1,231 +0,0 @@
> -//==-- ObjCRetainCount.h - Retain count summaries for Cocoa ---*- C++ 
> -*--//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===--===//
> -//
> -//  This file defines the core data structures for retain count "summaries"
> -//  for Objective-C and Core Foundation APIs.  These summaries are used
> -//  by the static analyzer to summarize the retain/release effects of
> -//  function and method calls.  This drives a path-sensitive typestate
> -//  analysis in the static analyzer, but can also potentially be used by
> -//  other clients.
> -//
> -//===--===//
> -
> -#ifndef LLVM_CLANG_STATICANALYZER_CHECKERS_OBJCRETAINCOUNT_H
> -#define LLVM_CLANG_STATICANALYZER_CHECKERS_OBJCRETAINCOUNT_H
> -
> -#include "clang/Basic/LLVM.h"
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/ADT/SmallVector.h"
> -
> -namespace clang {
> -class FunctionDecl;
> -class ObjCMethodDecl;
> -
> -namespace ento { namespace objc_retain {
> -
> -/// An ArgEffect summarizes the retain count behavior on an argument or 
> receiver
> -/// to a function or method.
> -enum ArgEffect {
> -  /// There is no effect.
> -  DoNothing,
> -
> -  /// The argument is treated as if an -autorelease message had been sent to
> -  /// the referenced object.
> -  Autorelease,
> -
> -  /// The argument is treated as if an -dealloc message had been sent to
> -  /// the referenced object.
> -  Dealloc,
> -
> -  /// The argument has its reference count decreased by 1.  This is as
> -  /// if CFRelease has been called on the argument.
> -  DecRef,
> -
> -  /// The argument has its reference count decreased by 1.  This is as
> -  /// if a -release message has been sent to the argument.  This differs
> -  /// in behavior from DecRef when GC is enabled.
> -  DecRefMsg,
> -
> -  /// The argument has its reference count decreased by 1 to model
> -  /// a transferred bridge cast under ARC.
> -  DecRefBridgedTransferred,
> -
> -  /// The argument has its reference count increased by 1.  This is as
> -  /// if a -retain message has been sent to the argument.  This differs
> -  /// in behavior from IncRef when GC is enabled.
> -  IncRefMsg,
> -
> -  /// The argument has its reference count increased by 1.  This is as
> -  /// if CFRetain has been call

r332491 - [Modules] Do not diagnose missing import in recovery mode if there isn't a decl to lookup

2018-05-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed May 16 10:00:24 2018
New Revision: 332491

URL: http://llvm.org/viewvc/llvm-project?rev=332491&view=rev
Log:
[Modules] Do not diagnose missing import in recovery mode if there isn't a decl 
to lookup

Clang often tries to create implicit module import for error recovery,
which does a great job helping out with diagnostics. However, sometimes
clang does not have enough information given that it's using an invalid
context to move on. Be more strict in those cases to avoid crashes.

We hit crash on invalids because of this but unfortunately there are no
testcases and I couldn't manage to create one. The crashtrace however
indicates pretty clear why it's happening.

rdar://problem/39313933

Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=332491&r1=332490&r2=332491&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 16 10:00:24 2018
@@ -7613,7 +7613,7 @@ bool Sema::RequireCompleteTypeImpl(Sourc
   // If the user is going to see an error here, recover by making the
   // definition visible.
   bool TreatAsComplete = Diagnoser && !isSFINAEContext();
-  if (Diagnoser)
+  if (Diagnoser && SuggestedDef)
 diagnoseMissingImport(Loc, SuggestedDef, MissingImportKind::Definition,
   /*Recover*/TreatAsComplete);
   return !TreatAsComplete;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, May 18, 2018 at 11:54 AM Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On May 18, 2018, at 11:48 AM, Eric Liu  wrote:
>
>
> So I have reverted this with r332751.
>
>
> Thanks!
>
>
> I can't see how this introduced cyclic dependencies in module build, as
> the dependencies should be clangTooling -> clangFormat ->
> clangToolingInclusions. I'm wondering if there is any module configurations
> that I need to update to make this work. Right now, module doesn't seem to
> make any difference between clangTooling and clangToolingInclusions...
> I'd appreciate it if someone who knows how clang module build is set up
> could help take a look.
>
>
> + Bruno & David who have more experience in this area than I do.
>

Gonna try to reproduce and take a look!


>
>
> Unfortunately, I couldn't reproduce this on my workstation as the module
> build seemed to be broken due to other errors.
>
>
> The build is dependent on having a set of modularized system headers --
> perhaps that's the issue.
>
>
> I was seeing a lot of warnings; the clang I used to build llvm was built
> near HEAD. Maybe my clang is too new?
>
>
> This sounds a bit suspicious. Can new clang diagnostics land without clean
> stage2 builds? If so, we can look into enabling -Werror on our stage2 bots
> to catch this sort of thing earlier.
>
> vedant
>
>
> Thanks,
> Eric
>
> On Fri, May 18, 2018 at 7:52 PM Eric Liu  wrote:
>
>> Sorry, I'll look into it right now. Will revert it if I can't find a
>> quick fix.
>>
>> On Fri, May 18, 2018, 19:49 Amara Emerson  wrote:
>>
>>> Hi Eric,
>>>
>>> Green dragon buildbots have started failing too, e.g.:
>>> http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/10222/
>>>
>>> If you don’t have a quick fix can you please revert it.
>>>
>>> Thanks,
>>> Amara
>>>
>>>
>>> On May 18, 2018, at 7:46 PM, Eric Liu  wrote:
>>>
>>> Hi Vedant,
>>>
>>> It seems that your build was not using cmake files in the source tree?
>>> lib/Tooling/Inclusions/ is a (new) standalone library
>>> (clangToolingInclusions, similar to clangToolingCore). You might need
>>> update your build to reflect this change. Let me know if you have any
>>> further question.
>>>
>>> Thanks,
>>> Eric
>>>
>>> On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  wrote:
>>>
 Hi Eric,

 I think there might be a cyclic dependency issue here, possibly one
 that's only visible with LLVM_ENABLE_MODULES=On. I see:

 While building module 'Clang_Tooling' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:

 While building module 'Clang_Format' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:

 In file included from :1:


 /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
 fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $>
 Clang_Format -> Clang_Tooling

 #include "clang/Tooling/Inclusions/IncludeStyle.h"
  ^
 While building module 'Clang_Tooling' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
 In file included from :22:

 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
 /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
 fatal error: could not build module 'Clang_Format'
 #include "clang/Format/Format.h"
  ^~~
 /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
 fatal error: could not build module 'Clang_Tooling'
 #include "clang/Tooling/Execution.h"

  ^~~
 3 errors generated.

 Could you take a look?

 thanks,
 vedant

 > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:
 >
 > Author: ioeric
 > Date: Fri May 18 07:16:37 2018
 > New Revision: 332720
 >
 > URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
 > Log:
 > Move #include manipulation code to new lib/Tooling/Inclusions.
 >
 > Summary:
 > clangToolingCore is linked into almost everything (incl. clang), but
 > not few tools need #include manipulation at this point. So pull this
 into a
 > separate library in Tooling.
 >
 > Review

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, May 18, 2018 at 12:46 PM Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

>
>
> On Fri, May 18, 2018 at 11:54 AM Vedant Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On May 18, 2018, at 11:48 AM, Eric Liu  wrote:
>>
>>
>> So I have reverted this with r332751.
>>
>>
>> Thanks!
>>
>>
>> I can't see how this introduced cyclic dependencies in module build, as
>> the dependencies should be clangTooling -> clangFormat ->
>> clangToolingInclusions. I'm wondering if there is any module configurations
>> that I need to update to make this work. Right now, module doesn't seem to
>> make any difference between clangTooling and clangToolingInclusions...
>> I'd appreciate it if someone who knows how clang module build is set up
>> could help take a look.
>>
>>
>> + Bruno & David who have more experience in this area than I do.
>>
>
> Gonna try to reproduce and take a look!
>

I could reproduce it. You should be good to go if you add another top level
module for Inclusions (and break the dep):

--- a/include/clang/module.modulemap
+++ b/include/clang/module.modulemap
@@ -153,3 +153,8 @@ module Clang_ToolingCore {
   requires cplusplus
   umbrella "Tooling/Core" module * { export * }
 }
+
+module Clang_ToolingInclusions {
+  requires cplusplus
+  umbrella "Tooling/Inclusions" module * { export * }
+}

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi,

On Mon, Oct 9, 2017 at 9:58 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Mon Oct  9 09:58:16 2017
> New Revision: 315214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315214&view=rev
> Log:
> [clangd] Added a command-line arg to mirror clangd input into a file.
>
> Summary: The arg is useful for debugging and creating test cases.
>
> Reviewers: bkramer, krasimir
>
> Reviewed By: bkramer
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D37970
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214&r1=315213&r2=315214&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine &Message) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214&r1=315213&r2=315214&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine &Message);
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine &Message) override;
>
> +  /// Mi

[clang-tools-extra] r315242 - Revert r315214 since diff -Z isn't portable, this is breaking:

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Oct  9 13:22:05 2017
New Revision: 315242

URL: http://llvm.org/viewvc/llvm-project?rev=315242&view=rev
Log:
Revert r315214 since diff -Z isn't portable, this is breaking:

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA


Removed:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315242&r1=315241&r2=315242&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 13:22:05 
2017
@@ -37,14 +37,6 @@ void JSONOutput::log(const Twine &Messag
   Logs.flush();
 }
 
-void JSONOutput::mirrorInput(const Twine &Message) {
-  if (!InputMirror)
-return;
-
-  *InputMirror << Message;
-  InputMirror->flush();
-}
-
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -155,14 +147,6 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
-  Out.mirrorInput(Line);
-  // Mirror '\n' that gets consumed by std::getline, but is not included in
-  // the resulting Line.
-  // Note that '\r' is part of Line, so we don't need to mirror it
-  // separately.
-  if (!In.eof())
-Out.mirrorInput("\n");
-
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -179,8 +163,9 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  "The previous value for this message ("
+  + std::to_string(ContentLength)
+  + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -200,13 +185,15 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
-  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
-" bytes of expected " + std::to_string(ContentLength) + ".\n");
+Out.log("Input was aborted. Read only "
++ std::to_string(In.gcount())
++ " bytes of expected "
++ std::to_string(ContentLength)
++ ".\n");
 break;
   }
 
@@ -222,8 +209,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log("Warning: Missing Content-Length header, or message has zero "
-  "length.\n");
+  Out.log( "Warning: Missing Content-Length header, or message has zero "
+   "length.\n" );
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315242&r1=315241&r2=315242&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 13:22:05 2017
@@ -24,9 +24,8 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
- llvm::raw_ostream *InputMirror = nullptr)
-  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
+  : Outs(Outs), Logs(Logs) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine &Message);
@@ -34,15 +33,9 @@ public:
   /// Write to the logging stream.
   void log(const Twine &Message) override;
 
-  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
-  /// null.
-  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
-  void mirrorInput(const Twine &Message);
-
 private:
   llvm::raw_ostream &Outs;
   llvm::raw_ostream &Logs;
-  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL

Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

2017-10-10 Thread Bruno Cardoso Lopes via cfe-commits
Hi Egor,

On Tue, Mar 21, 2017 at 6:20 AM, Egor Churaev via cfe-commits
 wrote:
> Author: echuraev
> Date: Tue Mar 21 08:20:57 2017
> New Revision: 298369
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298369&view=rev
> Log:
> [OpenCL] Added diagnostic for checking length of vector
>
> Reviewers: Anastasia, cfe-commits
>
> Reviewed By: Anastasia
>
> Subscribers: bader, yaxunl
>
> Differential Revision: https://reviews.llvm.org/D30937
>
> Added:
> cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprMember.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298369&r1=298368&r2=298369&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 21 08:20:57 
> 2017
> @@ -8236,6 +8236,8 @@ def err_opencl_ptrptr_kernel_param : Err
>  def err_kernel_arg_address_space : Error<
>"pointer arguments to kernel functions must reside in '__global', "
>"'__constant' or '__local' address space">;
> +def err_opencl_ext_vector_component_invalid_length : Error<
> +  "vector component access has invalid length %0.  Supported: 
> 1,2,3,4,8,16.">;
>  def err_opencl_function_variable : Error<
>"%select{non-kernel function|function scope}0 variable cannot be declared 
> in %1 address space">;
>  def err_static_function_scope : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=298369&r1=298368&r2=298369&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 21 08:20:57 2017
> @@ -284,6 +284,14 @@ IsRGBA(char c) {
>}
>  }
>
> +// OpenCL v1.1, s6.1.7
> +// The component swizzle length must be in accordance with the acceptable
> +// vector sizes.
> +static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
> +{
> +  return (len >= 1 && len <= 4) || len == 8 || len == 16;
> +}
> +
>  /// Check an ext-vector component access expression.
>  ///
>  /// VK should be set in advance to the value kind of the base
> @@ -376,6 +384,19 @@ CheckExtVectorComponent(Sema &S, QualTyp
>  }
>}
>
> +  if (!HalvingSwizzle) {
> +unsigned SwizzleLength = CompName->getLength();
> +
> +if (HexSwizzle)
> +  SwizzleLength--;
> +
> +if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) {
> +  S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)
> +<< SwizzleLength << SourceRange(CompLoc);
> +  return QualType();
> +}
> +  }
> +
>// The component accessor looks fine - now we need to compute the actual 
> type.
>// The vector type is implied by the component accessor. For example,
>// vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
>
> Added: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=298369&view=auto
> ==
> --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Mar 21 08:20:57 
> 2017
> @@ -0,0 +1,10 @@
> +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> +
> +typedef float float8 __attribute__((ext_vector_type(8)));
> +
> +void foo() {
> +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0);
> +
> +f2.s01234; // expected-error {{vector component access has invalid 
> length 5.  Supported: 1,2,3,4,8,16}}
> +f2.xyzxy; // expected-error {{vector component access has invalid length 
> 5.  Supported: 1,2,3,4,8,16}}
> +}

Sorry for the necromancy here, but I wonder if we should only make
this if LangOpts.OpenCL in on. Is there an initial intent for not to?

The rationale is that we have given users support for ext_vector_type
without OpenCL mode with arbitrary vectors lengths not defined in
"6.1.2 Built-In Vector Data Types", that said it makes sense to
support the component notation for those. I'm happy to fix it, I just
need to know if this covers some background I'm not aware of.

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r315287 - Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"

2017-10-10 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Oct 10, 2017 at 2:08 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Tue Oct 10 02:08:47 2017
> New Revision: 315287
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315287&view=rev
> Log:
> Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"
>
> This reverts commit r315242 and restores r315214.
>
> To fix original failure, replaced non-portable `diff -Z` with portable
> alternative: `diff -b`.
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315287&r1=315286&r2=315287&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Oct 10 02:08:47 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine &Message) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315287&r1=315286&r2=315287&view=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Tue Oct 10 02:08:47 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine &Message);
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine &Message) override;
>
> +  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror 
>

Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

2017-10-12 Thread Bruno Cardoso Lopes via cfe-commits
On Thu, Oct 12, 2017 at 8:39 AM, Anastasia Stulova
 wrote:
>
> I think this bit is a bit confusing to us. Some of our original OpenCL
> checks were removed in some places because in some cases OpenCL semantic was
> adopted elsewhere.

It's confusing indeed. We should probably enhance the docs for
scenarios like this.

> But I think this should indeed go under OpenCL check.

https://reviews.llvm.org/D38868

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315712 - Revert "[lit] Raise the logic for enabling clang & lld substitutions to llvm."

2017-10-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Oct 13 10:11:13 2017
New Revision: 315712

URL: http://llvm.org/viewvc/llvm-project?rev=315712&view=rev
Log:
Revert "[lit] Raise the logic for enabling clang & lld substitutions to llvm."

This reverts commit r315627, fixing bot failures:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

LIT is failing to properly apply substitution to debuginfo-tests
after this change.

rdar://problem/34979568

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=315712&r1=315711&r2=315712&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Fri Oct 13 10:11:13 2017
@@ -39,33 +39,71 @@ config.test_source_root = os.path.dirnam
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_obj_root, 'test')
 
-llvm_config.use_default_substitutions()
+# Clear some environment variables that might affect Clang.
+#
+# This first set of vars are read by Clang, but shouldn't affect tests
+# that aren't specifically looking for these features, or are required
+# simply to run the tests at all.
+#
+# FIXME: Should we have a tool that enforces this?
 
-llvm_config.use_clang()
+# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
+#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
+#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
+#  'VC80COMNTOOLS')
+possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+   'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+   'LIBCLANG_RESOURCE_USAGE',
+   'LIBCLANG_CODE_COMPLETION_LOGGING']
+# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
+if platform.system() != 'Windows':
+possibly_dangerous_env_vars.append('INCLUDE')
+
+llvm_config.clear_environment(possibly_dangerous_env_vars)
+
+# Tweak the PATH to include the tools dir and the scripts dir.
+llvm_config.with_environment(
+'PATH', [config.llvm_tools_dir, config.clang_tools_dir], append_path=True)
+
+llvm_config.with_environment('LD_LIBRARY_PATH', [
+ config.llvm_shlib_dir, config.llvm_libs_dir], 
append_path=True)
 
 # Propagate path to symbolizer for ASan/MSan.
 llvm_config.with_system_environment(
 ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
 
-config.substitutions.append(('%PATH%', config.environment['PATH']))
+llvm_config.use_default_substitutions()
 
+# Discover the 'clang' and 'clangcc' to use.
 
-# For each occurrence of a clang tool name, replace it with the full path to
-# the build directory holding that tool.  We explicitly specify the directories
-# to search to ensure that we get the tools just built and not some random
-# tools that might happen to be in the user's PATH.
-tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
-tools = [
-'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
-ToolSubst('%clang_func_map', command=FindTool(
-'clang-func-mapping'), unresolved='ignore'),
-]
+def inferClang(PATH):
+# Determine which clang to use.
+clang = os.getenv('CLANG')
 
-if config.clang_examples:
-tools.append('clang-interpreter')
+# If the user set clang in the environment, definitely use that and don't
+# try to validate.
+if clang:
+return clang
 
-llvm_config.add_tool_substitutions(tools, tool_dirs)
+# Otherwise look in the path.
+clang = lit.util.which('clang', PATH)
+
+if not clang:
+lit_config.fatal("couldn't find 'clang' program, try setting "
+ 'CLANG in your environment')
+
+return clang
+
+
+config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
+if not lit_config.quiet:
+lit_config.note('using clang: %r' % config.clang)
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
@@ -77,6 +115,87 @@ else:
 if has_plugins and config.llvm_plugin_ext:
 config.available_features.add('plugins')
 
+config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+config.substitutions.append(('%PATH%', config.environment['PATH']))
+
+if config.clang_examples:
+config.available_features.add('examples')
+
+builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
+
+tools = 

Re: r315627 - [lit] Raise the logic for enabling clang & lld substitutions to llvm.

2017-10-13 Thread Bruno Cardoso Lopes via cfe-commits
Hi Zachary,

I reverted this in r315712, since it's making one of our bots red
since yesterday (more explanations in the commit):
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

Cheers,

On Thu, Oct 12, 2017 at 2:56 PM, Zachary Turner via cfe-commits
 wrote:
> Author: zturner
> Date: Thu Oct 12 14:56:05 2017
> New Revision: 315627
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315627&view=rev
> Log:
> [lit] Raise the logic for enabling clang & lld substitutions to llvm.
>
> This paves the way for other projects which might /use/ clang or
> lld but not necessarily need to the full set of functionality
> available to clang and lld tests to be able to have a basic set
> of substitutions that allow a project to run the clang or lld
> executables.
>
> Modified:
> cfe/trunk/test/lit.cfg.py
>
> Modified: cfe/trunk/test/lit.cfg.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=315627&r1=315626&r2=315627&view=diff
> ==
> --- cfe/trunk/test/lit.cfg.py (original)
> +++ cfe/trunk/test/lit.cfg.py Thu Oct 12 14:56:05 2017
> @@ -39,162 +39,43 @@ config.test_source_root = os.path.dirnam
>  # test_exec_root: The root path where tests should be run.
>  config.test_exec_root = os.path.join(config.clang_obj_root, 'test')
>
> -# Clear some environment variables that might affect Clang.
> -#
> -# This first set of vars are read by Clang, but shouldn't affect tests
> -# that aren't specifically looking for these features, or are required
> -# simply to run the tests at all.
> -#
> -# FIXME: Should we have a tool that enforces this?
> -
> -# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
> -#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
> -#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
> -#  'VC80COMNTOOLS')
> -possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
> -   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
> -   'CPATH', 'C_INCLUDE_PATH', 
> 'CPLUS_INCLUDE_PATH',
> -   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
> -   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
> -   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
> -   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
> -   'LIBCLANG_RESOURCE_USAGE',
> -   'LIBCLANG_CODE_COMPLETION_LOGGING']
> -# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
> -if platform.system() != 'Windows':
> -possibly_dangerous_env_vars.append('INCLUDE')
> -
> -llvm_config.clear_environment(possibly_dangerous_env_vars)
> -
> -# Tweak the PATH to include the tools dir and the scripts dir.
> -llvm_config.with_environment(
> -'PATH', [config.llvm_tools_dir, config.clang_tools_dir], 
> append_path=True)
> +llvm_config.use_default_substitutions()
>
> -llvm_config.with_environment('LD_LIBRARY_PATH', [
> - config.llvm_shlib_dir, config.llvm_libs_dir], 
> append_path=True)
> +llvm_config.use_clang()
>
>  # Propagate path to symbolizer for ASan/MSan.
>  llvm_config.with_system_environment(
>  ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
>
> -llvm_config.use_default_substitutions()
> -
> -# Discover the 'clang' and 'clangcc' to use.
> -
> -
> -def inferClang(PATH):
> -# Determine which clang to use.
> -clang = os.getenv('CLANG')
> -
> -# If the user set clang in the environment, definitely use that and don't
> -# try to validate.
> -if clang:
> -return clang
> -
> -# Otherwise look in the path.
> -clang = lit.util.which('clang', PATH)
> -
> -if not clang:
> -lit_config.fatal("couldn't find 'clang' program, try setting "
> - 'CLANG in your environment')
> -
> -return clang
> -
> -
> -config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
> -if not lit_config.quiet:
> -lit_config.note('using clang: %r' % config.clang)
> -
> -# Plugins (loadable modules)
> -# TODO: This should be supplied by Makefile or autoconf.
> -if sys.platform in ['win32', 'cygwin']:
> -has_plugins = config.enable_shared
> -else:
> -has_plugins = True
> -
> -if has_plugins and config.llvm_plugin_ext:
> -config.available_features.add('plugins')
> -
> -config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
> -config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
>  config.substitutions.append(('%PATH%', config.environment['PATH']))
>
> -if config.clang_examples:
> -config.available_features.add('examples')
>
> -builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
> +# For each occurrence of a clang tool name, replace it with the full path to
> +# the build directory holding that tool. 

r315829 - Mark test as unsupported until r315808 is fixed

2017-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Sat Oct 14 15:14:23 2017
New Revision: 315829

URL: http://llvm.org/viewvc/llvm-project?rev=315829&view=rev
Log:
Mark test as unsupported until r315808 is fixed

This is causing:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/43381

Modified:
cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl

Modified: cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl?rev=315829&r1=315828&r2=315829&view=diff
==
--- cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl (original)
+++ cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl Sat Oct 14 
15:14:23 2017
@@ -1,4 +1,5 @@
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: system-darwin
 // RUN: not %clang_cc1 -emit-codegen-only -triple=amdgcn-- %s 2>&1 | FileCheck 
%s
 
 // CHECK: error: local memory limit exceeded (48) in use_huge_lds


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r315994 - [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.

2017-10-17 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

This is also failing
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/39697/

Can you take a look?

Thanks,

On Tue, Oct 17, 2017 at 9:07 AM, Eric Fiselier via cfe-commits
 wrote:
> These shadowing warnings should be fixed now.
>
> /Eric
>
> On Tue, Oct 17, 2017 at 10:03 AM, Maxim Kuvyrkov 
> wrote:
>>
>> Hi Eric,
>>
>> This seems to have broken ARM and AArch64 buildbots:
>>
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/850
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/931
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/873
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions/builds/826
>>
>> Would you please take a look?
>>
>> --
>> Maxim Kuvyrkov
>> www.linaro.org
>>
>>
>>
>>
>> > On Oct 17, 2017, at 4:03 PM, Eric Fiselier via cfe-commits
>> >  wrote:
>> >
>> > Author: ericwf
>> > Date: Tue Oct 17 06:03:17 2017
>> > New Revision: 315994
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=315994&view=rev
>> > Log:
>> > [libc++] Fix PR34898 - vector iterator constructors and assign method
>> > perform push_back instead of emplace_back.
>> >
>> > Summary:
>> > The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter,
>> > Iter)` don't correctly perform EmplaceConstruction from the result of
>> > dereferencing the iterator. This results in them performing an additional
>> > and unneeded copy.
>> >
>> > This patch addresses the issue by correctly using `emplace_back` in
>> > C++11 and newer.
>> >
>> > There are also some bugs in our `insert` implementation, but those will
>> > be handled separately.
>> >
>> > @mclow.lists We should probably merge this into 5.1, agreed?
>> >
>> > Reviewers: mclow.lists, dlj, EricWF
>> >
>> > Reviewed By: mclow.lists, EricWF
>> >
>> > Subscribers: cfe-commits, mclow.lists
>> >
>> > Differential Revision: https://reviews.llvm.org/D38757
>> >
>> > Added:
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
>> >libcxx/trunk/test/support/emplace_constructible.h
>> > Modified:
>> >libcxx/trunk/include/deque
>> >libcxx/trunk/include/list
>> >libcxx/trunk/include/vector
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
>> >libcxx/trunk/test/support/container_test_types.h
>> >
>> > Modified: libcxx/trunk/include/deque
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=315994&r1=315993&r2=315994&view=diff
>> >
>> > ==
>> > --- libcxx/trunk/include/deque (original)
>> > +++ libcxx/trunk/include/deque Tue Oct 17 06:03:17 2017
>> > @@ -1356,7 +1356,6 @@ public:
>> > iterator insert(const_iterator __p, initializer_list
>> > __il)
>> > {return insert(__p, __il.begin(), __il.end());}
>> > #endif  // _LIBCPP_CXX03_LANG
>> > -
>> > iterator insert(const_iterator __p, const value_type& __v);
>> > iterator insert(const_iterator __p, size_type __n, const value_type&
>> > __v);
>> > template 
>> > @@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIte
>> >
>> > !__is_forward_iterator<_InpIter>::value>::type*)
>> > {
>> > for (; __f != __l; ++__f)
>> > +#ifdef _LIBCPP_CXX03_LANG
>> > push_back(*__f);
>> > +#else
>> > +emplace_back(*__f);
>> > +#endif
>> > }
>> >
>> > template 
>> >
>> > Modified: libcxx/trunk/include/list
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=315994&r1=315993&r2=315994&view=diff
>> >
>> > ==
>> > --- libcxx/trunk/include/list (original)
>> > +++ libcxx/trunk/include/list Tue Oct 17 06:03:17 2017
>> > @@ -992,6 +992,15 @@ public:
>> > void push_front(const value_type& __x);
>> > void push_back(const value_type& __x);
>> >
>> > +#ifndef _LIBCPP_CXX03_LANG
>> > +template 
>> > +_LIBCPP_INLINE_VISIBILITY
>> > +void __emplace_back(_Arg&& __arg) {
>> > emplace_back(_VSTD::forward<_Arg>(__arg)); }
>> > +#else
>> > +_LIBCPP_INLINE_VISIBILITY
>> > +void __emplace_back(value_type const& __arg) { push_back(__arg); }
>> > +#endif
>> > +
>> > iterator insert(const_iterator __p, const value_type& __x);
>> > iterator insert(const_iterator __p, size_type __n, const value_type&
>> > __x);
>> > te

r316016 - [OpenCL] Restrict swizzle length check to OpenCL mode

2017-10-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 17 10:54:57 2017
New Revision: 316016

URL: http://llvm.org/viewvc/llvm-project?rev=316016&view=rev
Log:
[OpenCL] Restrict swizzle length check to OpenCL mode

Changes behavior introduced in r298369 to only error out on
vector component invalid length access on OpenCL mode.

Differential Revision: https://reviews.llvm.org/D38868

rdar://problem/33568748

Added:
cfe/trunk/test/Sema/vector_swizzle_length.c
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=316016&r1=316015&r2=316016&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Oct 17 10:54:57 2017
@@ -384,7 +384,9 @@ CheckExtVectorComponent(Sema &S, QualTyp
 }
   }
 
-  if (!HalvingSwizzle) {
+  // OpenCL mode requires swizzle length to be in accordance with accepted
+  // sizes. Clang however supports arbitrary lengths for other languages.
+  if (S.getLangOpts().OpenCL && !HalvingSwizzle) {
 unsigned SwizzleLength = CompName->getLength();
 
 if (HexSwizzle)

Added: cfe/trunk/test/Sema/vector_swizzle_length.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector_swizzle_length.c?rev=316016&view=auto
==
--- cfe/trunk/test/Sema/vector_swizzle_length.c (added)
+++ cfe/trunk/test/Sema/vector_swizzle_length.c Tue Oct 17 10:54:57 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only
+// expected-no-diagnostics
+
+typedef float float8 __attribute__((ext_vector_type(8)));
+
+void foo() {
+float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0};
+(void)f2.s01234;
+(void)f2.xyzxy;
+}

Modified: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=316016&r1=316015&r2=316016&view=diff
==
--- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (original)
+++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Oct 17 10:54:57 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only
 
 typedef float float8 __attribute__((ext_vector_type(8)));
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r341902 - [Modules] Add imported modules to the output of -module-file-info

2018-09-10 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Sep 10 22:17:13 2018
New Revision: 341902

URL: http://llvm.org/viewvc/llvm-project?rev=341902&view=rev
Log:
[Modules] Add imported modules to the output of -module-file-info

Fix a bug in the deserialization of IMPORTS section and allow for
imported modules to also be printed with -module-file-info.

rdar://problem/43867753

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=341902&r1=341901&r2=341902&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Sep 10 22:17:13 2018
@@ -232,7 +232,7 @@ public:
 
   /// If needsImportVisitation returns \c true, this is called for each
   /// AST file imported by this AST file.
-  virtual void visitImport(StringRef Filename) {}
+  virtual void visitImport(StringRef ModuleName, StringRef Filename) {}
 
   /// Indicates that a particular module file extension has been read.
   virtual void readModuleFileExtension(

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=341902&r1=341901&r2=341902&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Sep 10 22:17:13 2018
@@ -601,6 +601,17 @@ namespace {
 
   return true;
 }
+
+/// Returns true if this \c ASTReaderListener wants to receive the
+/// imports of the AST file via \c visitImport, false otherwise.
+bool needsImportVisitation() const override { return true; }
+
+/// If needsImportVisitation returns \c true, this is called for each
+/// AST file imported by this AST file.
+void visitImport(StringRef ModuleName, StringRef Filename) override {
+  Out.indent(2) << "Imports module '" << ModuleName
+<< "': " << Filename.str() << "\n";
+}
 #undef DUMP_BOOLEAN
   };
 }

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=341902&r1=341901&r2=341902&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Sep 10 22:17:13 2018
@@ -4868,11 +4868,11 @@ bool ASTReader::readASTFileControlBlock(
   unsigned Idx = 0, N = Record.size();
   while (Idx < N) {
 // Read information about the AST file.
-Idx += 5; // ImportLoc, Size, ModTime, Signature
-SkipString(Record, Idx); // Module name; FIXME: pass to listener?
+Idx += 1+1+1+1+5; // Kind, ImportLoc, Size, ModTime, Signature
+std::string ModuleName = ReadString(Record, Idx);
 std::string Filename = ReadString(Record, Idx);
 ResolveImportedPath(Filename, ModuleDir);
-Listener.visitImport(Filename);
+Listener.visitImport(ModuleName, Filename);
   }
   break;
 }

Modified: cfe/trunk/test/Modules/module_file_info.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module_file_info.m?rev=341902&r1=341901&r2=341902&view=diff
==
--- cfe/trunk/test/Modules/module_file_info.m (original)
+++ cfe/trunk/test/Modules/module_file_info.m Mon Sep 10 22:17:13 2018
@@ -16,6 +16,7 @@
 
 // CHECK: Module name: DependsOnModule
 // CHECK: Module map file: {{.*}}DependsOnModule.framework{{[/\\]}}module.map
+// CHECK: Imports module 'Module': {{.*}}Module.pcm
 
 // CHECK: Language options:
 // CHECK:   C99: Yes


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r337447 - [PCH+Modules] Load -fmodule-map-file content before including PCHs

2018-07-19 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jul 19 05:32:06 2018
New Revision: 337447

URL: http://llvm.org/viewvc/llvm-project?rev=337447&view=rev
Log:
[PCH+Modules] Load -fmodule-map-file content before including PCHs

Consider:
1) Generate PCH with -fmodules and -fmodule-map-file
2) Use PCH with -fmodules and the same -fmodule-map-file

If we don't load -fmodule-map-file content before including PCHs,
the modules that are dependencies in PCHs cannot get loaded,
since there's no matching module map file when reading back the AST.

rdar://problem/40852867

Differential Revision: https://reviews.llvm.org/D48685

Added:
cfe/trunk/test/Modules/module-imported-by-pch-with-modulemap.m
Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=337447&r1=337446&r2=337447&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jul 19 05:32:06 2018
@@ -766,6 +766,22 @@ bool FrontendAction::BeginSourceFile(Com
   if (!BeginSourceFileAction(CI))
 goto failure;
 
+  // If we were asked to load any module map files, do so now.
+  for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
+if (auto *File = CI.getFileManager().getFile(Filename))
+  CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
+  File, /*IsSystem*/false);
+else
+  CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
+  }
+
+  // Add a module declaration scope so that modules from -fmodule-map-file
+  // arguments may shadow modules found implicitly in search paths.
+  CI.getPreprocessor()
+  .getHeaderSearchInfo()
+  .getModuleMap()
+  .finishModuleDeclarationScope();
+
   // Create the AST context and consumer unless this is a preprocessor only
   // action.
   if (!usesPreprocessorOnly()) {
@@ -855,22 +871,6 @@ bool FrontendAction::BeginSourceFile(Com
"doesn't support modules");
   }
 
-  // If we were asked to load any module map files, do so now.
-  for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
-if (auto *File = CI.getFileManager().getFile(Filename))
-  CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile(
-  File, /*IsSystem*/false);
-else
-  CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
-  }
-
-  // Add a module declaration scope so that modules from -fmodule-map-file
-  // arguments may shadow modules found implicitly in search paths.
-  CI.getPreprocessor()
-  .getHeaderSearchInfo()
-  .getModuleMap()
-  .finishModuleDeclarationScope();
-
   // If we were asked to load any module files, do so now.
   for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles)
 if (!CI.loadModuleFile(ModuleFile))

Added: cfe/trunk/test/Modules/module-imported-by-pch-with-modulemap.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-imported-by-pch-with-modulemap.m?rev=337447&view=auto
==
--- cfe/trunk/test/Modules/module-imported-by-pch-with-modulemap.m (added)
+++ cfe/trunk/test/Modules/module-imported-by-pch-with-modulemap.m Thu Jul 19 
05:32:06 2018
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t.dst %t.cache
+// RUN: mkdir -p %t.dst/folder-with-modulemap %t.dst/pch-folder
+// RUN: echo '#import "folder-with-modulemap/included.h"' > %t.dst/header.h
+// RUN: echo 'extern int MyModuleVersion;' > 
%t.dst/folder-with-modulemap/MyModule.h
+// RUN: echo '@import MyModule;' > %t.dst/folder-with-modulemap/included.h
+// RUN: echo 'module MyModule { header "MyModule.h" }' > 
%t.dst/folder-with-modulemap/MyModule.modulemap
+
+// RUN: %clang_cc1 -emit-pch -o %t.dst/pch-folder/header.pch 
-fmodule-map-file=%t.dst/folder-with-modulemap/MyModule.modulemap -x 
objective-c-header -fmodules-cache-path=%t.cache -fmodules 
-fimplicit-module-maps %t.dst/header.h
+// RUN: %clang_cc1 -fsyntax-only 
-fmodule-map-file=%t.dst/folder-with-modulemap/MyModule.modulemap 
-fmodules-cache-path=%t.cache -fmodules -fimplicit-module-maps %s -include-pch 
%t.dst/pch-folder/header.pch -verify
+
+// expected-no-diagnostics
+
+void test() {
+  (void)MyModuleVersion; // should be found by implicit import
+}
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r337555 - [www] Add CodeCompass and CodeChecker to Clang Related Projects page

2018-07-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jul 20 07:46:10 2018
New Revision: 337555

URL: http://llvm.org/viewvc/llvm-project?rev=337555&view=rev
Log:
[www] Add CodeCompass and CodeChecker to Clang Related Projects page

Modified:
cfe/trunk/www/related.html

Modified: cfe/trunk/www/related.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/related.html?rev=337555&r1=337554&r2=337555&view=diff
==
--- cfe/trunk/www/related.html (original)
+++ cfe/trunk/www/related.html Fri Jul 20 07:46:10 2018
@@ -93,6 +93,28 @@
 
   
 
+  CodeCompass
+  
+
+  Site:
+http://github.com/Ericsson/CodeCompass";>http://github.com/Ericsson/CodeCompass
+
+
+CodeCompass is an open-source, extensible code comprehension framework 
which uses LLVM/Clang to analyze and visualize C and C++ projects. It also 
supports both regex-based text search, discovering complex C/C++ language 
elements, with advanced navigation and visualisation.
+
+  
+
+  CodeChecker
+  
+
+  Site:
+http://github.com/Ericsson/CodeChecker";>http://github.com/Ericsson/CodeChecker
+
+
+CodeChecker is a static analysis infrastructure built on the 
LLVM/Clang Static Analyzer toolchain. It provides a user interface to execute 
analysis of C/C++ projects with Clang SA and Clang-Tidy, which outputs are then 
stored into a database navigable via a web application. This web application 
and a corresponding command-line tool supports a variety of report management 
and issue triaging options, such as difference view between analyses, automatic 
incremental analysis, marking and commenting on individual reports.
+
+  
+
 
   
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r324965 - [Modules] Fix remapping from Foo.Private to Foo_Private to happen before typo correction

2018-02-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Feb 12 15:43:21 2018
New Revision: 324965

URL: http://llvm.org/viewvc/llvm-project?rev=324965&view=rev
Log:
[Modules] Fix remapping from Foo.Private to Foo_Private to happen before typo 
correction

Typo correction is the last step here, remapping should come first.

rdar://problem/37351970

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.modulemap

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=324965&r1=324964&r2=324965&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Feb 12 15:43:21 2018
@@ -1859,6 +1859,39 @@ CompilerInstance::loadModule(SourceLocat
 for (unsigned I = 1, N = Path.size(); I != N; ++I) {
   StringRef Name = Path[I].first->getName();
   clang::Module *Sub = Module->findSubmodule(Name);
+
+  // If the user is requesting Foo.Private and it doesn't exist, try to
+  // match Foo_Private and emit a warning asking for the user to write
+  // @import Foo_Private instead. FIXME: remove this when existing clients
+  // migrate off of Foo.Private syntax.
+  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
+  Module == Module->getTopLevelModule()) {
+SmallString<128> PrivateModule(Module->Name);
+PrivateModule.append("_Private");
+
+SmallVector, 2> PrivPath;
+auto &II = PP->getIdentifierTable().get(
+PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
+PrivPath.push_back(std::make_pair(&II, Path[0].second));
+
+if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
+  Sub =
+  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
+if (Sub) {
+  MapPrivateSubModToTopLevel = true;
+  if (!getDiagnostics().isIgnored(
+  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
+getDiagnostics().Report(Path[I].second,
+diag::warn_no_priv_submodule_use_toplevel)
+<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
+<< SourceRange(Path[0].second, Path[I].second)
+<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
+PrivateModule);
+getDiagnostics().Report(Sub->DefinitionLoc,
+diag::note_private_top_level_defined);
+  }
+}
+  }
   
   if (!Sub) {
 // Attempt to perform typo correction to find a module name that works.
@@ -1894,39 +1927,6 @@ CompilerInstance::loadModule(SourceLocat
 }
   }
 
-  // If the user is requesting Foo.Private and it doesn't exist, try to
-  // match Foo_Private and emit a warning asking for the user to write
-  // @import Foo_Private instead. FIXME: remove this when existing clients
-  // migrate off of Foo.Private syntax.
-  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
-  Module == Module->getTopLevelModule()) {
-SmallString<128> PrivateModule(Module->Name);
-PrivateModule.append("_Private");
-
-SmallVector, 2> PrivPath;
-auto &II = PP->getIdentifierTable().get(
-PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
-PrivPath.push_back(std::make_pair(&II, Path[0].second));
-
-if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
-  Sub =
-  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
-if (Sub) {
-  MapPrivateSubModToTopLevel = true;
-  if (!getDiagnostics().isIgnored(
-  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
-getDiagnostics().Report(Path[I].second,
-diag::warn_no_priv_submodule_use_toplevel)
-<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
-<< SourceRange(Path[0].second, Path[I].second)
-<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
-PrivateModule);
-getDiagnostics().Report(Sub->DefinitionLoc,
-diag::note_private_top_level_defined);
-  }
-}
-  }
-
   if (!Sub) {
 // No submodule by this name. Complain, and don't look for further
 // submodules.

Modified: 
cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Mo

r325154 - [Modules] Add more language features to be used with requires-declaration

2018-02-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Feb 14 11:01:03 2018
New Revision: 325154

URL: http://llvm.org/viewvc/llvm-project?rev=325154&view=rev
Log:
[Modules] Add more language features to be used with requires-declaration

Features added: c99, c11, c17, cplusplus14 and cplusplus17.

rdar://problem/36328787
rdar://problem/36668431

Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
cfe/trunk/test/Modules/requires.m

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Wed Feb 14 11:01:03 2018
@@ -430,6 +430,21 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+cplusplus14
+  C++14 support is available.
+
+cplusplus17
+  C++17 support is available.
+
+c99
+  C99 support is available.
+
+c11
+  C11 support is available.
+
+c17
+  C17 support is available.
+
 freestanding
   A freestanding environment is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Wed Feb 14 11:01:03 2018
@@ -78,6 +78,11 @@ static bool hasFeature(StringRef Feature
 .Case("coroutines", LangOpts.CoroutinesTS)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
+.Case("cplusplus14", LangOpts.CPlusPlus14)
+.Case("cplusplus17", LangOpts.CPlusPlus17)
+.Case("c99", LangOpts.C99)
+.Case("c11", LangOpts.C11)
+.Case("c17", LangOpts.C17)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC1)

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map 
(original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Wed Feb 
14 11:01:03 2018
@@ -37,4 +37,22 @@ framework module DependsOnModule {
   export *
 }
   }
+  explicit module CXX11 {
+requires cplusplus11
+  }
+  explicit module CXX14 {
+requires cplusplus14
+  }
+  explicit module CXX17 {
+requires cplusplus17
+  }
+  explicit module C99 {
+requires c99
+  }
+  explicit module C11 {
+requires c11
+  }
+  explicit module C17 {
+requires c17
+  }
 }

Modified: cfe/trunk/test/Modules/requires.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires.m?rev=325154&r1=325153&r2=325154&view=diff
==
--- cfe/trunk/test/Modules/requires.m (original)
+++ cfe/trunk/test/Modules/requires.m Wed Feb 14 11:01:03 2018
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify 
-fmodule-feature custom_req1
-
+// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -std=c89 
-DTEST_C_FEATURES
+#ifndef TEST_C_FEATURES
 // expected-error@DependsOnModule.framework/module.map:7 {{module 
'DependsOnModule.CXX' requires feature 'cplusplus'}}
 @import DependsOnModule.CXX; // expected-note {{module imported here}}
 @import DependsOnModule.NotCXX;
@@ -15,3 +16,17 @@
 @import RequiresWithMissingHeader.HeaderBefore; // expected-note {{module 
imported here}}
 // expected-er...@module.map:* {{module 
'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}}
 @import RequiresWithMissingHeader.HeaderAfter; // expected-note {{module 
imported here}}
+// expected-error@DependsOnModule.framework/module.map:40 {{module 
'DependsOnModule.CXX11' requires feature 'cplusplus11'}}
+@import DependsOnModule.CXX11; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:43 {{module 
'DependsOnModule.CXX14' requires feature 'cplusplus14'}}
+@import DependsOnModule.CXX14; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:46 {{module 
'DependsOnModule.CXX17' requires feature 'cplusplus17'}}
+@import DependsOnModule.C

r325305 - [Modules] Extend -fmodule-name semantic for frameworks with private modules

2018-02-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Feb 15 16:12:57 2018
New Revision: 325305

URL: http://llvm.org/viewvc/llvm-project?rev=325305&view=rev
Log:
[Modules] Extend -fmodule-name semantic for frameworks with private modules

Assume Foo.framework with two module maps and two modules Foo and
Foo_Private.

Framework authors need to skip building both Foo and Foo_Private when
using -fmodule-name=Foo, since both are part of the framework and used
interchangeably during compilation.

rdar://problem/37500098

Added:
cfe/trunk/test/Modules/module-name-private.m
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=325305&r1=325304&r2=325305&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Feb 15 16:12:57 2018
@@ -115,6 +115,24 @@ static bool isReservedId(StringRef Text,
   return false;
 }
 
+// The -fmodule-name option (represented here by \p CurrentModule) tells the
+// compiler to textually include headers in the specified module, meaning clang
+// won't build the specified module. This is useful in a number of situations,
+// for instance, when building a library that vends a module map, one might 
want
+// to avoid hitting intermediate build products containig the the module map or
+// avoid finding the system installed modulemap for that library.
+static bool isForModuleBuilding(Module *M, StringRef CurrentModule) {
+  StringRef TopLevelName = M->getTopLevelModuleName();
+
+  // When building framework Foo, we wanna make sure that Foo *and* Foo_Private
+  // are textually included and no modules are built for both.
+  if (M->getTopLevelModule()->IsFramework &&
+  !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private"))
+TopLevelName = TopLevelName.drop_back(8);
+
+  return TopLevelName == CurrentModule;
+}
+
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
   StringRef Text = II->getName();
@@ -1856,8 +1874,8 @@ void Preprocessor::HandleIncludeDirectiv
   // there is one. Don't do so if precompiled module support is disabled or we
   // are processing this module textually (because we're building the module).
   if (ShouldEnter && File && SuggestedModule && getLangOpts().Modules &&
-  SuggestedModule.getModule()->getTopLevelModuleName() !=
-  getLangOpts().CurrentModule) {
+  !isForModuleBuilding(SuggestedModule.getModule(),
+   getLangOpts().CurrentModule)) {
 // If this include corresponds to a module but that module is
 // unavailable, diagnose the situation and bail out.
 // FIXME: Remove this; loadModule does the same check (but produces
@@ -2004,7 +2022,7 @@ void Preprocessor::HandleIncludeDirectiv
   // ShouldEnter is false because we are skipping the header. In that
   // case, We are not importing the specified module.
   if (SkipHeader && getLangOpts().CompilingPCH &&
-  M->getTopLevelModuleName() == getLangOpts().CurrentModule)
+  isForModuleBuilding(M, getLangOpts().CurrentModule))
 return;
 
   makeModuleVisible(M, HashLoc);
@@ -2045,7 +2063,7 @@ void Preprocessor::HandleIncludeDirectiv
 // include headers in the specified module. We are not building the
 // specified module.
 if (getLangOpts().CompilingPCH &&
-M->getTopLevelModuleName() == getLangOpts().CurrentModule)
+isForModuleBuilding(M, getLangOpts().CurrentModule))
   return;
 
 assert(!CurLexerSubmodule && "should not have marked this as a module 
yet");

Added: cfe/trunk/test/Modules/module-name-private.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-name-private.m?rev=325305&view=auto
==
--- cfe/trunk/test/Modules/module-name-private.m (added)
+++ cfe/trunk/test/Modules/module-name-private.m Thu Feb 15 16:12:57 2018
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-canonical -fsyntax-only 
%s -Wprivate-module -fmodule-name=A -Rmodule-build
+
+// Because of -fmodule-name=A, no module (A or A_Private) is supposed to be
+// built and -Rmodule-build should not produce any output.
+
+// expected-no-diagnostics
+
+#import 
+#import 
+
+int foo() { return APRIVATE; }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r303630 - Allow to use vfs::FileSystem for file accesses inside ASTUnit.

2017-05-23 Thread Bruno Cardoso Lopes via cfe-commits
Any specific reason why this doesn't contain a testcase?

On Tue, May 23, 2017 at 4:37 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Tue May 23 06:37:52 2017
> New Revision: 303630
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303630&view=rev
> Log:
> Allow to use vfs::FileSystem for file accesses inside ASTUnit.
>
> Reviewers: bkramer, krasimir, arphaman, akyrtzi
>
> Reviewed By: bkramer
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D33397
>
> Modified:
> cfe/trunk/include/clang/Frontend/ASTUnit.h
> cfe/trunk/include/clang/Frontend/CompilerInvocation.h
> cfe/trunk/lib/Frontend/ASTUnit.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=303630&r1=303629&r2=303630&view=diff
> ==
> --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 23 06:37:52 2017
> @@ -59,6 +59,10 @@ class TargetInfo;
>  class FrontendAction;
>  class ASTDeserializationListener;
>
> +namespace vfs {
> +class FileSystem;
> +}
> +
>  /// \brief Utility class for loading a ASTContext from an AST file.
>  ///
>  class ASTUnit : public ModuleLoader {
> @@ -420,7 +424,8 @@ private:
>explicit ASTUnit(bool MainFileIsAST);
>
>bool Parse(std::shared_ptr PCHContainerOps,
> - std::unique_ptr OverrideMainBuffer);
> + std::unique_ptr OverrideMainBuffer,
> + IntrusiveRefCntPtr VFS);
>
>struct ComputedPreamble {
>  llvm::MemoryBuffer *Buffer;
> @@ -434,11 +439,13 @@ private:
>PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
>};
>ComputedPreamble ComputePreamble(CompilerInvocation &Invocation,
> -   unsigned MaxLines);
> +   unsigned MaxLines,
> +   IntrusiveRefCntPtr VFS);
>
>std::unique_ptr getMainBufferWithPrecompiledPreamble(
>std::shared_ptr PCHContainerOps,
> -  const CompilerInvocation &PreambleInvocationIn, bool AllowRebuild = 
> true,
> +  const CompilerInvocation &PreambleInvocationIn,
> +  IntrusiveRefCntPtr VFS, bool AllowRebuild = true,
>unsigned MaxLines = 0);
>void RealizeTopLevelDeclsFromPreamble();
>
> @@ -731,11 +738,17 @@ private:
>/// of this translation unit should be precompiled, to improve the 
> performance
>/// of reparsing. Set to zero to disable preambles.
>///
> +  /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note 
> that
> +  /// preamble is saved to a temporary directory on a RealFileSystem, so in 
> order
> +  /// for it to be loaded correctly, VFS should have access to it(i.e., be an
> +  /// overlay over RealFileSystem).
> +  ///
>/// \returns \c true if a catastrophic failure occurred (which means that 
> the
>/// \c ASTUnit itself is invalid), or \c false otherwise.
>bool LoadFromCompilerInvocation(
>std::shared_ptr PCHContainerOps,
> -  unsigned PrecompilePreambleAfterNParses);
> +  unsigned PrecompilePreambleAfterNParses,
> +  IntrusiveRefCntPtr VFS);
>
>  public:
>
> @@ -826,6 +839,11 @@ public:
>/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
>/// mainly to allow the caller to see the diagnostics.
>///
> +  /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note 
> that
> +  /// preamble is saved to a temporary directory on a RealFileSystem, so in 
> order
> +  /// for it to be loaded correctly, VFS should have access to it(i.e., be an
> +  /// overlay over RealFileSystem). RealFileSystem will be used if \p VFS is 
> nullptr.
> +  ///
>// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, 
> we
>// shouldn't need to specify them at construction time.
>static ASTUnit *LoadFromCommandLine(
> @@ -842,15 +860,23 @@ public:
>bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = 
> false,
>bool UserFilesAreVolatile = false, bool ForSerialization = false,
>llvm::Optional ModuleFormat = llvm::None,
> -  std::unique_ptr *ErrAST = nullptr);
> +  std::unique_ptr *ErrAST = nullptr,
> +  IntrusiveRefCntPtr VFS = nullptr);
>
>/// \brief Reparse the source files using the same command-line options 
> that
>/// were originally used to produce this translation unit.
>///
> +  /// \param VFS - A vfs::FileSystem to be used for all file accesses. Note 
> that
> +  /// preamble is saved to a temporary directory on a RealFileSystem, so in 
> order
> +  /// for it to be loaded correctly, VFS should give an access to this(i.e. 
> be an
> +  /// overlay over RealFileSystem). FileMgr->getVirtualFileSystem() will be 
> used if
> +  /// \p VFS is nullptr.
>

r303705 - [Modules] Fix overly conservative assertion for import diagnostic

2017-05-23 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue May 23 18:53:17 2017
New Revision: 303705

URL: http://llvm.org/viewvc/llvm-project?rev=303705&view=rev
Log:
[Modules] Fix overly conservative assertion for import diagnostic

We currenltly assert when want to diagnose a missing import and the decl
in question is already visible. It turns out that the decl in question
might be visible because another decl from the same module actually made
the module visible in a previous error diagnostic.

Remove the assertion and avoid re-exporting the module if it's already
visible.

rdar://problem/27975402

Differential Revision: https://reviews.llvm.org/D32828

Added:
cfe/trunk/test/Modules/Inputs/diagnose-missing-import/
cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
cfe/trunk/test/Modules/diagnose-missing-import.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=303705&r1=303704&r2=303705&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 23 18:53:17 2017
@@ -16097,7 +16097,8 @@ void Sema::ActOnModuleEnd(SourceLocation
 void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
   Module *Mod) {
   // Bail if we're not allowed to implicitly import a module here.
-  if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery)
+  if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery ||
+  VisibleModules.isVisible(Mod))
 return;
 
   // Create the implicit import declaration.

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=303705&r1=303704&r2=303705&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue May 23 18:53:17 2017
@@ -4933,8 +4933,6 @@ static NamedDecl *getDefinitionToImport(
 
 void Sema::diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
  MissingImportKind MIK, bool Recover) {
-  assert(!isVisible(Decl) && "missing import for non-hidden decl?");
-
   // Suggest importing a module providing the definition of this entity, if
   // possible.
   NamedDecl *Def = getDefinitionToImport(Decl);

Added: cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h?rev=303705&view=auto
==
--- cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h Tue May 23 
18:53:17 2017
@@ -0,0 +1,8 @@
+#ifndef A_h
+#define A_h
+
+@class NSString;
+static NSString * const xyzRiskyCloseOpenParam = @"riskyCloseParam";
+static inline void XYZLogEvent(NSString* eventName, NSString* params);
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap?rev=303705&view=auto
==
--- cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap 
(added)
+++ cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap Tue 
May 23 18:53:17 2017
@@ -0,0 +1,3 @@
+module NCI {
+  explicit module A { header "a.h" }
+}

Added: cfe/trunk/test/Modules/diagnose-missing-import.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diagnose-missing-import.m?rev=303705&view=auto
==
--- cfe/trunk/test/Modules/diagnose-missing-import.m (added)
+++ cfe/trunk/test/Modules/diagnose-missing-import.m Tue May 23 18:53:17 2017
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t 
-I%S/Inputs/diagnose-missing-import \
+// RUN:   -Werror=implicit-function-declaration -fsyntax-only \
+// RUN:   -fimplicit-module-maps -verify %s
+@import NCI;
+
+void foo() {
+  XYZLogEvent(xyzRiskyCloseOpenParam, xyzRiskyCloseOpenParam); // 
expected-error {{implicit declaration of function 'XYZLogEvent'}} 
expected-error {{declaration of 'XYZLogEvent' must be imported}} expected-error 
{{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 
'NCI.A'}} expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be 
imported from module 'NCI.A'}}
+}
+
+// expected-note@Inputs/diagnose-missing-import/a.h:5 {{previous declaration 
is here}}
+// expected-note@Inputs/diagnose-missing-import/a.h:5 {{previous d

Re: r303630 - Allow to use vfs::FileSystem for file accesses inside ASTUnit.

2017-05-24 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, May 24, 2017 at 12:18 AM, Ilya Biryukov  wrote:
> We test it in clangd (https://reviews.llvm.org/D33416).
> Logically, it's  a single change, split into two part: for cfe and
> clang-tools-extra.

I see, thanks!

>
> On Wed, May 24, 2017 at 1:48 AM, Bruno Cardoso Lopes
>  wrote:
>>
>> Any specific reason why this doesn't contain a testcase?
>>
>> On Tue, May 23, 2017 at 4:37 AM, Ilya Biryukov via cfe-commits
>>  wrote:
>> > Author: ibiryukov
>> > Date: Tue May 23 06:37:52 2017
>> > New Revision: 303630
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=303630&view=rev
>> > Log:
>> > Allow to use vfs::FileSystem for file accesses inside ASTUnit.
>> >
>> > Reviewers: bkramer, krasimir, arphaman, akyrtzi
>> >
>> > Reviewed By: bkramer
>> >
>> > Subscribers: klimek, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D33397
>> >
>> > Modified:
>> > cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > cfe/trunk/include/clang/Frontend/CompilerInvocation.h
>> > cfe/trunk/lib/Frontend/ASTUnit.cpp
>> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=303630&r1=303629&r2=303630&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
>> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 23 06:37:52 2017
>> > @@ -59,6 +59,10 @@ class TargetInfo;
>> >  class FrontendAction;
>> >  class ASTDeserializationListener;
>> >
>> > +namespace vfs {
>> > +class FileSystem;
>> > +}
>> > +
>> >  /// \brief Utility class for loading a ASTContext from an AST file.
>> >  ///
>> >  class ASTUnit : public ModuleLoader {
>> > @@ -420,7 +424,8 @@ private:
>> >explicit ASTUnit(bool MainFileIsAST);
>> >
>> >bool Parse(std::shared_ptr PCHContainerOps,
>> > - std::unique_ptr OverrideMainBuffer);
>> > + std::unique_ptr OverrideMainBuffer,
>> > + IntrusiveRefCntPtr VFS);
>> >
>> >struct ComputedPreamble {
>> >  llvm::MemoryBuffer *Buffer;
>> > @@ -434,11 +439,13 @@ private:
>> >PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
>> >};
>> >ComputedPreamble ComputePreamble(CompilerInvocation &Invocation,
>> > -   unsigned MaxLines);
>> > +   unsigned MaxLines,
>> > +   IntrusiveRefCntPtr
>> > VFS);
>> >
>> >std::unique_ptr
>> > getMainBufferWithPrecompiledPreamble(
>> >std::shared_ptr PCHContainerOps,
>> > -  const CompilerInvocation &PreambleInvocationIn, bool AllowRebuild
>> > = true,
>> > +  const CompilerInvocation &PreambleInvocationIn,
>> > +  IntrusiveRefCntPtr VFS, bool AllowRebuild =
>> > true,
>> >unsigned MaxLines = 0);
>> >void RealizeTopLevelDeclsFromPreamble();
>> >
>> > @@ -731,11 +738,17 @@ private:
>> >/// of this translation unit should be precompiled, to improve the
>> > performance
>> >/// of reparsing. Set to zero to disable preambles.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem).
>> > +  ///
>> >/// \returns \c true if a catastrophic failure occurred (which means
>> > that the
>> >/// \c ASTUnit itself is invalid), or \c false otherwise.
>> >bool LoadFromCompilerInvocation(
>> >std::shared_ptr PCHContainerOps,
>> > -  unsigned PrecompilePreambleAfterNParses);
>> > +  unsigned PrecompilePreambleAfterNParses,
>> > +  IntrusiveRefCntPtr VFS);
>> >
>> >  public:
>> >
>> > @@ -826,6 +839,11 @@ public:
>> >/// (e.g. because the PCH could not be loaded), this accepts the
>> > ASTUnit
>> >/// mainly to allow the caller to see the diagnostics.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem). RealFileSystem will be used if \p
>> > VFS is nullptr.
>> > +  ///
>> >// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the
>> > ASTUnit, we
>> >// shouldn't need to specify them at construction time.
>> >static ASTUnit *LoadFromCommandLine(
>> > @@ -842,15 +860,23 @@ public:
>> >bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies
>> > = false,
>> >bool UserFilesAreVolatile = false, bool ForSerialization = false,
>> >llvm::Optional ModuleFormat = llvm::None,
>> > -  std::un

Re: r284060 - Implement MS _BitScan intrinsics

2017-06-13 Thread Bruno Cardoso Lopes via cfe-commits
On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
 wrote:
> SGTM too. Regarding Duncan's last question -- I can't think of any such 
> customer. :) If you all think the right thing for clang to do is to infer 
> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

SGTM as well!

>
> Thanks all!
> Schwieb
>
> -Original Message-
> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
> Sent: Monday, June 12, 2017 1:55 PM
> To: Reid Kleckner 
> Cc: Saleem Abdulrasool ; Albert Gutowski 
> ; David Majnemer ; 
> cfe-commits ; Erik Schwiebert 
> 
> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>
>
>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>
>>> On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
>>> wrote:
>>> I'm worried about changing this signature all the time.  I suspect that it 
>>> will cause the following to be emitted for valid code:
>>>
>>> warning: incompatible pointer types passing 'unsigned long *' to parameter 
>>> of type 'unsigned int *' [-Wincompatible-pointer-types]
>>>
>>> Switching the signature on LP64 sounds much better to me.
>>
>> Right, we have to do this. It needs to be `long` on Windows.
>
> SGTM.  We'll go that way.

+1 here!

>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>
>> It’s probably also better to not try to infer our weird desired behavior. It 
>> should probably be controlled by a specific driver directive, like 
>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>> directive means that nobody can accidentally get this behavior if they for 
>> some reason do want LLP64 behavior with Windows intrinsics.
>
> This seems overly complicated.  Is there a customer that:
> - is on LP64,
> - is using -fms-extensions,
> - is using these intrinsics, and
> - wants them to be 64-bit longs instead of 32-bit ints?
> Put another way: who would use these intrinsics on LP64 and *not* want to 
> mimic LLP64?
>
> If everyone using the intrinsics on LP64 is going to have to specify 
> -fms-extensions-lp64-intrinsics, then we should just imply it.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284060 - Implement MS _BitScan intrinsics

2017-06-15 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
 wrote:
> On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>  wrote:
>> SGTM too. Regarding Duncan's last question -- I can't think of any such 
>> customer. :) If you all think the right thing for clang to do is to infer 
>> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

Thinking more about this; what if we mark such builtins as unsupported
for "LP64 (Darwin) + ms_extensions" and then you provide the
definitions via intrin.h (we can generate a compiler macro for this
scenario and conditionalize the include_next as we do for _MSC_VER)?
Do you use this header at all? Are there any other MS related flags
that get passed to the compiler?

> SGTM as well!
>
>>
>> Thanks all!
>> Schwieb
>>
>> -Original Message-
>> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> Sent: Monday, June 12, 2017 1:55 PM
>> To: Reid Kleckner 
>> Cc: Saleem Abdulrasool ; Albert Gutowski 
>> ; David Majnemer ; 
>> cfe-commits ; Erik Schwiebert 
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>>
>>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>>
 On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
 wrote:
 I'm worried about changing this signature all the time.  I suspect that it 
 will cause the following to be emitted for valid code:

 warning: incompatible pointer types passing 'unsigned long *' to parameter 
 of type 'unsigned int *' [-Wincompatible-pointer-types]

 Switching the signature on LP64 sounds much better to me.
>>>
>>> Right, we have to do this. It needs to be `long` on Windows.
>>
>> SGTM.  We'll go that way.
>
> +1 here!
>
>>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>>
>>> It’s probably also better to not try to infer our weird desired behavior. 
>>> It should probably be controlled by a specific driver directive, like 
>>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>>> directive means that nobody can accidentally get this behavior if they for 
>>> some reason do want LLP64 behavior with Windows intrinsics.
>>
>> This seems overly complicated.  Is there a customer that:
>> - is on LP64,
>> - is using -fms-extensions,
>> - is using these intrinsics, and
>> - wants them to be 64-bit longs instead of 32-bit ints?
>> Put another way: who would use these intrinsics on LP64 and *not* want to 
>> mimic LLP64?
>>
>> If everyone using the intrinsics on LP64 is going to have to specify 
>> -fms-extensions-lp64-intrinsics, then we should just imply it.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284060 - Implement MS _BitScan intrinsics

2017-06-19 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, Jun 16, 2017 at 5:08 PM, Duncan P. N. Exon Smith
 wrote:
>
> On Jun 16, 2017, at 11:02, Reid Kleckner  wrote:
>
> We should fix it.
>
>
> Agreed.
>
> We just need a new character code in the builtin function prototype
> encoding. Currently there is no encoding for a portable int32_t that
> magically becomes "long" on 32-bit Windows. The closest thing we have is
> 'W', which is used by Neon intrinsics to select between "long" and "long
> long". It was added in r202004.
>
>
> Yup, I saw the 'W' as well.  That's the same approach I was using in a patch
> yesterday morning (I picked lowercase L ('l'), but there may be a better
> choice).  Likely Bruno will follow up with a working patch soon (I hit some
> problems with tests and then got tied up).

Right, here it is: https://reviews.llvm.org/D34377

Let me know what you guys think!

>
> On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert 
> wrote:
>>
>> We (Office developers for Apple platforms at Microsoft) would prefer to
>> have the intrinsics work properly for LP64, as that will generate the most
>> optimal and efficient code. That said, we understand that this may be odd to
>> implement from the compiler's perspective and can work around it if the
>> intrinsics are not supported for ms-extensions+LP64. At the end of the day
>> we need the compiler to clearly adopt one of those two options, and not sit
>> somewhere in the middle as it currently does. We don't turn on any flags
>> other than -fms-extensions; we don’t attempt to define MSC_VER and we do
>> conditionalize code based on __clang__ so the code is aware it is being
>> compiled by clang vs MSVC.
>>
>> So I think we'd prefer what Duncan and Apple are offering to do, but if
>> the larger clang community thinks that is a bad idea and wants to explicitly
>> disable the intrinsics, we could live with that.
>>
>> Thanks,
>> Schwieb
>>
>> -Original Message-
>> From: Erik Schwiebert
>> Sent: Friday, June 16, 2017 8:49 AM
>> To: 'Bruno Cardoso Lopes' ; Brian Kelley
>> ; Tomasz Kukielka 
>> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits
>> 
>> Subject: RE: r284060 - Implement MS _BitScan intrinsics
>>
>> Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK
>> intrinsics headers. I'm not sure which method we'd prefer, so I'll walk down
>> the hall and ask them. Tomasz is our header maestro (because we play crazy
>> #include_next games so we can use both Windows and macOS SDKs!)
>>
>> We'll get back to you ASAP.
>>
>> Schwieb
>>
>> -Original Message-
>> From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com]
>> Sent: Thursday, June 15, 2017 4:41 PM
>> To: Erik Schwiebert 
>> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>> On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
>>  wrote:
>> > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>> >  wrote:
>> >> SGTM too. Regarding Duncan's last question -- I can't think of any such
>> >> customer. :) If you all think the right thing for clang to do is to infer
>> >> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with 
>> >> me!
>>
>> Thinking more about this; what if we mark such builtins as unsupported
>> for "LP64 (Darwin) + ms_extensions" and then you provide the
>> definitions via intrin.h (we can generate a compiler macro for this
>> scenario and conditionalize the include_next as we do for _MSC_VER)?
>> Do you use this header at all? Are there any other MS related flags
>> that get passed to the compiler?
>>
>> > SGTM as well!
>> >
>> >>
>> >> Thanks all!
>> >> Schwieb
>> >>
>> >> -Original Message-
>> >> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> >> Sent: Monday, June 12, 2017 1:55 PM
>> >> To: Reid Kleckner 
>> >> Cc: Saleem Abdulrasool ; Albert Gutowski
>> >> ; David Majnemer ;
>> >> cfe-commits ; Erik Schwiebert
>> >> 
>> >> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>> >>
>> >>
>> >>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>> >>>
>>  On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool
>>   wrote:
>>  I'm worried about changing this signature all the time.  I suspect
>>  that it will cause the following to be emitted for valid code:
>> 
>>  warning: incompatible pointer types passing 'unsigned long *' to
>>  parameter of type 'unsigned int *' [-Wincompatible-pointer-types]
>> 
>>  Switching the signature on LP64 sounds much better to me.
>> >>>
>> >>> Right, we have to do this. It needs to be `long` on Windows.
>> >>
>> >> SGTM.  We'll go that way.
>> >
>> > +1 here!
>> >
>> >>> On Jun 8, 2017, at 12:21, Erik Schwiebert 
>> >>> wrote:
>> >>>
>> >>> It’s probably also better to not try to infer our weird desired
>> >>> behavior. It should probably be controlled by a specific driver 
>> >>> directive,
>> >>> like “-fms-extensions-lp64-intrinsics” or something like that. Using a 
>> >>> new
>> >>> directive means that nobod

r305874 - Run dos2unix on ms-intrinsics-rotations.c test. NFC

2017-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Jun 20 21:20:40 2017
New Revision: 305874

URL: http://llvm.org/viewvc/llvm-project?rev=305874&view=rev
Log:
Run dos2unix on ms-intrinsics-rotations.c test. NFC

Modified:
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c?rev=305874&r1=305873&r2=305874&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c Tue Jun 20 21:20:40 2017
@@ -1,181 +1,181 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple thumbv7--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--linux -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--linux -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
-
-// rotate left
-
-unsigned char test_rotl8(unsigned char value, unsigned char shift) {
-  return _rotl8(value, shift);
-}
-// CHECK: i8 @test_rotl8
-// CHECK:   [[SHIFT:%[0-9]+]] = and i8 %{{[0-9]+}}, 7
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i8 8, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i8 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i8 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i8 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i8 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i8 [[VALUE]], i8 
[[ROTATED]]
-// CHECK:   ret i8 [[RESULT]]
-// CHECK  }
-
-unsigned short test_rotl16(unsigned short value, unsigned char shift) {
-  return _rotl16(value, shift);
-}
-// CHECK: i16 @test_rotl16
-// CHECK:   [[SHIFT:%[0-9]+]] = and i16 %{{[0-9]+}}, 15
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i16 16, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i16 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i16 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i16 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i16 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i16 [[VALUE]], i16 
[[ROTATED]]
-// CHECK:   ret i16 [[RESULT]]
-// CHECK  }
-
-unsigned int test_rotl(unsigned int value, int shift) {
-  return _rotl(value, shift);
-}
-// CHECK: i32 @test_rotl
-// CHECK:   [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 [[VALUE]], i32 
[[ROTATED]]
-// CHECK:   ret i32 [[RESULT]]
-// CHECK  }
-
-unsigned long test_lrotl(unsigned long value, int shift) {
-  return _lrotl(value, shift);
-}
-// CHECK-32BIT-LONG: i32 @test_lrotl
-// CHECK-32BIT-LONG:   [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31
-// CHECK-32BIT-LONG:   [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]]
-// CHECK-32BIT-LONG:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK-32BIT-LONG:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]]
-// CHECK-32BIT-LONG:   [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK-32BIT-LONG:   [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0
-// CHECK-32BIT-LONG:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 
[[VALUE]], i32 [[ROTATED]]
-// CHECK-32BIT-LONG:   ret i32 [[RESULT]]
-// CHECK-32BIT-LONG  }
-
-// CHECK-64BIT-LONG: i64 @test_lrotl
-// CHECK-64BIT-LONG:   [[SHIFT:%[0-9]+]] = and i64 %{{[0-9]+}}, 63
-// CHECK-64BIT-LONG:   [[NEGSHIFT:%[0-9]+]] = sub i64 64, [[SHIFT]]
-// CHECK-64BIT-LONG:   [[H

r305875 - Support MS builtins using 'long' on LP64 platforms

2017-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Jun 20 21:20:46 2017
New Revision: 305875

URL: http://llvm.org/viewvc/llvm-project?rev=305875&view=rev
Log:
Support MS builtins using 'long' on LP64 platforms

This allows for -fms-extensions to work the same on LP64. For example,
_BitScanReverse is expected to be 32-bit, matching Windows/LLP64, even
though long is 64-bit on x86_64 Darwin or Linux (LP64).

Implement this by adding a new character code 'N', which is 'int' if
the target is LP64 and the same 'L' otherwise

Differential Revision: https://reviews.llvm.org/D34377

rdar://problem/32599746

Added:
cfe/trunk/test/CodeGen/ms-intrinsics-other.c
Removed:
cfe/trunk/test/CodeGen/pr27892.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=305875&r1=305874&r2=305875&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jun 20 21:20:46 2017
@@ -52,6 +52,7 @@
 //  LL  -> long long
 //  LLL -> __int128_t (e.g. LLLi)
 //  W   -> int64_t
+//  N   -> 'int' size if target is LP64, 'L' otherwise.
 //  S   -> signed
 //  U   -> unsigned
 //  I   -> Required to constant fold to an integer constant expression.
@@ -718,11 +719,11 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn"
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
-LIBBUILTIN(_byteswap_ulong,  "ULiULi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ulong,  "UNiUNi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__exception_code, "ULi", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_exception_code,  "ULi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__exception_code, "UNi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_exception_code,  "UNi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__exception_info, "v*",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_exception_info,  "v*",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__abnormal_termination, "i", "n", ALL_MS_LANGUAGES)
@@ -730,33 +731,33 @@ LANGBUILTIN(_abnormal_termination,  "i",
 LANGBUILTIN(__GetExceptionInfo, "v*.", "ntu", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedAnd8,   "ccD*c","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedAnd16,  "ssD*s","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedAnd,"LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedAnd,"NiNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange8,   "ccD*cc", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange16,  "ssD*ss", "n", 
ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedCompareExchange,"LiLiD*LiLi", "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedCompareExchange,"NiNiD*NiNi", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange64,  "LLiLLiD*LLiLLi", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedDecrement16,"ssD*", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedDecrement,  "LiLiD*",   "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchange,   "LiLiD*Li", "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedDecrement,  "NiNiD*",   "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange,   "NiNiD*Ni", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchange8,  "ccD*c","n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchange16, "ssD*s","n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd8,   "ccD*c",  "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd16,  "ssD*s",  "n", 
ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchangeAdd,"LiLiD*Li",   "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangeAdd,"NiNiD*Ni",   "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangePointer,"v*v*D*v*",   "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeSub8,   "ccD*c","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeSub16,  "ssD*s","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchangeSub,"LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangeSub,"NiNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement16,"ssD*", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_Interl

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
Hi Richard,

Somehow this commit caused some methods in ObjC to do not become
visible in an interface when compiling with modules on. I filed
https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
changed the logic.

Thanks,

On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Wed May 17 21:29:20 2017
> New Revision: 303322
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303322&view=rev
> Log:
> [modules] Switch from inferring owning modules based on source location to
> inferring based on the current module at the point of creation.
>
> This should result in no functional change except when building a preprocessed
> module (or more generally when using #pragma clang module begin/end to switch
> module in the middle of a file), in which case it allows us to correctly track
> the owning module for declarations. We can't map from FileID to module in the
> preprocessed module case, since all modules would have the same FileID.
>
> There are still a couple of remaining places that try to infer a module from a
> source location; I'll clean those up in follow-up changes.
>
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/LangOptions.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322&r1=303321&r2=303322&view=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
> @@ -935,7 +935,7 @@ public:
>
>/// \brief Get the additional modules in which the definition \p Def has
>/// been merged.
> -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
> +  ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def) {
>  auto MergedIt = MergedDefModules.find(Def);
>  if (MergedIt == MergedDefModules.end())
>return None;
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322&r1=303321&r2=303322&view=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
> @@ -332,15 +332,15 @@ private:
>bool AccessDeclContextSanity() const;
>
>  protected:
> -
>Decl(Kind DK, DeclContext *DC, SourceLocation L)
> -: NextInContextAndBits(), DeclCtx(DC),
> -  Loc(L), DeclKind(DK), InvalidDecl(0),
> -  HasAttrs(false), Implicit(false), Used(false), Referenced(false),
> -  Access(AS_none), FromASTFile(0), Hidden(DC && cast(DC)->Hidden),
> -  IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
> -  CacheValidAndLinkage(0)
> -  {
> +  : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
> +InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
> +Referenced(false), Access(AS_none), FromASTFile(0),
> +Hidden(DC && cast(DC)->Hidden &&
> +   (!cast(DC)->isFromASTFile() ||
> +hasLocalOwningModuleStorage())),
> +IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
> +CacheValidAndLinkage(0) {
>  if (StatisticsEnabled) add(DK);
>}
>
> @@ -698,6 +698,9 @@ public:
>Module *getLocalOwningModule() const {
>  if (isFromASTFile() || !Hidden)
>return nullptr;
> +
> +assert(hasLocalOwningModuleStorage() &&
> +   "hidden local decl but no local module storage");
>  return reinterpret_cast(this)[-1];
>}
>void setLocalOwningModule(Module *M) {
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=303322&r1=303321&r2=303322&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Wed May 17 21:29:20 2017
> @@ -168,7 +168,7 @@ public:
>
>/// Do we need to track the owning module for a local declaration?
>bool trackLocalOwningModule() const {
> -return ModulesLocalVisibility;
> +return isCompilingModule() || ModulesLocalVisibility || ModulesTS;
>

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, Jun 21, 2017 at 4:44 PM, Richard Smith  wrote:
> On 21 June 2017 at 14:51, Bruno Cardoso Lopes 
> wrote:
>>
>> Hi Richard,
>>
>> Somehow this commit caused some methods in ObjC to do not become
>> visible in an interface when compiling with modules on. I filed
>> https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
>> gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
>> changed the logic.
>
>
> DeclObjC.cpp is making some incorrect assumptions about what the isHidden()
> flag on Decls means. Looks like we're going to need to move all of the ObjC
> lookup machinery out of DeclObjC into Sema to allow it to perform correct
> visibility checks. (For what it's worth, this would already have been broken
> for Objective-C++ and local submodule visibility mode prior to this change,
> as those modes both have situations where the "Hidden" flag is not the
> complete story with regard to whether a declaration is visible in a
> particular lookup context.)

Oh, that's bad.

Is there any workaround we can do on top of this change for now in
order to have the previous behavior for non-LSV and ObjC? This is
keeping Swift from building against upstream right now.

>
>>
>> Thanks,
>>
>> On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Wed May 17 21:29:20 2017
>> > New Revision: 303322
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=303322&view=rev
>> > Log:
>> > [modules] Switch from inferring owning modules based on source location
>> > to
>> > inferring based on the current module at the point of creation.
>> >
>> > This should result in no functional change except when building a
>> > preprocessed
>> > module (or more generally when using #pragma clang module begin/end to
>> > switch
>> > module in the middle of a file), in which case it allows us to correctly
>> > track
>> > the owning module for declarations. We can't map from FileID to module
>> > in the
>> > preprocessed module case, since all modules would have the same FileID.
>> >
>> > There are still a couple of remaining places that try to infer a module
>> > from a
>> > source location; I'll clean those up in follow-up changes.
>> >
>> > Modified:
>> > cfe/trunk/include/clang/AST/ASTContext.h
>> > cfe/trunk/include/clang/AST/DeclBase.h
>> > cfe/trunk/include/clang/Basic/LangOptions.h
>> > cfe/trunk/include/clang/Sema/Sema.h
>> > cfe/trunk/include/clang/Serialization/ASTWriter.h
>> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> > cfe/trunk/lib/Sema/SemaDecl.cpp
>> > cfe/trunk/lib/Sema/SemaLookup.cpp
>> > cfe/trunk/lib/Sema/SemaTemplate.cpp
>> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> > cfe/trunk/test/Modules/preprocess-module.cpp
>> > cfe/trunk/test/SemaCXX/modules-ts.cppm
>> >
>> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322&r1=303321&r2=303322&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> > +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
>> > @@ -935,7 +935,7 @@ public:
>> >
>> >/// \brief Get the additional modules in which the definition \p Def
>> > has
>> >/// been merged.
>> > -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
>> > +  ArrayRef getModulesWithMergedDefinition(const NamedDecl
>> > *Def) {
>> >  auto MergedIt = MergedDefModules.find(Def);
>> >  if (MergedIt == MergedDefModules.end())
>> >return None;
>> >
>> > Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322&r1=303321&r2=303322&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> > +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
>> > @@ -332,15 +332,15 @@ private:
>> >bool AccessDeclContextSanity() const;
>> >
>> >  protected:
>> > -
>> >Decl(Kind DK, DeclContext *DC, SourceLocation L)
>> > -: NextInContextAndBits(), DeclCtx(DC),
>> > -  Loc(L), DeclKind(DK), InvalidDecl(0),
>> > -  HasAttrs(false), Implicit(false), Used(false), Referenced(false),
>> > -  Access(AS_none), FromASTFile(0), Hidden(DC &&
>> > cast(DC)->Hidden),
>> > -  IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
>> > -  CacheValidAndLinkage(0)
>> > -  {
>> > +  : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
>> > +InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
>> > +Referenced(false), Access(AS_none), FromASTFile(0),
>> > +Hidden(DC && cast(DC)->Hidden &&
>> > +   (!cast(DC)->isFromASTFile() ||
>> > + 

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, Jun 21, 2017 at 4:56 PM, Richard Smith  wrote:
> On 21 June 2017 at 16:55, Bruno Cardoso Lopes 
> wrote:
>>
>> On Wed, Jun 21, 2017 at 4:44 PM, Richard Smith 
>> wrote:
>> > On 21 June 2017 at 14:51, Bruno Cardoso Lopes 
>> > wrote:
>> >>
>> >> Hi Richard,
>> >>
>> >> Somehow this commit caused some methods in ObjC to do not become
>> >> visible in an interface when compiling with modules on. I filed
>> >> https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
>> >> gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
>> >> changed the logic.
>> >
>> >
>> > DeclObjC.cpp is making some incorrect assumptions about what the
>> > isHidden()
>> > flag on Decls means. Looks like we're going to need to move all of the
>> > ObjC
>> > lookup machinery out of DeclObjC into Sema to allow it to perform
>> > correct
>> > visibility checks. (For what it's worth, this would already have been
>> > broken
>> > for Objective-C++ and local submodule visibility mode prior to this
>> > change,
>> > as those modes both have situations where the "Hidden" flag is not the
>> > complete story with regard to whether a declaration is visible in a
>> > particular lookup context.)
>>
>> Oh, that's bad.
>>
>> Is there any workaround we can do on top of this change for now in
>> order to have the previous behavior for non-LSV and ObjC? This is
>> keeping Swift from building against upstream right now.
>
>
> Yes, I'm working on what should (hopefully) be a fairly quick short-term
> fix.

Thanks Richard!

>
>>
>> >> Thanks,
>> >>
>> >> On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
>> >>  wrote:
>> >> > Author: rsmith
>> >> > Date: Wed May 17 21:29:20 2017
>> >> > New Revision: 303322
>> >> >
>> >> > URL: http://llvm.org/viewvc/llvm-project?rev=303322&view=rev
>> >> > Log:
>> >> > [modules] Switch from inferring owning modules based on source
>> >> > location
>> >> > to
>> >> > inferring based on the current module at the point of creation.
>> >> >
>> >> > This should result in no functional change except when building a
>> >> > preprocessed
>> >> > module (or more generally when using #pragma clang module begin/end
>> >> > to
>> >> > switch
>> >> > module in the middle of a file), in which case it allows us to
>> >> > correctly
>> >> > track
>> >> > the owning module for declarations. We can't map from FileID to
>> >> > module
>> >> > in the
>> >> > preprocessed module case, since all modules would have the same
>> >> > FileID.
>> >> >
>> >> > There are still a couple of remaining places that try to infer a
>> >> > module
>> >> > from a
>> >> > source location; I'll clean those up in follow-up changes.
>> >> >
>> >> > Modified:
>> >> > cfe/trunk/include/clang/AST/ASTContext.h
>> >> > cfe/trunk/include/clang/AST/DeclBase.h
>> >> > cfe/trunk/include/clang/Basic/LangOptions.h
>> >> > cfe/trunk/include/clang/Sema/Sema.h
>> >> > cfe/trunk/include/clang/Serialization/ASTWriter.h
>> >> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> >> > cfe/trunk/lib/Sema/SemaDecl.cpp
>> >> > cfe/trunk/lib/Sema/SemaLookup.cpp
>> >> > cfe/trunk/lib/Sema/SemaTemplate.cpp
>> >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> >> > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> >> > cfe/trunk/test/Modules/preprocess-module.cpp
>> >> > cfe/trunk/test/SemaCXX/modules-ts.cppm
>> >> >
>> >> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> >> > URL:
>> >> >
>> >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322&r1=303321&r2=303322&view=diff
>> >> >
>> >> >
>> >> > ==
>> >> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> >> > +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
>> >> > @@ -935,7 +935,7 @@ public:
>> >> >
>> >> >/// \brief Get the additional modules in which the definition \p
>> >> > Def
>> >> > has
>> >> >/// been merged.
>> >> > -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
>> >> > +  ArrayRef getModulesWithMergedDefinition(const NamedDecl
>> >> > *Def) {
>> >> >  auto MergedIt = MergedDefModules.find(Def);
>> >> >  if (MergedIt == MergedDefModules.end())
>> >> >return None;
>> >> >
>> >> > Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> >> > URL:
>> >> >
>> >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322&r1=303321&r2=303322&view=diff
>> >> >
>> >> >
>> >> > ==
>> >> > --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> >> > +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
>> >> > @@ -332,15 +332,15 @@ private:
>> >> >bool AccessDeclContextSanity() const;
>> >> >
>> >> >  protected:
>> >> > -
>> >> >Decl(Kind DK, DeclContext *DC, SourceLocation L)
>> >> > -: NextInContextAndBits(), DeclCtx(DC),
>> >> > -  L

r321337 - [Modules] Change private modules rules and warnings

2017-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 21 18:53:30 2017
New Revision: 321337

URL: http://llvm.org/viewvc/llvm-project?rev=321337&view=rev
Log:
[Modules] Change private modules rules and warnings

We used to advertise private modules to be declared as submodules
(Foo.Private). This has proven to not scale well since private headers
might carry several dependencies, introducing unwanted content into the
main module and often causing dep cycles.

Change the canonical way to name it to Foo_Private, forcing private
modules as top level ones, and provide warnings under -Wprivate-module
to suggest fixes for other private naming. Update documentation to
reflect that.

rdar://problem/31173501

Added:
cfe/trunk/test/Modules/Inputs/implicit-private-canonical/
cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Headers/a.h

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Headers/aprivate.h
  - copied, changed from r321326, 
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/PrivateHeaders/aprivate.h
  - copied, changed from r321326, 
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/PrivateHeaders/aprivate.h
  - copied, changed from r321326, 
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/
cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Headers/a.h

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Headers/aprivate.h
  - copied, changed from r321326, 
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/PrivateHeaders/aprivate.h
  - copied, changed from r321326, 
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
cfe/trunk/test/Modules/implicit-private-canonical.m
cfe/trunk/test/Modules/implicit-private-with-submodule.m
Removed:

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/add-remove-private.m
cfe/trunk/test/Modules/auto-module-import.m
cfe/trunk/test/Modules/global_index.m
cfe/trunk/test/Modules/implicit-private-with-different-name.m
cfe/trunk/test/Modules/modulemap-locations.m
cfe/trunk/test/Modules/prune.m
cfe/trunk/test/Modules/redefinition-c-tagtypes.m
cfe/trunk/test/Modules/requires-coroutines.mm
cfe/trunk/test/Modules/requires.m
cfe/trunk/test/Modules/requires.mm
cfe/trunk/test/Modules/subframework-from-intermediate-path.m
cfe/trunk/test/Modules/subframeworks.m

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=321337&r1=321336&r2=321337&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Dec 21 18:53:30 2017
@@ -859,10 +859,12 @@ express this with a single module map fi
 
   module Foo {
 header "Foo.h"
-
-explicit module Private {
-  header "Foo_Private.h"
-}
+...
+  }
+
+  module Foo_Private {
+header "Foo_Private.h"
+...
   }
 
 
@@ -873,7 +875,7 @@ build machinery.
 
 Privat

r321342 - [Modules] Map missing private submodules from Foo.Private to Foo_Private

2017-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 21 21:04:43 2017
New Revision: 321342

URL: http://llvm.org/viewvc/llvm-project?rev=321342&view=rev
Log:
[Modules] Map missing private submodules from Foo.Private to Foo_Private

In case `@import Foo.Private` fails because the submodule doesn't exist,
look for `Foo_Private` (if available) and build/load that module
instead. In that process emit a warning and tell the user about the
assumption.

The intention here is to assist all existing private modules owners
(in ObjC and Swift) to migrate to the new `Foo_Private` syntax.

rdar://problem/36023940

Added:
cfe/trunk/test/Modules/implicit-map-dot-private.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=321342&r1=321341&r2=321342&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Dec 21 
21:04:43 2017
@@ -198,6 +198,11 @@ def err_missing_module : Error<
 def err_no_submodule : Error<"no submodule named %0 in module '%1'">;
 def err_no_submodule_suggest : Error<
   "no submodule named %0 in module '%1'; did you mean '%2'?">;
+def warn_no_priv_submodule_use_toplevel : Warning<
+  "no submodule named %0 in module '%1'; using top level '%2'">,
+  InGroup;
+def note_private_top_level_defined : Note<
+  "module defined here">;
 def warn_missing_submodule : Warning<"missing submodule '%0'">,
   InGroup;
 def note_module_import_here : Note<"module imported here">;

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=321342&r1=321341&r2=321342&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Dec 21 21:04:43 2017
@@ -1854,6 +1854,7 @@ CompilerInstance::loadModule(SourceLocat
 
   // Verify that the rest of the module path actually corresponds to
   // a submodule.
+  bool MapPrivateSubModToTopLevel = false;
   if (!getLangOpts().ModulesTS && Path.size() > 1) {
 for (unsigned I = 1, N = Path.size(); I != N; ++I) {
   StringRef Name = Path[I].first->getName();
@@ -1892,7 +1893,40 @@ CompilerInstance::loadModule(SourceLocat
   Sub = Module->findSubmodule(Best[0]);
 }
   }
-  
+
+  // If the user is requesting Foo.Private and it doesn't exist, try to
+  // match Foo_Private and emit a warning asking for the user to write
+  // @import Foo_Private instead. FIXME: remove this when existing clients
+  // migrate off of Foo.Private syntax.
+  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
+  Module == Module->getTopLevelModule()) {
+SmallString<128> PrivateModule(Module->Name);
+PrivateModule.append("_Private");
+
+SmallVector, 2> PrivPath;
+auto &II = PP->getIdentifierTable().get(
+PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
+PrivPath.push_back(std::make_pair(&II, Path[0].second));
+
+if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
+  Sub =
+  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
+if (Sub) {
+  MapPrivateSubModToTopLevel = true;
+  if (!getDiagnostics().isIgnored(
+  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
+getDiagnostics().Report(Path[I].second,
+diag::warn_no_priv_submodule_use_toplevel)
+<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
+<< SourceRange(Path[0].second, Path[I].second)
+<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
+PrivateModule);
+getDiagnostics().Report(Sub->DefinitionLoc,
+diag::note_private_top_level_defined);
+  }
+}
+  }
+
   if (!Sub) {
 // No submodule by this name. Complain, and don't look for further
 // submodules.
@@ -1909,7 +1943,7 @@ CompilerInstance::loadModule(SourceLocat
   // Make the named module visible, if it's not already part of the module
   // we are parsing.
   if (ModuleName != getLangOpts().CurrentModule) {
-if (!Module->IsFromModuleFile) {
+if (!Module->IsFromModuleFile && !MapPrivateSubModToTopLevel) {
   // We have an umbrella header or directory that doesn't actually include
   // all of the headers within the directory it covers. Complain about
   // this missing submodule and recover by

r321781 - [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 18:17:40 2018
New Revision: 321781

URL: http://llvm.org/viewvc/llvm-project?rev=321781&view=rev
Log:
[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly 
found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

Differential Revision: https://reviews.llvm.org/D31269

rdar://problem/23612102

Added:
cfe/trunk/test/Modules/Inputs/shadow/
cfe/trunk/test/Modules/Inputs/shadow/A1/
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321781&r1=321780&r2=321781&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 18:17:40 
2018
@@ -94,6 +94,9 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
+def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
+def err_module_build_shadowed_submodule : Error<
+  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321781&r1=321780&r2=321781&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 18:17:40 2018
@@ -197,6 +197,9 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
+  /// \brief A module with the same name that shadows this module.
+  Module *ShadowingModule = nullptr;
+
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -375,13 +378,20 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable, this parameter
-  /// will be set to one of the requirements that is not met for use of
-  /// this module.
+  /// \param Req If this module is unavailable because of a missing 
requirement,
+  /// this parameter will be set to one of the req

r321786 - Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones"

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 23:31:24 2018
New Revision: 321786

URL: http://llvm.org/viewvc/llvm-project?rev=321786&view=rev
Log:
Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow 
implicitly found ones"

This reverts r321781 until I fix the leaks pointed out by bots:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12146
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3741

Removed:
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321786&r1=321785&r2=321786&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 23:31:24 
2018
@@ -94,9 +94,6 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
-def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
-def err_module_build_shadowed_submodule : Error<
-  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321786&r1=321785&r2=321786&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 23:31:24 2018
@@ -197,9 +197,6 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
-  /// \brief A module with the same name that shadows this module.
-  Module *ShadowingModule = nullptr;
-
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -378,20 +375,13 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable because of a missing 
requirement,
-  /// this parameter will be set to one of the requirements that is not met for
-  /// use of this module.
-  ///
-  /// \param MissingHeader If this module is unavailable because of a missing
-  /// header, this parameter will be set to one of the missing headers.
-  ///
-  /// \param ShadowingModule If this module is unavailable because it is
-  /// shadowed, this parameter will be set to the shadowing module.
+  /// \param Req If this module is unavailable, this parameter
+  /// will be set to one of the requirements that is not met for use of
+  /// this module.
   bool isAvailable(const LangOptions &LangOpts, 
const TargetInfo &Target,
Requirement &Req,
-   UnresolvedHeaderDirective &MissingHeader,
-   Module *&ShadowingModule) const;
+   UnresolvedHeaderDirective &MissingHeader) const;
 
   /// \brief Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=321786&r1=321785&r2=321786&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/He

r321855 - Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-04 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jan  4 18:33:18 2018
New Revision: 321855

URL: http://llvm.org/viewvc/llvm-project?rev=321855&view=rev
Log:
Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to 
shadow implicitly found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

Differential Revision: https://reviews.llvm.org/D31269

rdar://problem/23612102

Added:
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321855&r1=321854&r2=321855&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Jan  4 18:33:18 
2018
@@ -94,6 +94,9 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
+def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
+def err_module_build_shadowed_submodule : Error<
+  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321855&r1=321854&r2=321855&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Thu Jan  4 18:33:18 2018
@@ -197,6 +197,9 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
+  /// \brief A module with the same name that shadows this module.
+  Module *ShadowingModule = nullptr;
+
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -375,13 +378,20 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable, this parameter
-  /// will be set to one of the requirements that is not met for use of
-  /// this module.
+  /// \param Req If this module is unavailable because of a missing 
requirement,
+  /// this parameter will be set to one of the requirements that is not met for
+  /// use of this module.
+  ///
+  /// \param MissingHeader If this module is unavailable because of a missing
+  /// header, this parameter will be set to one of the missing headers.
+  ///
+  /// \param ShadowingModule If this module is unavailable because it is
+  /// shadowed, this parameter will be set to the shadowing module.
   bool isAvailable(const LangOptions &LangOpts, 
const TargetInfo &Target,
 

r321906 - Track shadow modules with a generation counter.

2018-01-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jan  5 14:13:56 2018
New Revision: 321906

URL: http://llvm.org/viewvc/llvm-project?rev=321906&view=rev
Log:
Track shadow modules with a generation counter.

This is a follow up to r321855, closing the gap between our internal shadow
modules implementation and upstream. It has been tested for longer and
provides a better approach for tracking shadow modules. Mostly NFCI.

rdar://problem/23612102

Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=321906&r1=321905&r2=321906&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri Jan  5 14:13:56 2018
@@ -726,7 +726,6 @@ private:
   LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
 bool IsSystem,
 const DirectoryEntry *Dir,
-bool IsExplicitlyProvided,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);
 

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=321906&r1=321905&r2=321906&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Jan  5 14:13:56 2018
@@ -198,16 +198,14 @@ private:
   /// header.
   llvm::DenseMap UmbrellaDirs;
 
-  /// \brief The set of modules provided explicitly (e.g. by 
-fmodule-map-file),
-  /// which are allowed to shadow other implicitly discovered modules.
-  llvm::DenseSet ExplicitlyProvidedModules;
+  /// \brief A generation counter that is used to test whether modules of the
+  /// same name may shadow or are illegal redefintions.
+  ///
+  /// Modules from earlier scopes may shadow modules from later ones.
+  /// Modules from the same scope may not have the same name.
+  unsigned CurrentModuleScopeID = 0;
 
-  bool mayShadowModuleBeingParsed(Module *ExistingModule,
-  bool IsExplicitlyProvided) {
-assert(!ExistingModule->Parent && "expected top-level module");
-return !IsExplicitlyProvided &&
-   ExplicitlyProvidedModules.count(ExistingModule);
-  }
+  llvm::DenseMap ModuleScopeIDs;
 
   /// \brief The set of attributes that can be attached to a module.
   struct Attributes {
@@ -489,9 +487,9 @@ public:
   ///
   /// \returns The found or newly-created module, along with a boolean value
   /// that will be true if the module is newly-created.
-  std::pair
-  findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
- bool IsExplicit, bool UsesExplicitModuleMapFile = false);
+  std::pair findOrCreateModule(StringRef Name, Module *Parent,
+   bool IsFramework,
+   bool IsExplicit);
 
   /// \brief Create a 'global module' for a C++ Modules TS module interface
   /// unit.
@@ -521,6 +519,19 @@ public:
   Module *createShadowedModule(StringRef Name, bool IsFramework,
Module *ShadowingModule);
 
+  /// \brief Creates a new declaration scope for module names, allowing
+  /// previously defined modules to shadow definitions from the new scope.
+  ///
+  /// \note Module names from earlier scopes will shadow names from the new
+  /// scope, which is the opposite of how shadowing works for variables.
+  void finishModuleDeclarationScope() { CurrentModuleScopeID += 1; }
+
+  bool mayShadowNewModule(Module *ExistingModule) {
+assert(!ExistingModule->Parent && "expected top-level module");
+assert(ModuleScopeIDs.count(ExistingModule) && "unknown module");
+return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID;
+  }
+
   /// \brief Retrieve the module map file containing the definition of the 
given
   /// module.
   ///
@@ -606,8 +617,6 @@ public:
   /// \brief Marks this header as being excluded from the given module.
   void excludeHeader(Module *Mod, Module::Header Header);
 
-  void setExplicitlyProvided(Module *Mod);
-
   /// \brief Parse the given module map file, and record any modules we 
   /// encounter.
   ///
@@ -634,7 +643,6 @@ public:
   /// \returns true if an error occurred, false otherwise.
   bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
   const DirectoryEntry *HomeDir,
-  bool IsExplicitlyProvided = false,
 

Re: r321855 - Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

On Mon, Jan 8, 2018 at 9:31 PM, Eric Fiselier  wrote:
> I haven't done a ton of investigation yet, but I suspect this commit is
> responsible for breaking my LLVM module selfhost build, which uses libc++ as
> the STL, and builds LLD (No bots appear to test this configuration).
>
> The error message can be found here:
> https://gist.github.com/EricWF/fb5e1d18eb1069d23788469b5fb15442
>
> I'll investigate further tomorrow, but I wanted to send this your way in
> case it looks familiar.

Haven't seen this one before, maybe because of this particular
configuration. I'm happy to help out fixing it, I can try a similar
setup and see what I get. It would be nice if you can confirm this is
the culprit commit though.


-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333718 - [Modules] Warning for module declarations lacking 'framework' qualifier

2018-05-31 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu May 31 18:26:18 2018
New Revision: 333718

URL: http://llvm.org/viewvc/llvm-project?rev=333718&view=rev
Log:
[Modules] Warning for module declarations lacking 'framework' qualifier

When a module declaration for a framework lacks the 'framework'
qualifier, the listed headers aren't found (because there's no
trigger for the special framework style path lookup) and the module
is silently not built. This leads to frameworks not being modularized
by accident, which is pretty bad.

Add a warning and suggest the user to add the 'framework' qualifier
when we can prove that it's the case.

rdar://problem/39193062

Added:
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/Foo.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/FooB.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/module.modulemap
cfe/trunk/test/Modules/incomplete-framework-module.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=333718&r1=333717&r2=333718&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu May 31 18:26:18 2018
@@ -285,6 +285,8 @@ def IncompatiblePointerTypes
 [IncompatiblePointerTypesDiscardsQualifiers,
  IncompatibleFunctionPointerTypes]>;
 def IncompleteUmbrella : DiagGroup<"incomplete-umbrella">;
+def IncompleteFrameworkModuleDeclaration
+  : DiagGroup<"incomplete-framework-module-declaration">;
 def NonModularIncludeInFrameworkModule
   : DiagGroup<"non-modular-include-in-framework-module">;
 def NonModularIncludeInModule : DiagGroup<"non-modular-include-in-module",

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=333718&r1=333717&r2=333718&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu May 31 18:26:18 2018
@@ -694,6 +694,11 @@ def warn_mmap_mismatched_private_module_
   InGroup;
 def note_mmap_rename_top_level_private_module : Note<
   "rename '%0' to ensure it can be found by name">;
+def warn_mmap_incomplete_framework_module_declaration : Warning<
+  "skipping '%0' because module declaration of '%1' lacks the 'framework' 
qualifier">,
+  InGroup;
+def note_mmap_add_framework_keyword : Note<
+  "use 'framework module' to declare module '%0'">;
 
 def err_mmap_duplicate_header_attribute : Error<
   "header attribute '%0' specified multiple times">;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=333718&r1=333717&r2=333718&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Thu May 31 18:26:18 2018
@@ -303,8 +303,15 @@ private:
   Module *resolveModuleId(const ModuleId &Id, Module *Mod, bool Complain) 
const;
 
   /// Add an unresolved header to a module.
+  ///
+  /// \param Mod The module in which we're adding the unresolved header
+  ///directive.
+  /// \param Header The unresolved header directive.
+  /// \param NeedsFramework If Mod is not a framework but a missing header 
would
+  ///be found in case Mod was, set it to true. False otherwise.
   void addUnresolvedHeader(Module *Mod,
-   Module::UnresolvedHeaderDirective Header);
+   Module::UnresolvedHeaderDirective Header,
+   bool &NeedsFramework);
 
   /// Look up the given header directive to find an actual header file.
   ///
@@ -312,14 +319,22 @@ private:
   /// \param Header The header directive to resolve.
   /// \param RelativePathName Filled in with the relative path name from the
   ///module to the resolved header.
+  /// \param NeedsFramework If M is not a framework but a missing header would
+  ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
   const FileEntry *findHeader(Module *M,
  

r334747 - [CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

2018-06-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jun 14 11:20:04 2018
New Revision: 334747

URL: http://llvm.org/viewvc/llvm-project?rev=334747&view=rev
Log:
[CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools
installed, we currently get the include path for libxml2 as
/usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2.

Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when
possible.

rdar://problem/41103601

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=334747&r1=334746&r2=334747&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Thu Jun 14 11:20:04 2018
@@ -40,7 +40,11 @@ set_target_properties(c-index-test
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
+include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
+  else()
+include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  endif()
   target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
 endif()
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334859 - [Modules] Improve .Private fix-its to handle 'explicit' and 'framework'

2018-06-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 15 13:13:28 2018
New Revision: 334859

URL: http://llvm.org/viewvc/llvm-project?rev=334859&view=rev
Log:
[Modules] Improve .Private fix-its to handle 'explicit' and 'framework'

When in the context of suggestion the fix-it from .Private to _Private
for private modules, trim off the 'explicit' and add 'framework' when
appropriate.

rdar://problem/41030554

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/implicit-private-with-submodule.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=334859&r1=334858&r2=334859&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Jun 15 13:13:28 2018
@@ -1403,6 +1403,13 @@ namespace clang {
 void parseConflict();
 void parseInferredModuleDecl(bool Framework, bool Explicit);
 
+/// Private modules are canonicalized as Foo_Private. Clang provides extra
+/// module map search logic to find the appropriate private module when PCH
+/// is used with implicit module maps. Warn when private modules are 
written
+/// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
+void diagnosePrivateModules(SourceLocation ExplicitLoc,
+SourceLocation FrameworkLoc);
+
 using Attributes = ModuleMap::Attributes;
 
 bool parseOptionalAttributes(Attributes &Attrs);
@@ -1672,11 +1679,8 @@ namespace {
 /// module map search logic to find the appropriate private module when PCH
 /// is used with implicit module maps. Warn when private modules are written
 /// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
-static void diagnosePrivateModules(const ModuleMap &Map,
-   DiagnosticsEngine &Diags,
-   const Module *ActiveModule,
-   SourceLocation InlineParent) {
-
+void ModuleMapParser::diagnosePrivateModules(SourceLocation ExplicitLoc,
+ SourceLocation FrameworkLoc) {
   auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
  const Module *M, SourceRange ReplLoc) {
 auto D = Diags.Report(ActiveModule->DefinitionLoc,
@@ -1693,6 +1697,7 @@ static void diagnosePrivateModules(const
 SmallString<128> FullName(ActiveModule->getFullModuleName());
 if (!FullName.startswith(M->Name) && !FullName.endswith("Private"))
   continue;
+SmallString<128> FixedPrivModDecl;
 SmallString<128> Canonical(M->Name);
 Canonical.append("_Private");
 
@@ -1702,8 +1707,20 @@ static void diagnosePrivateModules(const
   Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_submodule)
   << FullName;
-  GenNoteAndFixIt(FullName, Canonical, M,
-  SourceRange(InlineParent, ActiveModule->DefinitionLoc));
+
+  SourceLocation FixItInitBegin = CurrModuleDeclLoc;
+  if (FrameworkLoc.isValid())
+FixItInitBegin = FrameworkLoc;
+  if (ExplicitLoc.isValid())
+FixItInitBegin = ExplicitLoc;
+
+  if (FrameworkLoc.isValid() || ActiveModule->Parent->IsFramework)
+FixedPrivModDecl.append("framework ");
+  FixedPrivModDecl.append("module ");
+  FixedPrivModDecl.append(Canonical);
+
+  GenNoteAndFixIt(FullName, FixedPrivModDecl, M,
+  SourceRange(FixItInitBegin, 
ActiveModule->DefinitionLoc));
   continue;
 }
 
@@ -1747,6 +1764,7 @@ void ModuleMapParser::parseModuleDecl()
 
   // Parse 'explicit' or 'framework' keyword, if present.
   SourceLocation ExplicitLoc;
+  SourceLocation FrameworkLoc;
   bool Explicit = false;
   bool Framework = false;
 
@@ -1758,7 +1776,7 @@ void ModuleMapParser::parseModuleDecl()
 
   // Parse 'framework' keyword, if present.
   if (Tok.is(MMToken::FrameworkKeyword)) {
-consumeToken();
+FrameworkLoc = consumeToken();
 Framework = true;
   } 
   
@@ -1800,7 +1818,6 @@ void ModuleMapParser::parseModuleDecl()
   }
   
   Module *PreviousActiveModule = ActiveModule;  
-  SourceLocation LastInlineParentLoc = SourceLocation();
   if (Id.size() > 1) {
 // This module map defines a submodule. Go find the module of which it
 // is a submodule.
@@ -1811,7 +1828,6 @@ void ModuleMapParser::parseModuleDecl()
 if (I == 0)
   TopLevelModule = Next;
 ActiveModule = Next;
-LastInlineParentLoc = Id[I].second;
 continue;
   }
   
@@ -1934,7 +1950,7 @@ void ModuleMapParser::parseModuleDecl()
   !Diags.isIgnored(diag::warn_mmap_mismatched_private_mo

r335177 - Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 14:16:37 2018
New Revision: 335177

URL: http://llvm.org/viewvc/llvm-project?rev=335177&view=rev
Log:
Add python tool to dump and construct header maps

Header maps are binary files used by Xcode, which are used to map
header names or paths to other locations. Clang has support for
those since its inception, but there's not a lot of header map
testing around.

Since it's a binary format, testing becomes pretty much brittle
and its hard to even know what's inside if you don't have the
appropriate tools.

Add a python based tool that allows creating and dumping header
maps based on a json description of those. While here, rewrite
tests to use the tool and remove the binary files from the tree.

This tool was initially written by Daniel Dunbar.

Differential Revision: https://reviews.llvm.org/D46485

rdar://problem/39994722

Added:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
cfe/trunk/utils/hmaptool/
cfe/trunk/utils/hmaptool/CMakeLists.txt
cfe/trunk/utils/hmaptool/hmaptool   (with props)
Removed:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Preprocessor/headermap-rel.c
cfe/trunk/test/Preprocessor/headermap-rel2.c
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=335177&r1=335176&r2=335177&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jun 20 14:16:37 2018
@@ -753,6 +753,7 @@ endif()
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
   add_subdirectory(utils/ClangVisualizers)
 endif()
+add_subdirectory(utils/hmaptool)
 
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=335177&r1=335176&r2=335177&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun 20 14:16:37 2018
@@ -54,6 +54,7 @@ list(APPEND CLANG_TEST_DEPS
   clang-rename
   clang-refactor
   clang-diff
+  hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335177&r1=335176&r2=335177&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Wed Jun 20 14:16:37 2018
@@ -1,15 +1,9 @@
 // REQUIRES: crash-recovery, shell, system-darwin
 
-// This uses a headermap with this entry:
-//   Foo.h -> Foo/Foo.h
-
-// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid
-// adding another binary format to the repository.
-
 // RUN: rm -rf %t
-// RUN: mkdir -p %t/m
-// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i
+// RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
 // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
+// RUN: hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json 
%t/i/foo.hmap
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap?rev=335176&view=auto
==
Binary files cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(original) and cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(removed) differ

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json?rev=335177&view=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json (added)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json Wed Jun 20 
14:16:37 2018
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Foo.h" : "Foo/Foo.h"
+}
+}

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/he

r335184 - Warning for framework headers using double quote includes

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 15:11:59 2018
New Revision: 335184

URL: http://llvm.org/viewvc/llvm-project?rev=335184&view=rev
Log:
Warning for framework headers using double quote includes

Introduce -Wquoted-include-in-framework-header, which should fire a warning
whenever a quote include appears in a framework header and suggest a fix-it.
For instance, for header A.h added in the tests, this is how the warning looks
like:

./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "A0.h"
 ^~
 
./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "B.h"
 ^
 

This helps users to prevent frameworks from using local headers when in fact
they should be targetting system level ones.

The warning is off by default.

Differential Revision: https://reviews.llvm.org/D47157

rdar://problem/37077034

Added:
cfe/trunk/test/Modules/Inputs/double-quotes/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/B.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/

cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml
cfe/trunk/test/Modules/double-quotes.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335184&r1=335183&r2=335184&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jun 20 15:11:59 2018
@@ -31,6 +31,7 @@ def AutoDisableVptrSanitizer : DiagGroup
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
+def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335184&r1=335183&r2=335184&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Jun 20 15:11:59 2018
@@ -714,6 +714,11 @@ def warn_mmap_redundant_export_as : Warn
 def err_mmap_submodule_export_as : Error<
   "only top-level modules can be re-exported as public">;
 
+def warn_quoted_include_in_framework_header : Warning<
+  "double-quoted include \"%0\" in framework header, "
+  "expected angle-bracketed instead"
+  >, InGroup, DefaultIgnore;
+
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "
   "import of module '%1'">, InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335184&r1=335183&r2=335184&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Jun 20 15:11:59 2018
@@ -621,6 +621,59 @@ static const char *copyString(StringRef
   return CopyStr;
 }
 
+static bool isFrameworkStylePath(StringRef Path,
+ SmallVectorImpl &FrameworkName) {
+  using namespace llvm::sys;
+  path::const

Re: [PATCH] D46485: Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Hi Stella,

On Wed, Jun 20, 2018 at 3:44 PM Stella Stamenova via Phabricator
 wrote:
>
> stella.stamenova added a comment.
>
> This breaks the clang tests on Windows when building using Visual Studio as 
> none of the updated tests can find hmaptool.

Yes. I contacted Galina about that but maybe it was the wrong person
to contact.

> Visual Studio as a generator supports multiple configurations, so its bin 
> folder varies depending on the build configuration. The generalized version 
> of the bin directory is: ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin. This is 
> actually the proper bin directory to use for any generator because 
> ${CMAKE_CFG_INTDIR} is simply '.' when the generator (such as ninja) doesn't 
> support multiple configurations.

Good to know.

> I can look into a fix and submit a change for review tomorrow if you can't, 
> but in the future please make sure to use the full path to the bin directory 
> (${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) to avoid missing a generator.

I'll try to fix it now. Thanks for the heads up!

>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D46485
>
>
>


-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335190 - Fix hmaptool cmake file to work on Windows

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 16:08:43 2018
New Revision: 335190

URL: http://llvm.org/viewvc/llvm-project?rev=335190&view=rev
Log:
Fix hmaptool cmake file to work on Windows

Unbreak a few windows buildbots:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11315
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10411/steps/test-check-all/logs/stdio

Modified:
cfe/trunk/utils/hmaptool/CMakeLists.txt

Modified: cfe/trunk/utils/hmaptool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/hmaptool/CMakeLists.txt?rev=335190&r1=335189&r2=335190&view=diff
==
--- cfe/trunk/utils/hmaptool/CMakeLists.txt (original)
+++ cfe/trunk/utils/hmaptool/CMakeLists.txt Wed Jun 20 16:08:43 2018
@@ -1,14 +1,14 @@
 set(CLANG_HMAPTOOL hmaptool)
 
-add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL}
+add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL}
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/bin
+ ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL}
- ${CMAKE_BINARY_DIR}/bin/
+ ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
 
-list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL})
+list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
 install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
 
 add_custom_target(hmaptool ALL DEPENDS ${Depends})


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D46485: Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Attempted a fix in r335190, watching the bots.
On Wed, Jun 20, 2018 at 3:53 PM Bruno Cardoso Lopes
 wrote:
>
> Hi Stella,
>
> On Wed, Jun 20, 2018 at 3:44 PM Stella Stamenova via Phabricator
>  wrote:
> >
> > stella.stamenova added a comment.
> >
> > This breaks the clang tests on Windows when building using Visual Studio as 
> > none of the updated tests can find hmaptool.
>
> Yes. I contacted Galina about that but maybe it was the wrong person
> to contact.
>
> > Visual Studio as a generator supports multiple configurations, so its bin 
> > folder varies depending on the build configuration. The generalized version 
> > of the bin directory is: ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin. This 
> > is actually the proper bin directory to use for any generator because 
> > ${CMAKE_CFG_INTDIR} is simply '.' when the generator (such as ninja) 
> > doesn't support multiple configurations.
>
> Good to know.
>
> > I can look into a fix and submit a change for review tomorrow if you can't, 
> > but in the future please make sure to use the full path to the bin 
> > directory (${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) to avoid missing a 
> > generator.
>
> I'll try to fix it now. Thanks for the heads up!
>
> >
> >
> > Repository:
> >   rC Clang
> >
> > https://reviews.llvm.org/D46485
> >
> >
> >
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D46485: Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, Jun 20, 2018 at 5:42 PM Stella Stamenova  wrote:
>
> Thanks Bruno,
>
> I ran a build as well and I can see that hmaptool is now in the correct bin 
> directory. The tests still failed though because on Windows, at least, you 
> need to explicitly call python to run a script e.g. "python hmaptool".
>
> There are a few tests in LLVM that do that, for example:
>
> ; RUN: %python -c "print(' ' * 65536)" > %t.cache/llvmcache-foo
>
> I am not sure whether you can simply call python on hmaptool or if you would 
> have to include the fullpath to it though.

Oh, I see. I'll revert the commits while I find a solution for this.
Any chance you can give it a try before I re-commit if I send you an
updated patch?

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335194 - Revert "Fix hmaptool cmake file to work on Windows"

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 18:23:42 2018
New Revision: 335194

URL: http://llvm.org/viewvc/llvm-project?rev=335194&view=rev
Log:
Revert "Fix hmaptool cmake file to work on Windows"

This reverts commit 63711c3cd337a0d22617579a904af07481139611, due to
breaking bots:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11315
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10411/steps/test-check-all/logs/stdio

Modified:
cfe/trunk/utils/hmaptool/CMakeLists.txt

Modified: cfe/trunk/utils/hmaptool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/hmaptool/CMakeLists.txt?rev=335194&r1=335193&r2=335194&view=diff
==
--- cfe/trunk/utils/hmaptool/CMakeLists.txt (original)
+++ cfe/trunk/utils/hmaptool/CMakeLists.txt Wed Jun 20 18:23:42 2018
@@ -1,14 +1,14 @@
 set(CLANG_HMAPTOOL hmaptool)
 
-add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL}
+add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL}
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin
+ ${CMAKE_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL}
- ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/
+ ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
 
-list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
+list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL})
 install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
 
 add_custom_target(hmaptool ALL DEPENDS ${Depends})


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335195 - Revert "Warning for framework headers using double quote includes"

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 18:23:51 2018
New Revision: 335195

URL: http://llvm.org/viewvc/llvm-project?rev=335195&view=rev
Log:
Revert "Warning for framework headers using double quote includes"

This reverts commit 9b5ff2db7e31c4bb11a7d468260b068b41c7c285.

Broke bots:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11315
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10411/steps/test-check-all/logs/stdio

Removed:
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h

cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/B.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h

cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml
cfe/trunk/test/Modules/double-quotes.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335195&r1=335194&r2=335195&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jun 20 18:23:51 2018
@@ -31,7 +31,6 @@ def AutoDisableVptrSanitizer : DiagGroup
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
-def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335195&r1=335194&r2=335195&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Jun 20 18:23:51 2018
@@ -714,11 +714,6 @@ def warn_mmap_redundant_export_as : Warn
 def err_mmap_submodule_export_as : Error<
   "only top-level modules can be re-exported as public">;
 
-def warn_quoted_include_in_framework_header : Warning<
-  "double-quoted include \"%0\" in framework header, "
-  "expected angle-bracketed instead"
-  >, InGroup, DefaultIgnore;
-
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "
   "import of module '%1'">, InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335195&r1=335194&r2=335195&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Jun 20 18:23:51 2018
@@ -621,59 +621,6 @@ static const char *copyString(StringRef
   return CopyStr;
 }
 
-static bool isFrameworkStylePath(StringRef Path,
- SmallVectorImpl &FrameworkName) {
-  using namespace llvm::sys;
-  path::const_iterator I = path::begin(Path);
-  path::const_iterator E = path::end(Path);
-
-  // Detect different types of framework style paths:
-  //
-  //   ...Foo.framework/{Headers,PrivateHeaders}
-  //   ...Foo.framework/Versions/{A,Current}/{Headers,PrivateHeaders}
-  //   ...Foo.framework/Frameworks/Nested.framework/{Headers,PrivateHeaders}
-  //   ...
-  //
-  // and some other variations among these lines.
-  int FoundComp = 0;
-  while (I != E) {
-if (I->endswith(".framework")) {
-  FrameworkName.append(I->begin(), I->end());
-  ++FoundComp;
-}
-if (*I == "Headers" || *I == "PrivateHeaders")
-  ++FoundComp;
-++I;
-  }
-
-  return FoundComp >= 2;
-}
-
-static void
-diagnoseFrameworkInclude(DiagnosticsEngine &Diags, SourceLocation IncludeLoc,
- StringRef Includer, StringRef IncludeFilename,
- const FileEntry *IncludeFE, bool isAngled = false,
- bool FoundByHeaderMap = false) {
-  SmallString<128> FromFramework, ToFramework;
-  if (!isFrameworkStylePath(Includer, FromFramework))
-return;
-  bool IsIncludeeInFr

r335196 - Revert "Add python tool to dump and construct header maps"

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 18:23:58 2018
New Revision: 335196

URL: http://llvm.org/viewvc/llvm-project?rev=335196&view=rev
Log:
Revert "Add python tool to dump and construct header maps"

This reverts commit fcfa2dd517ec1a6045a81e8247e346d630a22618.

Broke bots:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11315
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10411/steps/test-check-all/logs/stdio

Added:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
Removed:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
cfe/trunk/utils/hmaptool/CMakeLists.txt
cfe/trunk/utils/hmaptool/hmaptool
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Preprocessor/headermap-rel.c
cfe/trunk/test/Preprocessor/headermap-rel2.c
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=335196&r1=335195&r2=335196&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jun 20 18:23:58 2018
@@ -753,7 +753,6 @@ endif()
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
   add_subdirectory(utils/ClangVisualizers)
 endif()
-add_subdirectory(utils/hmaptool)
 
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=335196&r1=335195&r2=335196&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun 20 18:23:58 2018
@@ -54,7 +54,6 @@ list(APPEND CLANG_TEST_DEPS
   clang-rename
   clang-refactor
   clang-diff
-  hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335196&r1=335195&r2=335196&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Wed Jun 20 18:23:58 2018
@@ -1,9 +1,15 @@
 // REQUIRES: crash-recovery, shell, system-darwin
 
+// This uses a headermap with this entry:
+//   Foo.h -> Foo/Foo.h
+
+// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid
+// adding another binary format to the repository.
+
 // RUN: rm -rf %t
-// RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
+// RUN: mkdir -p %t/m
+// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i
 // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
-// RUN: hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json 
%t/i/foo.hmap
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap?rev=335196&view=auto
==
Binary files cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap (added) 
and cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap Wed Jun 20 
18:23:58 2018 differ

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json?rev=335195&view=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json (original)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json (removed)
@@ -1,6 +0,0 @@
-{
-  "mappings" :
-{
- "Foo.h" : "Foo/Foo.h"
-}
-}

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap?rev=335196&view=auto
==
Binary files 
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap (added) 
and cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap Wed 
Jun 20 18:23:58 2018 differ

Removed: 
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
URL: 
http://llvm.org/viewvc/llvm-

r335295 - Re-apply: Add python tool to dump and construct header maps

2018-06-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jun 21 14:45:24 2018
New Revision: 335295

URL: http://llvm.org/viewvc/llvm-project?rev=335295&view=rev
Log:
Re-apply: Add python tool to dump and construct header maps

Header maps are binary files used by Xcode, which are used to map
header names or paths to other locations. Clang has support for
those since its inception, but there's not a lot of header map
testing around.

Since it's a binary format, testing becomes pretty much brittle
and its hard to even know what's inside if you don't have the
appropriate tools.

Add a python based tool that allows creating and dumping header
maps based on a json description of those. While here, rewrite
tests to use the tool and remove the binary files from the tree.

This tool was initially written by Daniel Dunbar.

Thanks to Stella Stamenova for helping make this work on Windows.

Differential Revision: https://reviews.llvm.org/D46485

rdar://problem/39994722

Added:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
cfe/trunk/utils/hmaptool/CMakeLists.txt
cfe/trunk/utils/hmaptool/hmaptool   (with props)
Removed:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Preprocessor/headermap-rel.c
cfe/trunk/test/Preprocessor/headermap-rel2.c
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=335295&r1=335294&r2=335295&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jun 21 14:45:24 2018
@@ -753,6 +753,7 @@ endif()
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
   add_subdirectory(utils/ClangVisualizers)
 endif()
+add_subdirectory(utils/hmaptool)
 
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=335295&r1=335294&r2=335295&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Jun 21 14:45:24 2018
@@ -54,6 +54,7 @@ list(APPEND CLANG_TEST_DEPS
   clang-rename
   clang-refactor
   clang-diff
+  hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335295&r1=335294&r2=335295&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Thu Jun 21 14:45:24 2018
@@ -1,15 +1,9 @@
 // REQUIRES: crash-recovery, shell, system-darwin
 
-// This uses a headermap with this entry:
-//   Foo.h -> Foo/Foo.h
-
-// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid
-// adding another binary format to the repository.
-
 // RUN: rm -rf %t
-// RUN: mkdir -p %t/m
-// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i
+// RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
 // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
+// RUN: '%python' hmaptool write 
%S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap?rev=335294&view=auto
==
Binary files cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(original) and cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(removed) differ

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json?rev=335295&view=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json (added)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json Thu Jun 21 
14:45:24 2018
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Foo.h" : "Foo/Foo.h"
+}
+}

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-heade

Re: r335330 - [hmaptool] Turn %hmaptool into a proper substitution

2018-06-22 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Ben!
On Fri, Jun 22, 2018 at 2:51 AM Benjamin Kramer via cfe-commits
 wrote:
>
> Author: d0k
> Date: Fri Jun 22 02:46:40 2018
> New Revision: 335330
>
> URL: http://llvm.org/viewvc/llvm-project?rev=335330&view=rev
> Log:
> [hmaptool] Turn %hmaptool into a proper substitution
>
> This is still super ugly, but at least it doesn't require working
> directories to just line up perfectly for python to find the tool.
>
> Modified:
> cfe/trunk/test/Modules/crash-vfs-headermaps.m
> cfe/trunk/test/Preprocessor/headermap-rel.c
> cfe/trunk/test/Preprocessor/headermap-rel2.c
> cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
> cfe/trunk/test/lit.cfg.py
>
> Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335330&r1=335329&r2=335330&view=diff
> ==
> --- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
> +++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Fri Jun 22 02:46:40 2018
> @@ -3,7 +3,7 @@
>  // RUN: rm -rf %t
>  // RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
>  // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
> -// RUN: '%python' hmaptool write 
> %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap
> +// RUN: %hmaptool write 
> %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json %t/i/foo.hmap
>
>  // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
>  // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \
>
> Modified: cfe/trunk/test/Preprocessor/headermap-rel.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel.c?rev=335330&r1=335329&r2=335330&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/headermap-rel.c (original)
> +++ cfe/trunk/test/Preprocessor/headermap-rel.c Fri Jun 22 02:46:40 2018
> @@ -1,5 +1,5 @@
>  // RUN: rm -f %t.hmap
> -// RUN: '%python' hmaptool write %S/Inputs/headermap-rel/foo.hmap.json 
> %t.hmap
> +// RUN: %hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap
>  // RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel
>  // RUN: FileCheck %s -input-file %t.i
>
>
> Modified: cfe/trunk/test/Preprocessor/headermap-rel2.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel2.c?rev=335330&r1=335329&r2=335330&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/headermap-rel2.c (original)
> +++ cfe/trunk/test/Preprocessor/headermap-rel2.c Fri Jun 22 02:46:40 2018
> @@ -1,5 +1,5 @@
>  // RUN: rm -f %t.hmap
> -// RUN: '%python' hmaptool write 
> %S/Inputs/headermap-rel2/project-headers.hmap.json %t.hmap
> +// RUN: %hmaptool write %S/Inputs/headermap-rel2/project-headers.hmap.json 
> %t.hmap
>  // RUN: %clang_cc1 -v -fsyntax-only %s -iquote %t.hmap -isystem 
> %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H
>  // RUN: %clang_cc1 -fsyntax-only %s -iquote %t.hmap -isystem 
> %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> 
> %t.out
>  // RUN: FileCheck %s -input-file %t.out
>
> Modified: cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c?rev=335330&r1=335329&r2=335330&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c (original)
> +++ cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Fri Jun 22 
> 02:46:40 2018
> @@ -1,5 +1,5 @@
>  // RUN: rm -f %t.hmap
> -// RUN: '%python' hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json 
> %t.hmap
> +// RUN: %hmaptool write %S/Inputs/nonportable-hmaps/foo.hmap.json %t.hmap
>  // RUN: %clang_cc1 -Eonly\
>  // RUN:   -I%t.hmap \
>  // RUN:   -I%S/Inputs/nonportable-hmaps  \
>
> Modified: cfe/trunk/test/lit.cfg.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=335330&r1=335329&r2=335330&view=diff
> ==
> --- cfe/trunk/test/lit.cfg.py (original)
> +++ cfe/trunk/test/lit.cfg.py Fri Jun 22 02:46:40 2018
> @@ -58,7 +58,7 @@ tool_dirs = [config.clang_tools_dir, con
>
>  tools = [
>  'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 
> 'clang-tblgen',
> -'opt', 'hmaptool',
> +'opt',
>  ToolSubst('%clang_func_map', command=FindTool(
>  'clang-func-mapping'), unresolved='ignore'),
>  ]
> @@ -69,6 +69,10 @@ if config.clang_examples:
>
>  llvm_config.add_tool_substitutions(tools, tool_dirs)
>
> +config.substitutions.append(
> +('%hmaptool', '%s %s' % (config.python_executable,
> +  

r335375 - Re-apply: Warning for framework headers using double quote includes

2018-06-22 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 22 11:05:17 2018
New Revision: 335375

URL: http://llvm.org/viewvc/llvm-project?rev=335375&view=rev
Log:
Re-apply: Warning for framework headers using double quote includes

Introduce -Wquoted-include-in-framework-header, which should fire a warning
whenever a quote include appears in a framework header and suggest a fix-it.
For instance, for header A.h added in the tests, this is how the warning looks
like:

./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "A0.h"
 ^~
 
./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "B.h"
 ^
 

This helps users to prevent frameworks from using local headers when in fact
they should be targetting system level ones.

The warning is off by default.

Differential Revision: https://reviews.llvm.org/D47157

rdar://problem/37077034

Added:
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h

cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/B.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h

cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml
cfe/trunk/test/Modules/double-quotes.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335375&r1=335374&r2=335375&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun 22 11:05:17 2018
@@ -31,6 +31,7 @@ def AutoDisableVptrSanitizer : DiagGroup
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
+def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335375&r1=335374&r2=335375&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun 22 11:05:17 2018
@@ -714,6 +714,11 @@ def warn_mmap_redundant_export_as : Warn
 def err_mmap_submodule_export_as : Error<
   "only top-level modules can be re-exported as public">;
 
+def warn_quoted_include_in_framework_header : Warning<
+  "double-quoted include \"%0\" in framework header, "
+  "expected angle-bracketed instead"
+  >, InGroup, DefaultIgnore;
+
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "
   "import of module '%1'">, InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335375&r1=335374&r2=335375&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Jun 22 11:05:17 2018
@@ -621,6 +621,59 @@ static const char *copyString(StringRef
   return CopyStr;
 }
 
+static bool isFrameworkStylePath(StringRef Path,
+ SmallVectorImpl &FrameworkName) {
+  using namespace llvm::sys;
+  path::const_iterator I = path::begin(Path);
+  path::const_iterator E = path::end(Path);
+
+  // Detect different types of framework style paths:
+  //
+  //   ...Foo.framework/{Headers,PrivateHeaders}
+  //   ...Foo.framework/Versions/{A,Current}/{Headers,PrivateHeaders}
+  //   ...Foo.framework/Frameworks/Nested.framework/{Headers,PrivateHeaders}
+  //   ...
+  //
+  // and some other variations among these lines.
+  int FoundComp = 0;
+  while (I != E) {
+if (I->endswith(".framework")) {
+  Framewo

Re: r335375 - Re-apply: Warning for framework headers using double quote includes

2018-06-22 Thread Bruno Cardoso Lopes via cfe-commits
Hi Nico,

> Why not enable it by default, or put it in -Wall at least? We don't like 
> off-by-default warnings :-)

Thanks for double checking. There's an explanation/discussion in the
review: https://reviews.llvm.org/D47157, let me know if you have
additional questions.

Cheers,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348789 - [constexpr][c++2a] Try-catch blocks in constexpr functions

2018-12-10 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Dec 10 11:03:12 2018
New Revision: 348789

URL: http://llvm.org/viewvc/llvm-project?rev=348789&view=rev
Log:
[constexpr][c++2a] Try-catch blocks in constexpr functions

Implement support for try-catch blocks in constexpr functions, as
proposed in http://wg21.link/P1002 and voted in San Diego for c++20.

The idea is that we can still never throw inside constexpr, so the catch
block is never entered. A try-catch block like this:

try { f(); } catch (...) { }

is then morally equivalent to just

{ f(); }

Same idea should apply for function/constructor try blocks.

rdar://problem/45530773

Differential Revision: https://reviews.llvm.org/D55097

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348789&r1=348788&r2=348789&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec 10 11:03:12 
2018
@@ -2357,6 +2357,13 @@ def warn_cxx11_compat_constexpr_body_inv
   "use of this statement in a constexpr %select{function|constructor}0 "
   "is incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;
+def ext_constexpr_body_invalid_stmt_cxx2a : ExtWarn<
+  "use of this statement in a constexpr %select{function|constructor}0 "
+  "is a C++2a extension">, InGroup;
+def warn_cxx17_compat_constexpr_body_invalid_stmt : Warning<
+  "use of this statement in a constexpr %select{function|constructor}0 "
+  "is incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_constexpr_type_definition : ExtWarn<
   "type definition in a constexpr %select{function|constructor}0 "
   "is a C++14 extension">, InGroup;
@@ -2409,6 +2416,16 @@ def note_constexpr_body_previous_return
   "previous return statement is here">;
 def err_constexpr_function_try_block : Error<
   "function try block not allowed in constexpr 
%select{function|constructor}0">;
+
+// c++2a function try blocks in constexpr
+def ext_constexpr_function_try_block_cxx2a : ExtWarn<
+  "function try block in constexpr %select{function|constructor}0 is "
+  "a C++2a extension">, InGroup;
+def warn_cxx17_compat_constexpr_function_try_block : Warning<
+  "function try block in constexpr %select{function|constructor}0 is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
+
 def err_constexpr_union_ctor_no_init : Error<
   "constexpr union constructor does not initialize any member">;
 def err_constexpr_ctor_missing_init : Error<

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=348789&r1=348788&r2=348789&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Dec 10 11:03:12 2018
@@ -4279,6 +4279,9 @@ static EvalStmtResult EvaluateStmt(StmtR
   case Stmt::CaseStmtClass:
   case Stmt::DefaultStmtClass:
 return EvaluateStmt(Result, Info, cast(S)->getSubStmt(), Case);
+  case Stmt::CXXTryStmtClass:
+// Evaluate try blocks by evaluating all sub statements.
+return EvaluateStmt(Result, Info, cast(S)->getTryBlock(), 
Case);
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=348789&r1=348788&r2=348789&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Dec 10 11:03:12 2018
@@ -1803,7 +1803,7 @@ static void CheckConstexprCtorInitialize
 static bool
 CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S,
SmallVectorImpl &ReturnStmts,
-   SourceLocation &Cxx1yLoc) {
+   SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc) 
{
   // - its function-body shall be [...] a compound-statement that contains only
   switch (S->getStmtClass()) {
   case Stmt::NullStmtClass:
@@ -1840,7 +1840,7 @@ CheckConstexprFunctionStmt(Sema &SemaRef
 CompoundStmt *CompStmt = cast(S);
 for (auto *BodyIt : CompStmt->body()) {
   if (!CheckConstexprFunctionStmt(SemaRef, Dcl, BodyIt, ReturnStmts,
-  Cxx1yLoc))
+  Cxx1yLoc, Cxx2aLoc))
 return false;
 }
 return true;
@@ -1858,11 +1858,11 @@ CheckConstex

r342499 - [Modules] Add platform and environment features to requires clause

2018-09-18 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep 18 10:11:13 2018
New Revision: 342499

URL: http://llvm.org/viewvc/llvm-project?rev=342499&view=rev
Log:
[Modules] Add platform and environment features to requires clause

Allows module map writers to add build requirements based on
platform/os. This helps when target features and language dialects
aren't enough to conditionalize building a module, among other things,
it allow module maps for different platforms to live in the same file.

rdar://problem/43909745

Differential Revision: https://reviews.llvm.org/D51910

Added:
cfe/trunk/test/Modules/target-platform-features.m
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=342499&r1=342498&r2=342499&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Tue Sep 18 10:11:13 2018
@@ -411,7 +411,7 @@ A *requires-declaration* specifies the r
   *feature*:
 ``!``:sub:`opt` *identifier*
 
-The requirements clause allows specific modules or submodules to specify that 
they are only accessible with certain language dialects or on certain 
platforms. The feature list is a set of identifiers, defined below. If any of 
the features is not available in a given translation unit, that translation 
unit shall not import the module. When building a module for use by a 
compilation, submodules requiring unavailable features are ignored. The 
optional ``!`` indicates that a feature is incompatible with the module.
+The requirements clause allows specific modules or submodules to specify that 
they are only accessible with certain language dialects, platforms, 
environments and target specific features. The feature list is a set of 
identifiers, defined below. If any of the features is not available in a given 
translation unit, that translation unit shall not import the module. When 
building a module for use by a compilation, submodules requiring unavailable 
features are ignored. The optional ``!`` indicates that a feature is 
incompatible with the module.
 
 The following features are defined:
 
@@ -466,6 +466,11 @@ tls
 *target feature*
   A specific target feature (e.g., ``sse4``, ``avx``, ``neon``) is available.
 
+*platform/os*
+  A os/platform variant (e.g. ``freebsd``, ``win32``, ``windows``, ``linux``, 
``ios``, ``macos``, ``iossimulator``) is available.
+
+*environment*
+  A environment variant (e.g. ``gnu``, ``gnueabi``, ``android``, ``msvc``) is 
available.
 
 **Example:** The ``std`` module can be extended to also include C++ and C++11 
headers using a *requires-declaration*:
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=342499&r1=342498&r2=342499&view=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Tue Sep 18 10:11:13 2018
@@ -71,6 +71,37 @@ Module::~Module() {
   }
 }
 
+static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) 
{
+  StringRef Platform = Target.getPlatformName();
+  StringRef Env = Target.getTriple().getEnvironmentName();
+
+  // Attempt to match platform and environment.
+  if (Platform == Feature || Target.getTriple().getOSName() == Feature ||
+  Env == Feature)
+return true;
+
+  auto CmpPlatformEnv = [](StringRef LHS, StringRef RHS) {
+auto Pos = LHS.find("-");
+if (Pos == StringRef::npos)
+  return false;
+SmallString<128> NewLHS = LHS.slice(0, Pos);
+NewLHS += LHS.slice(Pos+1, LHS.size());
+return NewLHS == RHS;
+  };
+
+  SmallString<128> PlatformEnv = Target.getTriple().getOSAndEnvironmentName();
+  // Darwin has different but equivalent variants for simulators, example:
+  //   1. x86_64-apple-ios-simulator
+  //   2. x86_64-apple-iossimulator
+  // where both are valid examples of the same platform+environment but in the
+  // variant (2) the simulator is hardcoded as part of the platform name. Both
+  // forms above should match for "iossimulator" requirement.
+  if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator"))
+return PlatformEnv == Feature || CmpPlatformEnv(PlatformEnv, Feature);
+
+  return PlatformEnv == Feature;
+}
+
 /// Determine whether a translation unit built using the current
 /// language options has the given feature.
 static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
@@ -93,7 +124,8 @@ static bool hasFeature(StringRef Feature
 .Case("opencl", LangOpts.OpenCL)
 .Case("tls", Target.isTLSSupported())
 .Case("zvector", LangOpts.ZVector)
-.Default(Target.hasFeature(Feature));
+.Default(Target.hasFeature(Feature) ||
+   

r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 16:50:58 2017
New Revision: 312595

URL: http://llvm.org/viewvc/llvm-project?rev=312595&view=rev
Log:
[Darwin] Enable -fstack-protector (back) by default with -ffreestanding

Go back to behavior prior to r289005.

rdar://problem/32987198

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/stack-protector.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595&r1=312594&r2=312595&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
@@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-// Only use a default stack protector on Darwin in case -ffreestanding is
-// not specified.
-if (EffectiveTriple.isOSDarwin() && !IsHosted)
-  StackProtectorLevel = 0;
-else
   StackProtectorLevel = DefaultStackProtectorLevel;
   }
 

Modified: cfe/trunk/test/Driver/stack-protector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=312595&r1=312594&r2=312595&view=diff
==
--- cfe/trunk/test/Driver/stack-protector.c (original)
+++ cfe/trunk/test/Driver/stack-protector.c Tue Sep  5 16:50:58 2017
@@ -36,27 +36,20 @@
 // Test default stack protector values for Darwin platforms
 
 // RUN: %clang -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_WATCHOS
+// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_WATCHOS
 // SSP_WATCHOS: "-stack-protector" "1"
 // RUN: %clang -target arm64-apple-ios8.0.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_IOS
+// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_IOS
 // SSP_IOS: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
 // SSP_MACOSX: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_5
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_5
 // SSP_MACOSX_10_5: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 
-mkernel -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_KERNEL
 // SSP_MACOSX_KERNEL-NOT: "-stack-protector"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_6_KERNEL
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_6_KERNEL
 // SSP_MACOSX_10_6_KERNEL: "-stack-protector" "1"
 
-// Test default stack protector values for Darwin platforms with -ffreestanding
-
-// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_WATCHOS
-// SSP_FREE_WATCHOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_IOS
-// SSP_FREE_IOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX
-// SSP_FREE_MACOSX-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_5
-// SSP_FREE_MACOSX_10_5-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_6_KERNEL
-// SSP_FREE_MACOSX_10_6_KERNEL-NOT: "-stack-protector"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312599 - Fix indentation mistake from r312595

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 17:44:10 2017
New Revision: 312599

URL: http://llvm.org/viewvc/llvm-project?rev=312599&view=rev
Log:
Fix indentation mistake from r312595

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312599&r1=312598&r2=312599&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 17:44:10 2017
@@ -2302,7 +2302,7 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-  StackProtectorLevel = DefaultStackProtectorLevel;
+StackProtectorLevel = DefaultStackProtectorLevel;
   }
 
   if (StackProtectorLevel) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Sep 5, 2017 at 4:58 PM, Joerg Sonnenberger via cfe-commits
 wrote:
> On Tue, Sep 05, 2017 at 11:50:58PM -0000, Bruno Cardoso Lopes via cfe-commits 
> wrote:
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595&r1=312594&r2=312595&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
>> @@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
>>  else if (A->getOption().matches(options::OPT_fstack_protector_all))
>>StackProtectorLevel = LangOptions::SSPReq;
>>} else {
>> -// Only use a default stack protector on Darwin in case -ffreestanding 
>> is
>> -// not specified.
>> -if (EffectiveTriple.isOSDarwin() && !IsHosted)
>> -  StackProtectorLevel = 0;
>> -else
>>StackProtectorLevel = DefaultStackProtectorLevel;
>>}
>
> Indentation?

Thanks for the catch, done in r312599

>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372039 - [Modules][Objective-C] Use complete decl from module when diagnosing missing import

2019-09-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Sep 16 15:00:29 2019
New Revision: 372039

URL: http://llvm.org/viewvc/llvm-project?rev=372039&view=rev
Log:
[Modules][Objective-C] Use complete decl from module when diagnosing missing 
import

Summary:
Otherwise the definition (first found) for ObjCInterfaceDecl's might
precede the module one, which will eventually lead to crash, since
diagnoseMissingImport needs one coming from a module.

This behavior changed after Richard's r342018, which started to look
into the definition of ObjCInterfaceDecls.

rdar://problem/49237144

Reviewers: rsmith, arphaman

Subscribers: jkorous, dexonsmith, ributzka, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66982

Added:
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Bar.h

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Foo.h

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/PrivateHeaders/RandoPriv.h
cfe/trunk/test/Modules/interface-diagnose-missing-import.m
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=372039&r1=372038&r2=372039&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Sep 16 15:00:29 2019
@@ -5273,8 +5273,11 @@ static NamedDecl *getDefinitionToImport(
 return FD->getDefinition();
   if (TagDecl *TD = dyn_cast(D))
 return TD->getDefinition();
+  // The first definition for this ObjCInterfaceDecl might be in the TU
+  // and not associated with any module. Use the one we know to be complete
+  // and have just seen in a module.
   if (ObjCInterfaceDecl *ID = dyn_cast(D))
-return ID->getDefinition();
+return ID;
   if (ObjCProtocolDecl *PD = dyn_cast(D))
 return PD->getDefinition();
   if (TemplateDecl *TD = dyn_cast(D))

Added: 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Bar.h?rev=372039&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Bar.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Bar.h
 Mon Sep 16 15:00:29 2019
@@ -0,0 +1 @@
+// interface-diagnose-missing-import/Foo.framework/Headers/Bar.h

Added: 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Foo.h?rev=372039&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Foo.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Headers/Foo.h
 Mon Sep 16 15:00:29 2019
@@ -0,0 +1,2 @@
+#import 
+#import 

Added: 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap?rev=372039&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap
 Mon Sep 16 15:00:29 2019
@@ -0,0 +1,6 @@
+// interface-diagnose-missing-import/Foo.framework/Modules/module.modulemap
+framework module Foo {
+  umbrella header "Foo.h"
+  export *
+  module * { export * }
+}

Added: 
cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/PrivateHeaders/RandoPriv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/interface-diagnose-missing-import/Foo.framework/PrivateHeaders/RandoPriv.h?rev=372039&view=auto
==
--- 
cfe/t

r330152 - Use export_as for autolinking frameworks

2018-04-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 16 12:42:32 2018
New Revision: 330152

URL: http://llvm.org/viewvc/llvm-project?rev=330152&view=rev
Log:
Use export_as for autolinking frameworks

framework module SomeKitCore {
  ...
  export_as SomeKit
}

Given the module above, while generting autolink information during
codegen, clang should to emit '-framework SomeKitCore' only if SomeKit
was not imported in the relevant TU, otherwise it should use '-framework
SomeKit' instead.

rdar://problem/38269782

Added:
cfe/trunk/test/Modules/Inputs/exportas-link/
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Headers/OtherKit.h
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/SKWidget.h

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/SomeKit.h
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/SomeKit.tbd
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/SKWidget.h

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/SomeKitCore.h
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/SomeKitCore.tbd
cfe/trunk/test/Modules/use-exportas-for-link.m
Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=330152&r1=330151&r2=330152&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Mon Apr 16 12:42:32 2018
@@ -331,6 +331,10 @@ public:
   /// an entity from this module is used.
   llvm::SmallVector LinkLibraries;
 
+  /// Autolinking uses the framework name for linking purposes
+  /// when this is false and the export_as name otherwise.
+  bool UseExportAsModuleLinkName = false;
+
   /// \brief The set of "configuration macros", which are macros that
   /// (intentionally) change how this module is built.
   std::vector ConfigMacros;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=330152&r1=330151&r2=330152&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Mon Apr 16 12:42:32 2018
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
@@ -104,7 +105,19 @@ class ModuleMap {
   /// \brief The number of modules we have created in total.
   unsigned NumCreatedModules = 0;
 
+  /// In case a module has a export_as entry, it might have a pending link
+  /// name to be determined if that module is imported.
+  llvm::StringMap> PendingLinkAsModule;
+
 public:
+  /// Use PendingLinkAsModule information to mark top level link names that
+  /// are going to be replaced by export_as aliases.
+  void resolveLinkAsDependencies(Module *Mod);
+
+  /// Make module to use export_as as the link dependency name if enough
+  /// information is available or add it to a pending list otherwise.
+  void addLinkAsDependency(Module *Mod);
+
   /// \brief Flags describing the role of a module header.
   enum ModuleHeaderRole {
 /// \brief This header is normally included in the module.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330152&r1=330151&r2=330152&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule

r330240 - [Modules] Turn on system header validation for implicit modules

2018-04-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Apr 17 23:07:49 2018
New Revision: 330240

URL: http://llvm.org/viewvc/llvm-project?rev=330240&view=rev
Log:
[Modules] Turn on system header validation for implicit modules

After r300027 implicit builds might fail when updating the SDK on
darwin. Make validation of system headers default when implicit modules
is on and allow modules to be rebuild when system headers change.

rdar://problem/19767523

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/modules.m

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330240&r1=330239&r2=330240&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 17 23:07:49 2018
@@ -1217,6 +1217,8 @@ def fmodules_disable_diagnostic_validati
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,
   Group, Flags<[CC1Option]>,
   HelpText<"Validate the system headers that a module depends on when loading 
the module">;
+def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
+  Group, Flags<[DriverOption]>;
 def fmodules : Flag <["-"], "fmodules">, Group,
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Enable the 'modules' language feature">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=330240&r1=330239&r2=330240&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Apr 17 23:07:49 2018
@@ -2546,11 +2546,13 @@ static void RenderModulesOptions(Compila
 CmdArgs.push_back("-fmodules-strict-decluse");
 
   // -fno-implicit-modules turns off implicitly compiling modules on demand.
+  bool ImplicitModules = false;
   if (!Args.hasFlag(options::OPT_fimplicit_modules,
 options::OPT_fno_implicit_modules, HaveClangModules)) {
 if (HaveModules)
   CmdArgs.push_back("-fno-implicit-modules");
   } else if (HaveModules) {
+ImplicitModules = true;
 // -fmodule-cache-path specifies where our implicitly-built module files
 // should be written.
 SmallString<128> Path;
@@ -2657,7 +2659,11 @@ static void RenderModulesOptions(Compila
 options::OPT_fmodules_validate_once_per_build_session);
   }
 
-  Args.AddLastArg(CmdArgs, options::OPT_fmodules_validate_system_headers);
+  if (Args.hasFlag(options::OPT_fmodules_validate_system_headers,
+   options::OPT_fno_modules_validate_system_headers,
+   ImplicitModules))
+CmdArgs.push_back("-fmodules-validate-system-headers");
+
   Args.AddLastArg(CmdArgs, 
options::OPT_fmodules_disable_diagnostic_validation);
 }
 

Modified: cfe/trunk/test/Driver/modules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules.m?rev=330240&r1=330239&r2=330240&view=diff
==
--- cfe/trunk/test/Driver/modules.m (original)
+++ cfe/trunk/test/Driver/modules.m Tue Apr 17 23:07:49 2018
@@ -30,9 +30,15 @@
 // RUN: %clang -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT-NOT: 
-fmodules-validate-system-headers
 
+// RUN: %clang -fmodules -fsyntax-only -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD %s
+// MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD: 
-fmodules-validate-system-headers
+
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
+// MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID-NOT: 
-fmodules-validate-system-headers
+
 // RUN: %clang -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: 
-fmodules-disable-diagnostic-validation
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331063 - [Modules][ObjC] ASTReader should add protocols for class extensions

2018-04-27 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Apr 27 11:01:23 2018
New Revision: 331063

URL: http://llvm.org/viewvc/llvm-project?rev=331063&view=rev
Log:
[Modules][ObjC] ASTReader should add protocols for class extensions

During deserialization clang is currently missing the merging of
protocols into the canonical interface for the class extension.

This merging only currently happens during parsing and should also
be considered during deserialization.

rdar://problem/38724303

Added:
cfe/trunk/test/Modules/Inputs/class-extension/
cfe/trunk/test/Modules/Inputs/class-extension/a-private.h
cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h
cfe/trunk/test/Modules/Inputs/class-extension/a.h
cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap
cfe/trunk/test/Modules/class-extension-protocol.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=331063&r1=331062&r2=331063&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Apr 27 11:01:23 2018
@@ -1205,6 +1205,12 @@ void ASTDeclReader::VisitObjCCategoryDec
 ProtoLocs.push_back(ReadSourceLocation());
   CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
   Reader.getContext());
+
+  // Protocols in the class extension belong to the class.
+  if (NumProtoRefs > 0 && CD->ClassInterface && CD->IsClassExtension())
+CD->ClassInterface->mergeClassExtensionProtocolList(
+(ObjCProtocolDecl *const *)ProtoRefs.data(), NumProtoRefs,
+Reader.getContext());
 }
 
 void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) 
{

Added: cfe/trunk/test/Modules/Inputs/class-extension/a-private.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a-private.h?rev=331063&view=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a-private.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a-private.h Fri Apr 27 
11:01:23 2018
@@ -0,0 +1,5 @@
+#import "a.h"
+#import "a-proto.h"
+
+@interface A () 
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h?rev=331063&view=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h Fri Apr 27 11:01:23 
2018
@@ -0,0 +1,7 @@
+@protocol NSObject
+@end
+
+@protocol AProto 
+@property (nonatomic, readwrite, assign) int p0;
+@property (nonatomic, readwrite, assign) int p1;
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a.h?rev=331063&view=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a.h Fri Apr 27 11:01:23 2018
@@ -0,0 +1,5 @@
+@interface NSObject
+@end
+
+@interface A : NSObject
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap?rev=331063&view=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap Fri Apr 27 
11:01:23 2018
@@ -0,0 +1,11 @@
+
+module A {
+  header "a.h"
+  header "a-proto.h"
+  export *
+}
+
+module AP {
+  header "a-private.h"
+  export *
+}

Added: cfe/trunk/test/Modules/class-extension-protocol.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/class-extension-protocol.m?rev=331063&view=auto
==
--- cfe/trunk/test/Modules/class-extension-protocol.m (added)
+++ cfe/trunk/test/Modules/class-extension-protocol.m Fri Apr 27 11:01:23 2018
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 %s -fsyntax-only -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t.cache -I%S/Inputs/class-extension -verify
+// expected-no-diagnostics
+
+#import "a-private.h"
+
+int foo(A *X) {
+  return X.p0 + X.p1;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331232 - [Modules] Handle ObjC/C ODR-like semantics for EnumConstantDecl

2018-04-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 30 15:14:29 2018
New Revision: 331232

URL: http://llvm.org/viewvc/llvm-project?rev=331232&view=rev
Log:
[Modules] Handle ObjC/C ODR-like semantics for EnumConstantDecl

Support for ObjC/C ODR-like semantics with structural equivalence
checking was added back in r306918. There enums are handled and also
checked for structural equivalence. However, at use time of
EnumConstantDecl, support was missing for preventing ambiguous
name lookup.

Add the missing bits for properly merging EnumConstantDecl.

rdar://problem/38374569

Added:
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/Headers/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/Headers/b.h
cfe/trunk/test/Modules/non-ambiguous-enum.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=331232&r1=331231&r2=331232&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Apr 30 15:14:29 2018
@@ -2547,6 +2547,20 @@ void ASTDeclReader::mergeRedeclarable(Re
   }
 }
 
+/// ODR-like semantics for C/ObjC allow us to merge tag types and a structural
+/// check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89
+/// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
+/// that some types are mergeable during deserialization, otherwise name
+/// lookup fails. This is the case for EnumConstantDecl.
+bool allowODRLikeMergeInC(NamedDecl *ND) {
+  if (!ND)
+return false;
+  // TODO: implement merge for other necessary decls.
+  if (dyn_cast(ND))
+return true;
+  return false;
+}
+
 /// \brief Attempts to merge the given declaration (D) with another declaration
 /// of the same entity, for the case where the entity is not actually
 /// redeclarable. This happens, for instance, when merging the fields of
@@ -2557,10 +2571,12 @@ void ASTDeclReader::mergeMergeable(Merge
   if (!Reader.getContext().getLangOpts().Modules)
 return;
 
-  // ODR-based merging is only performed in C++. In C, identically-named things
-  // in different translation units are not redeclarations (but may still have
-  // compatible types).
-  if (!Reader.getContext().getLangOpts().CPlusPlus)
+  // ODR-based merging is performed in C++ and in some cases (tag types) in C.
+  // Note that C identically-named things in different translation units are
+  // not redeclarations, but may still have compatible types, where ODR-like
+  // semantics may apply.
+  if (!Reader.getContext().getLangOpts().CPlusPlus &&
+  !allowODRLikeMergeInC(dyn_cast(static_cast(D
 return;
 
   if (FindExistingResult ExistingRes = findExisting(static_cast(D)))

Added: cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h?rev=331232&view=auto
==
--- cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h 
Mon Apr 30 15:14:29 2018
@@ -0,0 +1 @@
+#include 

Added: cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h?rev=331232&view=auto
==
--- cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h 
Mon Apr 30 15:14:29 2018
@@ -0,0 +1 @@
+#include 

Added: 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap?rev=331232&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framew

r331233 - [Modules] Fix testcases from r331232

2018-04-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 30 15:57:02 2018
New Revision: 331233

URL: http://llvm.org/viewvc/llvm-project?rev=331233&view=rev
Log:
[Modules] Fix testcases from r331232

Modified:

cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/non-ambiguous-enum.m

Modified: 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap?rev=331233&r1=331232&r2=331233&view=diff
==
--- 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 (original)
+++ 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 Mon Apr 30 15:57:02 2018
@@ -1,6 +1,5 @@
 
 framework module A {
   header "a.h"
-  //module * { export * }
   export *
 }

Modified: cfe/trunk/test/Modules/non-ambiguous-enum.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/non-ambiguous-enum.m?rev=331233&r1=331232&r2=331233&view=diff
==
--- cfe/trunk/test/Modules/non-ambiguous-enum.m (original)
+++ cfe/trunk/test/Modules/non-ambiguous-enum.m Mon Apr 30 15:57:02 2018
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-F%S/Inputs/non-ambiguous-enum -fsyntax-only %s -verify
-#import 
-#import 
+#import 
+#import 
 
 // expected-no-diagnostics
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331322 - [Modules] Allow @import to reach submodules in private module maps

2018-05-01 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue May  1 19:25:03 2018
New Revision: 331322

URL: http://llvm.org/viewvc/llvm-project?rev=331322&view=rev
Log:
[Modules] Allow @import to reach submodules in private module maps

A @import targeting a top level module from a private module map file
(@import Foo_Private), would fail if there's any submodule declaration
around (module Foo.SomeSub) in the same private module map.

This happens because compileModuleImpl, when building Foo_Private, will
start with the private module map and will not parse the public one,
which leads to unsuccessful parsing of Foo.SomeSub, since top level Foo
was never parsed.

Declaring other submodules in the private module map is not common and
should usually be avoided, but it shouldn't fail to build. Canonicalize
compileModuleImpl to always look at the public module first, so that all
necessary information is available when parsing the private one.

rdar://problem/39822328

Added:
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/PrivateHeaders/APrivate.h
cfe/trunk/test/Modules/submodule-in-private-mmap.m
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=331322&r1=331321&r2=331322&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue May  1 19:25:03 2018
@@ -1188,6 +1188,19 @@ compileModuleImpl(CompilerInstance &Impo
   return !Instance.getDiagnostics().hasErrorOccurred();
 }
 
+static const FileEntry *getPublicModuleMap(const FileEntry *File,
+   FileManager &FileMgr) {
+  StringRef Filename = llvm::sys::path::filename(File->getName());
+  SmallString<128> PublicFilename(File->getDir()->getName());
+  if (Filename == "module_private.map")
+llvm::sys::path::append(PublicFilename, "module.map");
+  else if (Filename == "module.private.modulemap")
+llvm::sys::path::append(PublicFilename, "module.modulemap");
+  else
+return nullptr;
+  return FileMgr.getFile(PublicFilename);
+}
+
 /// \brief Compile a module file for the given module, using the options 
 /// provided by the importing compiler instance. Returns true if the module
 /// was built without errors.
@@ -1204,6 +1217,13 @@ static bool compileModuleImpl(CompilerIn
   bool Result;
   if (const FileEntry *ModuleMapFile =
   ModMap.getContainingModuleMapFile(Module)) {
+// Canonicalize compilation to start with the public module map. This is
+// vital for submodules declarations in the private module maps to be
+// correctly parsed when depending on a top level module in the public one.
+if (const FileEntry *PublicMMFile = getPublicModuleMap(
+ModuleMapFile, ImportingInstance.getFileManager()))
+  ModuleMapFile = PublicMMFile;
+
 // Use the module map where this module resides.
 Result = compileModuleImpl(
 ImportingInstance, ImportLoc, Module->getTopLevelModuleName(),

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h?rev=331322&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h 
Tue May  1 19:25:03 2018
@@ -0,0 +1 @@
+// A.h

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h?rev=331322&view=auto
==
(empty)

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.

r335542 - Warning for framework include violation from Headers to PrivateHeaders

2018-06-25 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jun 25 15:24:17 2018
New Revision: 335542

URL: http://llvm.org/viewvc/llvm-project?rev=335542&view=rev
Log:
Warning for framework include violation from Headers to PrivateHeaders

Framework vendors usually layout their framework headers in the
following way:

Foo.framework/Headers -> "public" headers
Foo.framework/PrivateHeader -> "private" headers

Since both headers in both directories can be found with #import
, it's easy to make mistakes and include headers in
Foo.framework/PrivateHeader from headers in Foo.framework/Headers, which
usually configures a layering violation on Darwin ecosystems. One of the
problem this causes is dep cycles when modules are used, since it's very
common for "private" modules to include from the "public" ones; adding
an edge the other way around will trigger cycles.

Add a warning to catch those cases such that:

./A.framework/Headers/A.h:1:10: warning: public framework header includes 
private framework header 'A/APriv.h'
#include 
 ^

rdar://problem/38712182

Added:
cfe/trunk/test/Modules/Inputs/framework-public-includes-private/
cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/Headers/A.h

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/PrivateHeaders/APriv.h

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/A.framework/PrivateHeaders/APriv2.h
cfe/trunk/test/Modules/Inputs/framework-public-includes-private/a.hmap.json

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/flat-header-path/

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.h

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.modulemap

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.private.modulemap

cfe/trunk/test/Modules/Inputs/framework-public-includes-private/flat-header-path/ZPriv.h
cfe/trunk/test/Modules/Inputs/framework-public-includes-private/z.hmap.json
cfe/trunk/test/Modules/Inputs/framework-public-includes-private/z.yaml
cfe/trunk/test/Modules/framework-public-includes-private.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335542&r1=335541&r2=335542&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Jun 25 15:24:17 2018
@@ -32,6 +32,8 @@ def Availability : DiagGroup<"availabili
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
 def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
+def FrameworkIncludePrivateFromPublic :
+  DiagGroup<"framework-include-private-from-public">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335542&r1=335541&r2=335542&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon Jun 25 15:24:17 2018
@@ -718,6 +718,9 @@ def warn_quoted_include_in_framework_hea
   "double-quoted include \"%0\" in framework header, "
   "expected angle-bracketed instead"
   >, InGroup, DefaultIgnore;
+def warn_framework_include_private_from_public : Warning<
+  "public framework header includes private framework header '%0'"
+  >, InGroup;
 
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335542&r1=335541&r2=335542&view=diff
==
--- cfe/trunk/lib/

r335543 - Fix tests from r335542 to use %hmaptool

2018-06-25 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jun 25 15:25:48 2018
New Revision: 335543

URL: http://llvm.org/viewvc/llvm-project?rev=335543&view=rev
Log:
Fix tests from r335542 to use %hmaptool

Modified:
cfe/trunk/test/Modules/framework-public-includes-private.m

Modified: cfe/trunk/test/Modules/framework-public-includes-private.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/framework-public-includes-private.m?rev=335543&r1=335542&r2=335543&view=diff
==
--- cfe/trunk/test/Modules/framework-public-includes-private.m (original)
+++ cfe/trunk/test/Modules/framework-public-includes-private.m Mon Jun 25 
15:25:48 2018
@@ -3,8 +3,8 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
-// RUN: hmaptool write %S/Inputs/framework-public-includes-private/a.hmap.json 
%t/a.hmap
-// RUN: hmaptool write %S/Inputs/framework-public-includes-private/z.hmap.json 
%t/z.hmap
+// RUN: %hmaptool write 
%S/Inputs/framework-public-includes-private/a.hmap.json %t/a.hmap
+// RUN: %hmaptool write 
%S/Inputs/framework-public-includes-private/z.hmap.json %t/z.hmap
 
 // RUN: sed -e "s:TEST_DIR:%S/Inputs/framework-public-includes-private:g" \
 // RUN:   %S/Inputs/framework-public-includes-private/z.yaml > %t/z.yaml


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335780 - [Modules][ObjC] Warn on the use of '@import' in framework headers

2018-06-27 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 27 13:29:36 2018
New Revision: 335780

URL: http://llvm.org/viewvc/llvm-project?rev=335780&view=rev
Log:
[Modules][ObjC] Warn on the use of '@import' in framework headers

Using @import in framework headers inhibit the use of such headers
when not using modules, this is specially bad for headers that end
up in the SDK (or any other system framework). Add a warning to give
users some indication that this is discouraged.

rdar://problem/39192894

Added:
cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/
cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/

cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Headers/A.h

cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/module.modulemap
cfe/trunk/test/Modules/at-import-in-framework-header.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/VFS/umbrella-mismatch.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335780&r1=335779&r2=335780&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jun 27 13:29:36 2018
@@ -34,6 +34,7 @@ def AutoImport : DiagGroup<"auto-import"
 def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def FrameworkIncludePrivateFromPublic :
   DiagGroup<"framework-include-private-from-public">;
+def FrameworkHdrAtImport : DiagGroup<"atimport-in-framework-header">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=335780&r1=335779&r2=335780&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Jun 27 13:29:36 
2018
@@ -248,6 +248,11 @@ def err_unexpected_at : Error<"unexpecte
 def err_atimport : Error<
 "use of '@import' when modules are disabled">;
 
+def warn_atimport_in_framework_header : Warning<
+  "use of '@import' in framework header is discouraged, "
+  "including this header requires -fmodules">,
+  InGroup;
+
 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;
 def err_illegal_decl_reference_to_reference : Error<

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=335780&r1=335779&r2=335780&view=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Jun 27 13:29:36 2018
@@ -20,6 +20,7 @@
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/Support/Path.h"
 using namespace clang;
 
 
@@ -2123,6 +2124,7 @@ Decl *Parser::ParseModuleImport(SourceLo
   assert((AtLoc.isInvalid() ? Tok.is(tok::kw_import)
 : Tok.isObjCAtKeyword(tok::objc_import)) &&
  "Improper start to module import");
+  bool IsObjCAtImport = Tok.isObjCAtKeyword(tok::objc_import);
   SourceLocation ImportLoc = ConsumeToken();
   SourceLocation StartLoc = AtLoc.isInvalid() ? ImportLoc : AtLoc;
   
@@ -2146,6 +2148,16 @@ Decl *Parser::ParseModuleImport(SourceLo
   if (Import.isInvalid())
 return nullptr;
 
+  // Using '@import' in framework headers requires modules to be enabled so 
that
+  // the header is parseable. Emit a warning to make the user aware.
+  if (IsObjCAtImport && AtLoc.isValid()) {
+auto &SrcMgr = PP.getSourceManager();
+auto *FE = SrcMgr.getFileEntryForID(SrcMgr.getFileID(AtLoc));
+if (FE && llvm::sys::path::parent_path(FE->getDir()->getName())
+  .endswith(".framework"))
+  Diags.Report(AtLoc, diag::warn_atimport_in_framework_header);
+  }
+
   return Import.get();
 }
 

Added: 
cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Headers/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/at-import-in-framework-header/A.framework/Headers/A.h?rev=335780&view=auto
=

r336031 - Add protocol redefinition to the current scope/context

2018-06-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 29 17:49:27 2018
New Revision: 336031

URL: http://llvm.org/viewvc/llvm-project?rev=336031&view=rev
Log:
Add protocol redefinition to the current scope/context

Not doing so causes the AST writter to assert since the decl in question
never gets emitted. This is fine when modules is not used, but otherwise
we need to serialize something other than garbage.

rdar://problem/39844933

Differential Revision: https://reviews.llvm.org/D47297

Added:
cfe/trunk/test/Modules/Inputs/protocol-redefinition/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/

cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/

cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/

cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/

cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/protocol-redefinition.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=336031&r1=336030&r2=336031&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jun 29 17:49:27 2018
@@ -1210,6 +1210,11 @@ Sema::ActOnStartProtocolInterface(Source
 PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName,
  ProtocolLoc, AtProtoInterfaceLoc,
  /*PrevDecl=*/nullptr);
+
+// If we are using modules, add the decl to the context in order to
+// serialize something meaningful.
+if (getLangOpts().Modules)
+  PushOnScopeChains(PDecl, TUScope);
 PDecl->startDefinition();
   } else {
 if (PrevDecl) {

Added: 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h?rev=336031&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Headers/Base.h
 Fri Jun 29 17:49:27 2018
@@ -0,0 +1,3 @@
+@protocol Foo
+- (void)someMethodOnFoo;
+@end

Added: 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap?rev=336031&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Base.framework/Modules/module.modulemap
 Fri Jun 29 17:49:27 2018
@@ -0,0 +1,4 @@
+framework module Base {
+  header "Base.h"
+  export *
+}
\ No newline at end of file

Added: 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h?rev=336031&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Headers/Kit.h 
Fri Jun 29 17:49:27 2018
@@ -0,0 +1,6 @@
+#import 
+
+// REDECLARATION
+@protocol Foo
+- (void)someMethodOnFoo;
+@end

Added: 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap?rev=336031&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/protocol-redefinition/Kit.framework/Modules/module.modulemap
 Fri Jun 29 17:49:27 2018
@@ -0,0 +1,4 @@
+framework module Kit {
+  header "Kit.h"
+  export *
+}
\ No newline at end of file

Added: cfe/trunk/test/Modules/protocol-redefinition.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/protocol-red

r336920 - Revert "[modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts"

2018-07-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jul 12 10:38:48 2018
New Revision: 336920

URL: http://llvm.org/viewvc/llvm-project?rev=336920&view=rev
Log:
Revert "[modules] Fix 37878; Autoload subdirectory modulemaps with specific 
LangOpts"

This reverts commit f40124d4f05ecf4f880cf4e8f26922d861f705f3 / r336660.

This change shouldn't be affecting `@import` behavior, but turns out it is:
https://ci.swift.org/view/swift-master-next/job/oss-swift-incremental-RA-osx-master-next/2800/consoleFull#-12570166563122a513-f36a-4c87-8ed7-cbc36a1ec144

Working on a reduced testcase for this, reverting in the meantime.

rdar://problem/4210

Removed:
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/a.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/b.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/c.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/module.modulemap
cfe/trunk/test/Modules/autoload-subdirectory.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=336920&r1=336919&r2=336920&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Jul 12 10:38:48 2018
@@ -529,12 +529,8 @@ public:
   /// search directories to produce a module definition. If not, this lookup
   /// will only return an already-known module.
   ///
-  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
-  /// in subdirectories.
-  ///
   /// \returns The module with the given name.
-  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true,
-   bool AllowExtraModuleMapSearch = false);
+  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true);
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
@@ -599,12 +595,8 @@ private:
   /// but for compatibility with some buggy frameworks, additional attempts
   /// may be made to find the module under a related-but-different search-name.
   ///
-  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
-  /// in subdirectories.
-  ///
   /// \returns The module named ModuleName.
-  Module *lookupModule(StringRef ModuleName, StringRef SearchName,
-   bool AllowExtraModuleMapSearch = false);
+  Module *lookupModule(StringRef ModuleName, StringRef SearchName);
 
   /// Retrieve a module with the given name, which may be part of the
   /// given framework.

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=336920&r1=336919&r2=336920&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jul 12 10:38:48 2018
@@ -1653,10 +1653,8 @@ CompilerInstance::loadModule(SourceLocat
 // Retrieve the cached top-level module.
 Module = Known->second;
   } else if (ModuleName == getLangOpts().CurrentModule) {
-// This is the module we're building.
-Module = PP->getHeaderSearchInfo().lookupModule(
-ModuleName, /*AllowSearch*/ true,
-/*AllowExtraModuleMapSearch*/ !IsInclusionDirective);
+// This is the module we're building. 
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
 /// FIXME: perhaps we should (a) look for a module using the module name
 //  to file map (PrebuiltModuleFiles) and (b) diagnose if still not found?
 //if (Module == nullptr) {
@@ -1668,8 +1666,7 @@ CompilerInstance::loadModule(SourceLocat
 Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
   } else {
 // Search for a module with the given name.
-Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true,
-!IsInclusionDirective);
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
 HeaderSearchOptions &HSOpts =
 PP->getHeaderSearchInfo().getHeaderSearchOpts();
 
@@ -1746,8 +1743,7 @@ CompilerInstance::loadModule(SourceLocat
ImportLoc, ARRFlags)) {
 case ASTReader::Success: {
   if (Source != ModuleCache && !Module) {
-Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true,
-!IsInclusionDirective);
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
 if (!Module || !Module->getASTFile() ||
 FileMgr->getFile(

r337430 - Reapply r336660: [Modules] Autoload subdirectory modulemaps with specific LangOpts

2018-07-18 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jul 18 16:21:19 2018
New Revision: 337430

URL: http://llvm.org/viewvc/llvm-project?rev=337430&view=rev
Log:
Reapply r336660: [Modules] Autoload subdirectory modulemaps with specific 
LangOpts

Summary:
Reproducer and errors:
https://bugs.llvm.org/show_bug.cgi?id=37878

lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't
find ModuleName in (proper) search paths. This was causing iteration over all
files in the search path subdirectories for example "/usr/include/foobar" in
bugzilla case.

Users don't expect Clang to load modulemaps in subdirectories implicitly, and
also the disk access is not cheap.

if (AllowExtraModuleMapSearch) true with ObjC with @import ModuleName.

Reviewers: rsmith, aprantl, bruno

Subscribers: cfe-commits, teemperor, v.g.vassilev

Differential Revision: https://reviews.llvm.org/D48367

Added:
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/a.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/b.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/c.h
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
cfe/trunk/test/Modules/Inputs/autoload-subdirectory/module.modulemap
cfe/trunk/test/Modules/autoload-subdirectory.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=337430&r1=337429&r2=337430&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Jul 18 16:21:19 2018
@@ -529,8 +529,12 @@ public:
   /// search directories to produce a module definition. If not, this lookup
   /// will only return an already-known module.
   ///
+  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
+  /// in subdirectories.
+  ///
   /// \returns The module with the given name.
-  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true);
+  Module *lookupModule(StringRef ModuleName, bool AllowSearch = true,
+   bool AllowExtraModuleMapSearch = false);
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
@@ -595,8 +599,12 @@ private:
   /// but for compatibility with some buggy frameworks, additional attempts
   /// may be made to find the module under a related-but-different search-name.
   ///
+  /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps
+  /// in subdirectories.
+  ///
   /// \returns The module named ModuleName.
-  Module *lookupModule(StringRef ModuleName, StringRef SearchName);
+  Module *lookupModule(StringRef ModuleName, StringRef SearchName,
+   bool AllowExtraModuleMapSearch = false);
 
   /// Retrieve a module with the given name, which may be part of the
   /// given framework.

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=337430&r1=337429&r2=337430&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Jul 18 16:21:19 2018
@@ -1653,8 +1653,10 @@ CompilerInstance::loadModule(SourceLocat
 // Retrieve the cached top-level module.
 Module = Known->second;
   } else if (ModuleName == getLangOpts().CurrentModule) {
-// This is the module we're building. 
-Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+// This is the module we're building.
+Module = PP->getHeaderSearchInfo().lookupModule(
+ModuleName, /*AllowSearch*/ true,
+/*AllowExtraModuleMapSearch*/ !IsInclusionDirective);
 /// FIXME: perhaps we should (a) look for a module using the module name
 //  to file map (PrebuiltModuleFiles) and (b) diagnose if still not found?
 //if (Module == nullptr) {
@@ -1666,7 +1668,8 @@ CompilerInstance::loadModule(SourceLocat
 Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
   } else {
 // Search for a module with the given name.
-Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true,
+!IsInclusionDirective);
 HeaderSearchOptions &HSOpts =
 PP->getHeaderSearchInfo().getHeaderSearchOpts();
 
@@ -1743,7 +1746,8 @@ CompilerInstance::loadModule(SourceLocat
ImportLoc, ARRFlags)) {
 case ASTReader::Success: {
   if (Source != ModuleCache && !Module) {
-Module = PP->getHeaderSearchInfo().lookupModu

r374841 - [Modules][PCH] Hash input files content

2019-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Oct 14 16:02:03 2019
New Revision: 374841

URL: http://llvm.org/viewvc/llvm-project?rev=374841&view=rev
Log:
[Modules][PCH] Hash input files content

Summary:
When files often get touched during builds, the mtime based validation
leads to different problems in implicit modules builds, even when the
content doesn't actually change:

- Modules only: module invalidation due to out of date files. Usually causing 
rebuild traffic.
- Modules + PCH: build failures because clang cannot rebuild a module if it 
comes from building a PCH.
- PCH: build failures because clang cannot rebuild a PCH in case one of the 
input headers has different mtime.

This patch proposes hashing the content of input files (headers and
module maps), which is performed during serialization time. When looking
at input files for validation, clang only computes the hash in case
there's a mtime mismatch.

I've tested a couple of different hash algorithms availble in LLVM in
face of building modules+pch for `#import `:
- `hash_code`: performace diff within the noise, total module cache increased 
by 0.07%.
- `SHA1`: 5% slowdown. Haven't done real size measurements, but it'd be 
BLOCK_ID+20 bytes per input file, instead of BLOCK_ID+8 bytes from `hash_code`.
- `MD5`: 3% slowdown. Like above, but BLOCK_ID+16 bytes per input file.

Given the numbers above, the patch uses `hash_code`. The patch also
improves invalidation error msgs to point out which type of problem the
user is facing: "mtime", "size" or "content".

rdar://problem/29320105

Reviewers: dexonsmith, arphaman, rsmith, aprantl

Subscribers: jkorous, cfe-commits, ributzka

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67249

Added:
cfe/trunk/test/Modules/validate-file-content.m
cfe/trunk/test/PCH/validate-file-content.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=374841&r1=374840&r2=374841&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Mon Oct 14 
16:02:03 2019
@@ -18,13 +18,16 @@ def err_fe_pch_malformed : Error<
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built">,
+"file '%0' has been modified since the precompiled header '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built">,
+"file '%0' has been modified since the module file '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built">,
+"file '%0' has been modified since the AST file '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
@@ -399,6 +402,8 @@ def warn_module_uses_date_time : Warning
 def err_module_no_size_mtime_for_header : Error<
   "cannot emit module %0: %select{size|mtime}1 must be explicitly specified "
   "for missing header file \"%2\"">;
+def err_module_unable_to_hash_content : Error<
+  "failed to hash content for '%0' because memory buffer cannot be retrieved">;
 } // let CategoryName
 } // let Component
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374841&r1=374840&r2=374841&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 14 16:02:03 2019
@@ -1368,6 +1368,28 @@ def fmodules_validate_system_headers : F
   HelpText<"Validate the system headers that a module depends on when loading 
the module">;
 def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
   Group, Flags<[DriverOption]>;
+
+def fvalidate_ast_input_files_content:
+  Flag <["-"], "fvalidate-ast-input-files

Re: r374841 - [Modules][PCH] Hash input files content

2019-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Eric!

On Mon, Oct 14, 2019 at 8:12 PM Eric Christopher  wrote:
>
> This was breaking a few bots and I couldn't find you on irc so I've
> reverted it thusly:
>
> echristo@jhereg ~/s/llvm-project> git llvm push
> Pushing 1 commit:
>   175b1b856ea Temporarily Revert [Modules][PCH] Hash input files
> content as it's breaking a few bots.
> Sendingcfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> Sendingcfe/trunk/include/clang/Driver/Options.td
> Sendingcfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> Sendingcfe/trunk/include/clang/Serialization/ASTBitCodes.h
> Sendingcfe/trunk/include/clang/Serialization/ASTReader.h
> Sendingcfe/trunk/lib/Driver/ToolChains/Clang.cpp
> Sendingcfe/trunk/lib/Frontend/CompilerInstance.cpp
> Sendingcfe/trunk/lib/Frontend/CompilerInvocation.cpp
> Sendingcfe/trunk/lib/Serialization/ASTReader.cpp
> Sendingcfe/trunk/lib/Serialization/ASTWriter.cpp
> Deleting   cfe/trunk/test/Modules/validate-file-content.m
> Deleting   cfe/trunk/test/PCH/validate-file-content.m
> Transmitting file data ..done
> Committing transaction...
> Committed revision 374842.
> Committed 175b1b856ea to svn.
>
> Sorry for the inconvenience!
>
> -eric
>
> On Mon, Oct 14, 2019 at 3:59 PM Bruno Cardoso Lopes via cfe-commits
>  wrote:
> >
> > Author: bruno
> > Date: Mon Oct 14 16:02:03 2019
> > New Revision: 374841
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=374841&view=rev
> > Log:
> > [Modules][PCH] Hash input files content
> >
> > Summary:
> > When files often get touched during builds, the mtime based validation
> > leads to different problems in implicit modules builds, even when the
> > content doesn't actually change:
> >
> > - Modules only: module invalidation due to out of date files. Usually 
> > causing rebuild traffic.
> > - Modules + PCH: build failures because clang cannot rebuild a module if it 
> > comes from building a PCH.
> > - PCH: build failures because clang cannot rebuild a PCH in case one of the 
> > input headers has different mtime.
> >
> > This patch proposes hashing the content of input files (headers and
> > module maps), which is performed during serialization time. When looking
> > at input files for validation, clang only computes the hash in case
> > there's a mtime mismatch.
> >
> > I've tested a couple of different hash algorithms availble in LLVM in
> > face of building modules+pch for `#import `:
> > - `hash_code`: performace diff within the noise, total module cache 
> > increased by 0.07%.
> > - `SHA1`: 5% slowdown. Haven't done real size measurements, but it'd be 
> > BLOCK_ID+20 bytes per input file, instead of BLOCK_ID+8 bytes from 
> > `hash_code`.
> > - `MD5`: 3% slowdown. Like above, but BLOCK_ID+16 bytes per input file.
> >
> > Given the numbers above, the patch uses `hash_code`. The patch also
> > improves invalidation error msgs to point out which type of problem the
> > user is facing: "mtime", "size" or "content".
> >
> > rdar://problem/29320105
> >
> > Reviewers: dexonsmith, arphaman, rsmith, aprantl
> >
> > Subscribers: jkorous, cfe-commits, ributzka
> >
> > Tags: #clang
> >
> > Differential Revision: https://reviews.llvm.org/D67249
> >
> > Added:
> > cfe/trunk/test/Modules/validate-file-content.m
> > cfe/trunk/test/PCH/validate-file-content.m
> > Modified:
> > cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> > cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> > cfe/trunk/include/clang/Serialization/ASTReader.h
> > cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> > cfe/trunk/lib/Frontend/CompilerInstance.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=374841&r1=374840&r2=374841&view=diff
> > ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticSerial

r374895 - Reapply: [Modules][PCH] Hash input files content

2019-10-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 15 07:23:55 2019
New Revision: 374895

URL: http://llvm.org/viewvc/llvm-project?rev=374895&view=rev
Log:
Reapply: [Modules][PCH] Hash input files content

Summary:
When files often get touched during builds, the mtime based validation
leads to different problems in implicit modules builds, even when the
content doesn't actually change:

- Modules only: module invalidation due to out of date files. Usually causing 
rebuild traffic.
- Modules + PCH: build failures because clang cannot rebuild a module if it 
comes from building a PCH.
- PCH: build failures because clang cannot rebuild a PCH in case one of the 
input headers has different mtime.

This patch proposes hashing the content of input files (headers and
module maps), which is performed during serialization time. When looking
at input files for validation, clang only computes the hash in case
there's a mtime mismatch.

I've tested a couple of different hash algorithms availble in LLVM in
face of building modules+pch for `#import `:
- `hash_code`: performace diff within the noise, total module cache increased 
by 0.07%.
- `SHA1`: 5% slowdown. Haven't done real size measurements, but it'd be 
BLOCK_ID+20 bytes per input file, instead of BLOCK_ID+8 bytes from `hash_code`.
- `MD5`: 3% slowdown. Like above, but BLOCK_ID+16 bytes per input file.

Given the numbers above, the patch uses `hash_code`. The patch also
improves invalidation error msgs to point out which type of problem the
user is facing: "mtime", "size" or "content".

rdar://problem/29320105

Reviewers: dexonsmith, arphaman, rsmith, aprantl

Subscribers: jkorous, cfe-commits, ributzka

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67249

llvm-svn: 374841

Added:
cfe/trunk/test/Modules/validate-file-content.m
cfe/trunk/test/PCH/validate-file-content.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=374895&r1=374894&r2=374895&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Oct 15 
07:23:55 2019
@@ -18,13 +18,16 @@ def err_fe_pch_malformed : Error<
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built">,
+"file '%0' has been modified since the precompiled header '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built">,
+"file '%0' has been modified since the module file '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built">,
+"file '%0' has been modified since the AST file '%1' was built"
+": %select{size|mtime|content}2 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
@@ -399,6 +402,8 @@ def warn_module_uses_date_time : Warning
 def err_module_no_size_mtime_for_header : Error<
   "cannot emit module %0: %select{size|mtime}1 must be explicitly specified "
   "for missing header file \"%2\"">;
+def err_module_unable_to_hash_content : Error<
+  "failed to hash content for '%0' because memory buffer cannot be retrieved">;
 } // let CategoryName
 } // let Component
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374895&r1=374894&r2=374895&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Oct 15 07:23:55 2019
@@ -1368,6 +1368,28 @@ def fmodules_validate_system_headers : F
   HelpText<"Validate the system headers that a module depends on when loading 
the module">;
 def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
   Group, Flags<[DriverOption]>;
+
+def fvalidate_ast_input_files_content:
+  Flag <["-"],

[clang] d892eec - Reapply: Make header inclusion order from umbrella dirs deterministic

2020-04-21 Thread Bruno Cardoso Lopes via cfe-commits

Author: Bruno Cardoso Lopes
Date: 2020-04-21T15:45:54-07:00
New Revision: d892eec710caae84099f38fdb89d32ca15a23c1a

URL: 
https://github.com/llvm/llvm-project/commit/d892eec710caae84099f38fdb89d32ca15a23c1a
DIFF: 
https://github.com/llvm/llvm-project/commit/d892eec710caae84099f38fdb89d32ca15a23c1a.diff

LOG: Reapply: Make header inclusion order from umbrella dirs deterministic

Sort the headers by name before adding the includes in
collectModuleHeaderIncludes. This makes the include order for building
umbrellas deterministic across different filesystems and also guarantees
that the ASTWriter always dump top headers in the same order.

There's currently no good way to test for this behavior.

This was first introduced in r289478 and reverted few times because of
ASANifed test failures on open source bots (both from LLVM and Swift).

Finally reproduced the problem in a Linux machine and use std::sort as a
fix, since we are not dealing with POD-like types.

rdar://problem/28116411

Added: 


Modified: 
clang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 6168057d115d..dc361b2fdd24 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -364,6 +364,7 @@ static std::error_code collectModuleHeaderIncludes(
 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
 
 llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
+SmallVector, 8> Headers;
 for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
  Dir != End && !EC; Dir.increment(EC)) {
   // Check whether this entry has an extension typically associated with
@@ -394,13 +395,25 @@ static std::error_code collectModuleHeaderIncludes(
++It)
 llvm::sys::path::append(RelativeHeader, *It);
 
-  // Include this header as part of the umbrella directory.
-  Module->addTopHeader(*Header);
-  addHeaderInclude(RelativeHeader, Includes, LangOpts, Module->IsExternC);
+  std::string RelName = RelativeHeader.c_str();
+  Headers.push_back(std::make_pair(RelName, *Header));
 }
 
 if (EC)
   return EC;
+
+// Sort header paths and make the header inclusion order deterministic
+// across 
diff erent OSs and filesystems.
+llvm::sort(Headers.begin(), Headers.end(), [](
+  const std::pair &LHS,
+  const std::pair &RHS) {
+return LHS.first < RHS.first;
+});
+for (auto &H : Headers) {
+  // Include this header as part of the umbrella directory.
+  Module->addTopHeader(H.second);
+  addHeaderInclude(H.first, Includes, LangOpts, Module->IsExternC);
+}
   }
 
   // Recurse into submodules.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-19 Thread Bruno Cardoso Lopes via cfe-commits
bruno marked an inline comment as done.


Comment at: lib/Sema/SemaExpr.cpp:8084
@@ +8083,3 @@
+  *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+  return LHSType;
+}

ahatanak wrote:
> My understanding is that, when we have a compound assign like "LHS += RHS", 
> this function (CheckVectorOperands) is supposed to return the result type 
> (LHS + RHS). However, it is returning different types for "<1 x T> += T"  and 
> "T += <1 x T>" (the former returns <1 x T> and the latter returns T). Would 
> CheckAssignmentOperands reject the compound statement if you returned the 
> vector type here?
> 
> Also, are you planning to allow the same kind of conversions done above for 
> non-compound assignment statements (e.g., <4 x short> += <2 x int>) in the 
> future?
1) CheckAssignmentOperands doesn't reject the compound statement if we return 
the vector type instead, because it already supports vector to scalar cast 
idiom. It makes more sense to return a vector indeed, gonna change that.

2) It would be nice to catch up with GCC with the idioms supported for regular 
(non-ext) vectors (like splatting scalar operands to vectors in a arith 
binops), and those, AFAIK, don't include support for truncation as in the 
example you suggested. I guess this is supported with ext-vectors, but I don't 
see any reason to support it for "regular" vectors.


https://reviews.llvm.org/D24472



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-19 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 71869.
bruno marked an inline comment as done.
bruno added a comment.

Update after Akira's comment


https://reviews.llvm.org/D24472

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c

Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -53,14 +53,13 @@
   float2 f2;
   double d, a, b, c;
   float64x2_t v = {0.0, 1.0};
-  f2 += d;
+  // FIXME: These diagnostics are inaccurate: should complain that 'double' to 
vector 'float2' involves truncation
+  f2 += d; // expected-error {{cannot convert between vector values of 
different size ('float2' (vector of 2 'float' values) and 'double')}}
+  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
   a = 3.0 + vget_low_f64(v);
   b = vget_low_f64(v) + 3.0;
   c = vget_low_f64(v);
-  // LAX conversions within compound assignments are not supported.
-  // FIXME: This diagnostic is inaccurate.
-  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
-  c -= vget_low_f64(v); // expected-error {{cannot convert between vector 
values of different size}}
+  c -= vget_low_f64(v);
   // LAX conversions between scalar and vector types require same size and one 
element sized vectors.
   d = f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
   d = d + f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8051,6 +8051,7 @@
 
   // If there's an ext-vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  // FIXME: this should also work for regular vector types as supported in GCC.
   if (!RHSVecType && isa(LHSVecType)) {
 if (!tryVectorConvertAndSplat(*this, &RHS, RHSType,
   LHSVecType->getElementType(), LHSType))
@@ -8063,16 +8064,31 @@
   return RHSType;
   }
 
-  // If we're allowing lax vector conversions, only the total (data) size needs
-  // to be the same. If one of the types is scalar, the result is always the
-  // vector type. Don't allow this if the scalar operand is an lvalue.
+  // FIXME: The code below also handles convertion between vectors and
+  // non-scalars, we should break this down into fine grained specific checks
+  // and emit proper diagnostics.
   QualType VecType = LHSVecType ? LHSType : RHSType;
-  QualType ScalarType = LHSVecType ? RHSType : LHSType;
-  ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS;
-  if (isLaxVectorConversion(ScalarType, VecType) &&
-  !ScalarExpr->get()->isLValue()) {
-*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
-return VecType;
+  const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
+  QualType OtherType = LHSVecType ? RHSType : LHSType;
+  ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
+  if (isLaxVectorConversion(OtherType, VecType)) {
+// If we're allowing lax vector conversions, only the total (data) size
+// needs to be the same. For non compound assignment, if one of the types 
is
+// scalar, the result is always the vector type.
+if (!IsCompAssign) {
+  *OtherExpr = ImpCastExprToType(OtherExpr->get(), VecType, CK_BitCast);
+  return VecType;
+// In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
+// any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
+// type. Note that this is already done by non-compound assignments in
+// CheckAssignmentConstraints. If it's a scalar type, only biscast for
+// <1 x T> -> T.
+} else if (OtherType->isExtVectorType() ||
+   (OtherType->isScalarType() && VT->getNumElements() == 1)) {
+  ExprResult *RHSExpr = &RHS;
+  *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+  return LHSType;
+}
   }
 
   // Okay, the expression is invalid.


Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -53,14 +53,13 @@
   float2 f2;
   double d, a, b, c;
   float64x2_t v = {0.0, 1.0};
-  f2 += d;
+  // FIXME: These diagnostics are inaccurate: should complain that 'double' to vector 'float2' involves truncation
+  f2 += d; // expected-error {{cannot convert between vector values of different size ('float2' (vector of 2 'float' values) and 'double')}}
+  d += f2; // expected-error {{cannot convert between vector values of different size}}
   a = 3.0 + vget_low_f64(v);
   b = vget_low_f64(v) + 3.0;
   c = vget_low_f64(v);
-  // LAX conversions within compound assignments are not supported.
-  // FIXME: This diagnostic is inaccurate.
-  d += f2; // expected-error {{cannot convert between vector values of different si

Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-19 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 71870.
bruno added a comment.

Update again (now with the right patch) after Akira's comment


https://reviews.llvm.org/D24472

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c

Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -53,14 +53,13 @@
   float2 f2;
   double d, a, b, c;
   float64x2_t v = {0.0, 1.0};
-  f2 += d;
+  // FIXME: These diagnostics are inaccurate: should complain that 'double' to 
vector 'float2' involves truncation
+  f2 += d; // expected-error {{cannot convert between vector values of 
different size ('float2' (vector of 2 'float' values) and 'double')}}
+  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
   a = 3.0 + vget_low_f64(v);
   b = vget_low_f64(v) + 3.0;
   c = vget_low_f64(v);
-  // LAX conversions within compound assignments are not supported.
-  // FIXME: This diagnostic is inaccurate.
-  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
-  c -= vget_low_f64(v); // expected-error {{cannot convert between vector 
values of different size}}
+  c -= vget_low_f64(v);
   // LAX conversions between scalar and vector types require same size and one 
element sized vectors.
   d = f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
   d = d + f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8051,6 +8051,7 @@
 
   // If there's an ext-vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  // FIXME: this should also work for regular vector types as supported in GCC.
   if (!RHSVecType && isa(LHSVecType)) {
 if (!tryVectorConvertAndSplat(*this, &RHS, RHSType,
   LHSVecType->getElementType(), LHSType))
@@ -8063,16 +8064,31 @@
   return RHSType;
   }
 
-  // If we're allowing lax vector conversions, only the total (data) size needs
-  // to be the same. If one of the types is scalar, the result is always the
-  // vector type. Don't allow this if the scalar operand is an lvalue.
+  // FIXME: The code below also handles convertion between vectors and
+  // non-scalars, we should break this down into fine grained specific checks
+  // and emit proper diagnostics.
   QualType VecType = LHSVecType ? LHSType : RHSType;
-  QualType ScalarType = LHSVecType ? RHSType : LHSType;
-  ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS;
-  if (isLaxVectorConversion(ScalarType, VecType) &&
-  !ScalarExpr->get()->isLValue()) {
-*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
-return VecType;
+  const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
+  QualType OtherType = LHSVecType ? RHSType : LHSType;
+  ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
+  if (isLaxVectorConversion(OtherType, VecType)) {
+// If we're allowing lax vector conversions, only the total (data) size
+// needs to be the same. For non compound assignment, if one of the types 
is
+// scalar, the result is always the vector type.
+if (!IsCompAssign) {
+  *OtherExpr = ImpCastExprToType(OtherExpr->get(), VecType, CK_BitCast);
+  return VecType;
+// In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
+// any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
+// type. Note that this is already done by non-compound assignments in
+// CheckAssignmentConstraints. If it's a scalar type, only biscast for
+// <1 x T> -> T. The result is also a vector type.
+} else if (OtherType->isExtVectorType() ||
+   (OtherType->isScalarType() && VT->getNumElements() == 1)) {
+  ExprResult *RHSExpr = &RHS;
+  *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+  return VecType;
+}
   }
 
   // Okay, the expression is invalid.


Index: test/Sema/vector-cast.c
===
--- test/Sema/vector-cast.c
+++ test/Sema/vector-cast.c
@@ -53,14 +53,13 @@
   float2 f2;
   double d, a, b, c;
   float64x2_t v = {0.0, 1.0};
-  f2 += d;
+  // FIXME: These diagnostics are inaccurate: should complain that 'double' to vector 'float2' involves truncation
+  f2 += d; // expected-error {{cannot convert between vector values of different size ('float2' (vector of 2 'float' values) and 'double')}}
+  d += f2; // expected-error {{cannot convert between vector values of different size}}
   a = 3.0 + vget_low_f64(v);
   b = vget_low_f64(v) + 3.0;
   c = vget_low_f64(v);
-  // LAX conversions within compound assignments are not supported.
-  // FIXME: This diagnostic is inaccurate.
-  d += f2; // expected-error {{cannot convert between ve

Re: [PATCH] D24820: Add -stats-file option

2016-09-23 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.


Comment at: lib/Driver/Tools.cpp:6102
@@ +6101,3 @@
+StatsFile.assign(Output.getFilename());
+llvm::sys::path::remove_filename(StatsFile);
+  }

Why removing StatsFile here? IIUC, at this point StatsFile is still the same as 
the output (if it's a file).


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24820: Add -stats-file option

2016-09-23 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Maybe add some docs to explain the new flags?



Comment at: lib/Driver/Tools.cpp:6102
@@ +6101,3 @@
+StatsFile.assign(Output.getFilename());
+llvm::sys::path::remove_filename(StatsFile);
+  }

MatzeB wrote:
> bruno wrote:
> > Why removing StatsFile here? IIUC, at this point StatsFile is still the 
> > same as the output (if it's a file).
> a) It behaves like -save-temps=obj (`clang -save-temps=obj foo.c -o bar` will 
> give you foo.i, foo.o, ...;
> b) This makes sense when you have multiple (`clang -save-stats=obj foo.c 
> bar.c -o baz`) inputs for which you need multiple .stats filenames but you 
> only have 1 output name 
> c) It magically works for `-o -` as well
> 
Ok, I see now, I misread `remove_filename` as `remove`


Comment at: test/Driver/save-stats.c:1
@@ +1,2 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats %s -### 2>&1 | 
FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin -save-stats=cwd %s -### 2>&1 | 
FileCheck %s

Is -save-stats == -save-stats=cwd? It doesn't seem so by looking at 
lib/Driver/Tools.cpp. Need test for the diag::err_drv_invalid_value as well.


Comment at: test/Driver/save-stats.c:12
@@ +11,3 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o 
obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats"
+// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o"

aprantl wrote:
> This is up to taste, but just accepting {{.}} as the path separator would be 
> sufficient IMO and might be more readable.
+1 to Adrian's suggestion


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-23 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:8090
@@ +8089,3 @@
+  *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+  return VecType;
+}

ahatanak wrote:
> Sorry I wasn't clear, but I was asking whether you were planning to  allow 
> the following conversions for compound statements.
> 
> ```
> typedef short s4 __attribute__ ((vector_size(8)));
> typedef int i2 __attribute__ ((vector_size(8)));
> s4 a;
> i2 b;
> a = a + b; // clang accepts this.
> a += b; // currently clang rejects this.
> ```
> 
> Also, I feel clang is inconsistent in warning about incompatible types. In 
> the following example, it issues a warning for the first line, but is silent 
> about the second line:
> 
> ```
> a = b + a; // incompatible vector types warning
> a = a + b; // no warning
> ```
> 
> I don't think we have to fix everything in this patch, but just wanted to 
> know what your thoughts were.
You're right, the diagnostics are bad here, this patch adds some FIXMEs so we 
can later work on it. A PR would be nice though (we have an internal track for 
that as well, see rdar://problem/28067874).

Given your example:

  a = a + b; // clang accepts this. 
  a += b; // currently clang rejects this.

IMO, clang should reject `a = a + b` too if not in OpenCL mode, which means 
whenever (a) `a` and `b` have same size but different num elt and (b) `a` and 
`b` are generic vectors (non ext-vectors). However, It looks like we have tests 
that rely on this behavior, we should probably find out why first and clean it 
up.

I also think we should support splatting when one of the operands is a scalar 
and the other a non ext-vector (as of now we currently only do it for OpenCL). 
This is basically what GCC supports 
https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html.


https://reviews.llvm.org/D24472



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24820: Add -stats-stats option

2016-09-26 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks Matthias

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24516: [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-09-26 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping


https://reviews.llvm.org/D24516



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24752: [Modules] Add missing dependencies to clang builtins modulemap

2016-09-27 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.


Comment at: lib/Headers/module.modulemap:133
@@ -131,2 +132,3 @@
 explicit module aes {
+  export sse2
   header "__wmmintrin_aes.h"

The mmx case above makes sense to me, but I find conceptually odd that we need 
to re-export sse2 in aes module, why not explicitly #include  in 
the source file?


https://reviews.llvm.org/D24752



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-27 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.
bruno added a comment.

Hi Daniel,

This is very nice.

In https://reviews.llvm.org/D24861#553606, @danielmarjamaki wrote:

> Compiling 2064 projects resulted in 904 warnings
>
> Here are the results:
>  https://drive.google.com/file/d/0BykPmWrCOxt2N04tYl8zVHA3MXc/view?usp=sharing
>
> The results looks acceptable imho. The code looks intentional in many cases 
> so I believe there are users that will disable this warning. Probably there 
> are true positives where the evaluation order is not really known. There were 
> many warnings about macro arguments where the macro bitshifts the argument - 
> these macros look very shaky to me.
>
> I saw some warnings about such code:
>
>   a * b << c
>   
>
> Maybe we should not warn about this. As far as I see, the result will be the 
> same if (a*b) or (b< signedness issues. What do you think? I'll keep these warnings for now.


Any idea on how expensive would be to reason about these false positives and 
avoid them?


Repository:
  rL LLVM

https://reviews.llvm.org/D24861



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-28 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

@rnk, do you have any concerns about this patch?


https://reviews.llvm.org/D24472



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282968 - [Sema] Support lax conversions for compound assignments

2016-09-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Sep 30 17:19:38 2016
New Revision: 282968

URL: http://llvm.org/viewvc/llvm-project?rev=282968&view=rev
Log:
[Sema] Support lax conversions for compound assignments

Support lax convertions on compound assignment expressions like:

  typedef __attribute__((vector_size(8))) double float64x1_t;
  typedef __attribute__((vector_size(16))) double float64x2_t;
  float64x1_t vget_low_f64(float64x2_t __p0);

  double c = 3.0;
  float64x2_t v = {0.0, 1.0};
  c += vget_low_f64(v);

This restores one more valid behavior pre r266366, and is a incremental
follow up from work committed in r274646.

While here, make the check more strict, add FIXMEs, clean up variable
names to match what they can actually be and update testcases to reflect
that. We now reject:

  typedef float float2 __attribute__ ((vector_size (8)));
  double d;
  f2 += d;

which doesn't fit as a direct bitcast anyway.

Differential Revision: https://reviews.llvm.org/D24472

rdar://problem/28033929

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/vector-cast.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=282968&r1=282967&r2=282968&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep 30 17:19:38 2016
@@ -8052,6 +8052,7 @@ QualType Sema::CheckVectorOperands(ExprR
 
   // If there's an ext-vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  // FIXME: this should also work for regular vector types as supported in GCC.
   if (!RHSVecType && isa(LHSVecType)) {
 if (!tryVectorConvertAndSplat(*this, &RHS, RHSType,
   LHSVecType->getElementType(), LHSType))
@@ -8064,16 +8065,31 @@ QualType Sema::CheckVectorOperands(ExprR
   return RHSType;
   }
 
-  // If we're allowing lax vector conversions, only the total (data) size needs
-  // to be the same. If one of the types is scalar, the result is always the
-  // vector type. Don't allow this if the scalar operand is an lvalue.
+  // FIXME: The code below also handles convertion between vectors and
+  // non-scalars, we should break this down into fine grained specific checks
+  // and emit proper diagnostics.
   QualType VecType = LHSVecType ? LHSType : RHSType;
-  QualType ScalarType = LHSVecType ? RHSType : LHSType;
-  ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS;
-  if (isLaxVectorConversion(ScalarType, VecType) &&
-  !ScalarExpr->get()->isLValue()) {
-*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
-return VecType;
+  const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
+  QualType OtherType = LHSVecType ? RHSType : LHSType;
+  ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
+  if (isLaxVectorConversion(OtherType, VecType)) {
+// If we're allowing lax vector conversions, only the total (data) size
+// needs to be the same. For non compound assignment, if one of the types 
is
+// scalar, the result is always the vector type.
+if (!IsCompAssign) {
+  *OtherExpr = ImpCastExprToType(OtherExpr->get(), VecType, CK_BitCast);
+  return VecType;
+// In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
+// any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
+// type. Note that this is already done by non-compound assignments in
+// CheckAssignmentConstraints. If it's a scalar type, only bitcast for
+// <1 x T> -> T. The result is also a vector type.
+} else if (OtherType->isExtVectorType() ||
+   (OtherType->isScalarType() && VT->getNumElements() == 1)) {
+  ExprResult *RHSExpr = &RHS;
+  *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+  return VecType;
+}
   }
 
   // Okay, the expression is invalid.

Modified: cfe/trunk/test/Sema/vector-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-cast.c?rev=282968&r1=282967&r2=282968&view=diff
==
--- cfe/trunk/test/Sema/vector-cast.c (original)
+++ cfe/trunk/test/Sema/vector-cast.c Fri Sep 30 17:19:38 2016
@@ -53,14 +53,13 @@ void f4() {
   float2 f2;
   double d, a, b, c;
   float64x2_t v = {0.0, 1.0};
-  f2 += d;
+  // FIXME: These diagnostics are inaccurate: should complain that 'double' to 
vector 'float2' involves truncation
+  f2 += d; // expected-error {{cannot convert between vector values of 
different size ('float2' (vector of 2 'float' values) and 'double')}}
+  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
   a = 3.0 + vget_low_f64(v);
   b = vget_low_f64(v) + 3.0;
   c = vget_low_f64(v);
-  // LAX conversions within compound assignments are not supported.
-  // FIXME: This diagnostic is inaccurate.
-  d += f2; // exp

[PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Thanks Reid & Akira,

Committed r282968


https://reviews.llvm.org/D24472



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24516: [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-03 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D24516



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24752: [Modules] Add missing dependencies to clang builtins modulemap

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.


> eladcohen wrote in module.modulemap:133
> emmintrin.h is already included explicitly in wmmintrin.h & __wmmintrin_aes.h.
> 
> If a user includes / there is no problem, since the 
> intel submodule has an 'export *' directive and both aes & sse2 will be 
> imported.
> 
> However, if the user only includes  (like in the 2nd half of the 
> test I added), and uses modules, then any use of the '___m128i' type (which 
> is used in the aes intrinsics and declared in sse2) will result with the 
> error:
> "File tst.c Line 11: missing '#include '; declaration of 
> '___m128i' must be imported from module '_Builtin_intrinsics.intel.sse2' 
> before it is required"
> 
> IIUC the possible fixes for this are adding 'export *' or 'export sse2' to 
> the aes submodule.

I see, if you need the type to use the exported functions it makes sense to 
re-export it. It might be worth adding a comment // note: for ___m128i

https://reviews.llvm.org/D24752



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added a comment.

Hi Elad,

Is there any reason why you can't explicit model this in your build system by 
pre-building the intrinsics and pointing to a module cache path containing the 
pcm files? By doing that we don't need to have a specific compile flag.


https://reviews.llvm.org/D25337



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added a comment.

Testcase?



> clang.rst:398
> +  Print the library path for the currently used compiler runtime library
> +  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
>  

You can probably drop the "appropriately"

> Options.td:1865
> +  HelpText<"Print the library path for the currently used compiler runtime "
> +   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" 
> appropriately)">;
>  def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;

Same here

https://reviews.llvm.org/D25338



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D25338



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-07 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added inline comments.



Comment at: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td:2306
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<

Although the motivation is to support the same warning present in GCC, I think 
this is helpful enough anyway so that we might skip calling it 
"gnu-vec-elem-size" and have a more generic name instead? How about plain 
"vec-elem-size"?



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

Besides `__ext_vector_type__`, would this also trigger for `vector_size`? Right 
now this is an error for `vector_size` primarily because the number of elements 
is different, can you confirm this won't change?


https://reviews.llvm.org/D24669



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-10 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.

LGTM


https://reviews.llvm.org/D25338



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-10-10 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a reviewer: bruno.
bruno added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3915
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)

You should keep using the VFS to obtain the file.  You probably also want to 
add a comment here to describe what you mentioned in the patch Summary.


https://reviews.llvm.org/D24954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-10-10 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: CMakeLists.txt:198
 
+set(CLANG_DEFAULT_LINKER "" CACHE STRING
+  "Default linker to use (\"bfd\" or \"gold\" or \"lld\", empty for platform 
default")

mgorny wrote:
> Is there a reason not to allow using the absolute path here, like for the 
> command-line option?
I agree here, if we're adding a cmake options for this, it should accept full 
paths to the linker to be used (without any need for its type like gold, bfd, 
etc) as well.

Additionally, if "" maps to "ld", plain CLANG_DEFAULT_LINKER="ld" should also 
work here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25263



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-10-10 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3915
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)

mgorny wrote:
> bruno wrote:
> > You should keep using the VFS to obtain the file.  You probably also want 
> > to add a comment here to describe what you mentioned in the patch Summary.
> Hmm, this method is consistent with all the other distributions in the 
> method. It seems that `getVFS()` is only used for `exists()` checks there. 
> Are you sure I should change this, without touching the other reads first?
Right, there seems to be some inconsistent usage here.  Ideally we should go 
through the VFS, but given the precedence it's understandable if you don't make 
it in this patch.

AFAIU, this drops support for SLES10 and I guess that this would also be true 
for SLES9? It seems that the checking could be improved a bit by checking the 
digits (as in the distros above)? Also add a comment explaining why.


https://reviews.llvm.org/D24954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   >