[clang-tools-extra] r339454 - [clangd] extend the publishDiagnostics response to send back fixits to the

2018-08-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug 10 10:25:07 2018
New Revision: 339454

URL: http://llvm.org/viewvc/llvm-project?rev=339454&view=rev
Log:
[clangd] extend the publishDiagnostics response to send back fixits to the
client if the client supports this extension

This commit extends the 'textDocument/publishDiagnostics' notification sent from
Clangd to the client.  When it's enabled, Clangd sends out the fixits associated
with the appropriate diagnostic in the body of the 'publishDiagnostics'
notification. The client can enable this extension by setting 'clangdFixSupport'
to true in the textDocument capabilities during initialization.

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=339454&r1=339453&r2=339454&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Aug 10 10:25:07 2018
@@ -82,6 +82,8 @@ void ClangdLSPServer::onInitialize(Initi
 
   CCOpts.EnableSnippets =
   
Params.capabilities.textDocument.completion.completionItem.snippetSupport;
+  DiagOpts.EmbedFixesInDiagnostics =
+  Params.capabilities.textDocument.publishDiagnostics.clangdFixSupport;
 
   if (Params.capabilities.workspace && Params.capabilities.workspace->symbol &&
   Params.capabilities.workspace->symbol->symbolKind) {
@@ -486,11 +488,25 @@ void ClangdLSPServer::onDiagnosticsReady
   DiagnosticToReplacementMap LocalFixIts; // Temporary storage
   for (auto &Diag : Diagnostics) {
 toLSPDiags(Diag, [&](clangd::Diagnostic Diag, llvm::ArrayRef Fixes) {
-  DiagnosticsJSON.push_back(json::Object{
+  json::Object LSPDiag({
   {"range", Diag.range},
   {"severity", Diag.severity},
   {"message", Diag.message},
   });
+  // LSP extension: embed the fixes in the diagnostic.
+  if (DiagOpts.EmbedFixesInDiagnostics && !Fixes.empty()) {
+json::Array ClangdFixes;
+for (const auto &Fix : Fixes) {
+  WorkspaceEdit WE;
+  URIForFile URI{File};
+  WE.changes = {{URI.uri(), std::vector(Fix.Edits.begin(),
+  Fix.Edits.end())}};
+  ClangdFixes.push_back(
+  json::Object{{"edit", toJSON(WE)}, {"title", Fix.Message}});
+}
+LSPDiag["clangd_fixes"] = std::move(ClangdFixes);
+  }
+  DiagnosticsJSON.push_back(std::move(LSPDiag));
 
   auto &FixItsForDiagnostic = LocalFixIts[Diag];
   std::copy(Fixes.begin(), Fixes.end(),

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=339454&r1=339453&r2=339454&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Fri Aug 10 10:25:07 2018
@@ -155,6 +155,8 @@ private:
   RealFileSystemProvider FSProvider;
   /// Options used for code completion
   clangd::CodeCompleteOptions CCOpts;
+  /// Options used for diagnostics.
+  ClangdDiagnosticOptions DiagOpts;
   /// The supported kinds of the client.
   SymbolKindBitset SupportedSymbolKinds;
 

Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=339454&r1=339453&r2=339454&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Fri Aug 10 10:25:07 2018
@@ -23,6 +23,12 @@
 namespace clang {
 namespace clangd {
 
+struct ClangdDiagnosticOptions {
+  /// If true, Clangd uses an LSP extension to embed the fixes with the
+  /// diagnostics that are sent to the client.
+  bool EmbedFixesInDiagnostics = false;
+};
+
 /// Contains basic information about a diagnostic.
 struct DiagBase {
   std::string Message;

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=339454&r1=339453&r2=339454&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Aug 10 10:25:07 2018
@@ -178,6 +178,15 @@ bool fromJSON(const json::Value &Params,
   return true;
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  

[clang-tools-extra] r339737 - [clangd] add missing test from r339454

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:20:35 2018
New Revision: 339737

URL: http://llvm.org/viewvc/llvm-project?rev=339737&view=rev
Log:
[clangd] add missing test from r339454

I forgot to checkin the test for the fixits into SVN.

Added:
clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test

Added: clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test?rev=339737&view=auto
==
--- clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test (added)
+++ clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test Tue Aug 
14 15:20:35 2018
@@ -0,0 +1,66 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"publishDiagnostics":{"clangdFixSupport":true}}},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"struct
 Point {}; union Point p;"}}}
+#  CHECK:"method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:"params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"clangd_fixes": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"edit": {
+# CHECK-NEXT:  "changes": {
+# CHECK-NEXT:"file://{{.*}}/foo.c": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"newText": "struct",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:]
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"title": "change 'union' to 'struct'"
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"message": "Use of 'Point' with tag type that does not 
match previous declaration\n\nfoo.c:1:8: note: previous use is here",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 1
+# CHECK-NEXT:  },
+# CHECK-NEXT:  {
+# CHECK-NEXT:"message": "Previous use is here\n\nfoo.c:1:18: error: 
use of 'Point' with tag type that does not match previous declaration",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 12,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 3
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}


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


[clang-tools-extra] r339738 - [clangd] add an extension field to LSP to transfer the diagnostic's category

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:21:40 2018
New Revision: 339738

URL: http://llvm.org/viewvc/llvm-project?rev=339738&view=rev
Log:
[clangd] add an extension field to LSP to transfer the diagnostic's category

This patch adds a 'category' extension field to the LSP diagnostic that's sent
by Clangd. This extension is always on by default.

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test
clang-tools-extra/trunk/test/clangd/compile-commands-path.test
clang-tools-extra/trunk/test/clangd/diagnostics.test
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
clang-tools-extra/trunk/test/clangd/execute-command.test
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/fixits.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=339738&r1=339737&r2=339738&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Aug 14 15:21:40 2018
@@ -506,6 +506,8 @@ void ClangdLSPServer::onDiagnosticsReady
 }
 LSPDiag["clangd_fixes"] = std::move(ClangdFixes);
   }
+  if (!Diag.category.empty())
+LSPDiag["category"] = Diag.category;
   DiagnosticsJSON.push_back(std::move(LSPDiag));
 
   auto &FixItsForDiagnostic = LocalFixIts[Diag];

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=339738&r1=339737&r2=339738&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Tue Aug 14 15:21:40 2018
@@ -226,6 +226,7 @@ void toLSPDiags(
 clangd::Diagnostic Res;
 Res.range = D.Range;
 Res.severity = getSeverity(D.Severity);
+Res.category = D.Category;
 return Res;
   };
 
@@ -292,6 +293,9 @@ void StoreDiags::HandleDiagnostic(Diagno
 D.InsideMainFile = InsideMainFile;
 D.File = Info.getSourceManager().getFilename(Info.getLocation());
 D.Severity = DiagLevel;
+D.Category = DiagnosticIDs::getCategoryNameFromID(
+ DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
+ .str();
 return D;
   };
 

Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=339738&r1=339737&r2=339738&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Tue Aug 14 15:21:40 2018
@@ -37,6 +37,7 @@ struct DiagBase {
   std::string File;
   clangd::Range Range;
   DiagnosticsEngine::Level Severity = DiagnosticsEngine::Note;
+  std::string Category;
   // Since File is only descriptive, we store a separate flag to distinguish
   // diags from the main file.
   bool InsideMainFile = false;

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=339738&r1=339737&r2=339738&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Tue Aug 14 15:21:40 2018
@@ -544,6 +544,12 @@ struct Diagnostic {
 
   /// The diagnostic's message.
   std::string message;
+
+  /// The diagnostic's category. Can be omitted.
+  /// An LSP extension that's used to send the name of the category over to the
+  /// client. The category typically describes the compilation stage during
+  /// which the issue was produced, e.g. "Semantic Issue" or "Parse Issue".
+  std::string category;
 };
 
 /// A LSP-specific comparator used to find diagnostic in a container like

Modified: 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test?rev=339738&r1=339737&r2=339738&view=diff
==
--- 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test 
(original)
+++ 
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test 
Tue Aug 14 15:21:40 2018
@@ -23,6 +23,7 @@
 # CHECK-NEXT:   "params": {
 # CHECK-NEXT: "diagnostics":

[clang-tools-extra] r339739 - [clangd] update the new test to check for diagnostic's category as well

2018-08-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 14 15:27:03 2018
New Revision: 339739

URL: http://llvm.org/viewvc/llvm-project?rev=339739&view=rev
Log:
[clangd] update the new test to check for diagnostic's category as well

Modified:
clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test

Modified: clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test?rev=339739&r1=339738&r2=339739&view=diff
==
--- clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test Tue Aug 
14 15:27:03 2018
@@ -6,6 +6,7 @@
 # CHECK-NEXT:"params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"clangd_fixes": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {


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


r340102 - [ObjC] Error out when using forward-declared protocol in a @protocol

2018-08-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug 17 15:18:08 2018
New Revision: 340102

URL: http://llvm.org/viewvc/llvm-project?rev=340102&view=rev
Log:
[ObjC] Error out when using forward-declared protocol in a @protocol
expression

Clang emits invalid protocol metadata when a @protocol expression is used with a
forward-declared protocol. The protocol metadata is missing protocol conformance
list of the protocol since we don't have access to the definition of it in the
compiled translation unit. The linker then might end up picking the invalid
metadata when linking which will lead to incorrect runtime protocol conformance
checks.

This commit makes sure that Clang fails to compile code that uses a @protocol
expression with a forward-declared protocol. This ensures that Clang does not
emit invalid protocol metadata. I added an extra assert in CodeGen to ensure
that this kind of issue won't happen in other places.

rdar://32787811

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/CodeGenObjC/forward-declare-protocol-gnu.m
cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
cfe/trunk/test/CodeGenObjC/hidden-visibility.m
cfe/trunk/test/CodeGenObjC/link-errors.m
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
cfe/trunk/test/CodeGenObjC/protocols-lazy.m
cfe/trunk/test/CodeGenObjC/protocols.m
cfe/trunk/test/PCH/objc_exprs.h
cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm
cfe/trunk/test/SemaObjC/protocol-expr-neg-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=340102&r1=340101&r2=340102&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Aug 17 15:18:08 2018
@@ -620,7 +620,8 @@ def DeallocInCategory:DiagGroup<"dealloc
 def SelectorTypeMismatch : DiagGroup<"selector-type-mismatch">;
 def Selector : DiagGroup<"selector", [SelectorTypeMismatch]>;
 def Protocol : DiagGroup<"protocol">;
-def AtProtocol : DiagGroup<"at-protocol">;
+// No longer in use, preserve for backwards compatibility.
+def : DiagGroup<"at-protocol">;
 def PropertyAccessDotSyntax: DiagGroup<"property-access-dot-syntax">;
 def PropertyAttr : DiagGroup<"property-attribute-mismatch">;
 def SuperSubClassMismatch : DiagGroup<"super-class-method-mismatch">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=340102&r1=340101&r2=340102&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 17 15:18:08 
2018
@@ -867,8 +867,8 @@ def err_protocol_has_circular_dependency
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;
 def warn_undef_protocolref : Warning<"cannot find protocol definition for %0">;
-def warn_atprotocol_protocol : Warning<
-  "@protocol is using a forward protocol declaration of %0">, 
InGroup;
+def err_atprotocol_protocol : Error<
+  "@protocol is using a forward protocol declaration of %0">;
 def warn_readonly_property : Warning<
   "attribute 'readonly' of property %0 restricts attribute "
   "'readwrite' of property inherited from %1">,

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=340102&r1=340101&r2=340102&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Aug 17 15:18:08 2018
@@ -6838,8 +6838,9 @@ llvm::Constant *CGObjCNonFragileABIMac::
 return Entry;
 
   // Use the protocol definition, if there is one.
-  if (const ObjCProtocolDecl *Def = PD->getDefinition())
-PD = Def;
+  assert(PD->hasDefinition() &&
+ "emitting protocol metadata without definition");
+  PD = PD->getDefinition();
 
   auto methodLists = ProtocolMethodLists::get(PD);
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=340102&r1=340101&r2=340102&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Aug 17 15:18:08 2018
@@ -8095,16 +8095,6 @@ Sema::CheckSingleAssignmentConstraints(Q
 if (RHS.isInvalid())
   return Incompatible;
   }
-
-  Expr

[clang-tools-extra] r340449 - [clangd] send diagnostic categories only when 'categorySupport'

2018-08-22 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 22 13:30:06 2018
New Revision: 340449

URL: http://llvm.org/viewvc/llvm-project?rev=340449&view=rev
Log:
[clangd] send diagnostic categories only when 'categorySupport'
capability was given by the client

After r339738 Clangd started sending categories with each diagnostic, but that
broke the eglot client. This commit puts the categories behind a capability to
fix that breakage.

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

Added:
clang-tools-extra/trunk/test/clangd/diagnostic-category.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test
clang-tools-extra/trunk/test/clangd/compile-commands-path.test
clang-tools-extra/trunk/test/clangd/diagnostics.test
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
clang-tools-extra/trunk/test/clangd/execute-command.test
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/fixits-embed-in-diagnostic.test
clang-tools-extra/trunk/test/clangd/fixits.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=340449&r1=340448&r2=340449&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Aug 22 13:30:06 2018
@@ -84,6 +84,8 @@ void ClangdLSPServer::onInitialize(Initi
   
Params.capabilities.textDocument.completion.completionItem.snippetSupport;
   DiagOpts.EmbedFixesInDiagnostics =
   Params.capabilities.textDocument.publishDiagnostics.clangdFixSupport;
+  DiagOpts.SendDiagnosticCategory =
+  Params.capabilities.textDocument.publishDiagnostics.categorySupport;
 
   if (Params.capabilities.workspace && Params.capabilities.workspace->symbol &&
   Params.capabilities.workspace->symbol->symbolKind) {
@@ -506,7 +508,7 @@ void ClangdLSPServer::onDiagnosticsReady
 }
 LSPDiag["clangd_fixes"] = std::move(ClangdFixes);
   }
-  if (!Diag.category.empty())
+  if (DiagOpts.SendDiagnosticCategory && !Diag.category.empty())
 LSPDiag["category"] = Diag.category;
   DiagnosticsJSON.push_back(std::move(LSPDiag));
 

Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=340449&r1=340448&r2=340449&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Wed Aug 22 13:30:06 2018
@@ -27,6 +27,12 @@ struct ClangdDiagnosticOptions {
   /// If true, Clangd uses an LSP extension to embed the fixes with the
   /// diagnostics that are sent to the client.
   bool EmbedFixesInDiagnostics = false;
+
+  /// If true, Clangd uses an LSP extension to send the diagnostic's
+  /// category to the client. The category typically describes the compilation
+  /// stage during which the issue was produced, e.g. "Semantic Issue" or 
"Parse
+  /// Issue".
+  bool SendDiagnosticCategory = false;
 };
 
 /// Contains basic information about a diagnostic.

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=340449&r1=340448&r2=340449&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Wed Aug 22 13:30:06 2018
@@ -184,6 +184,7 @@ bool fromJSON(const llvm::json::Value &P
   if (!O)
 return false;
   O.map("clangdFixSupport", R.clangdFixSupport);
+  O.map("categorySupport", R.categorySupport);
   return true;
 }
 

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=340449&r1=340448&r2=340449&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Wed Aug 22 13:30:06 2018
@@ -255,6 +255,10 @@ struct PublishDiagnosticsClientCapabilit
   /// Whether the client accepts diagnostics with fixes attached using the
   /// "clangd_fixes" extension.
   bool clangdFixSupport = false;
+
+  /// Whether the client accepts diagnostics with category attached to it
+  /// using the "category" extension.
+  bool categorySupport = false;
 };
 bool fromJSON(const llvm::json::Value &,
   PublishDiagnosticsClientCapabilities &);

Modified: 
clang-tools-extra/trunk/test/

r333046 - [AST][ObjC] Print implicit property expression that only has a setter without crashing

2018-05-22 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May 22 17:52:20 2018
New Revision: 333046

URL: http://llvm.org/viewvc/llvm-project?rev=333046&view=rev
Log:
[AST][ObjC] Print implicit property expression that only has a setter without 
crashing

rdar://40447209

Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=333046&r1=333045&r2=333046&view=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue May 22 17:52:20 2018
@@ -825,6 +825,9 @@ public:
   static Selector constructSetterSelector(IdentifierTable &Idents,
   SelectorTable &SelTable,
   const IdentifierInfo *Name);
+
+  /// Return the property name for the given setter selector.
+  static std::string getPropertyNameFromSetterSelector(Selector Sel);
 };
 
 /// DeclarationNameExtra - Common base of the MultiKeywordSelector,

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=333046&r1=333045&r2=333046&view=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue May 22 17:52:20 2018
@@ -1406,9 +1406,13 @@ void StmtPrinter::VisitObjCPropertyRefEx
 OS << Node->getClassReceiver()->getName() << ".";
   }
 
-  if (Node->isImplicitProperty())
-Node->getImplicitPropertyGetter()->getSelector().print(OS);
-  else
+  if (Node->isImplicitProperty()) {
+if (const auto *Getter = Node->getImplicitPropertyGetter())
+  Getter->getSelector().print(OS);
+else
+  OS << SelectorTable::getPropertyNameFromSetterSelector(
+  Node->getImplicitPropertySetter()->getSelector());
+  } else
 OS << Node->getExplicitProperty()->getName();
 }
 

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=333046&r1=333045&r2=333046&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue May 22 17:52:20 2018
@@ -645,6 +645,12 @@ SelectorTable::constructSetterSelector(I
   return SelTable.getUnarySelector(SetterName);
 }
 
+std::string SelectorTable::getPropertyNameFromSetterSelector(Selector Sel) {
+  StringRef Name = Sel.getNameForSlot(0);
+  assert(Name.startswith("set") && "invalid setter name");
+  return (Twine(toLowercase(Name[3])) + Name.drop_front(4)).str();
+}
+
 size_t SelectorTable::getTotalMemory() const {
   SelectorTableImpl &SelTabImpl = getSelectorTableImpl(Impl);
   return SelTabImpl.Allocator.getTotalMemory();

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=333046&r1=333045&r2=333046&view=diff
==
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Tue May 22 17:52:20 2018
@@ -50,3 +50,13 @@ struct __attribute__((objc_bridge_relate
 
 // CHECK: @class C1;
 // CHECK: struct __attribute__((objc_bridge_related(C1, , ))) S1;
+
+@interface ImplicitPropertyWithSetterOnly
+
+- (void)setX:(int)x;
+
+@end
+
+void printImplicitPropertyWithSetterOnly(ImplicitPropertyWithSetterOnly *x) {
+  x.x = 313; // CHECK: x.x = 313;
+}


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


r314509 - [docs][refactor] Add refactoring engine design documentation

2017-09-29 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Sep 29 05:21:38 2017
New Revision: 314509

URL: http://llvm.org/viewvc/llvm-project?rev=314509&view=rev
Log:
[docs][refactor] Add refactoring engine design documentation

This commit adds a refactoring engine design document that talks about the
design and provides several example of how the engine can be used.

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

Added:
cfe/trunk/docs/RefactoringEngine.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/RefactoringEngine.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/RefactoringEngine.rst?rev=314509&view=auto
==
--- cfe/trunk/docs/RefactoringEngine.rst (added)
+++ cfe/trunk/docs/RefactoringEngine.rst Fri Sep 29 05:21:38 2017
@@ -0,0 +1,253 @@
+==
+Clang's refactoring engine
+==
+
+This document describes the design of Clang's refactoring engine and provides
+a couple of examples that show how various primitives in the refactoring API
+can be used to implement different refactoring actions. The :doc:`LibTooling`
+library provides several other APIs that are used when developing a
+refactoring action.
+
+Refactoring engine can be used to implement local refactorings that are
+initiated using a selection in an editor or an IDE. You can combine
+:doc:`AST matchers` and the refactoring engine to implement
+refactorings that don't lend themselves well to source selection and/or have to
+query ASTs for some particular nodes.
+
+We assume basic knowledge about the Clang AST. See the :doc:`Introduction
+to the Clang AST ` if you want to learn more
+about how the AST is structured.
+
+..  FIXME: create new refactoring action tutorial and link to the tutorial
+
+Introduction
+
+
+Clang's refactoring engine defines a set refactoring actions that implement
+a number of different source transformations. The ``clang-refactor``
+command-line tool can be used to perform these refactorings. Certain
+refactorings are also available in other clients like text editors and IDEs.
+
+A refactoring action is a class that defines a list of related refactoring
+operations (rules). These rules are grouped under a common umbrella - a single
+``clang-refactor`` command. In addition to rules, the refactoring action
+provides the action's command name and description to ``clang-refactor``.
+Each action must implement the ``RefactoringAction`` interface. Here's an
+outline of a ``local-rename`` action:
+
+.. code-block:: c++
+
+  class LocalRename final : public RefactoringAction {
+  public:
+StringRef getCommand() const override { return "local-rename"; }
+
+   StringRef getDescription() const override {
+  return "Finds and renames symbols in code with no indexer support";
+}
+
+RefactoringActionRules createActionRules() const override {
+  ...
+}
+  };
+
+Refactoring Action Rules
+
+
+An individual refactoring action is responsible for creating the set of
+grouped refactoring action rules that represent one refactoring operation.
+Although the rules in one action may have a number of different 
implementations,
+they should strive to produce a similar result. It should be easy for users to
+identify which refactoring action produced the result regardless of which
+refactoring action rule was used.
+
+The distinction between actions and rules enables the creation of actions
+that define a set of different rules that produce similar results. For example,
+the "add missing switch cases" refactoring operation typically adds missing
+cases to one switch at a time. However, it could be useful to have a
+refactoring that works on all switches that operate on a particular enum, as
+one could then automatically update all of them after adding a new enum
+constant. To achieve that, we can create two different rules that will use one
+``clang-refactor`` subcommand. The first rule will describe a local operation
+that's initiated when the user selects a single switch. The second rule will
+describe a global operation that works across translation units and is 
initiated
+when the user provides the name of the enum to clang-refactor (or the user 
could
+select the enum declaration instead). The clang-refactor tool will then analyze
+the selection and other options passed to the refactoring action, and will pick
+the most appropriate rule for the given selection and other options.
+
+Rule Types
+^^
+
+Clang's refactoring engine supports several different refactoring rules:
+
+- ``SourceChangeRefactoringRule`` produces source replacements that are applied
+  to the source files. Subclasses that choose to implement this rule have to
+  implement the ``createSourceReplacements`` member function. This type of
+  rule is typically used to implement local refactorings that transform the
+  source in one translation unit only.
+
+- ``FindSymbolOccurrences

r314704 - [refactor] Simplify the refactoring interface

2017-10-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct  2 11:42:43 2017
New Revision: 314704

URL: http://llvm.org/viewvc/llvm-project?rev=314704&view=rev
Log:
[refactor] Simplify the refactoring interface

This commit simplifies the interface for the refactoring action rules and the
refactoring requirements. It merges the selection constraints and the selection
requirements into one class. The refactoring actions rules must now be
implemented using subclassing instead of raw function / lambda pointers. This
change also removes a bunch of template-based traits and other
template definitions that are now redundant.

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

Removed:

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
cfe/trunk/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=314704&r1=314703&r2=314704&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Mon Oct 
 2 11:42:43 2017
@@ -19,10 +19,12 @@ namespace tooling {
 class RefactoringResultConsumer;
 class RefactoringRuleContext;
 
-/// A common refactoring action rule interface.
-class RefactoringActionRule {
+/// A common refactoring action rule interface that defines the 'invoke'
+/// function that performs the refactoring operation (either fully or
+/// partially).
+class RefactoringActionRuleBase {
 public:
-  virtual ~RefactoringActionRule() {}
+  virtual ~RefactoringActionRuleBase() {}
 
   /// Initiates and performs a specific refactoring action.
   ///
@@ -30,17 +32,19 @@ public:
   /// consumer to propagate the result of the refactoring action.
   virtual void invoke(RefactoringResultConsumer &Consumer,
   RefactoringRuleContext &Context) = 0;
+};
 
+/// A refactoring action rule is a wrapper class around a specific refactoring
+/// action rule (SourceChangeRefactoringRule, etc) that, in addition to 
invoking
+/// the action, describes the requirements that determine when the action can 
be
+/// initiated.
+class RefactoringActionRule : public RefactoringActionRuleBase {
+public:
   /// Returns true when the rule has a source selection requirement that has
   /// to be fullfilled before refactoring can be performed.
   virtual bool hasSelectionRequirement() = 0;
 };
 
-/// A set of refactoring action rules that should have unique initiation
-/// requirements.
-using RefactoringActionRules =
-std::vector>;
-
 } // end namespace tooling
 } // end namespace clang
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?rev=314704&r1=314703&r2=314704&view=diff
==
--- 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
(original)
+++ 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
Mon Oct  2 11:42:43 2017
@@ -10,48 +10,49 @@
 #ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H
 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H
 
-#include 
"clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Tooling/Refactoring/RefactoringRuleContext.h"
 #include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
 namespace tooling {
-namespace refactoring_action_rules {
 
-/// Creates a selection requirement from the given requirement.
+/// A refactoring action rule requirement determines when a refactoring action
+/// rule can be invoked. The rule can be invoked only when all of the
+/// requirements are satisfied.
 ///
-/// Requirements must subclass \c selection::Requirement and implement
-/// evaluateSelection member function.
-template 
-internal::SourceSelectionRequirement<
-typename selection::internal::EvaluateSelectionChecker<
-decltype(&T::evaluateSele

r314708 - Add std::move in RefactoringActionRulesTest.cpp

2017-10-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct  2 12:02:42 2017
New Revision: 314708

URL: http://llvm.org/viewvc/llvm-project?rev=314708&view=rev
Log:
Add std::move in RefactoringActionRulesTest.cpp

Should fix http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental

Modified:
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=314708&r1=314707&r2=314708&view=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Mon Oct  2 
12:02:42 2017
@@ -196,7 +196,7 @@ TEST_F(RefactoringActionRulesTest, Retur
   Occurrences.push_back(SymbolOccurrence(SymbolName("test"),
  SymbolOccurrence::MatchingSymbol,
  Selection.getBegin()));
-  return Occurrences;
+  return std::move(Occurrences);
 }
   };
 


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


r315087 - [refactor] add support for refactoring options

2017-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct  6 11:12:29 2017
New Revision: 315087

URL: http://llvm.org/viewvc/llvm-project?rev=315087&view=rev
Log:
[refactor] add support for refactoring options

This commit adds initial support for refactoring options. One can now use
optional and required std::string options.

This commit also adds a NewNameOption for the local-rename refactoring action to
allow rename to work with custom names.

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOption.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptions.h
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/test/Refactor/LocalRename/Field.cpp
cfe/trunk/test/Refactor/tool-test-support.c
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=315087&r1=315086&r2=315087&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Fri Oct 
 6 11:12:29 2017
@@ -16,6 +16,7 @@
 namespace clang {
 namespace tooling {
 
+class RefactoringOptionVisitor;
 class RefactoringResultConsumer;
 class RefactoringRuleContext;
 
@@ -43,6 +44,14 @@ public:
   /// Returns true when the rule has a source selection requirement that has
   /// to be fullfilled before refactoring can be performed.
   virtual bool hasSelectionRequirement() = 0;
+
+  /// Traverses each refactoring option used by the rule and invokes the
+  /// \c visit callback in the consumer for each option.
+  ///
+  /// Options are visited in the order of use, e.g. if a rule has two
+  /// requirements that use options, the options from the first requirement
+  /// are visited before the options in the second requirement.
+  virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0;
 };
 
 } // end namespace tooling

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?rev=315087&r1=315086&r2=315087&view=diff
==
--- 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
(original)
+++ 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
Fri Oct  6 11:12:29 2017
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Tooling/Refactoring/RefactoringOption.h"
 #include "clang/Tooling/Refactoring/RefactoringRuleContext.h"
 #include "llvm/Support/Error.h"
 #include 
@@ -53,6 +54,45 @@ public:
   }
 };
 
+/// A base class for any requirement that requires some refactoring options.
+class RefactoringOptionsRequirement : public RefactoringActionRuleRequirement {
+public:
+  virtual ~RefactoringOptionsRequirement() {}
+
+  /// Returns the set of refactoring options that are used when evaluating this
+  /// requirement.
+  virtual ArrayRef>
+  getRefactoringOptions() const = 0;
+};
+
+/// A requirement that evaluates to the value of the given \c OptionType when
+/// the \c OptionType is a required option. When the \c OptionType is an
+/// optional option, the requirement will evaluate to \c None if the option is
+/// not specified or to an appropriate value otherwise.
+template 
+class OptionRequirement : public RefactoringOptionsRequirement {
+public:
+  OptionRequirement() : Opt(createRefactoringOption()) {}
+
+  ArrayRef>
+  getRefactoringOptions() const final override {
+return static_cast &>(Opt);
+  }
+
+  Expected
+  evaluate(RefactoringRuleContext &) const {
+return Opt->getValue();
+  }
+
+private:
+  /// The partially-owned option.
+  ///
+  /// The ownership of the option is shared among the different requirements
+  /// because the same option can be used by multiple rules in one refactoring
+  /// action.
+  std::shared_ptr Opt;
+};
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h?rev=315087&r1=315086&r2=3

r315093 - [ObjC] Don't warn on readwrite properties with custom setters that

2017-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct  6 12:24:26 2017
New Revision: 315093

URL: http://llvm.org/viewvc/llvm-project?rev=315093&view=rev
Log:
[ObjC] Don't warn on readwrite properties with custom setters that
override readonly properties from protocols

rdar://34192541

Added:
cfe/trunk/test/SemaObjC/property-implement-readonly-with-custom-setter.m
Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=315093&r1=315092&r2=315093&view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Oct  6 12:24:26 2017
@@ -1599,7 +1599,11 @@ Sema::DiagnosePropertyMismatch(ObjCPrope
   // meaningless for readonly properties, so don't diagnose if the
   // atomic property is 'readonly'.
   checkAtomicPropertyMismatch(*this, SuperProperty, Property, false);
-  if (Property->getSetterName() != SuperProperty->getSetterName()) {
+  // Readonly properties from protocols can be implemented as "readwrite"
+  // with a custom setter name.
+  if (Property->getSetterName() != SuperProperty->getSetterName() &&
+  !(SuperProperty->isReadOnly() &&
+isa(SuperProperty->getDeclContext( {
 Diag(Property->getLocation(), diag::warn_property_attribute)
   << Property->getDeclName() << "setter" << inheritedName;
 Diag(SuperProperty->getLocation(), diag::note_property_declare);

Added: cfe/trunk/test/SemaObjC/property-implement-readonly-with-custom-setter.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-implement-readonly-with-custom-setter.m?rev=315093&view=auto
==
--- cfe/trunk/test/SemaObjC/property-implement-readonly-with-custom-setter.m 
(added)
+++ cfe/trunk/test/SemaObjC/property-implement-readonly-with-custom-setter.m 
Fri Oct  6 12:24:26 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://34192541
+
+@class NSString;
+
+@protocol MyProtocol
+@property (nonatomic, strong, readonly) NSString *myString;
+@end
+
+@interface MyClass 
+// Don't warn about this setter:
+@property (nonatomic, strong, setter=setMYString:) NSString *myString;
+
+
+@property (nonatomic, strong, readonly) NSString *overridenInClass; // 
expected-note {{property declared here}}
+@end
+
+@interface MySubClass: MyClass
+@property (nonatomic, strong, setter=setMYOverride:) NSString 
*overridenInClass;
+// expected-warning@-1 {{'setter' attribute on property 'overridenInClass' 
does not match the property inherited from 'MyClass'}}
+@end


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


r315095 - Revert r315087

2017-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct  6 12:49:29 2017
New Revision: 315095

URL: http://llvm.org/viewvc/llvm-project?rev=315095&view=rev
Log:
Revert r315087

clang-refactor crashes on some bots after this commit

Removed:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOption.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptions.h
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/test/Refactor/LocalRename/Field.cpp
cfe/trunk/test/Refactor/tool-test-support.c
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=315095&r1=315094&r2=315095&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Fri Oct 
 6 12:49:29 2017
@@ -16,7 +16,6 @@
 namespace clang {
 namespace tooling {
 
-class RefactoringOptionVisitor;
 class RefactoringResultConsumer;
 class RefactoringRuleContext;
 
@@ -44,14 +43,6 @@ public:
   /// Returns true when the rule has a source selection requirement that has
   /// to be fullfilled before refactoring can be performed.
   virtual bool hasSelectionRequirement() = 0;
-
-  /// Traverses each refactoring option used by the rule and invokes the
-  /// \c visit callback in the consumer for each option.
-  ///
-  /// Options are visited in the order of use, e.g. if a rule has two
-  /// requirements that use options, the options from the first requirement
-  /// are visited before the options in the second requirement.
-  virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0;
 };
 
 } // end namespace tooling

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?rev=315095&r1=315094&r2=315095&view=diff
==
--- 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
(original)
+++ 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
Fri Oct  6 12:49:29 2017
@@ -11,7 +11,6 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Tooling/Refactoring/RefactoringOption.h"
 #include "clang/Tooling/Refactoring/RefactoringRuleContext.h"
 #include "llvm/Support/Error.h"
 #include 
@@ -54,45 +53,6 @@ public:
   }
 };
 
-/// A base class for any requirement that requires some refactoring options.
-class RefactoringOptionsRequirement : public RefactoringActionRuleRequirement {
-public:
-  virtual ~RefactoringOptionsRequirement() {}
-
-  /// Returns the set of refactoring options that are used when evaluating this
-  /// requirement.
-  virtual ArrayRef>
-  getRefactoringOptions() const = 0;
-};
-
-/// A requirement that evaluates to the value of the given \c OptionType when
-/// the \c OptionType is a required option. When the \c OptionType is an
-/// optional option, the requirement will evaluate to \c None if the option is
-/// not specified or to an appropriate value otherwise.
-template 
-class OptionRequirement : public RefactoringOptionsRequirement {
-public:
-  OptionRequirement() : Opt(createRefactoringOption()) {}
-
-  ArrayRef>
-  getRefactoringOptions() const final override {
-return static_cast &>(Opt);
-  }
-
-  Expected
-  evaluate(RefactoringRuleContext &) const {
-return Opt->getValue();
-  }
-
-private:
-  /// The partially-owned option.
-  ///
-  /// The ownership of the option is shared among the different requirements
-  /// because the same option can be used by multiple rules in one refactoring
-  /// action.
-  std::shared_ptr Opt;
-};
-
 } // end namespace tooling
 } // end namespace clang
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h?rev=315095&r1=315094&r2=315095&view=diff
==
--- 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h 
(original)
+++ 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h 

r315103 - -Wdocumentation should allow '...' params in variadic function type aliases

2017-10-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct  6 13:51:04 2017
New Revision: 315103

URL: http://llvm.org/viewvc/llvm-project?rev=315103&view=rev
Log:
-Wdocumentation should allow '...' params in variadic function type aliases

rdar://34811344

Modified:
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=315103&r1=315102&r2=315103&view=diff
==
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Fri Oct  6 13:51:04 2017
@@ -813,7 +813,7 @@ bool Sema::isAnyFunctionDecl() {
 }
 
 bool Sema::isFunctionOrMethodVariadic() {
-  if (!isAnyFunctionDecl() && !isObjCMethodDecl() && !isFunctionTemplateDecl())
+  if (!isFunctionDecl() || !ThisDeclInfo->CurrentDecl)
 return false;
   if (const FunctionDecl *FD =
 dyn_cast(ThisDeclInfo->CurrentDecl))
@@ -824,6 +824,14 @@ bool Sema::isFunctionOrMethodVariadic()
   if (const ObjCMethodDecl *MD =
 dyn_cast(ThisDeclInfo->CurrentDecl))
 return MD->isVariadic();
+  if (const TypedefNameDecl *TD =
+  dyn_cast(ThisDeclInfo->CurrentDecl)) {
+QualType Type = TD->getUnderlyingType();
+if (Type->isFunctionPointerType() || Type->isBlockPointerType())
+  Type = Type->getPointeeType();
+if (const auto *FT = Type->getAs())
+  return FT->isVariadic();
+  }
   return false;
 }
 

Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=315103&r1=315102&r2=315103&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Fri Oct  6 13:51:04 2017
@@ -1282,3 +1282,25 @@ struct HasMoreFields {
 };
 
 }
+
+/*!
+ * Function pointer typedef with variadic params.
+ *
+ * @param a
+ * works
+ *
+ * @param ...
+ * now should work too.
+ */
+typedef void (*VariadicFnType)(int a, ...);
+
+/*!
+ * Function pointer type alias with variadic params.
+ *
+ * @param a
+ * works
+ *
+ * @param ...
+ * now should work too.
+ */
+using VariadicFnType2 = void (*)(int a, ...);

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=315103&r1=315102&r2=315103&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Fri Oct  6 13:51:04 2017
@@ -299,3 +299,14 @@ void (^_Nullable blockPointerVariableTha
 @property void (^blockReturnsNothing)();
 
 @end
+
+/*!
+ * Block typedef with variadic params.
+ *
+ * @param a
+ * works
+ *
+ * @param ...
+ * now should work too.
+ */
+typedef void (^VariadicBlockType)(int a, ...);


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


r315398 - A '<' with a trigraph '#' is not a valid editor placeholder

2017-10-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 10 17:41:20 2017
New Revision: 315398

URL: http://llvm.org/viewvc/llvm-project?rev=315398&view=rev
Log:
A '<' with a trigraph '#' is not a valid editor placeholder

Credit to OSS-Fuzz for discovery:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3137#c5

rdar://34923985

Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Parser/editor-placeholder-recovery.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=315398&r1=315397&r2=315398&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Oct 10 17:41:20 2017
@@ -3542,7 +3542,8 @@ LexNextToken:
 } else if (LangOpts.Digraphs && Char == '%') { // '<%' -> '{'
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
   Kind = tok::l_brace;
-} else if (Char == '#' && lexEditorPlaceholder(Result, CurPtr)) {
+} else if (Char == '#' && /*Not a trigraph*/ SizeTmp == 1 &&
+   lexEditorPlaceholder(Result, CurPtr)) {
   return true;
 } else {
   Kind = tok::less;

Modified: cfe/trunk/test/Parser/editor-placeholder-recovery.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/editor-placeholder-recovery.cpp?rev=315398&r1=315397&r2=315398&view=diff
==
--- cfe/trunk/test/Parser/editor-placeholder-recovery.cpp (original)
+++ cfe/trunk/test/Parser/editor-placeholder-recovery.cpp Tue Oct 10 17:41:20 
2017
@@ -69,3 +69,7 @@ void Struct::method(<#Struct &x#>, noSup
   // expected-error@-2 {{editor placeholder in source file}}
 #endif
 }
+
+void handleTrigraph() {
+   // expected-error {{expected expression}} expected-error 
{{expected expression}} expected-warning {{trigraph converted to '#' character}}
+}


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


r315661 - Recommit r315087 "[refactor] add support for refactoring options"

2017-10-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Oct 12 18:53:13 2017
New Revision: 315661

URL: http://llvm.org/viewvc/llvm-project?rev=315661&view=rev
Log:
Recommit r315087 "[refactor] add support for refactoring options"

The recommit fixes a UB bug that occurred only on a small number of bots.

Original message:

This commit adds initial support for refactoring options. One can now use
optional and required std::string options.

This commit also adds a NewNameOption for the local-rename refactoring action to
allow rename to work with custom names.

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOption.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptionVisitor.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringOptions.h
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/Rename/RenamingAction.h
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/test/Refactor/LocalRename/Field.cpp
cfe/trunk/test/Refactor/tool-test-support.c
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=315661&r1=315660&r2=315661&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Thu Oct 
12 18:53:13 2017
@@ -16,6 +16,7 @@
 namespace clang {
 namespace tooling {
 
+class RefactoringOptionVisitor;
 class RefactoringResultConsumer;
 class RefactoringRuleContext;
 
@@ -43,6 +44,14 @@ public:
   /// Returns true when the rule has a source selection requirement that has
   /// to be fullfilled before refactoring can be performed.
   virtual bool hasSelectionRequirement() = 0;
+
+  /// Traverses each refactoring option used by the rule and invokes the
+  /// \c visit callback in the consumer for each option.
+  ///
+  /// Options are visited in the order of use, e.g. if a rule has two
+  /// requirements that use options, the options from the first requirement
+  /// are visited before the options in the second requirement.
+  virtual void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) = 0;
 };
 
 } // end namespace tooling

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?rev=315661&r1=315660&r2=315661&view=diff
==
--- 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
(original)
+++ 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
Thu Oct 12 18:53:13 2017
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_REQUIREMENTS_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Tooling/Refactoring/RefactoringOption.h"
 #include "clang/Tooling/Refactoring/RefactoringRuleContext.h"
 #include "llvm/Support/Error.h"
 #include 
@@ -53,6 +54,45 @@ public:
   }
 };
 
+/// A base class for any requirement that requires some refactoring options.
+class RefactoringOptionsRequirement : public RefactoringActionRuleRequirement {
+public:
+  virtual ~RefactoringOptionsRequirement() {}
+
+  /// Returns the set of refactoring options that are used when evaluating this
+  /// requirement.
+  virtual ArrayRef>
+  getRefactoringOptions() const = 0;
+};
+
+/// A requirement that evaluates to the value of the given \c OptionType when
+/// the \c OptionType is a required option. When the \c OptionType is an
+/// optional option, the requirement will evaluate to \c None if the option is
+/// not specified or to an appropriate value otherwise.
+template 
+class OptionRequirement : public RefactoringOptionsRequirement {
+public:
+  OptionRequirement() : Opt(createRefactoringOption()) {}
+
+  ArrayRef>
+  getRefactoringOptions() const final override {
+return Opt;
+  }
+
+  Expected
+  evaluate(RefactoringRuleContext &) const {
+return static_cast(Opt.get())->getValue();
+  }
+
+private:
+  /// The partially-owned option.
+  ///
+  /// The ownership of the option is shared among the different requirements
+  /// because the same option can be used by multiple rules in one refactoring
+  /// action.
+  std::shared_ptr Opt;
+};
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
URL: 
http://llvm.org/viewvc

r315738 - [clang-refactor] Apply source replacements

2017-10-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct 13 12:42:05 2017
New Revision: 315738

URL: http://llvm.org/viewvc/llvm-project?rev=315738&view=rev
Log:
[clang-refactor] Apply source replacements

This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

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

Added:
cfe/trunk/test/Refactor/tool-apply-replacements.cpp
cfe/trunk/test/Refactor/tool-selection-option.c
Modified:
cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h?rev=315738&r1=315737&r2=315738&view=diff
==
--- cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h (original)
+++ cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h Fri Oct 13 12:42:05 
2017
@@ -51,6 +51,51 @@ public:
   }
 };
 
+/// A source range that has been parsed on the command line.
+struct ParsedSourceRange {
+  std::string FileName;
+  /// The starting location of the range. The first element is the line and
+  /// the second element is the column.
+  std::pair Begin;
+  /// The ending location of the range. The first element is the line and the
+  /// second element is the column.
+  std::pair End;
+
+  /// Returns a parsed source range from a string or None if the string is
+  /// invalid.
+  ///
+  /// These source string has the following format:
+  ///
+  /// file:start_line:start_column[-end_line:end_column]
+  ///
+  /// If the end line and column are omitted, the starting line and columns
+  /// are used as the end values.
+  static Optional fromString(StringRef Str) {
+std::pair RangeSplit;
+// Avoid splitting '-' when there's no end line & column as '-' might be
+// part of the filename.
+if (Str.count(':') > 2)
+  RangeSplit = Str.rsplit('-');
+else
+  RangeSplit = {Str, ""};
+auto Begin = ParsedSourceLocation::FromString(RangeSplit.first);
+if (Begin.FileName.empty())
+  return None;
+unsigned EndLine, EndColumn;
+if (RangeSplit.second.empty()) {
+  EndLine = Begin.Line;
+  EndColumn = Begin.Column;
+} else {
+  std::pair Split = RangeSplit.second.rsplit(':');
+  if (Split.first.getAsInteger(10, EndLine) ||
+  Split.second.getAsInteger(10, EndColumn))
+return None;
+}
+return ParsedSourceRange{std::move(Begin.FileName),
+ {Begin.Line, Begin.Column},
+ {EndLine, EndColumn}};
+  }
+};
 }
 
 namespace llvm {

Added: cfe/trunk/test/Refactor/tool-apply-replacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-apply-replacements.cpp?rev=315738&view=auto
==
--- cfe/trunk/test/Refactor/tool-apply-replacements.cpp (added)
+++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp Fri Oct 13 12:42:05 2017
@@ -0,0 +1,11 @@
+// RUN: rm -f %t.cp.cpp
+// RUN: cp %s %t.cp.cpp
+// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test 
%t.cp.cpp --
+// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
+// RUN: cp %s %t.cp.cpp
+// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 
-new-name=test %t.cp.cpp --
+// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
+
+class RenameMe {
+// CHECK: class test {
+};

Added: cfe/trunk/test/Refactor/tool-selection-option.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-selection-option.c?rev=315738&view=auto
==
--- cfe/trunk/test/Refactor/tool-selection-option.c (added)
+++ cfe/trunk/test/Refactor/tool-selection-option.c Fri Oct 13 12:42:05 2017
@@ -0,0 +1,15 @@
+// RUN: rm -f %t.cp.c
+// RUN: cp %s %t.cp.c
+// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5 -new-name=test -v 
%t.cp.c -- | FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5-6:9 -new-name=test 
-v %t.cp.c -- | FileCheck --check-prefix=CHECK2 %s
+
+int test;
+
+// CHECK1: invoking action 'local-rename':
+// CHECK1-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:5
+
+// CHECK2: invoking action 'local-rename':
+// CHECK2-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:9
+
+// RUN: not clang-refactor local-rename -selection=%s:6:5 -new-name=test -v 
%t.cp.c -- 2>&1 | FileCheck --check-prefix=CHECK-FILE-ERR %s
+// CHECK-FILE-ERR: given file is not in the target TU

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=315738&r1=315737&r2=315738&view=diff
=

r315755 - Fix -Woverloaded-virtual warning in clang-refactor

2017-10-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct 13 14:15:25 2017
New Revision: 315755

URL: http://llvm.org/viewvc/llvm-project?rev=315755&view=rev
Log:
Fix -Woverloaded-virtual warning in clang-refactor

Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=315755&r1=315754&r2=315755&view=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Fri Oct 13 14:15:25 2017
@@ -314,6 +314,10 @@ public:
 SourceChanges.insert(SourceChanges.begin(), Changes.begin(), 
Changes.end());
   }
 
+  void handle(SymbolOccurrences Occurrences) override {
+RefactoringResultConsumer::handle(std::move(Occurrences));
+  }
+
   const AtomicChanges &getSourceChanges() const { return SourceChanges; }
 
 private:


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


r315774 - Revert r315738

2017-10-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct 13 15:47:44 2017
New Revision: 315774

URL: http://llvm.org/viewvc/llvm-project?rev=315774&view=rev
Log:
Revert r315738

The ParsedSourceRange class does not work correctly on Windows with the ':'
drive separators

Removed:
cfe/trunk/test/Refactor/tool-apply-replacements.cpp
cfe/trunk/test/Refactor/tool-selection-option.c
Modified:
cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h?rev=315774&r1=315773&r2=315774&view=diff
==
--- cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h (original)
+++ cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h Fri Oct 13 15:47:44 
2017
@@ -51,51 +51,6 @@ public:
   }
 };
 
-/// A source range that has been parsed on the command line.
-struct ParsedSourceRange {
-  std::string FileName;
-  /// The starting location of the range. The first element is the line and
-  /// the second element is the column.
-  std::pair Begin;
-  /// The ending location of the range. The first element is the line and the
-  /// second element is the column.
-  std::pair End;
-
-  /// Returns a parsed source range from a string or None if the string is
-  /// invalid.
-  ///
-  /// These source string has the following format:
-  ///
-  /// file:start_line:start_column[-end_line:end_column]
-  ///
-  /// If the end line and column are omitted, the starting line and columns
-  /// are used as the end values.
-  static Optional fromString(StringRef Str) {
-std::pair RangeSplit;
-// Avoid splitting '-' when there's no end line & column as '-' might be
-// part of the filename.
-if (Str.count(':') > 2)
-  RangeSplit = Str.rsplit('-');
-else
-  RangeSplit = {Str, ""};
-auto Begin = ParsedSourceLocation::FromString(RangeSplit.first);
-if (Begin.FileName.empty())
-  return None;
-unsigned EndLine, EndColumn;
-if (RangeSplit.second.empty()) {
-  EndLine = Begin.Line;
-  EndColumn = Begin.Column;
-} else {
-  std::pair Split = RangeSplit.second.rsplit(':');
-  if (Split.first.getAsInteger(10, EndLine) ||
-  Split.second.getAsInteger(10, EndColumn))
-return None;
-}
-return ParsedSourceRange{std::move(Begin.FileName),
- {Begin.Line, Begin.Column},
- {EndLine, EndColumn}};
-  }
-};
 }
 
 namespace llvm {

Removed: cfe/trunk/test/Refactor/tool-apply-replacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-apply-replacements.cpp?rev=315773&view=auto
==
--- cfe/trunk/test/Refactor/tool-apply-replacements.cpp (original)
+++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp (removed)
@@ -1,11 +0,0 @@
-// RUN: rm -f %t.cp.cpp
-// RUN: cp %s %t.cp.cpp
-// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test 
%t.cp.cpp --
-// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
-// RUN: cp %s %t.cp.cpp
-// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 
-new-name=test %t.cp.cpp --
-// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
-
-class RenameMe {
-// CHECK: class test {
-};

Removed: cfe/trunk/test/Refactor/tool-selection-option.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-selection-option.c?rev=315773&view=auto
==
--- cfe/trunk/test/Refactor/tool-selection-option.c (original)
+++ cfe/trunk/test/Refactor/tool-selection-option.c (removed)
@@ -1,15 +0,0 @@
-// RUN: rm -f %t.cp.c
-// RUN: cp %s %t.cp.c
-// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5 -new-name=test -v 
%t.cp.c -- | FileCheck --check-prefix=CHECK1 %s
-// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5-6:9 -new-name=test 
-v %t.cp.c -- | FileCheck --check-prefix=CHECK2 %s
-
-int test;
-
-// CHECK1: invoking action 'local-rename':
-// CHECK1-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:5
-
-// CHECK2: invoking action 'local-rename':
-// CHECK2-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:9
-
-// RUN: not clang-refactor local-rename -selection=%s:6:5 -new-name=test -v 
%t.cp.c -- 2>&1 | FileCheck --check-prefix=CHECK-FILE-ERR %s
-// CHECK-FILE-ERR: given file is not in the target TU

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=315774&r1=315773&r2=315774&view=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Fri Oct 13 15:47:44 201

r315785 - [Lex] Avoid out-of-bounds dereference in SkipLineComment

2017-10-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Oct 13 18:18:30 2017
New Revision: 315785

URL: http://llvm.org/viewvc/llvm-project?rev=315785&view=rev
Log:
[Lex] Avoid out-of-bounds dereference in SkipLineComment

Credit to OSS-Fuzz for discovery:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3145

rdar://34526482

Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=315785&r1=315784&r2=315785&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri Oct 13 18:18:30 2017
@@ -2144,7 +2144,8 @@ bool Lexer::SkipLineComment(Token &Resul
 // If we read multiple characters, and one of those characters was a \r or
 // \n, then we had an escaped newline within the comment.  Emit diagnostic
 // unless the next line is also a // comment.
-if (CurPtr != OldPtr+1 && C != '/' && CurPtr[0] != '/') {
+if (CurPtr != OldPtr + 1 && C != '/' &&
+(CurPtr == BufferEnd + 1 || CurPtr[0] != '/')) {
   for (; OldPtr != CurPtr; ++OldPtr)
 if (OldPtr[0] == '\n' || OldPtr[0] == '\r') {
   // Okay, we found a // comment that ends in a newline, if the next

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=315785&r1=315784&r2=315785&view=diff
==
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Fri Oct 13 18:18:30 2017
@@ -473,4 +473,9 @@ TEST_F(LexerTest, GetBeginningOfTokenWit
   }
 }
 
+TEST_F(LexerTest, AvoidPastEndOfStringDereference) {
+  std::vector LexedTokens = Lex("  //  \\\n");
+  EXPECT_TRUE(LexedTokens.empty());
+}
+
 } // anonymous namespace


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


r315918 - Recommit r315738 "[clang-refactor] Apply source replacements"

2017-10-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct 16 10:31:16 2017
New Revision: 315918

URL: http://llvm.org/viewvc/llvm-project?rev=315918&view=rev
Log:
Recommit r315738 "[clang-refactor] Apply source replacements"

The fixed commit ensures that ParsedSourceRange works correctly
with Windows paths.

Original message:

This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

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

Added:
cfe/trunk/test/Refactor/tool-apply-replacements.cpp
cfe/trunk/test/Refactor/tool-selection-option.c
cfe/trunk/unittests/Frontend/ParsedSourceLocationTest.cpp
Modified:
cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
cfe/trunk/unittests/Frontend/CMakeLists.txt

Modified: cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h?rev=315918&r1=315917&r2=315918&view=diff
==
--- cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h (original)
+++ cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h Mon Oct 16 10:31:16 
2017
@@ -51,6 +51,52 @@ public:
   }
 };
 
+/// A source range that has been parsed on the command line.
+struct ParsedSourceRange {
+  std::string FileName;
+  /// The starting location of the range. The first element is the line and
+  /// the second element is the column.
+  std::pair Begin;
+  /// The ending location of the range. The first element is the line and the
+  /// second element is the column.
+  std::pair End;
+
+  /// Returns a parsed source range from a string or None if the string is
+  /// invalid.
+  ///
+  /// These source string has the following format:
+  ///
+  /// file:start_line:start_column[-end_line:end_column]
+  ///
+  /// If the end line and column are omitted, the starting line and columns
+  /// are used as the end values.
+  static Optional fromString(StringRef Str) {
+std::pair RangeSplit = Str.rsplit('-');
+unsigned EndLine, EndColumn;
+bool HasEndLoc = false;
+if (!RangeSplit.second.empty()) {
+  std::pair Split = RangeSplit.second.rsplit(':');
+  if (Split.first.getAsInteger(10, EndLine) ||
+  Split.second.getAsInteger(10, EndColumn)) {
+// The string does not end in end_line:end_column, so the '-'
+// probably belongs to the filename which menas the whole
+// string should be parsed.
+RangeSplit.first = Str;
+  } else
+HasEndLoc = true;
+}
+auto Begin = ParsedSourceLocation::FromString(RangeSplit.first);
+if (Begin.FileName.empty())
+  return None;
+if (!HasEndLoc) {
+  EndLine = Begin.Line;
+  EndColumn = Begin.Column;
+}
+return ParsedSourceRange{std::move(Begin.FileName),
+ {Begin.Line, Begin.Column},
+ {EndLine, EndColumn}};
+  }
+};
 }
 
 namespace llvm {

Added: cfe/trunk/test/Refactor/tool-apply-replacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-apply-replacements.cpp?rev=315918&view=auto
==
--- cfe/trunk/test/Refactor/tool-apply-replacements.cpp (added)
+++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp Mon Oct 16 10:31:16 2017
@@ -0,0 +1,11 @@
+// RUN: rm -f %t.cp.cpp
+// RUN: cp %s %t.cp.cpp
+// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test 
%t.cp.cpp --
+// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
+// RUN: cp %s %t.cp.cpp
+// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 
-new-name=test %t.cp.cpp --
+// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp
+
+class RenameMe {
+// CHECK: class test {
+};

Added: cfe/trunk/test/Refactor/tool-selection-option.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-selection-option.c?rev=315918&view=auto
==
--- cfe/trunk/test/Refactor/tool-selection-option.c (added)
+++ cfe/trunk/test/Refactor/tool-selection-option.c Mon Oct 16 10:31:16 2017
@@ -0,0 +1,15 @@
+// RUN: rm -f %t.cp.c
+// RUN: cp %s %t.cp.c
+// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5 -new-name=test -v 
%t.cp.c -- | FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-refactor local-rename -selection=%t.cp.c:6:5-6:9 -new-name=test 
-v %t.cp.c -- | FileCheck --check-prefix=CHECK2 %s
+
+int test;
+
+// CHECK1: invoking action 'local-rename':
+// CHECK1-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:5
+
+// CHECK2: invoking action 'local-rename':
+// CHECK2-NEXT: -selection={{.*}}.cp.c:6:5 -> {{.*}}.cp.c:6:9
+
+// RUN: not clang-refactor local-rename -selection=%s:6:5 -new-name=test -v 
%t.cp.c -- 2>&1 | FileCheck --chec

r315923 - clang-refactor: Use llvm_unreachable in an unused override

2017-10-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct 16 11:07:16 2017
New Revision: 315923

URL: http://llvm.org/viewvc/llvm-project?rev=315923&view=rev
Log:
clang-refactor: Use llvm_unreachable in an unused override

As suggested by David Blaikie!

Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=315923&r1=315922&r2=315923&view=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Mon Oct 16 11:07:16 2017
@@ -315,7 +315,7 @@ public:
   }
 
   void handle(SymbolOccurrences Occurrences) override {
-RefactoringResultConsumer::handle(std::move(Occurrences));
+llvm_unreachable("symbol occurrence results are not handled yet");
   }
 
   const AtomicChanges &getSourceChanges() const { return SourceChanges; }


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


r315924 - [refactor] allow the use of refactoring diagnostics

2017-10-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Oct 16 11:28:26 2017
New Revision: 315924

URL: http://llvm.org/viewvc/llvm-project?rev=315924&view=rev
Log:
[refactor] allow the use of refactoring diagnostics

This commit allows the refactoring library to use its own set of
refactoring-specific diagnostics to reports things like initiation errors.

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

Added:
cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
cfe/trunk/test/Refactor/LocalRename/NoSymbolSelectedError.cpp
cfe/trunk/tools/clang-refactor/ToolRefactoringResultConsumer.h
Modified:
cfe/trunk/include/clang/Basic/AllDiagnostics.h
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/include/clang/Basic/Diagnostic.td
cfe/trunk/include/clang/Basic/DiagnosticIDs.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringRuleContext.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
cfe/trunk/tools/clang-refactor/TestSupport.cpp
cfe/trunk/tools/clang-refactor/TestSupport.h
cfe/trunk/tools/diagtool/DiagnosticNames.cpp
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp

Modified: cfe/trunk/include/clang/Basic/AllDiagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AllDiagnostics.h?rev=315924&r1=315923&r2=315924&view=diff
==
--- cfe/trunk/include/clang/Basic/AllDiagnostics.h (original)
+++ cfe/trunk/include/clang/Basic/AllDiagnostics.h Mon Oct 16 11:28:26 2017
@@ -25,6 +25,7 @@
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Serialization/SerializationDiagnostic.h"
+#include "clang/Tooling/Refactoring/RefactoringDiagnostic.h"
 
 namespace clang {
 template 

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=315924&r1=315923&r2=315924&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Mon Oct 16 11:28:26 2017
@@ -14,6 +14,7 @@ clang_diag_gen(Driver)
 clang_diag_gen(Frontend)
 clang_diag_gen(Lex)
 clang_diag_gen(Parse)
+clang_diag_gen(Refactoring)
 clang_diag_gen(Sema)
 clang_diag_gen(Serialization)
 clang_tablegen(DiagnosticGroups.inc -gen-clang-diag-groups

Modified: cfe/trunk/include/clang/Basic/Diagnostic.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.td?rev=315924&r1=315923&r2=315924&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.td (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.td Mon Oct 16 11:28:26 2017
@@ -138,6 +138,7 @@ include "DiagnosticDriverKinds.td"
 include "DiagnosticFrontendKinds.td"
 include "DiagnosticLexKinds.td"
 include "DiagnosticParseKinds.td"
+include "DiagnosticRefactoringKinds.td"
 include "DiagnosticSemaKinds.td"
 include "DiagnosticSerializationKinds.td"
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=315924&r1=315923&r2=315924&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Mon Oct 16 11:28:26 2017
@@ -38,7 +38,8 @@ namespace clang {
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
   DIAG_SIZE_SEMA  = 3500,
-  DIAG_SIZE_ANALYSIS  =  100
+  DIAG_SIZE_ANALYSIS  =  100,
+  DIAG_SIZE_REFACTORING   = 1000,
 };
 // Start position for diagnostics.
 enum {
@@ -53,7 +54,8 @@ namespace clang {
   DIAG_START_CROSSTU   = DIAG_START_COMMENT   + DIAG_SIZE_CROSSTU,
   DIAG_START_SEMA  = DIAG_START_CROSSTU   + DIAG_SIZE_COMMENT,
   DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
+  DIAG_START_REFACTORING   = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS,
+  DIAG_UPPER_LIMIT = DIAG_START_REFACTORING   + 
DIAG_SIZE_REFACTORING
 };
 
 class CustomDiagInfo;

Added: cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td?rev=315924&view=auto
==
--- cfe/trunk/inclu

r316104 - [refactor] selection: new CodeRangeASTSelection represents a set of selected

2017-10-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Oct 18 11:48:58 2017
New Revision: 316104

URL: http://llvm.org/viewvc/llvm-project?rev=316104&view=rev
Log:
[refactor] selection: new CodeRangeASTSelection represents a set of selected
consecutive statements

This commit adds a CodeRangeASTSelection value to the refactoring library. This
value represents a set of selected statements in one body of code.

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h?rev=316104&r1=316103&r2=316104&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h Wed Oct 18 
11:48:58 2017
@@ -59,6 +59,8 @@ struct SelectedASTNode {
   SelectedASTNode &operator=(SelectedASTNode &&) = default;
 
   void dump(llvm::raw_ostream &OS = llvm::errs()) const;
+
+  using ReferenceType = std::reference_wrapper;
 };
 
 /// Traverses the given ASTContext and creates a tree of selected AST nodes.
@@ -68,6 +70,70 @@ struct SelectedASTNode {
 Optional findSelectedASTNodes(const ASTContext &Context,
SourceRange SelectionRange);
 
+/// An AST selection value that corresponds to a selection of a set of
+/// statements that belong to one body of code (like one function).
+///
+/// For example, the following selection in the source.
+///
+/// \code
+/// void function() {
+///  // selection begin:
+///  int x = 0;
+///  {
+/// // selection end
+/// x = 1;
+///  }
+///  x = 2;
+/// }
+/// \endcode
+///
+/// Would correspond to a code range selection of statements "int x = 0"
+/// and the entire compound statement that follows it.
+///
+/// A \c CodeRangeASTSelection value stores references to the full
+/// \c SelectedASTNode tree and should not outlive it.
+class CodeRangeASTSelection {
+public:
+  CodeRangeASTSelection(CodeRangeASTSelection &&) = default;
+  CodeRangeASTSelection &operator=(CodeRangeASTSelection &&) = default;
+
+  /// Returns the parent hierarchy (top to bottom) for the selected nodes.
+  ArrayRef getParents() { return Parents; }
+
+  /// Returns the number of selected statements.
+  size_t size() const {
+if (!AreChildrenSelected)
+  return 1;
+return SelectedNode.get().Children.size();
+  }
+
+  const Stmt *operator[](size_t I) const {
+if (!AreChildrenSelected) {
+  assert(I == 0 && "Invalid index");
+  return SelectedNode.get().Node.get();
+}
+return SelectedNode.get().Children[I].Node.get();
+  }
+
+  static Optional
+  create(SourceRange SelectionRange, const SelectedASTNode &ASTSelection);
+
+private:
+  CodeRangeASTSelection(SelectedASTNode::ReferenceType SelectedNode,
+ArrayRef Parents,
+bool AreChildrenSelected)
+  : SelectedNode(SelectedNode), Parents(Parents.begin(), Parents.end()),
+AreChildrenSelected(AreChildrenSelected) {}
+
+  /// The reference to the selected node (or reference to the selected
+  /// child nodes).
+  SelectedASTNode::ReferenceType SelectedNode;
+  /// The parent hierarchy (top to bottom) for the selected noe.
+  llvm::SmallVector Parents;
+  /// True only when the children of the selected node are actually selected.
+  bool AreChildrenSelected;
+};
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=316104&r1=316103&r2=316104&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Wed Oct 18 11:48:58 2017
@@ -225,3 +225,108 @@ static void dump(const SelectedASTNode &
 }
 
 void SelectedASTNode::dump(llvm::raw_ostream &OS) const { ::dump(*this, OS); }
+
+/// Returns true if the given node has any direct children with the following
+/// selection kind.
+///
+/// Note: The direct children also include children of direct children with the
+/// "None" selection kind.
+static bool hasAnyDirectChildrenWithKind(const SelectedASTNode &Node,
+ SourceSelectionKind Kind) {
+  assert(Kind != SourceSelectionKind::None && "invalid predicate!");
+  for (const auto &Child : Node.Children) {
+if (Child.SelectionKind == Kind)
+  return true;
+if (Child.SelectionKind == SourceSelectionKind::None)
+  return hasAnyDirectChildrenWithKind(Child, Kind);
+  }
+  return false;
+}
+
+namespace {
+struct SelectedNodeWithP

r316105 - [refactor] Add a doc comment to the test function in the selection

2017-10-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Oct 18 11:51:48 2017
New Revision: 316105

URL: http://llvm.org/viewvc/llvm-project?rev=316105&view=rev
Log:
[refactor] Add a doc comment to the test function in the selection
unittest.

As suggested by Haojian Wu!

Modified:
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=316105&r1=316104&r2=316105&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Oct 18 11:51:48 2017
@@ -59,6 +59,11 @@ public:
   }
 };
 
+/// This is a test utility function that computes the AST selection at the
+/// given location with an optional selection range.
+///
+/// A location roughly corresponds to a cursor location in an editor, while
+/// the optional range corresponds to the selection range in an editor.
 void findSelectedASTNodesWithRange(
 StringRef Source, FileLocation Location, Optional 
SelectionRange,
 llvm::function_refhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316458 - [code completion] Complete ObjC methods in @implementation without leading

2017-10-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 24 09:39:37 2017
New Revision: 316458

URL: http://llvm.org/viewvc/llvm-project?rev=316458&view=rev
Log:
[code completion] Complete ObjC methods in @implementation without leading
'-'/'+' prefix

rdar://12040840

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-method-decls.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=316458&r1=316457&r2=316458&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 24 09:39:37 2017
@@ -10210,8 +10210,7 @@ public:
   void CodeCompleteObjCPropertyDefinition(Scope *S);
   void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
   IdentifierInfo *PropertyName);
-  void CodeCompleteObjCMethodDecl(Scope *S,
-  bool IsInstanceMethod,
+  void CodeCompleteObjCMethodDecl(Scope *S, Optional IsInstanceMethod,
   ParsedType ReturnType);
   void CodeCompleteObjCMethodDeclSelector(Scope *S,
   bool IsInstanceMethod,

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=316458&r1=316457&r2=316458&view=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue Oct 24 09:39:37 2017
@@ -753,9 +753,15 @@ Parser::ParseExternalDeclaration(ParsedA
 SingleDecl = ParseObjCMethodDefinition();
 break;
   case tok::code_completion:
-  Actions.CodeCompleteOrdinaryName(getCurScope(), 
- CurParsedObjCImpl? Sema::PCC_ObjCImplementation
-  : Sema::PCC_Namespace);
+if (CurParsedObjCImpl) {
+  // Code-complete Objective-C methods even without leading '-'/'+' prefix.
+  Actions.CodeCompleteObjCMethodDecl(getCurScope(),
+ /*IsInstanceMethod=*/None,
+ /*ReturnType=*/nullptr);
+}
+Actions.CodeCompleteOrdinaryName(
+getCurScope(),
+CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : 
Sema::PCC_Namespace);
 cutOffParsing();
 return nullptr;
   case tok::kw_export:

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=316458&r1=316457&r2=316458&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Oct 24 09:39:37 2017
@@ -6647,7 +6647,7 @@ typedef llvm::DenseMap<
 /// indexed by selector so they can be easily found.
 static void FindImplementableMethods(ASTContext &Context,
  ObjCContainerDecl *Container,
- bool WantInstanceMethods,
+ Optional WantInstanceMethods,
  QualType ReturnType,
  KnownMethodsMap &KnownMethods,
  bool InOriginalClass = true) {
@@ -6718,7 +6718,7 @@ static void FindImplementableMethods(AST
   // we want the methods from this container to override any methods
   // we've previously seen with the same selector.
   for (auto *M : Container->methods()) {
-if (M->isInstanceMethod() == WantInstanceMethods) {
+if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) 
{
   if (!ReturnType.isNull() &&
   !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType()))
 continue;
@@ -7390,8 +7390,7 @@ static void AddObjCKeyValueCompletions(O
   }
 }
 
-void Sema::CodeCompleteObjCMethodDecl(Scope *S, 
-  bool IsInstanceMethod,
+void Sema::CodeCompleteObjCMethodDecl(Scope *S, Optional 
IsInstanceMethod,
   ParsedType ReturnTy) {
   // Determine the return type of the method we're declaring, if
   // provided.
@@ -7446,7 +7445,13 @@ void Sema::CodeCompleteObjCMethodDecl(Sc
 ObjCMethodDecl *Method = M->second.getPointer();
 CodeCompletionBuilder Builder(Results.getAllocator(),
   Results.getCodeCompletionTUInfo());
-
+
+// Add the '-'/'+' prefix if it wasn't provided yet.
+if (!IsInstanceMethod) {
+  Builder.AddTextChunk(Method->isInstanceMethod() ? "-" : "+");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+}
+
 // If the result type was not already provided, add it to the
 // pattern as (type).
  

r316465 - [refactor] Initial outline of implementation of "extract function" refactoring

2017-10-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 24 10:18:45 2017
New Revision: 316465

URL: http://llvm.org/viewvc/llvm-project?rev=316465&view=rev
Log:
[refactor] Initial outline of implementation of "extract function" refactoring

This commit adds an initial, skeleton outline of the "extract function"
refactoring. The extracted function doesn't capture variables / rewrite code
yet, it just basically does a simple copy-paste.
The following initiation rules are specified:

- extraction can only be done for executable code in a function/method/block.
  This means that you can't extract a global variable initialize into a function
  right now.
- simple literals and references are not extractable.

This commit also adds support for full source ranges to clang-refactor's test
mode.

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

Added:
cfe/trunk/lib/Tooling/Refactoring/ASTSelectionRequirements.cpp
cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
cfe/trunk/test/Refactor/Extract/
cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td
cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRegistry.def

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringRuleContext.h
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/test/Refactor/LocalRename/Field.cpp
cfe/trunk/test/Refactor/LocalRename/NoSymbolSelectedError.cpp
cfe/trunk/test/Refactor/tool-test-support.c
cfe/trunk/tools/clang-refactor/TestSupport.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td?rev=316465&r1=316464&r2=316465&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticRefactoringKinds.td Tue Oct 24 
10:18:45 2017
@@ -19,6 +19,13 @@ def err_refactor_no_selection : Error<"r
   "without a selection">;
 def err_refactor_selection_no_symbol : Error<"there is no symbol at the given "
   "location">;
+def err_refactor_selection_invalid_ast : Error<"the provided selection does "
+  "not overlap with the AST nodes of interest">;
+
+def err_refactor_code_outside_of_function : Error<"the selected code is not a "
+  "part of a function's / method's body">;
+def err_refactor_extract_simple_expression : Error<"the selected expression "
+  "is too simple to extract">;
 
 }
 

Modified: cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h?rev=316465&r1=316464&r2=316465&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/ASTSelection.h Tue Oct 24 
10:18:45 2017
@@ -115,6 +115,21 @@ public:
 return SelectedNode.get().Children[I].Node.get();
   }
 
+  /// Returns true when a selected code range is in a function-like body
+  /// of code, like a function, method or a block.
+  ///
+  /// This function can be used to test against selected expressions that are
+  /// located outside of a function, e.g. global variable initializers, default
+  /// argument values, or even template arguments.
+  ///
+  /// Use the \c getFunctionLikeNearestParent to get the function-like parent
+  /// declaration.
+  bool isInFunctionLikeBodyOfCode() const;
+
+  /// Returns the nearest function-like parent declaration or null if such
+  /// declaration doesn't exist.
+  const Decl *getFunctionLikeNearestParent() const;
+
   static Optional
   create(SourceRange SelectionRange, const SelectedASTNode &ASTSelection);
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRegistry.def?rev=316465&r1=316464&r2=316465&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRegistry.def 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRegistry.def 
Tue Oct 24 10:18:45 2017
@@ -3,5 +3,6 @@
 #endif
 
 REFACTORING_ACTION(LocalRename)
+REFACTORING_ACTION(Extract)
 
 #undef REFACTORING_ACTION

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h?r

r316467 - Add missing clangRewrite lib dependency for clangToolingRefactor

2017-10-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 24 10:23:53 2017
New Revision: 316467

URL: http://llvm.org/viewvc/llvm-project?rev=316467&view=rev
Log:
Add missing clangRewrite lib dependency for clangToolingRefactor

Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt?rev=316467&r1=316466&r2=316467&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt Tue Oct 24 10:23:53 2017
@@ -19,5 +19,6 @@ add_clang_library(clangToolingRefactor
   clangFormat
   clangIndex
   clangLex
+  clangRewrite
   clangToolingCore
   )


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


r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

2018-09-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Sep  7 11:59:45 2018
New Revision: 341697

URL: http://llvm.org/viewvc/llvm-project?rev=341697&view=rev
Log:
warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'

Addresses first post-commit feedback for r335081 from Nico

Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=341697&r1=341696&r2=341697&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep  7 
11:59:45 2018
@@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa
   "OpenCL version %0 does not support the option '%1'">, InGroup;
 
 def warn_stdlibcxx_not_found : Warning<
-  "include path for stdlibc++ headers not found; pass '-std=libc++' on the "
+  "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the "
   "command line to use the libc++ standard library instead">,
   InGroup>;
 }

Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp?rev=341697&r1=341696&r2=341697&view=diff
==
--- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
+++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep  7 11:59:45 
2018
@@ -1,5 +1,5 @@
 // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 
2>&1 | FileCheck %s
 // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist 
-stdlib=libc++ %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-std=libc++' on 
the command line to use the libc++ standard library instead
+// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' 
on the command line to use the libc++ standard library instead
 
 // expected-no-diagnostics


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


[libcxx] r337782 - Revert r337727 as it caused Darwin bot failures

2018-07-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jul 23 17:27:31 2018
New Revision: 337782

URL: http://llvm.org/viewvc/llvm-project?rev=337782&view=rev
Log:
Revert r337727 as it caused Darwin bot failures

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=337782&r1=337781&r2=337782&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jul 23 17:27:31 2018
@@ -378,7 +378,7 @@ endif ()
 set(LIBCXX_COMPILER${CMAKE_CXX_COMPILER})
 set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
-set(LIBCXX_HEADER_DIR  ${LIBCXX_BINARY_DIR})
+set(LIBCXX_HEADER_DIR  ${LLVM_BINARY_DIR})
 set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
 
 string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION


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


[libcxx] r337968 - [libc++] Follow-up to r337960: specify lambda's return type to avoid

2018-07-25 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jul 25 14:50:44 2018
New Revision: 337968

URL: http://llvm.org/viewvc/llvm-project?rev=337968&view=rev
Log:
[libc++] Follow-up to r337960: specify lambda's return type to avoid
-Wc++11-narrowing warning on Darwin

The internal CI produced the following diagnostic:
error: non-constant-expression cannot be narrowed from type 'long long' to 
'__darwin_suseconds_t' (aka 'int') in initializer list [-Wc++11-narrowing]
  struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
^~

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337968&r1=337967&r2=337968&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
14:50:44 2018
@@ -393,7 +393,7 @@ bool set_file_times(const path& p, std::
 error_code& ec) {
 #if !defined(_LIBCPP_USE_UTIMENSAT)
   using namespace chrono;
-  auto Convert = [](long nsec) {
+  auto Convert = [](long nsec) -> decltype(std::declval<::timeval>().tv_usec) {
 return duration_cast(nanoseconds(nsec)).count();
   };
   struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},


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


[libcxx] r337984 - [libc++] Follow-up to r337968: use an explicit cast as suggested by Eric

2018-07-25 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jul 25 16:59:54 2018
New Revision: 337984

URL: http://llvm.org/viewvc/llvm-project?rev=337984&view=rev
Log:
[libc++] Follow-up to r337968: use an explicit cast as suggested by Eric

Modified:
libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337984&r1=337983&r2=337984&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 
16:59:54 2018
@@ -393,8 +393,10 @@ bool set_file_times(const path& p, std::
 error_code& ec) {
 #if !defined(_LIBCPP_USE_UTIMENSAT)
   using namespace chrono;
-  auto Convert = [](long nsec) -> decltype(std::declval<::timeval>().tv_usec) {
-return duration_cast(nanoseconds(nsec)).count();
+  auto Convert = [](long nsec) {
+using int_type = decltype(std::declval<::timeval>().tv_usec);
+auto dur = duration_cast(nanoseconds(nsec)).count();
+return static_cast(dur);
   };
   struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
  {TS[1].tv_sec, Convert(TS[1].tv_nsec)}};


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


[clang-tools-extra] r338597 - [clangd] allow clients to control the compilation database by passing in

2018-08-01 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug  1 10:39:29 2018
New Revision: 338597

URL: http://llvm.org/viewvc/llvm-project?rev=338597&view=rev
Log:
[clangd] allow clients to control the compilation database by passing in
compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request

This commit allows clangd to use an in-memory compilation database that's
controlled from the LSP client (-compile_args_from=lsp). It extends the
'workspace/didChangeConfiguration' request to allow the client to pass in a
compilation database subset that needs to be updated in the workspace.

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

Added:
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=338597&r1=338596&r2=338597&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Aug  1 10:39:29 2018
@@ -135,11 +135,8 @@ void ClangdLSPServer::onExit(ExitParams
 
 void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams &Params) {
   PathRef File = Params.textDocument.uri.file();
-  if (Params.metadata && !Params.metadata->extraFlags.empty()) {
-NonCachedCDB.setExtraFlagsForFile(File,
-  std::move(Params.metadata->extraFlags));
-CDB.invalidate(File);
-  }
+  if (Params.metadata && !Params.metadata->extraFlags.empty())
+CDB.setExtraFlagsForFile(File, std::move(Params.metadata->extraFlags));
 
   std::string &Contents = Params.textDocument.text;
 
@@ -250,6 +247,7 @@ void ClangdLSPServer::onDocumentDidClose
   PathRef File = Params.textDocument.uri.file();
   DraftMgr.removeDraft(File);
   Server.removeDocument(File);
+  CDB.invalidate(File);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
@@ -405,12 +403,29 @@ void ClangdLSPServer::applyConfiguration
 const ClangdConfigurationParamsChange &Settings) {
   // Compilation database change.
   if (Settings.compilationDatabasePath.hasValue()) {
-NonCachedCDB.setCompileCommandsDir(
-Settings.compilationDatabasePath.getValue());
-CDB.clear();
+CDB.setCompileCommandsDir(Settings.compilationDatabasePath.getValue());
 
 reparseOpenedFiles();
   }
+
+  // Update to the compilation database.
+  if (Settings.compilationDatabaseChanges) {
+const auto &CompileCommandUpdates = *Settings.compilationDatabaseChanges;
+bool ShouldReparseOpenFiles = false;
+for (auto &Entry : CompileCommandUpdates) {
+  /// The opened files need to be reparsed only when some existing
+  /// entries are changed.
+  PathRef File = Entry.first;
+  if (!CDB.setCompilationCommandForFile(
+  File, tooling::CompileCommand(
+std::move(Entry.second.workingDirectory), File,
+std::move(Entry.second.compilationCommand),
+/*Output=*/"")))
+ShouldReparseOpenFiles = true;
+}
+if (ShouldReparseOpenFiles)
+  reparseOpenedFiles();
+  }
 }
 
 // FIXME: This function needs to be properly tested.
@@ -422,10 +437,13 @@ void ClangdLSPServer::onChangeConfigurat
 ClangdLSPServer::ClangdLSPServer(JSONOutput &Out,
  const clangd::CodeCompleteOptions &CCOpts,
  llvm::Optional CompileCommandsDir,
+ bool ShouldUseInMemoryCDB,
  const ClangdServer::Options &Opts)
-: Out(Out), NonCachedCDB(std::move(CompileCommandsDir)), CDB(NonCachedCDB),
+: Out(Out), CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory()
+ : CompilationDB::makeDirectoryBased(
+   std::move(CompileCommandsDir))),
   CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()),
-  Server(CDB, FSProvider, /*DiagConsumer=*/*this, Opts) {}
+  Server(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this, Opts) {}
 
 bool ClangdLSPServer::run(std::FILE *In, JSONStreamStyle InputStyle) {
   assert(!IsDone && "Run was called before");
@@ -504,3 +522,67 @@ void ClangdLSPServer::reparseOpenedFiles
 Server.addDocument(FilePath, *DraftMgr.getDraft(FilePath),
WantDiagnostics::Auto);
 }
+
+ClangdLSPServer::CompilationDB ClangdLSPServer::CompilationDB::makeInMemory() {
+  return CompilationDB(

[clang-tools-extra] r338919 - [clangd] capitalize diagnostic messages

2018-08-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug  3 13:43:28 2018
New Revision: 338919

URL: http://llvm.org/viewvc/llvm-project?rev=338919&view=rev
Log:
[clangd] capitalize diagnostic messages

The diagnostic messages that are sent to the client from Clangd are now always
capitalized.

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

Modified:
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/test/clangd/diagnostics.test
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
clang-tools-extra/trunk/test/clangd/execute-command.test
clang-tools-extra/trunk/test/clangd/extra-flags.test
clang-tools-extra/trunk/test/clangd/fixits.test
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=338919&r1=338918&r2=338919&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Fri Aug  3 13:43:28 2018
@@ -145,6 +145,13 @@ void printDiag(llvm::raw_string_ostream
   OS << diagLeveltoString(D.Severity) << ": " << D.Message;
 }
 
+/// Capitalizes the first word in the diagnostic's message.
+std::string capitalize(std::string Message) {
+  if (!Message.empty())
+Message[0] = llvm::toUpper(Message[0]);
+  return Message;
+}
+
 /// Returns a message sent to LSP for the main diagnostic in \p D.
 /// The message includes all the notes with their corresponding locations.
 /// However, notes with fix-its are excluded as those usually only contain a
@@ -166,7 +173,7 @@ std::string mainMessage(const Diag &D) {
 printDiag(OS, Note);
   }
   OS.flush();
-  return Result;
+  return capitalize(std::move(Result));
 }
 
 /// Returns a message sent to LSP for the note of the main diagnostic.
@@ -179,7 +186,7 @@ std::string noteMessage(const Diag &Main
   OS << "\n\n";
   printDiag(OS, Main);
   OS.flush();
-  return Result;
+  return capitalize(std::move(Result));
 }
 } // namespace
 

Modified: clang-tools-extra/trunk/test/clangd/diagnostics.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/diagnostics.test?rev=338919&r1=338918&r2=338919&view=diff
==
--- clang-tools-extra/trunk/test/clangd/diagnostics.test (original)
+++ clang-tools-extra/trunk/test/clangd/diagnostics.test Fri Aug  3 13:43:28 
2018
@@ -6,7 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"message": "return type of 'main' is not 'int'",
+# CHECK-NEXT:"message": "Return type of 'main' is not 'int'",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
 # CHECK-NEXT:"character": 4,

Modified: 
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test?rev=338919&r1=338918&r2=338919&view=diff
==
--- clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test 
Fri Aug  3 13:43:28 2018
@@ -24,7 +24,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"message": "variable 'i' is uninitialized when used here",
+# CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
 # CHECK-NEXT:"character": 28,

Modified: clang-tools-extra/trunk/test/clangd/execute-command.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/execute-command.test?rev=338919&r1=338918&r2=338919&view=diff
==
--- clang-tools-extra/trunk/test/clangd/execute-command.test (original)
+++ clang-tools-extra/trunk/test/clangd/execute-command.test Fri Aug  3 
13:43:28 2018
@@ -6,7 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"message": "using the result of an assignment as a 
condition without parentheses",
+# CHECK-NEXT:"message": "Using the result of an assignment as a 
condition without parentheses",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
 # CHECK-NEXT:"character": 37,

Modified: clang-tools-extra/trunk/test/clangd/extra-flags.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/extra-flags.test?rev=338919&r1=338918&r2=338919&view=diff
==
--- clang-tools-extra/trunk/test/

r324514 - [PR36008] Avoid -Wsign-compare warning for enum constants in

2018-02-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Feb  7 12:45:39 2018
New Revision: 324514

URL: http://llvm.org/viewvc/llvm-project?rev=324514&view=rev
Log:
[PR36008] Avoid -Wsign-compare warning for enum constants in
typeof expressions

This commit looks through typeof type at the original expression when diagnosing
-Wsign-compare to avoid an unfriendly diagnostic.

rdar://36588828

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/compare.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=324514&r1=324513&r2=324514&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Feb  7 12:45:39 2018
@@ -8955,6 +8955,16 @@ static void AnalyzeComparison(Sema &S, B
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;

Modified: cfe/trunk/test/Sema/compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compare.c?rev=324514&r1=324513&r2=324514&view=diff
==
--- cfe/trunk/test/Sema/compare.c (original)
+++ cfe/trunk/test/Sema/compare.c Wed Feb  7 12:45:39 2018
@@ -391,3 +391,16 @@ typedef char two_chars[2];
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}


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


r324651 - PR36307: Consume the #pragma options align annotation token after

2018-02-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Feb  8 13:20:43 2018
New Revision: 324651

URL: http://llvm.org/viewvc/llvm-project?rev=324651&view=rev
Log:
PR36307: Consume the #pragma options align annotation token after
semantic analysis to prevent incorrect -Wpragma-pack warning for an included
file

rdar://37354951

Added:
cfe/trunk/test/Sema/Inputs/pragma-align-no-header-change-warning.h
cfe/trunk/test/Sema/pragma-align-no-header-change-warning.c
Modified:
cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=324651&r1=324650&r2=324651&view=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Thu Feb  8 13:20:43 2018
@@ -509,8 +509,10 @@ void Parser::HandlePragmaAlign() {
   Sema::PragmaOptionsAlignKind Kind =
 static_cast(
 reinterpret_cast(Tok.getAnnotationValue()));
-  SourceLocation PragmaLoc = ConsumeAnnotationToken();
-  Actions.ActOnPragmaOptionsAlign(Kind, PragmaLoc);
+  Actions.ActOnPragmaOptionsAlign(Kind, Tok.getLocation());
+  // Consume the token after processing the pragma to enable pragma-specific
+  // #include warnings.
+  ConsumeAnnotationToken();
 }
 
 void Parser::HandlePragmaDump() {

Added: cfe/trunk/test/Sema/Inputs/pragma-align-no-header-change-warning.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inputs/pragma-align-no-header-change-warning.h?rev=324651&view=auto
==
--- cfe/trunk/test/Sema/Inputs/pragma-align-no-header-change-warning.h (added)
+++ cfe/trunk/test/Sema/Inputs/pragma-align-no-header-change-warning.h Thu Feb  
8 13:20:43 2018
@@ -0,0 +1,5 @@
+#pragma options align=mac68k
+
+struct S { int x; };
+
+#pragma options align=reset

Added: cfe/trunk/test/Sema/pragma-align-no-header-change-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-align-no-header-change-warning.c?rev=324651&view=auto
==
--- cfe/trunk/test/Sema/pragma-align-no-header-change-warning.c (added)
+++ cfe/trunk/test/Sema/pragma-align-no-header-change-warning.c Thu Feb  8 
13:20:43 2018
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -Wpragma-pack -I 
%S/Inputs -verify %s
+// expected-no-diagnostics
+
+#include "pragma-align-no-header-change-warning.h"
+


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


r325994 - [Sema][ObjC] Process category attributes before checking protocol uses

2018-02-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Feb 23 15:49:43 2018
New Revision: 325994

URL: http://llvm.org/viewvc/llvm-project?rev=325994&view=rev
Log:
[Sema][ObjC] Process category attributes before checking protocol uses

This ensures that any availability attributes are attached to the
category before the availability for the referenced protocols is checked.

rdar://37829755

Added:
cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.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=325994&r1=325993&r2=325994&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Feb 23 15:49:43 2018
@@ -1835,6 +1835,13 @@ ActOnStartCategoryInterface(SourceLocati
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(CDecl);
 
+  // Process the attributes before looking at protocols to ensure that the
+  // availability attribute is attached to the category to provide availability
+  // checking for protocol uses.
+  if (AttrList)
+ProcessDeclAttributeList(TUScope, CDecl, AttrList);
+  AddPragmaAttributes(TUScope, CDecl);
+
   if (NumProtoRefs) {
 diagnoseUseOfProtocols(*this, CDecl, (ObjCProtocolDecl*const*)ProtoRefs,
NumProtoRefs, ProtoLocs);
@@ -1846,10 +1853,6 @@ ActOnStartCategoryInterface(SourceLocati
 NumProtoRefs, Context); 
   }
 
-  if (AttrList)
-ProcessDeclAttributeList(TUScope, CDecl, AttrList);
-  AddPragmaAttributes(TUScope, CDecl);
-
   CheckObjCDeclScope(CDecl);
   return ActOnObjCContainerStartDefinition(CDecl);
 }

Added: cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m?rev=325994&view=auto
==
--- cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m 
(added)
+++ cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m Fri 
Feb 23 15:49:43 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios10 -Wunguarded-availability -fblocks 
-fsyntax-only -verify %s
+
+__attribute__((availability(ios,unavailable)))
+@protocol Prot // expected-note {{here}}
+
+@end
+
+@interface A
+@end
+
+__attribute__((availability(ios,unavailable)))
+@interface A (Cat)  // No error.
+@end
+
+__attribute__((availability(tvos,unavailable)))
+@interface B @end
+@interface B (Cat)  // expected-error {{'Prot' is unavailable: not 
available on iOS}}
+@end


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


r303751 - [index] The references to explicit class properties should be recorded

2017-05-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 24 09:23:40 2017
New Revision: 303751

URL: http://llvm.org/viewvc/llvm-project?rev=303751&view=rev
Log:
[index] The references to explicit class properties should be recorded

rdar://32376363

Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=303751&r1=303750&r2=303751&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Wed May 24 09:23:40 2017
@@ -254,6 +254,18 @@ public:
   SymbolRoleSet Roles = getRolesForRef(E, Relations);
   return IndexCtx.handleReference(E->getExplicitProperty(), 
E->getLocation(),
   Parent, ParentDC, Roles, Relations, E);
+} else if (const ObjCMethodDecl *Getter = E->getImplicitPropertyGetter()) {
+  // Class properties that are explicitly defined using @property
+  // declarations are represented implicitly as there is no ivar for class
+  // properties.
+  if (Getter->isClassMethod()) {
+if (const auto *PD = Getter->getCanonicalDecl()->findPropertyDecl()) {
+  SmallVector Relations;
+  SymbolRoleSet Roles = getRolesForRef(E, Relations);
+  return IndexCtx.handleReference(PD, E->getLocation(), Parent,
+  ParentDC, Roles, Relations, E);
+}
+  }
 }
 
 // No need to do a handleReference for the objc method, because there will

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=303751&r1=303750&r2=303751&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Wed May 24 09:23:40 2017
@@ -397,8 +397,17 @@ struct Separate separateE;
 void classReceivers() {
   ClassReceivers.p1 = 0;
 // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-2]]:18 | instance-property/ObjC | p1 | 
c:objc(cs)ClassReceivers(cpy)p1 |  | Ref,Writ,RelCont | rel: 1
+// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
+// CHECK: [[@LINE-4]]:18 | class-method/ObjC | setP1: | 
c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | 
Ref,Call,Impl,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
   (void)ClassReceivers.p1;
 // CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-2]]:24 | instance-property/ObjC | p1 | 
c:objc(cs)ClassReceivers(cpy)p1 |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
+// CHECK: [[@LINE-4]]:24 | class-method/ObjC | p1 | 
c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | 
Ref,Call,Impl,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
+
   ClassReceivers.implicit = 0;
 // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
   (void)ClassReceivers.implicit;


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


r303761 - Warn about uses of `@available` that can't suppress the

2017-05-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 24 10:15:29 2017
New Revision: 303761

URL: http://llvm.org/viewvc/llvm-project?rev=303761&view=rev
Log:
Warn about uses of `@available` that can't suppress the
-Wunguarded-availability warnings

rdar://32306520

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Parser/objc-available.m
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 10:15:29 
2017
@@ -2886,6 +2886,10 @@ def warn_partial_message : Warning<"%0 i
 def warn_partial_fwdclass_message : Warning<
 "%0 may be partial because the receiver type is unknown">,
 InGroup, DefaultIgnore;
+def warn_at_available_unchecked_use : Warning<
+  "%select{@available|__builtin_available}0 does not guard availability here; "
+  "use if (%select{@available|__builtin_available}0) instead">,
+  InGroup>;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed May 24 10:15:29 2017
@@ -7284,6 +7284,12 @@ public:
 return true;
   }
 
+  bool VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+SemaRef.Diag(E->getLocStart(), diag::warn_at_available_unchecked_use)
+<< (!SemaRef.getLangOpts().ObjC1);
+return true;
+  }
+
   bool VisitTypeLoc(TypeLoc Ty);
 };
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed May 24 10:15:29 2017
@@ -15762,6 +15762,13 @@ ExprResult Sema::ActOnObjCAvailabilityCh
   if (Spec != AvailSpecs.end())
 Version = Spec->getVersion();
 
+  // The use of `@available` in the enclosing function should be analyzed to
+  // warn when it's used inappropriately (i.e. not if(@available)).
+  if (getCurFunctionOrMethodDecl())
+getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
+  else if (getCurBlock() || getCurLambda())
+getCurFunction()->HasPotentialAvailabilityViolations = true;
+
   return new (Context)
   ObjCAvailabilityCheckExpr(Version, AtLoc, RParen, Context.BoolTy);
 }

Modified: cfe/trunk/test/Parser/objc-available.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-available.m?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/test/Parser/objc-available.m (original)
+++ cfe/trunk/test/Parser/objc-available.m Wed May 24 10:15:29 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -triple 
x86_64-apple-macosx10.10.0 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability 
-Wno-unsupported-availability-guard -triple x86_64-apple-macosx10.10.0 -verify 
%s
 
 void f() {
 

Modified: cfe/trunk/test/SemaObjC/unguarded-availability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability.m?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/test/SemaObjC/unguarded-availability.m (original)
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m Wed May 24 10:15:29 2017
@@ -10,7 +10,7 @@ int func_10_11() AVAILABLE_10_11; // exp
 #ifdef OBJCPP
 // expected-note@+2 6 {{marked partial here}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 6 {{'func_10_12' has been 
explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been 
explicitly marked partial here}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -155,6 +155,16 @@ void test_at(Subscriptable *x) {
   id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only 
available on macOS 10.12 or newer}} expected-note{{@available}}
 }
 
+void uncheckAtAvailable() {
+  if (@available(macOS 10.12, *) || 0) // expected-warning {{@available does 
not guard availability here; use if (@available) instead}}
+func_10_12(); // expected-warning {{'func_10_12' is only available on 
macOS 10.12 or newer}}

r304538 - Avoid calling report_fatal_error in the destructor of raw_fd_ostream

2017-06-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  2 05:36:56 2017
New Revision: 304538

URL: http://llvm.org/viewvc/llvm-project?rev=304538&view=rev
Log:
Avoid calling report_fatal_error in the destructor of raw_fd_ostream
when saving a module timestamp file

This commit doesn't include a test as it requires a test that reproduces
a file write/close error that couldn't really be constructed artificially.

rdar://31860650

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

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304538&r1=304537&r2=304538&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jun  2 05:36:56 2017
@@ -3697,6 +3697,8 @@ static void updateModuleTimestamp(Module
   if (EC)
 return;
   OS << "Timestamp file\n";
+  OS.close();
+  OS.clear_error(); // Avoid triggering a fatal error.
 }
 
 /// \brief Given a cursor at the start of an AST file, scan ahead and drop the


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


r304542 - Tie the macOS tests in test/Integration to the latest macOS SDK

2017-06-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  2 06:26:35 2017
New Revision: 304542

URL: http://llvm.org/viewvc/llvm-project?rev=304542&view=rev
Log:
Tie the macOS tests in test/Integration to the latest macOS SDK

This change will ensure that these tests won't fail when a new SDK that
utilizes new compiler features is used.
See https://reviews.llvm.org/D32178 for more context.

Modified:
cfe/trunk/test/Integration/carbon.c
cfe/trunk/test/Integration/cocoa-pch.m
cfe/trunk/test/Integration/cocoa.m
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/Integration/carbon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Integration/carbon.c?rev=304542&r1=304541&r2=304542&view=diff
==
--- cfe/trunk/test/Integration/carbon.c (original)
+++ cfe/trunk/test/Integration/carbon.c Fri Jun  2 06:26:35 2017
@@ -1,4 +1,5 @@
 // RUN: %clang -fsyntax-only %s
+// REQUIRES: macos-sdk-10.12
 #ifdef __APPLE__
 #include 
 #endif

Modified: cfe/trunk/test/Integration/cocoa-pch.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Integration/cocoa-pch.m?rev=304542&r1=304541&r2=304542&view=diff
==
--- cfe/trunk/test/Integration/cocoa-pch.m (original)
+++ cfe/trunk/test/Integration/cocoa-pch.m Fri Jun  2 06:26:35 2017
@@ -1,6 +1,7 @@
 // RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch
 // RUN: touch %t.empty.m
 // RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang 
-ast-dump 2>&1 > /dev/null
+// REQUIRES: macos-sdk-10.12
 #ifdef __APPLE__
 #include 
 #endif

Modified: cfe/trunk/test/Integration/cocoa.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Integration/cocoa.m?rev=304542&r1=304541&r2=304542&view=diff
==
--- cfe/trunk/test/Integration/cocoa.m (original)
+++ cfe/trunk/test/Integration/cocoa.m Fri Jun  2 06:26:35 2017
@@ -1,4 +1,5 @@
 // RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats
+// REQUIRES: macos-sdk-10.12
 #ifdef __APPLE__
 #include 
 #endif

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=304542&r1=304541&r2=304542&view=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Fri Jun  2 06:26:35 2017
@@ -529,3 +529,6 @@ if run_console_tests != 0:
   config.available_features.add('console')
 
 lit.util.usePlatformSdkOnDarwin(config, lit_config)
+macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
+if macOSSDKVersion is not None:
+config.available_features.add('macos-sdk-' + macOSSDKVersion)


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


r304553 - ASTPrinter: Objective-C method declarations don't need a space after

2017-06-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  2 10:02:59 2017
New Revision: 304553

URL: http://llvm.org/viewvc/llvm-project?rev=304553&view=rev
Log:
ASTPrinter: Objective-C method declarations don't need a space after
the return type

rdar://32332039

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m
cfe/trunk/test/Modules/lookup.m
cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=304553&r1=304552&r2=304553&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jun  2 10:02:59 2017
@@ -1189,7 +1189,9 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   for (const auto *PI : OMD->parameters()) {
 // FIXME: selector is missing here!
 pos = name.find_first_of(':', lastPos);
-Out << " " << name.substr(lastPos, pos - lastPos) << ':';
+if (lastPos != 0)
+  Out << " ";
+Out << name.substr(lastPos, pos - lastPos) << ':';
 PrintObjCMethodType(OMD->getASTContext(), 
 PI->getObjCDeclQualifier(),
 PI->getType());
@@ -1198,7 +1200,7 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   }
 
   if (OMD->param_begin() == OMD->param_end())
-Out << " " << name;
+Out << name;
 
   if (OMD->isVariadic())
   Out << ", ...";

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=304553&r1=304552&r2=304553&view=diff
==
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Fri Jun  2 10:02:59 2017
@@ -17,25 +17,30 @@
 @implementation I
 - (void)MethP 
__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
 - (void)MethI 
__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
+
+- (void)methodWithArg:(int)x andAnotherOne:(int)y { }
 @end
 
 // CHECK: @protocol P
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I : NSObject 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I(CAT)
-// CHECK: - (void) MethCAT __attribute__((availability(macos, 
introduced=10_1_0, deprecated=10_2)));
+// CHECK: - (void)MethCAT __attribute__((availability(macos, 
introduced=10_1_0, deprecated=10_2)));
 // CHECK: @end
 
 // CHECK: @implementation I
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: }
+
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
 // CHECK: }
 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: - (void)methodWithArg:(int)x andAnotherOne:(int)y {
 // CHECK: }
 
 // CHECK: @end

Modified: cfe/trunk/test/Modules/lookup.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup.m?rev=304553&r1=304552&r2=304553&view=diff
==
--- cfe/trunk/test/Modules/lookup.m (original)
+++ cfe/trunk/test/Modules/lookup.m Fri Jun  2 10:02:59 2017
@@ -14,7 +14,7 @@ void test(id x) {
 // expected-note@Inputs/lookup_right.h:3{{also found}}
 }
 
-// CHECK-PRINT: - (int) method;
-// CHECK-PRINT: - (double) method
+// CHECK-PRINT: - (int)method;
+// CHECK-PRINT: - (double)method
 // CHECK-PRINT: void test(id x)
 

Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=304553&r1=304552&r2=304553&view=diff
==
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Fri Jun  2 10:02:59 2017
@@ -1228,7 +1228,7 @@ TEST(DeclPrinter, TestObjCMethod1) {
 "@end\n",
 namedDecl(hasName("A:inRange:"),
   hasDescendant(namedDecl(hasName("printThis".bind("id"),
-"- (int) A:(id)anObject inRange:(long)range"));
+"- (int)A:(id)anObject inRange:(long)range"));
 }
 
 TEST(DeclPrinter, TestObjCProtocol1) {


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


r305117 - [libclang] Merge multiple availability clauses when getting the platform's

2017-06-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  9 16:29:45 2017
New Revision: 305117

URL: http://llvm.org/viewvc/llvm-project?rev=305117&view=rev
Log:
[libclang] Merge multiple availability clauses when getting the platform's
availability

Patch by Ronald Wampler!

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

Modified:
cfe/trunk/test/Index/availability.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.c?rev=305117&r1=305116&r2=305117&view=diff
==
--- cfe/trunk/test/Index/availability.c (original)
+++ cfe/trunk/test/Index/availability.c Fri Jun  9 16:29:45 2017
@@ -8,13 +8,15 @@ enum {
 
 enum {
   old_enum_plat
-} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
+} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
 
-// RUN: c-index-test -test-load-source all %s > %t
-// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
-// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
-// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
-// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar(void) __attribute__((availability(macosx,introduced=10.4))) 
__attribute__((availability(macosx,obsoleted=10.6))) 
__attribute__((availability(ios,introduced=3.2))) 
__attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
 
-// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar2(void) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: FunctionDecl=foo:3:6 {{.*}} (ios, introduced=3.2, deprecated=4.1) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, 
deprecated=10.5, obsoleted=10.7)
+// CHECK: FunctionDecl=bar:13:6 {{.*}} (ios, introduced=3.2) (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
+// CHECK: FunctionDecl=bar2:15:6 {{.*}} (ios, introduced=3.2, deprecated=10.0) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=305117&r1=305116&r2=305117&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jun  9 16:29:45 2017
@@ -7216,15 +7216,11 @@ static CXVersion convertVersion(VersionT
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability 
*availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7236,7 +7232,7 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7247,38 +7243,71 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->getMessage());

r305122 - Revert r305117

2017-06-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  9 17:06:36 2017
New Revision: 305122

URL: http://llvm.org/viewvc/llvm-project?rev=305122&view=rev
Log:
Revert r305117

It caused `Index/availability.c` test failure on Linux

Modified:
cfe/trunk/test/Index/availability.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.c?rev=305122&r1=305121&r2=305122&view=diff
==
--- cfe/trunk/test/Index/availability.c (original)
+++ cfe/trunk/test/Index/availability.c Fri Jun  9 17:06:36 2017
@@ -8,15 +8,13 @@ enum {
 
 enum {
   old_enum_plat
-} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
+} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
 
-void bar(void) __attribute__((availability(macosx,introduced=10.4))) 
__attribute__((availability(macosx,obsoleted=10.6))) 
__attribute__((availability(ios,introduced=3.2))) 
__attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
+// RUN: c-index-test -test-load-source all %s > %t
+// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
+// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
+// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
+// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
 
-void bar2(void) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
-
-// RUN: c-index-test -test-load-source all %s | FileCheck %s
-// CHECK: FunctionDecl=foo:3:6 {{.*}} (ios, introduced=3.2, deprecated=4.1) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
-// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, 
deprecated=10.5, obsoleted=10.7)
-// CHECK: FunctionDecl=bar:13:6 {{.*}} (ios, introduced=3.2) (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
-// CHECK: FunctionDecl=bar2:15:6 {{.*}} (ios, introduced=3.2, deprecated=10.0) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.7)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=305122&r1=305121&r2=305122&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jun  9 17:06:36 2017
@@ -7216,11 +7216,15 @@ static CXVersion convertVersion(VersionT
   return Out;
 }
 
-static void getCursorPlatformAvailabilityForDecl(
-const Decl *D, int *always_deprecated, CXString *deprecated_message,
-int *always_unavailable, CXString *unavailable_message,
-SmallVectorImpl &AvailabilityAttrs) {
+static int getCursorPlatformAvailabilityForDecl(const Decl *D,
+int *always_deprecated,
+CXString *deprecated_message,
+int *always_unavailable,
+CXString *unavailable_message,
+   CXPlatformAvailability 
*availability,
+int availability_size) {
   bool HadAvailAttr = false;
+  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7232,7 +7236,7 @@ static void getCursorPlatformAvailabilit
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7243,71 +7247,38 @@ static void getCursorPlatformAvailabilit
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
-  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
+  if (N < availability_size) {
+availability[N].Platform
+  = cxstring::createDup(Avail->getPlatform()->getName());
+availability[N].Introduced = convertVersion(Avail->getIntroduced());
+availability[N].Deprecated = convertVersion(Avail->getDeprecated());
+availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
+availability[N].Unavailable = Avail->getUnavailable();
+availability[N].Message = cxstring::createDup(Avail->getMessage());
+  }
+  ++N;
 }
   }
 
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst

r305221 - Recommit r305117: [libclang] Merge multiple availability clauses when

2017-06-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jun 12 14:06:30 2017
New Revision: 305221

URL: http://llvm.org/viewvc/llvm-project?rev=305221&view=rev
Log:
Recommit r305117: [libclang] Merge multiple availability clauses when
getting the platform's availability

Patch by Ronald Wampler!

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

Modified:
cfe/trunk/test/Index/availability.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.c?rev=305221&r1=305220&r2=305221&view=diff
==
--- cfe/trunk/test/Index/availability.c (original)
+++ cfe/trunk/test/Index/availability.c Mon Jun 12 14:06:30 2017
@@ -8,13 +8,15 @@ enum {
 
 enum {
   old_enum_plat
-} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
+} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
 
-// RUN: c-index-test -test-load-source all %s > %t
-// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
-// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
-// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
-// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar(void) __attribute__((availability(macosx,introduced=10.4))) 
__attribute__((availability(macosx,obsoleted=10.6))) 
__attribute__((availability(ios,introduced=3.2))) 
__attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
 
-// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar2(void) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: FunctionDecl=foo:3:6{{.*}}(ios, introduced=3.2, deprecated=4.1) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, 
deprecated=10.5, obsoleted=10.7)
+// CHECK: FunctionDecl=bar:13:6{{.*}}(ios, introduced=3.2) (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
+// CHECK: FunctionDecl=bar2:15:6{{.*}}(ios, introduced=3.2, deprecated=10.0) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=305221&r1=305220&r2=305221&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Jun 12 14:06:30 2017
@@ -7216,15 +7216,11 @@ static CXVersion convertVersion(VersionT
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability 
*availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7236,7 +7232,7 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7247,38 +7243,71 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->get

r305504 - [index] Index static_assert declarations

2017-06-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 15 15:50:43 2017
New Revision: 305504

URL: http://llvm.org/viewvc/llvm-project?rev=305504&view=rev
Log:
[index] Index static_assert declarations

static_assert declarations have to be visited while indexing so that we can
gather the references to declarations that are present in their assert
expression.

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305504&r1=305503&r2=305504&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 15:50:43 2017
@@ -682,6 +682,13 @@ public:
   bool VisitImportDecl(const ImportDecl *D) {
 return IndexCtx.importedModule(D);
   }
+
+  bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
+IndexCtx.indexBody(D->getAssertExpr(),
+   dyn_cast(D->getDeclContext()),
+   D->getLexicalDeclContext());
+return true;
+  }
 };
 
 } // anonymous namespace

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305504&r1=305503&r2=305504&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 15:50:43 2017
@@ -433,3 +433,19 @@ template
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+struct StaticAssertRef {
+  static constexpr bool constVar = true;
+};
+
+static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | 
c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0
+// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef 
|  | Ref | rel: 0
+
+void staticAssertInFn() {
+  static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | 
c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | 
rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef 
|  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+}


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


r305508 - [index] Record C++17 global binding declarations

2017-06-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 15 16:19:01 2017
New Revision: 305508

URL: http://llvm.org/viewvc/llvm-project?rev=305508&view=rev
Log:
[index] Record C++17 global binding declarations

The global C++17 binding declarations should be indexed as variable symbols.

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305508&r1=305507&r2=305508&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 16:19:01 2017
@@ -293,6 +293,12 @@ public:
 return true;
   }
 
+  bool VisitDecompositionDecl(const DecompositionDecl *D) {
+for (const auto *Binding : D->bindings())
+  TRY_DECL(Binding, IndexCtx.handleDecl(Binding));
+return Base::VisitDecompositionDecl(D);
+  }
+
   bool VisitFieldDecl(const FieldDecl *D) {
 SmallVector Relations;
 gatherTemplatePseudoOverrides(D, Relations);

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=305508&r1=305507&r2=305508&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Jun 15 16:19:01 2017
@@ -301,6 +301,10 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::TypeAlias;
   Info.Lang = SymbolLanguage::CXX;
   break;
+case Decl::Binding:
+  Info.Kind = SymbolKind::Variable;
+  Info.Lang = SymbolLanguage::CXX;
+  break;
 default:
   break;
 }

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305508&r1=305507&r2=305508&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 16:19:01 2017
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target 
x86_64-apple-macosx10.7 | FileCheck %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def 
| rel: 0
 class Cls { public:
@@ -449,3 +449,29 @@ void staticAssertInFn() {
 // CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef 
|  | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
 }
+
+namespace cpp17structuredBinding {
+
+struct Cpp17StructuredBinding {
+  int x, y;
+
+  Cpp17StructuredBinding(int x, int y): x(x), y(y) { }
+};
+
+auto [structuredBinding1, structuredBinding2] = 
Cpp17StructuredBinding(Record::C, 0);
+// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | 
c:@N@cpp17structuredBinding@structuredBinding1 |  | Decl,RelChild | 
rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Decl,RelChild | 
rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+
+void localStructuredBindingAndRef() {
+  int ref = structuredBinding1;
+// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | 
c:@N@cpp17structuredBinding@structuredBinding1 |  | Ref,Read,RelCont 
| rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
+  auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, 
structuredBinding2);
+// CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont 
| rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
+// CHECK-NOT: localBinding
+}
+
+}


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


r305511 - [Completion] Code complete the members for a dependent type after a '::'

2017-06-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 15 16:40:54 2017
New Revision: 305511

URL: http://llvm.org/viewvc/llvm-project?rev=305511&view=rev
Log:
[Completion] Code complete the members for a dependent type after a '::'

This commit is a follow up to r302797 which added support for dependent
completions after the '.' and '->' operators. This commit adds support for
dependent completions after the '::' operator.

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

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/member-access.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=305511&r1=305510&r2=305511&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jun 15 16:40:54 2017
@@ -4542,8 +4542,10 @@ void Sema::CodeCompleteQualifiedId(Scope
bool EnteringContext) {
   if (!SS.getScopeRep() || !CodeCompleter)
 return;
-  
-  DeclContext *Ctx = computeDeclContext(SS, EnteringContext);
+
+  // Always pretend to enter a context to ensure that a dependent type
+  // resolves to a dependent record.
+  DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true);
   if (!Ctx)
 return;
 
@@ -4573,7 +4575,9 @@ void Sema::CodeCompleteQualifiedId(Scope
   Results.ExitScope();  
   
   CodeCompletionDeclConsumer Consumer(Results, CurContext);
-  LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer);
+  LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer,
+ /*IncludeGlobalScope=*/true,
+ /*IncludeDependentBases=*/true);
 
   HandleCodeCompleteResults(this, CodeCompleter, 
 Results.getCompletionContext(),

Modified: cfe/trunk/test/CodeCompletion/member-access.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=305511&r1=305510&r2=305511&view=diff
==
--- cfe/trunk/test/CodeCompletion/member-access.cpp (original)
+++ cfe/trunk/test/CodeCompletion/member-access.cpp Thu Jun 15 16:40:54 2017
@@ -145,4 +145,22 @@ public:
 // CHECK-CC6: o2 : [#BaseTemplate#]o2
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | 
FileCheck -check-prefix=CHECK-CC6 %s
   }
+
+  static void staticFn(T &obj);
+
+  struct Nested { };
 };
+
+template
+void dependentColonColonCompletion() {
+  Template::staticFn();
+// CHECK-CC7: function : [#void#]function()
+// CHECK-CC7: Nested : Nested
+// CHECK-CC7: o1 : [#BaseTemplate#]o1
+// CHECK-CC7: o2 : [#BaseTemplate#]o2
+// CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>)
+// CHECK-CC7: Template : Template
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | 
FileCheck -check-prefix=CHECK-CC7 %s
+  typename Template::Nested m;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | 
FileCheck -check-prefix=CHECK-CC7 %s
+}


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


r305576 - [PR33394] Avoid lexing editor placeholders when Clang is used only

2017-06-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 16 15:13:39 2017
New Revision: 305576

URL: http://llvm.org/viewvc/llvm-project?rev=305576&view=rev
Log:
[PR33394] Avoid lexing editor placeholders when Clang is used only
for preprocessing

r300667 added support for editor placeholder to Clang. That commit didn’t take
into account that users who use Clang for preprocessing only (-E) will get the
"editor placeholder in source file" error when preprocessing their source
(PR33394). This commit ensures that Clang doesn't lex editor placeholders when
running a preprocessor only action.

rdar://32718000

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

Added:
cfe/trunk/test/Frontend/pp-only-no-editor-placeholders.c
Modified:
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=305576&r1=305575&r2=305576&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Fri Jun 16 15:13:39 2017
@@ -98,6 +98,9 @@ public:
   /// When enabled, preprocessor is in a mode for parsing a single file only.
   bool SingleFileParseMode = false;
 
+  /// When enabled, the preprocessor will construct editor placeholder tokens.
+  bool LexEditorPlaceholders = true;
+
   /// \brief True if the SourceManager should report the original file name for
   /// contents of files that were remapped to other files. Defaults to true.
   bool RemappedFilesKeepOriginalName;
@@ -185,6 +188,7 @@ public:
 ImplicitPTHInclude.clear();
 TokenCache.clear();
 SingleFileParseMode = false;
+LexEditorPlaceholders = true;
 RetainRemappedFileBuffers = true;
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = 0;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=305576&r1=305575&r2=305576&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jun 16 15:13:39 2017
@@ -2379,9 +2379,51 @@ static void ParseLangArgs(LangOptions &O
   Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
 }
 
+static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
+  switch (Action) {
+  case frontend::ASTDeclList:
+  case frontend::ASTDump:
+  case frontend::ASTPrint:
+  case frontend::ASTView:
+  case frontend::EmitAssembly:
+  case frontend::EmitBC:
+  case frontend::EmitHTML:
+  case frontend::EmitLLVM:
+  case frontend::EmitLLVMOnly:
+  case frontend::EmitCodeGenOnly:
+  case frontend::EmitObj:
+  case frontend::FixIt:
+  case frontend::GenerateModule:
+  case frontend::GenerateModuleInterface:
+  case frontend::GeneratePCH:
+  case frontend::GeneratePTH:
+  case frontend::ParseSyntaxOnly:
+  case frontend::ModuleFileInfo:
+  case frontend::VerifyPCH:
+  case frontend::PluginAction:
+  case frontend::PrintDeclContext:
+  case frontend::RewriteObjC:
+  case frontend::RewriteTest:
+  case frontend::RunAnalysis:
+  case frontend::MigrateSource:
+return false;
+
+  case frontend::DumpRawTokens:
+  case frontend::DumpTokens:
+  case frontend::InitOnly:
+  case frontend::PrintPreamble:
+  case frontend::PrintPreprocessedInput:
+  case frontend::RewriteMacros:
+  case frontend::RunPreprocessorOnly:
+return true;
+  }
+  llvm_unreachable("invalid frontend action");
+}
+
 static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
   FileManager &FileMgr,
-  DiagnosticsEngine &Diags) {
+  DiagnosticsEngine &Diags,
+  frontend::ActionKind Action) {
   using namespace options;
   Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch);
   Opts.ImplicitPTHInclude = Args.getLastArgValue(OPT_include_pth);
@@ -2454,6 +2496,12 @@ static void ParsePreprocessorArgs(Prepro
 else
   Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
   }
+
+  // Always avoid lexing editor placeholders when we're just running the
+  // preprocessor as we never want to emit the
+  // "editor placeholder in source file" error in PP only mode.
+  if (isStrictlyPreprocessorAction(Action))
+Opts.LexEditorPlaceholders = false;
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
@@ -2461,45 +2509,10 @@ static void ParsePreprocessorOutputArgs(
 frontend::ActionKind Action) {
   using namespace options;
 
-  switch (Action) {
-  case frontend::ASTDeclList:
-  case front

r305678 - [driver][macOS] Pick the system version for the deployment target

2017-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jun 19 05:57:27 2017
New Revision: 305678

URL: http://llvm.org/viewvc/llvm-project?rev=305678&view=rev
Log:
[driver][macOS] Pick the system version for the deployment target
if the SDK is newer than the system

This commit improves the driver by making sure that it picks the system version
for the deployment target when the version of the macOS SDK is newer than the
system version.

rdar://29449467

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-sdkroot.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=305678&r1=305677&r2=305678&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Jun 19 05:57:27 2017
@@ -1118,6 +1118,25 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   }
 }
 
+/// Returns the most appropriate macOS target version for the current process.
+///
+/// If the macOS SDK version is the same or earlier than the system version,
+/// then the SDK version is returned. Otherwise the system version is returned.
+static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
+  unsigned Major, Minor, Micro;
+  llvm::Triple(llvm::sys::getProcessTriple())
+  .getMacOSXVersion(Major, Minor, Micro);
+  VersionTuple SystemVersion(Major, Minor, Micro);
+  bool HadExtra;
+  if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
+ HadExtra))
+return MacOSSDKVersion;
+  VersionTuple SDKVersion(Major, Minor, Micro);
+  if (SDKVersion > SystemVersion)
+return SystemVersion.getAsString();
+  return MacOSSDKVersion;
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 
@@ -1210,7 +1229,7 @@ void Darwin::AddDeploymentTarget(Derived
 SDK.startswith("iPhoneSimulator"))
   iOSTarget = Version;
 else if (SDK.startswith("MacOSX"))
-  OSXTarget = Version;
+  OSXTarget = getSystemOrSDKMacOSVersion(Version);
 else if (SDK.startswith("WatchOS") ||
  SDK.startswith("WatchSimulator"))
   WatchOSTarget = Version;

Modified: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=305678&r1=305677&r2=305678&view=diff
==
--- cfe/trunk/test/Driver/darwin-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Mon Jun 19 05:57:27 2017
@@ -74,3 +74,12 @@
 // CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
 // CHECK-MACOSX: ld
 // CHECK-MACOSX: "-macosx_version_min" "10.10.0"
+
+// Ensure that we never pick a version that's based on the SDK that's newer 
than
+// the system version:
+// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
+// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
+// RUN: %clang -target x86_64-apple-darwin -isysroot 
%t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
+
+// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"


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


r305680 - Add missing OS check to r305678

2017-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jun 19 06:25:37 2017
New Revision: 305680

URL: http://llvm.org/viewvc/llvm-project?rev=305680&view=rev
Log:
Add missing OS check to r305678

That commit failed on non-macOS buildbots as I've forgotten to make sure that
the system on which Clang is running on is actually macOS.

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

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=305680&r1=305679&r2=305680&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Jun 19 06:25:37 2017
@@ -1124,8 +1124,10 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 /// then the SDK version is returned. Otherwise the system version is returned.
 static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
   unsigned Major, Minor, Micro;
-  llvm::Triple(llvm::sys::getProcessTriple())
-  .getMacOSXVersion(Major, Minor, Micro);
+  llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+  if (!SystemTriple.isMacOSX())
+return MacOSSDKVersion;
+  SystemTriple.getMacOSXVersion(Major, Minor, Micro);
   VersionTuple SystemVersion(Major, Minor, Micro);
   bool HadExtra;
   if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,


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


r305685 - Move the test from r305678 to a separte file with 'REQUIRES: system-darwin'

2017-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jun 19 07:13:59 2017
New Revision: 305685

URL: http://llvm.org/viewvc/llvm-project?rev=305685&view=rev
Log:
Move the test from r305678 to a separte file with 'REQUIRES: system-darwin'

Otherwise it will fail on non-macOS systems.

Added:
cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c
Modified:
cfe/trunk/test/Driver/darwin-sdkroot.c

Added: cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c?rev=305685&view=auto
==
--- cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c (added)
+++ cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c Mon Jun 19 07:13:59 2017
@@ -0,0 +1,10 @@
+// REQUIRES: system-darwin
+
+// Ensure that we never pick a version that's based on the SDK that's newer 
than
+// the system version:
+// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
+// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
+// RUN: %clang -target x86_64-apple-darwin -isysroot 
%t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
+
+// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"

Modified: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=305685&r1=305684&r2=305685&view=diff
==
--- cfe/trunk/test/Driver/darwin-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Mon Jun 19 07:13:59 2017
@@ -74,12 +74,3 @@
 // CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
 // CHECK-MACOSX: ld
 // CHECK-MACOSX: "-macosx_version_min" "10.10.0"
-
-// Ensure that we never pick a version that's based on the SDK that's newer 
than
-// the system version:
-// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
-// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
-// RUN: %clang -target x86_64-apple-darwin -isysroot 
%t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
-
-// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"


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


r305719 - [Parser][ObjC] Use an artificial EOF token while parsing lexed ObjC methods

2017-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Jun 19 12:53:21 2017
New Revision: 305719

URL: http://llvm.org/viewvc/llvm-project?rev=305719&view=rev
Log:
[Parser][ObjC] Use an artificial EOF token while parsing lexed ObjC methods

This change avoid a crash that occurred when skipping to EOF while parsing an
ObjC interface/implementation.

rdar://31963299

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

Added:
cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
cfe/trunk/test/Parser/objc-at-interface-eof-crash.m
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=305719&r1=305718&r2=305719&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Jun 19 12:53:21 2017
@@ -3627,6 +3627,14 @@ void Parser::ParseLexedObjCMethodDefs(Le
   SourceLocation OrigLoc = Tok.getLocation();
 
   assert(!LM.Toks.empty() && "ParseLexedObjCMethodDef - Empty body!");
+  // Store an artificial EOF token to ensure that we don't run off the end of
+  // the method's body when we come to parse it.
+  Token Eof;
+  Eof.startToken();
+  Eof.setKind(tok::eof);
+  Eof.setEofData(MCDecl);
+  Eof.setLocation(OrigLoc);
+  LM.Toks.push_back(Eof);
   // Append the current token at the end of the new token stream so that it
   // doesn't get lost.
   LM.Toks.push_back(Tok);
@@ -3658,7 +3666,7 @@ void Parser::ParseLexedObjCMethodDefs(Le
   Actions.ActOnDefaultCtorInitializers(MCDecl);
 ParseFunctionStatementBody(MCDecl, BodyScope);
   }
-  
+
   if (Tok.getLocation() != OrigLoc) {
 // Due to parsing error, we either went over the cached tokens or
 // there are still cached tokens left. If it's the latter case skip the
@@ -3670,4 +3678,6 @@ void Parser::ParseLexedObjCMethodDefs(Le
   while (Tok.getLocation() != OrigLoc && Tok.isNot(tok::eof))
 ConsumeAnyToken();
   }
+  // Clean up the remaining EOF token.
+  ConsumeAnyToken();
 }

Added: cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m?rev=305719&view=auto
==
--- cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m (added)
+++ cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m Mon Jun 19 
12:53:21 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface ClassA
+
+- (void)fileExistsAtPath:(int)x;
+
+@end
+
+@interface ClassB
+
+@end
+
+@implementation ClassB // expected-note {{implementation started here}}
+
+- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
+  mgr fileExistsAtPath:0
+} // expected-error {{expected ']'}}
+
+@implementation ClassC // expected-error {{missing '@end'}} // expected-error 
{{expected '}'}} // expected-warning {{cannot find interface declaration for 
'ClassC'}}
+
+@end

Added: cfe/trunk/test/Parser/objc-at-interface-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-interface-eof-crash.m?rev=305719&view=auto
==
--- cfe/trunk/test/Parser/objc-at-interface-eof-crash.m (added)
+++ cfe/trunk/test/Parser/objc-at-interface-eof-crash.m Mon Jun 19 12:53:21 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface ClassA
+
+- (void)fileExistsAtPath:(int)x;
+
+@end
+
+@interface ClassB
+
+@end
+
+@implementation ClassB // expected-note {{implementation started here}}
+
+- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
+  mgr fileExistsAtPath:0
+} // expected-error {{expected ']'}}
+
+@interface ClassC // expected-error {{missing '@end'}} // expected-error 
{{expected '}'}}
+
+@end


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


r305803 - Split the expectations in tests from r305719 over multiple lines to

2017-06-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 20 11:12:26 2017
New Revision: 305803

URL: http://llvm.org/viewvc/llvm-project?rev=305803&view=rev
Log:
Split the expectations in tests from r305719 over multiple lines to
enhance readability

As suggested by Duncan Exon Smith!

Modified:
cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
cfe/trunk/test/Parser/objc-at-interface-eof-crash.m

Modified: cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m?rev=305803&r1=305802&r2=305803&view=diff
==
--- cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m (original)
+++ cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m Tue Jun 20 
11:12:26 2017
@@ -16,6 +16,9 @@
   mgr fileExistsAtPath:0
 } // expected-error {{expected ']'}}
 
-@implementation ClassC // expected-error {{missing '@end'}} // expected-error 
{{expected '}'}} // expected-warning {{cannot find interface declaration for 
'ClassC'}}
+@implementation ClassC //  \
+  // expected-error {{missing '@end'}} \
+  // expected-error {{expected '}'}}   \
+  // expected-warning {{cannot find interface declaration for 'ClassC'}}
 
 @end

Modified: cfe/trunk/test/Parser/objc-at-interface-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-interface-eof-crash.m?rev=305803&r1=305802&r2=305803&view=diff
==
--- cfe/trunk/test/Parser/objc-at-interface-eof-crash.m (original)
+++ cfe/trunk/test/Parser/objc-at-interface-eof-crash.m Tue Jun 20 11:12:26 2017
@@ -16,6 +16,8 @@
   mgr fileExistsAtPath:0
 } // expected-error {{expected ']'}}
 
-@interface ClassC // expected-error {{missing '@end'}} // expected-error 
{{expected '}'}}
+@interface ClassC //   \
+  // expected-error {{missing '@end'}} \
+  // expected-error {{expected '}'}}
 
 @end


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


r305804 - Add a missing '[' to the tests from r305719

2017-06-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 20 11:16:11 2017
New Revision: 305804

URL: http://llvm.org/viewvc/llvm-project?rev=305804&view=rev
Log:
Add a missing '[' to the tests from r305719

This clarifies the tests as the missing ']' is important, and not the '['.

Modified:
cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
cfe/trunk/test/Parser/objc-at-interface-eof-crash.m

Modified: cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m?rev=305804&r1=305803&r2=305804&view=diff
==
--- cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m (original)
+++ cfe/trunk/test/Parser/objc-at-implementation-eof-crash.m Tue Jun 20 
11:16:11 2017
@@ -13,7 +13,7 @@
 @implementation ClassB // expected-note {{implementation started here}}
 
 - (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
-  mgr fileExistsAtPath:0
+  [mgr fileExistsAtPath:0
 } // expected-error {{expected ']'}}
 
 @implementation ClassC //  \

Modified: cfe/trunk/test/Parser/objc-at-interface-eof-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-at-interface-eof-crash.m?rev=305804&r1=305803&r2=305804&view=diff
==
--- cfe/trunk/test/Parser/objc-at-interface-eof-crash.m (original)
+++ cfe/trunk/test/Parser/objc-at-interface-eof-crash.m Tue Jun 20 11:16:11 2017
@@ -13,7 +13,7 @@
 @implementation ClassB // expected-note {{implementation started here}}
 
 - (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
-  mgr fileExistsAtPath:0
+  [mgr fileExistsAtPath:0
 } // expected-error {{expected ']'}}
 
 @interface ClassC //   \


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


r305891 - Revert r305678: [driver][macOS] Pick the system version for the

2017-06-21 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jun 21 05:27:24 2017
New Revision: 305891

URL: http://llvm.org/viewvc/llvm-project?rev=305891&view=rev
Log:
Revert r305678: [driver][macOS] Pick the system version for the
deployment target if the SDK is newer than the system

This commit also reverts follow-up commits r305680 and r305685 that have
buildbot fixes.

The change in r305678 wasn't correct because it relied on
`llvm::sys::getProcessTriple`, which uses a pre-configured OS version. We should
lookup the actual macOS version of the system on which the compiler is running.

Removed:
cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=305891&r1=305890&r2=305891&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Jun 21 05:27:24 2017
@@ -1118,27 +1118,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   }
 }
 
-/// Returns the most appropriate macOS target version for the current process.
-///
-/// If the macOS SDK version is the same or earlier than the system version,
-/// then the SDK version is returned. Otherwise the system version is returned.
-static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) {
-  unsigned Major, Minor, Micro;
-  llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
-  if (!SystemTriple.isMacOSX())
-return MacOSSDKVersion;
-  SystemTriple.getMacOSXVersion(Major, Minor, Micro);
-  VersionTuple SystemVersion(Major, Minor, Micro);
-  bool HadExtra;
-  if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro,
- HadExtra))
-return MacOSSDKVersion;
-  VersionTuple SDKVersion(Major, Minor, Micro);
-  if (SDKVersion > SystemVersion)
-return SystemVersion.getAsString();
-  return MacOSSDKVersion;
-}
-
 void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 
@@ -1231,7 +1210,7 @@ void Darwin::AddDeploymentTarget(Derived
 SDK.startswith("iPhoneSimulator"))
   iOSTarget = Version;
 else if (SDK.startswith("MacOSX"))
-  OSXTarget = getSystemOrSDKMacOSVersion(Version);
+  OSXTarget = Version;
 else if (SDK.startswith("WatchOS") ||
  SDK.startswith("WatchSimulator"))
   WatchOSTarget = Version;

Removed: cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c?rev=305890&view=auto
==
--- cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c (original)
+++ cfe/trunk/test/Driver/darwin-sdk-vs-os-version.c (removed)
@@ -1,10 +0,0 @@
-// REQUIRES: system-darwin
-
-// Ensure that we never pick a version that's based on the SDK that's newer 
than
-// the system version:
-// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk
-// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk
-// RUN: %clang -target x86_64-apple-darwin -isysroot 
%t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s
-
-// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99"


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


r305911 - [index] Nested class declarations should be annotated with the

2017-06-21 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jun 21 08:51:04 2017
New Revision: 305911

URL: http://llvm.org/viewvc/llvm-project?rev=305911&view=rev
Log:
[index] Nested class declarations should be annotated with the
"specializationOf" relation if they pseudo-override a type in the base template

This commit fixes an issue where Xcode's renaming engine couldn't find the
reference to the second occurrence of "InnerClass" in this example:

template struct Ts { template struct InnerClass { }; };

template<> struct Ts {
template struct InnerClass; // This occurrence wasn't renamed
};

rdar://31884960

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305911&r1=305910&r2=305911&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jun 21 08:51:04 2017
@@ -351,9 +351,11 @@ public:
 IndexCtx.indexTagDecl(D, Relations);
   } else {
 auto *Parent = dyn_cast(D->getDeclContext());
+SmallVector Relations;
+gatherTemplatePseudoOverrides(D, Relations);
 return IndexCtx.handleReference(D, D->getLocation(), Parent,
 D->getLexicalDeclContext(),
-SymbolRoleSet());
+SymbolRoleSet(), Relations);
   }
 }
 return true;

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305911&r1=305910&r2=305911&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Wed Jun 21 08:51:04 2017
@@ -134,6 +134,9 @@ class PseudoOverridesInSpecializations {
 
   template struct InnerTemplate { };
   template struct InnerTemplate  { };
+
+  template
+  class InnerClass { };
 };
 
 template<>
@@ -195,8 +198,22 @@ class PseudoOverridesInSpecializations2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerTemplate
   template struct InnerTemplate  { };
+
+  template
+  class InnerClass;
+// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | 
c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass |  | 
Ref,RelCont,RelSpecialization | rel: 2
+// CHECK-NEXT: RelCont
+// CHECK-NEXT: RelSpecialization | InnerClass | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerClass
 };
 
+template
+class PseudoOverridesInSpecializations::InnerClass {
+};
+// CHECK: [[@LINE-2]]:54 | class(Gen)/C++ | InnerClass | 
c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass |  | 
Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild
+// CHECK: [[@LINE-4]]:7 | class(Gen)/C++ | PseudoOverridesInSpecializations | 
c:@ST>2#T#T@PseudoOverridesInSpecializations |  | Ref,RelCont | rel: 
1
+// CHECK-NEXT: RelCont
+
 template
 class PseudoOverridesInSpecializations {
   typedef float TypealiasOrRecord;


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


r305996 - [index] Add the "SpecializationOf" relation to the forward declarations

2017-06-22 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 22 06:20:07 2017
New Revision: 305996

URL: http://llvm.org/viewvc/llvm-project?rev=305996&view=rev
Log:
[index] Add the "SpecializationOf" relation to the forward declarations
of class template specializations

This commit fixes an issue where a forward declaration of a class template
specialization was not related to the base template. We need to relate even
forward declarations because specializations don't have to be defined.

rdar://32869409

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305996&r1=305995&r2=305996&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 22 06:20:07 2017
@@ -611,18 +611,16 @@ public:
ClassTemplateSpecializationDecl *D) 
{
 // FIXME: Notify subsequent callbacks if info comes from implicit
 // instantiation.
-if (D->isThisDeclarationADefinition()) {
-  llvm::PointerUnion
-  Template = D->getSpecializedTemplateOrPartial();
-  const Decl *SpecializationOf =
-  Template.is()
-  ? (Decl *)Template.get()
-  : Template.get();
-  IndexCtx.indexTagDecl(
-  D, 
SymbolRelation(SymbolRoleSet(SymbolRole::RelationSpecializationOf),
-SpecializationOf));
-}
+llvm::PointerUnion
+Template = D->getSpecializedTemplateOrPartial();
+const Decl *SpecializationOf =
+Template.is()
+? (Decl *)Template.get()
+: Template.get();
+IndexCtx.indexTagDecl(
+D, SymbolRelation(SymbolRoleSet(SymbolRole::RelationSpecializationOf),
+  SpecializationOf));
 if (TypeSourceInfo *TSI = D->getTypeAsWritten())
   IndexCtx.indexTypeSourceInfo(TSI, /*Parent=*/nullptr,
D->getLexicalDeclContext());

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305996&r1=305995&r2=305996&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 22 06:20:07 2017
@@ -282,7 +282,9 @@ class SpecializationDecl { };
 
 template<>
 class SpecializationDecl;
-// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#I |  | Decl,RelSpecialization | rel: 1
+// CHECK-NEXT: RelSpecialization | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl
+// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
 
 template<>
 class SpecializationDecl { };
@@ -292,8 +294,10 @@ class SpecializationDecl { };
 
 template
 class PartialSpecilizationClass;
-// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | PartialSpecilizationClass | 
c:@ST>2#T#T@PartialSpecilizationClass |  | Ref | rel: 0
-// CHECK-NEXT: [[@LINE-2]]:33 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
+// CHECK: [[@LINE-1]]:7 | class(Gen,TPS)/C++ | PartialSpecilizationClass | 
c:@SP>1#T@PartialSpecilizationClass>#$@S@Cls#t0.0 |  | 
Decl,RelSpecialization | rel: 1
+// CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | 
c:@ST>2#T#T@PartialSpecilizationClass
+// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | PartialSpecilizationClass | 
c:@ST>2#T#T@PartialSpecilizationClass |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-4]]:33 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
 
 template<>
 class PartialSpecilizationClass : Cls { };


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


r306033 - [Sema] Add -Wunguarded-availability-new

2017-06-22 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jun 22 12:02:24 2017
New Revision: 306033

URL: http://llvm.org/viewvc/llvm-project?rev=306033&view=rev
Log:
[Sema] Add -Wunguarded-availability-new

The new compiler warning -Wunguarded-availability-new is a subset of
-Wunguarded-availability. It is on by default. It only warns about uses of APIs
that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and
tvOS >= 11. We decided to use this kind of solution as we didn't want to turn
on -Wunguarded-availability by default, because we didn't want our users to get
warnings about uses of old APIs in their existing projects.

rdar://31054725

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

Added:
cfe/trunk/test/SemaObjC/unguarded-availability-new.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=306033&r1=306032&r2=306033&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jun 22 12:02:24 2017
@@ -98,7 +98,9 @@ def CXX11CompatDeprecatedWritableStr :
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
-def UnguardedAvailability : DiagGroup<"unguarded-availability">;
+def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
+def UnguardedAvailability : DiagGroup<"unguarded-availability",
+  [UnguardedAvailabilityNew]>;
 // partial-availability is an alias of unguarded-availability.
 def : DiagGroup<"partial-availability", [UnguardedAvailability]>;
 def DeprecatedDynamicExceptionSpec

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=306033&r1=306032&r2=306033&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 22 12:02:24 
2017
@@ -2870,8 +2870,13 @@ def note_protocol_method : Note<
 def warn_unguarded_availability :
   Warning<"%0 is only available on %1 %2 or newer">,
   InGroup, DefaultIgnore;
+def warn_unguarded_availability_new :
+  Warning,
+  InGroup;
 def warn_partial_availability : Warning<"%0 is only available conditionally">,
 InGroup, DefaultIgnore;
+def warn_partial_availability_new : Warning,
+  InGroup;
 def note_partial_availability_silence : Note<
   "explicitly redeclare %0 to silence this warning">;
 def note_unguarded_available_silence : Note<
@@ -2879,9 +2884,14 @@ def note_unguarded_available_silence : N
   " this warning">;
 def warn_partial_message : Warning<"%0 is partial: %1">,
 InGroup, DefaultIgnore;
+def warn_partial_message_new : Warning,
+  InGroup;
 def warn_partial_fwdclass_message : Warning<
 "%0 may be partial because the receiver type is unknown">,
 InGroup, DefaultIgnore;
+def warn_partial_fwdclass_message_new :
+  Warning,
+  InGroup;
 def warn_at_available_unchecked_use : Warning<
   "%select{@available|__builtin_available}0 does not guard availability here; "
   "use if (%select{@available|__builtin_available}0) instead">,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=306033&r1=306032&r2=306033&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jun 22 12:02:24 2017
@@ -6903,6 +6903,32 @@ static bool ShouldDiagnoseAvailabilityIn
   return true;
 }
 
+static bool
+shouldDiagnoseAvailabilityByDefault(const ASTContext &Context,
+const VersionTuple &DeploymentVersion,
+const VersionTuple &DeclVersion) {
+  const auto &Triple = Context.getTargetInfo().getTriple();
+  VersionTuple ForceAvailabilityFromVersion;
+  switch (Triple.getOS()) {
+  case llvm::Triple::IOS:
+  case llvm::Triple::TvOS:
+ForceAvailabilityFromVersion = VersionTuple(/*Major=*/11);
+break;
+  case llvm::Triple::WatchOS:
+ForceAvailabilityFromVersion = VersionTuple(/*Major=*/4);
+break;
+  case llvm::Triple::Darwin:
+  case llvm::Triple::MacOSX:
+ForceAvailabilityFromVersion = VersionTuple(/*Major=*/10, /*Minor=*/13);
+break;
+  default:
+// New targets should always warn about availability.
+return Triple.getVendor() == llvm::Triple::Apple;
+  }
+  return DeploymentVersion >= ForceAvai

r306103 - PR26195: Set correct NestedNameSpecifierLoc for the dependent initializer

2017-06-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 23 09:10:07 2017
New Revision: 306103

URL: http://llvm.org/viewvc/llvm-project?rev=306103&view=rev
Log:
PR26195: Set correct NestedNameSpecifierLoc for the dependent initializer

This commit fixes incorrect source positions of dependent c'tor initializers
like in the following code:

template
struct Derived: MyBase::InnerIterator
{

Derived() : MyBase::InnerIterator() {} /// This line is problematic: all 
positions point to InnerIterator and nothing points to MyBase
};

Patch by Serge Preis!

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

Added:
cfe/trunk/test/Index/ctor-init-source-loc.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=306103&r1=306102&r2=306103&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jun 23 09:10:07 2017
@@ -3778,6 +3778,15 @@ Sema::BuildMemInitializer(Decl *Construc
   if (BaseType.isNull())
 return true;
 
+  TInfo = Context.CreateTypeSourceInfo(BaseType);
+  DependentNameTypeLoc TL =
+  TInfo->getTypeLoc().castAs();
+  if (!TL.isNull()) {
+TL.setNameLoc(IdLoc);
+TL.setElaboratedKeywordLoc(SourceLocation());
+TL.setQualifierLoc(SS.getWithLocInContext(Context));
+  }
+
   R.clear();
   R.setLookupName(MemberOrBase);
 }

Added: cfe/trunk/test/Index/ctor-init-source-loc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ctor-init-source-loc.cpp?rev=306103&view=auto
==
--- cfe/trunk/test/Index/ctor-init-source-loc.cpp (added)
+++ cfe/trunk/test/Index/ctor-init-source-loc.cpp Fri Jun 23 09:10:07 2017
@@ -0,0 +1,117 @@
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+template
+struct Derived:  MyBase::InnerIterator
+{
+Derived() : MyBase::InnerIterator() {}
+// CHECK:  TypeRef=MyBase:2:19 Extent=[5:17 - 5:23]
+};
+
+template
+struct Derived2:  MyBase::Deeper::InnerIterator
+{
+Derived2() : MyBase::Deeper::InnerIterator() {}
+// CHECK:  TypeRef=MyBase:9:19 Extent=[12:18 - 12:24]
+};
+
+template
+struct Templ;
+
+template
+struct Derived3:  Templ::InnerIterator
+{
+Derived3() : Templ::InnerIterator() {}
+// CHECK: TemplateRef=Templ:17:8 Extent=[22:18 - 22:23]
+// CHECK: TypeRef=MyBase:19:19 Extent=[22:24 - 22:30]
+};
+
+
+struct Outer {
+template 
+struct Inner {
+typedef Q Parm;
+};
+};
+
+template
+struct Derived4:  Outer::Inner::Parm
+{
+Derived4() : Outer::Inner::Parm() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[38:18 - 38:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[38:25 - 38:30]
+// CHECK: TypeRef=Q:35:19 Extent=[38:31 - 38:32]
+};
+
+template
+struct Derived5:  Outer::Inner::Parm::InnerIterator
+{
+Derived5() : Outer::Inner::Parm::InnerIterator() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[47:18 - 47:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[47:25 - 47:30]
+// CHECK: TypeRef=Q:44:19 Extent=[47:31 - 47:32]
+};
+
+template
+struct Derived6:  Outer::Inner
+{
+Derived6() : Outer::Inner() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[56:18 - 56:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[56:25 - 56:30]
+// CHECK: TypeRef=Q:53:19 Extent=[56:31 - 56:32]
+};
+
+struct Base {};
+
+struct Derived7:  Outer::Inner::Parm
+{
+Derived7() : Outer::Inner::Parm() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[66:18 - 66:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[66:25 - 66:30]
+// CHECK: TypeRef=struct Base:62:8 Extent=[66:31 - 66:35]
+};
+
+struct Derived8:  Outer::Inner
+{
+Derived8() : Outer::Inner() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[74:18 - 74:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[74:25 - 74:30]
+// CHECK: TypeRef=struct Base:62:8 Extent=[74:31 - 74:35]
+};
+
+namespace Namespace {
+template struct Templ;
+
+struct Outer {
+template 
+struct Inner {
+typedef Q Parm;
+};
+};
+}
+
+template
+struct Derived9:  Namespace::Templ::InnerIterator
+{
+Derived9() : Namespace::Templ::InnerIterator() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[94:18 - 94:27]
+// CHECK: TemplateRef=Templ:81:33 Extent=[94:29 - 94:34]
+// CHECK: TypeRef=MyBase:91:19 Extent=[94:35 - 94:41]
+};
+
+template
+struct Derived10:  Namespace::Templ
+{
+Derived10() : Namespace::Templ() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[103:19 - 103:28]
+// CHECK: TemplateRef=Templ:81:33 Extent=[103:30 - 103:35]
+// CHECK: TypeRef=MyBase:100:19 Extent=[103:36 - 103:42]
+};
+
+template
+struct Derived11:  Namespace::Outer::Inner::Parm
+{
+Derived11() : Namespace::Outer::Inner::Parm() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[112:19 

r306111 - Revert r306103: "PR26195: Set correct NestedNameSpecifierLoc for the

2017-06-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun 23 10:10:54 2017
New Revision: 306111

URL: http://llvm.org/viewvc/llvm-project?rev=306111&view=rev
Log:
Revert r306103: "PR26195: Set correct NestedNameSpecifierLoc for the
dependent initializer"

It caused buildbot failures such as this one:
http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/3777/steps/test_clang/logs/Clang%20%3A%3A%20Index__ctor-init-source-loc.cpp

Removed:
cfe/trunk/test/Index/ctor-init-source-loc.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=306111&r1=306110&r2=306111&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jun 23 10:10:54 2017
@@ -3778,15 +3778,6 @@ Sema::BuildMemInitializer(Decl *Construc
   if (BaseType.isNull())
 return true;
 
-  TInfo = Context.CreateTypeSourceInfo(BaseType);
-  DependentNameTypeLoc TL =
-  TInfo->getTypeLoc().castAs();
-  if (!TL.isNull()) {
-TL.setNameLoc(IdLoc);
-TL.setElaboratedKeywordLoc(SourceLocation());
-TL.setQualifierLoc(SS.getWithLocInContext(Context));
-  }
-
   R.clear();
   R.setLookupName(MemberOrBase);
 }

Removed: cfe/trunk/test/Index/ctor-init-source-loc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ctor-init-source-loc.cpp?rev=306110&view=auto
==
--- cfe/trunk/test/Index/ctor-init-source-loc.cpp (original)
+++ cfe/trunk/test/Index/ctor-init-source-loc.cpp (removed)
@@ -1,117 +0,0 @@
-// RUN: c-index-test -test-load-source all %s | FileCheck %s
-template
-struct Derived:  MyBase::InnerIterator
-{
-Derived() : MyBase::InnerIterator() {}
-// CHECK:  TypeRef=MyBase:2:19 Extent=[5:17 - 5:23]
-};
-
-template
-struct Derived2:  MyBase::Deeper::InnerIterator
-{
-Derived2() : MyBase::Deeper::InnerIterator() {}
-// CHECK:  TypeRef=MyBase:9:19 Extent=[12:18 - 12:24]
-};
-
-template
-struct Templ;
-
-template
-struct Derived3:  Templ::InnerIterator
-{
-Derived3() : Templ::InnerIterator() {}
-// CHECK: TemplateRef=Templ:17:8 Extent=[22:18 - 22:23]
-// CHECK: TypeRef=MyBase:19:19 Extent=[22:24 - 22:30]
-};
-
-
-struct Outer {
-template 
-struct Inner {
-typedef Q Parm;
-};
-};
-
-template
-struct Derived4:  Outer::Inner::Parm
-{
-Derived4() : Outer::Inner::Parm() {}
-// CHECK: TypeRef=struct Outer:28:8 Extent=[38:18 - 38:23]
-// CHECK: TemplateRef=Inner:30:12 Extent=[38:25 - 38:30]
-// CHECK: TypeRef=Q:35:19 Extent=[38:31 - 38:32]
-};
-
-template
-struct Derived5:  Outer::Inner::Parm::InnerIterator
-{
-Derived5() : Outer::Inner::Parm::InnerIterator() {}
-// CHECK: TypeRef=struct Outer:28:8 Extent=[47:18 - 47:23]
-// CHECK: TemplateRef=Inner:30:12 Extent=[47:25 - 47:30]
-// CHECK: TypeRef=Q:44:19 Extent=[47:31 - 47:32]
-};
-
-template
-struct Derived6:  Outer::Inner
-{
-Derived6() : Outer::Inner() {}
-// CHECK: TypeRef=struct Outer:28:8 Extent=[56:18 - 56:23]
-// CHECK: TemplateRef=Inner:30:12 Extent=[56:25 - 56:30]
-// CHECK: TypeRef=Q:53:19 Extent=[56:31 - 56:32]
-};
-
-struct Base {};
-
-struct Derived7:  Outer::Inner::Parm
-{
-Derived7() : Outer::Inner::Parm() {}
-// CHECK: TypeRef=struct Outer:28:8 Extent=[66:18 - 66:23]
-// CHECK: TemplateRef=Inner:30:12 Extent=[66:25 - 66:30]
-// CHECK: TypeRef=struct Base:62:8 Extent=[66:31 - 66:35]
-};
-
-struct Derived8:  Outer::Inner
-{
-Derived8() : Outer::Inner() {}
-// CHECK: TypeRef=struct Outer:28:8 Extent=[74:18 - 74:23]
-// CHECK: TemplateRef=Inner:30:12 Extent=[74:25 - 74:30]
-// CHECK: TypeRef=struct Base:62:8 Extent=[74:31 - 74:35]
-};
-
-namespace Namespace {
-template struct Templ;
-
-struct Outer {
-template 
-struct Inner {
-typedef Q Parm;
-};
-};
-}
-
-template
-struct Derived9:  Namespace::Templ::InnerIterator
-{
-Derived9() : Namespace::Templ::InnerIterator() {}
-// CHECK: NamespaceRef=Namespace:80:11 Extent=[94:18 - 94:27]
-// CHECK: TemplateRef=Templ:81:33 Extent=[94:29 - 94:34]
-// CHECK: TypeRef=MyBase:91:19 Extent=[94:35 - 94:41]
-};
-
-template
-struct Derived10:  Namespace::Templ
-{
-Derived10() : Namespace::Templ() {}
-// CHECK: NamespaceRef=Namespace:80:11 Extent=[103:19 - 103:28]
-// CHECK: TemplateRef=Templ:81:33 Extent=[103:30 - 103:35]
-// CHECK: TypeRef=MyBase:100:19 Extent=[103:36 - 103:42]
-};
-
-template
-struct Derived11:  Namespace::Outer::Inner::Parm
-{
-Derived11() : Namespace::Outer::Inner::Parm() {}
-// CHECK: NamespaceRef=Namespace:80:11 Extent=[112:19 - 112:28]
-// CHECK: TypeRef=struct Namespace::Outer:83:12 Extent=[112:30 - 112:35]
-// CHECK: TemplateRef=Inner:85:16 Extent=[112:37 - 112:42]
-// CHECK: TypeRef=MyBase:109

r320734 - [Preprocessor] Implement __is_target_{arch|vendor|os|environment} function-like

2017-12-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec 14 11:22:02 2017
New Revision: 320734

URL: http://llvm.org/viewvc/llvm-project?rev=320734&view=rev
Log:
[Preprocessor] Implement __is_target_{arch|vendor|os|environment} function-like
builtin macros

This patch implements the __is_target_arch, __is_target_vendor, __is_target_os,
and __is_target_environment Clang preprocessor extensions that were proposed by
@compnerd in Bob's cfe-dev post:
http://lists.llvm.org/pipermail/cfe-dev/2017-November/056166.html.

These macros can be used to examine the components of the target triple at
compile time. A has_builtin(is_target_???) preprocessor check can be used to
check for their availability.

__is_target_arch allows you to check if an arch is specified without worring
about a specific subarch, e.g.

__is_target_arch(arm) returns 1 for the target arch "armv7"
__is_target_arch(armv7) returns 1 for the target arch "armv7"
__is_target_arch(armv6) returns 0 for the target arch "armv7"

__is_target_vendor and __is_target_environment match the specific vendor
or environment. __is_target_os matches the specific OS, but
__is_target_os(darwin) will match any Darwin-based OS. "Unknown" can be used
to test if the triple's component is specified.

rdar://35753116

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320734&r1=320733&r2=320734&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec 14 11:22:02 2017
@@ -110,6 +110,10 @@ Non-comprehensive list of changes in thi
   If a gcc installation is found, it still prefers ``.ctors`` if the found
   gcc is older than 4.7.0.
 
+- The new builtin preprocessor macros ``__is_target_arch``,
+  ``__is_target_vendor``, ``__is_target_os``, and ``__is_target_environment``
+  can be used to to examine the individual components of the target triple.
+
 New Compiler Flags
 --
 

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=320734&r1=320733&r2=320734&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Dec 14 11:22:02 2017
@@ -175,6 +175,10 @@ class Preprocessor {
   IdentifierInfo *Ident__has_cpp_attribute;// __has_cpp_attribute
   IdentifierInfo *Ident__has_c_attribute;  // __has_c_attribute
   IdentifierInfo *Ident__has_declspec; // __has_declspec_attribute
+  IdentifierInfo *Ident__is_target_arch;   // __is_target_arch
+  IdentifierInfo *Ident__is_target_vendor; // __is_target_vendor
+  IdentifierInfo *Ident__is_target_os; // __is_target_os
+  IdentifierInfo *Ident__is_target_environment;// __is_target_environment
 
   SourceLocation DATELoc, TIMELoc;
 

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=320734&r1=320733&r2=320734&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Dec 14 11:22:02 2017
@@ -375,6 +375,11 @@ void Preprocessor::RegisterBuiltinMacros
   Ident__has_include_next = RegisterBuiltinMacro(*this, "__has_include_next");
   Ident__has_warning  = RegisterBuiltinMacro(*this, "__has_warning");
   Ident__is_identifier= RegisterBuiltinMacro(*this, "__is_identifier");
+  Ident__is_target_arch   = RegisterBuiltinMacro(*this, "__is_target_arch");
+  Ident__is_target_vendor = RegisterBuiltinMacro(*this, "__is_target_vendor");
+  Ident__is_target_os = RegisterBuiltinMacro(*this, "__is_target_os");
+  Ident__is_target_environment =
+  RegisterBuiltinMacro(*this, "__is_target_environment");
 
   // Modules.
   Ident__building_module  = RegisterBuiltinMacro(*this, "__building_module");
@@ -1593,6 +1598,57 @@ static IdentifierInfo *ExpectFeatureIden
   return nullptr;
 }
 
+/// Implements the __is_target_arch builtin macro.
+static bool isTargetArch(const TargetInfo &TI, const IdentifierInfo *II) {
+  std::string ArchName = II->getName().lower() + "--";
+  llvm::Triple Arch(ArchName);
+  const llvm::Triple &TT = TI.getTriple();
+  if (TT.isThumb()) {
+// arm matches thumb or thumbv7. armv7 matches thumbv7.
+if ((Arch.getSubArch() == llvm::Triple::NoSubArch ||
+ Arch.getSubArch() == TT.getSubArch()) &&
+((TT.getArch() == llvm::Triple::thumb &&
+  Arch.getArch() == llvm::Triple::arm) ||
+ (TT.getArch() == llvm::Triple::thumbeb &&
+

r320735 - Commit missing tests for r320734

2017-12-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec 14 11:22:41 2017
New Revision: 320735

URL: http://llvm.org/viewvc/llvm-project?rev=320735&view=rev
Log:
Commit missing tests for r320734

Added:
cfe/trunk/test/Preprocessor/is_target.c
cfe/trunk/test/Preprocessor/is_target_arm.c
cfe/trunk/test/Preprocessor/is_target_os_darwin.c
cfe/trunk/test/Preprocessor/is_target_unknown.c

Added: cfe/trunk/test/Preprocessor/is_target.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target.c?rev=320735&view=auto
==
--- cfe/trunk/test/Preprocessor/is_target.c (added)
+++ cfe/trunk/test/Preprocessor/is_target.c Thu Dec 14 11:22:41 2017
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin-simulator -verify 
%s
+
+#if !__is_target_arch(x86_64) || !__is_target_arch(X86_64)
+  #error "mismatching arch"
+#endif
+
+#if __is_target_arch(arm64)
+  #error "mismatching arch"
+#endif
+
+// Silently ignore invalid archs. This will ensure that older compilers will
+// accept headers that support new arches/vendors/os variants.
+#if __is_target_arch(foo)
+  #error "invalid arch"
+#endif
+
+#if !__is_target_vendor(apple) || !__is_target_vendor(APPLE)
+  #error "mismatching vendor"
+#endif
+
+#if __is_target_vendor(unknown)
+  #error "mismatching vendor"
+#endif
+
+#if __is_target_vendor(foo)
+  #error "invalid vendor"
+#endif
+
+#if !__is_target_os(darwin) || !__is_target_os(DARWIN)
+  #error "mismatching os"
+#endif
+
+#if __is_target_os(ios)
+  #error "mismatching os"
+#endif
+
+#if __is_target_os(foo)
+  #error "invalid os"
+#endif
+
+#if !__is_target_environment(simulator) || !__is_target_environment(SIMULATOR)
+  #error "mismatching environment"
+#endif
+
+#if __is_target_environment(unknown)
+  #error "mismatching environment"
+#endif
+
+#if __is_target_environment(foo)
+  #error "invalid environment"
+#endif
+
+#if !__has_builtin(__is_target_arch) || !__has_builtin(__is_target_os) || 
!__has_builtin(__is_target_vendor) || !__has_builtin(__is_target_environment)
+  #error "has builtin doesn't work"
+#endif
+
+#if __is_target_arch(11) // expected-error {{builtin feature check macro 
requires a parenthesized identifier}}
+  #error "invalid arch"
+#endif
+
+#if __is_target_arch x86 // expected-error{{missing '(' after 
'__is_target_arch'}}
+  #error "invalid arch"
+#endif
+
+#if __is_target_arch ( x86  // expected-error {{unterminated function-like 
macro invocation}}
+  #error "invalid arch"
+#endif // expected-error@-2 {{expected value in expression}}

Added: cfe/trunk/test/Preprocessor/is_target_arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target_arm.c?rev=320735&view=auto
==
--- cfe/trunk/test/Preprocessor/is_target_arm.c (added)
+++ cfe/trunk/test/Preprocessor/is_target_arm.c Thu Dec 14 11:22:41 2017
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -triple thumbv7--windows-msvc19.11.0 -verify 
%s
+// RUN: %clang_cc1 -fsyntax-only -triple armv7--windows-msvc19.11.0 -DARM 
-verify %s
+// expected-no-diagnostics
+
+// ARM does match arm and thumb.
+#if !__is_target_arch(arm)
+  #error "mismatching arch"
+#endif
+
+#if __is_target_arch(armeb) || __is_target_arch(armebv7) || 
__is_target_arch(thumbeb) || __is_target_arch(thumbebv7)
+  #error "mismatching arch"
+#endif
+
+// ARMV7 does match armv7 and thumbv7.
+#if !__is_target_arch(armv7)
+  #error "mismatching arch"
+#endif
+
+// ARMV6 does not match armv7 or thumbv7.
+#if __is_target_arch(armv6)
+  #error "mismatching arch"
+#endif
+
+#if __is_target_arch(arm64)
+  #error "mismatching arch"
+#endif
+
+#ifndef ARM
+
+// Allow checking for precise arch + subarch.
+#if !__is_target_arch(thumbv7)
+  #error "mismatching arch"
+#endif
+
+// But also allow checking for the arch without subarch.
+#if !__is_target_arch(thumb)
+  #error "mismatching arch"
+#endif
+
+// Same arch with a different subarch doesn't match.
+#if __is_target_arch(thumbv6)
+  #error "mismatching arch"
+#endif
+
+#else
+
+#if __is_target_arch(thumbv7) || __is_target_arch(thumb)
+  #error "mismatching arch"
+#endif
+
+#endif

Added: cfe/trunk/test/Preprocessor/is_target_os_darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target_os_darwin.c?rev=320735&view=auto
==
--- cfe/trunk/test/Preprocessor/is_target_os_darwin.c (added)
+++ cfe/trunk/test/Preprocessor/is_target_os_darwin.c Thu Dec 14 11:22:41 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macos -DMAC -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-ios -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-tvos -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-watchos -verify %s
+// expected-no-diagnostics
+
+#if !__is_target_os(darwin)
+  #error "misma

r320748 - [libclang] Add support for checking abstractness of records

2017-12-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec 14 14:01:50 2017
New Revision: 320748

URL: http://llvm.org/viewvc/llvm-project?rev=320748&view=rev
Log:
[libclang] Add support for checking abstractness of records

This patch allows checking whether a C++ record declaration is abstract through
libclang and clang.cindex (Python).

Patch by Johann Klähn!

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/load-classes.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=320748&r1=320747&r2=320748&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Dec 14 14:01:50 2017
@@ -1479,6 +1479,18 @@ class Cursor(Structure):
 """
 return conf.lib.clang_CXXMethod_isVirtual(self)
 
+def is_abstract_record(self):
+"""Returns True if the cursor refers to a C++ record declaration
+that has pure virtual member functions.
+"""
+return conf.lib.clang_CXXRecord_isAbstract(self)
+
+def is_abstract_record(self):
+"""Returns True if the cursor refers to a C++ record declaration
+that has pure virtual member functions.
+"""
+return conf.lib.clang_CXXRecord_isAbstract(self)
+
 def is_scoped_enum(self):
 """Returns True if the cursor refers to a scoped enum declaration.
 """
@@ -3401,6 +3413,14 @@ functionList = [
[Cursor],
bool),
 
+  ("clang_CXXRecord_isAbstract",
+   [Cursor],
+   bool),
+
+  ("clang_CXXRecord_isAbstract",
+   [Cursor],
+   bool),
+
   ("clang_EnumDecl_isScoped",
[Cursor],
bool),

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=320748&r1=320747&r2=320748&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Dec 14 14:01:50 
2017
@@ -275,6 +275,28 @@ class TestCursor(unittest.TestCase):
 self.assertTrue(foo.is_virtual_method())
 self.assertFalse(bar.is_virtual_method())
 
+def test_is_abstract_record(self):
+"""Ensure Cursor.is_abstract_record works."""
+source = 'struct X { virtual void x() = 0; }; struct Y : X { void x(); 
};'
+tu = get_tu(source, lang='cpp')
+
+cls = get_cursor(tu, 'X')
+self.assertTrue(cls.is_abstract_record())
+
+cls = get_cursor(tu, 'Y')
+self.assertFalse(cls.is_abstract_record())
+
+def test_is_abstract_record(self):
+"""Ensure Cursor.is_abstract_record works."""
+source = 'struct X { virtual void x() = 0; }; struct Y : X { void x(); 
};'
+tu = get_tu(source, lang='cpp')
+
+cls = get_cursor(tu, 'X')
+self.assertTrue(cls.is_abstract_record())
+
+cls = get_cursor(tu, 'Y')
+self.assertFalse(cls.is_abstract_record())
+
 def test_is_scoped_enum(self):
 """Ensure Cursor.is_scoped_enum works."""
 source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};'

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=320748&r1=320747&r2=320748&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Dec 14 14:01:50 2017
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 44
+#define CINDEX_VERSION_MINOR 45
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -4467,6 +4467,12 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_
 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
 
 /**
+ * \brief Determine if a C++ record is abstract, i.e. whether a class or struct
+ * has a pure virtual member function.
+ */
+CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
+
+/**
  * \brief Determine if an enum declaration refers to a scoped enum.
  */
 CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);

Modified: cfe/trunk/test/Index/load-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-classes.cpp?rev=320748&r1=320747&r2=320748&view=diff
==
--- cfe/trunk/test/I

r320766 - Remove duplicate python libclang changes from r320748

2017-12-14 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec 14 15:40:42 2017
New Revision: 320766

URL: http://llvm.org/viewvc/llvm-project?rev=320766&view=rev
Log:
Remove duplicate python libclang changes from r320748

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=320766&r1=320765&r2=320766&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Dec 14 15:40:42 2017
@@ -1485,12 +1485,6 @@ class Cursor(Structure):
 """
 return conf.lib.clang_CXXRecord_isAbstract(self)
 
-def is_abstract_record(self):
-"""Returns True if the cursor refers to a C++ record declaration
-that has pure virtual member functions.
-"""
-return conf.lib.clang_CXXRecord_isAbstract(self)
-
 def is_scoped_enum(self):
 """Returns True if the cursor refers to a scoped enum declaration.
 """
@@ -3413,10 +3407,6 @@ functionList = [
[Cursor],
bool),
 
-  ("clang_CXXRecord_isAbstract",
-   [Cursor],
-   bool),
-
   ("clang_CXXRecord_isAbstract",
[Cursor],
bool),

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=320766&r1=320765&r2=320766&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Dec 14 15:40:42 
2017
@@ -286,17 +286,6 @@ class TestCursor(unittest.TestCase):
 cls = get_cursor(tu, 'Y')
 self.assertFalse(cls.is_abstract_record())
 
-def test_is_abstract_record(self):
-"""Ensure Cursor.is_abstract_record works."""
-source = 'struct X { virtual void x() = 0; }; struct Y : X { void x(); 
};'
-tu = get_tu(source, lang='cpp')
-
-cls = get_cursor(tu, 'X')
-self.assertTrue(cls.is_abstract_record())
-
-cls = get_cursor(tu, 'Y')
-self.assertFalse(cls.is_abstract_record())
-
 def test_is_scoped_enum(self):
 """Ensure Cursor.is_scoped_enum works."""
 source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};'


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


r320853 - __is_target_arch: Check the arch and subarch instead of the arch name

2017-12-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Dec 15 11:58:38 2017
New Revision: 320853

URL: http://llvm.org/viewvc/llvm-project?rev=320853&view=rev
Log:
__is_target_arch: Check the arch and subarch instead of the arch name

This ensures that when compiling for "arm64" __is_target_arch will succeed for
both "arm64" and "aarch64".

Thanks to Bob Wilson who pointed this out!

Added:
cfe/trunk/test/Preprocessor/is_target_arm64.c
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=320853&r1=320852&r2=320853&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Dec 15 11:58:38 2017
@@ -1615,9 +1615,9 @@ static bool isTargetArch(const TargetInf
   }
   // Check the parsed arch when it has no sub arch to allow Clang to
   // match thumb to thumbv7 but to prohibit matching thumbv6 to thumbv7.
-  return (Arch.getSubArch() == llvm::Triple::NoSubArch &&
-  Arch.getArch() == TT.getArch()) ||
- Arch.getArchName() == TT.getArchName();
+  return (Arch.getSubArch() == llvm::Triple::NoSubArch ||
+  Arch.getSubArch() == TT.getSubArch()) &&
+ Arch.getArch() == TT.getArch();
 }
 
 /// Implements the __is_target_vendor builtin macro.

Added: cfe/trunk/test/Preprocessor/is_target_arm64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target_arm64.c?rev=320853&view=auto
==
--- cfe/trunk/test/Preprocessor/is_target_arm64.c (added)
+++ cfe/trunk/test/Preprocessor/is_target_arm64.c Fri Dec 15 11:58:38 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios11 -verify %s
+// expected-no-diagnostics
+
+#if !__is_target_arch(arm64) || !__is_target_arch(aarch64)
+  #error "mismatching arch"
+#endif
+
+#if __is_target_arch(aarch64_be)
+  #error "mismatching arch"
+#endif


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


r320854 - __is_target_environment: Check the environment after parsing it

2017-12-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Dec 15 12:07:53 2017
New Revision: 320854

URL: http://llvm.org/viewvc/llvm-project?rev=320854&view=rev
Log:
__is_target_environment: Check the environment after parsing it

This ensures that target triples with environment versions can still work with
__is_target_environment.

Added:
cfe/trunk/test/Preprocessor/is_target_environment_version.c
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=320854&r1=320853&r2=320854&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Dec 15 12:07:53 2017
@@ -1643,10 +1643,9 @@ static bool isTargetOS(const TargetInfo
 /// Implements the __is_target_environment builtin macro.
 static bool isTargetEnvironment(const TargetInfo &TI,
 const IdentifierInfo *II) {
-  StringRef EnvName = TI.getTriple().getEnvironmentName();
-  if (EnvName.empty())
-EnvName = "unknown";
-  return EnvName.equals_lower(II->getName());
+  std::string EnvName = (llvm::Twine("---") + II->getName().lower()).str();
+  llvm::Triple Env(EnvName);
+  return TI.getTriple().getEnvironment() == Env.getEnvironment();
 }
 
 /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded

Added: cfe/trunk/test/Preprocessor/is_target_environment_version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target_environment_version.c?rev=320854&view=auto
==
--- cfe/trunk/test/Preprocessor/is_target_environment_version.c (added)
+++ cfe/trunk/test/Preprocessor/is_target_environment_version.c Fri Dec 15 
12:07:53 2017
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-windows-msvc18.0.0 -verify 
%s
+// expected-no-diagnostics
+
+#if !__is_target_environment(msvc)
+  #error "mismatching environment"
+#endif


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


r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Dec 19 11:05:04 2017
New Revision: 321099

URL: http://llvm.org/viewvc/llvm-project?rev=321099&view=rev
Log:
[driver][darwin] Take the OS version specified in "-target" as the target
OS instead of inferring it from SDK / environment

The OS version is specified in -target should be used instead of the one in an
environment variable / SDK name.

rdar://35813850

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c
cfe/trunk/test/Driver/objc-weak.m
cfe/trunk/test/Driver/pic.c
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=321099&r1=321098&r2=321099&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
@@ -1233,6 +1233,10 @@ struct DarwinPlatform {
 llvm_unreachable("Unsupported Darwin Source Kind");
   }
 
+  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
+ StringRef OSVersion, Arg *A) {
+return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion, A);
+  }
   static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
Arg *A) {
 return DarwinPlatform(OSVersionArg, Platform, A);
@@ -1250,33 +1254,32 @@ struct DarwinPlatform {
   }
   static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
StringRef Value) {
-DarwinPlatformKind Platform;
+return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS), Value);
+  }
+
+private:
+  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg *Argument)
+  : Kind(Kind), Platform(Platform), Argument(Argument) {}
+  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef Value,
+ Arg *Argument = nullptr)
+  : Kind(Kind), Platform(Platform), OSVersion(Value), Argument(Argument) {}
+
+  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS) {
 switch (OS) {
 case llvm::Triple::Darwin:
 case llvm::Triple::MacOSX:
-  Platform = DarwinPlatformKind::MacOS;
-  break;
+  return DarwinPlatformKind::MacOS;
 case llvm::Triple::IOS:
-  Platform = DarwinPlatformKind::IPhoneOS;
-  break;
+  return DarwinPlatformKind::IPhoneOS;
 case llvm::Triple::TvOS:
-  Platform = DarwinPlatformKind::TvOS;
-  break;
+  return DarwinPlatformKind::TvOS;
 case llvm::Triple::WatchOS:
-  Platform = DarwinPlatformKind::WatchOS;
-  break;
+  return DarwinPlatformKind::WatchOS;
 default:
   llvm_unreachable("Unable to infer Darwin variant");
 }
-return DarwinPlatform(InferredFromArch, Platform, Value);
   }
 
-private:
-  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg *Argument)
-  : Kind(Kind), Platform(Platform), Argument(Argument) {}
-  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef Value)
-  : Kind(Kind), Platform(Platform), OSVersion(Value), Argument(nullptr) {}
-
   SourceKind Kind;
   DarwinPlatformKind Platform;
   std::string OSVersion;
@@ -1449,20 +1452,15 @@ inferDeploymentTargetFromArch(DerivedArg
   const Driver &TheDriver) {
   llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;
 
-  // Set the OSTy based on -target if -arch isn't present.
-  if (Args.hasArg(options::OPT_target) && !Args.hasArg(options::OPT_arch)) {
-OSTy = Triple.getOS();
-  } else {
-StringRef MachOArchName = Toolchain.getMachOArchName(Args);
-if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
-MachOArchName == "arm64")
-  OSTy = llvm::Triple::IOS;
-else if (MachOArchName == "armv7k")
-  OSTy = llvm::Triple::WatchOS;
-else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
- MachOArchName != "armv7em")
-  OSTy = llvm::Triple::MacOSX;
-  }
+  StringRef MachOArchName = Toolchain.getMachOArchName(Args);
+  if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
+  MachOArchName == "arm64")
+OSTy = llvm::Triple::IOS;
+  else if (MachOArchName == "armv7k")
+OSTy = llvm::Triple::WatchOS;
+  else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
+   MachOArchName != "armv7em")
+OSTy = llvm::Triple::MacOSX;
 
   if (OSTy == llvm::Triple::UnknownOS)
 return None;
@@ -1470,6 +1468,19 @@ inferDeploymentTargetFromArch(DerivedArg
 getOSVersion(OSTy, Triple, TheDriver));
 }
 
+/// Returns the deployment target that's specified using the -target option.
+Optional getDeploymentTargetFromTargetArg(
+DerivedArgList &Args, const 

r321102 - [driver][darwin] Set the 'simulator' environment when it's specified

2017-12-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Dec 19 11:56:14 2017
New Revision: 321102

URL: http://llvm.org/viewvc/llvm-project?rev=321102&view=rev
Log:
[driver][darwin] Set the 'simulator' environment when it's specified
in '-target'

rdar://35742458

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=321102&r1=321101&r2=321102&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:56:14 2017
@@ -1181,9 +1181,12 @@ struct DarwinPlatform {
   };
 
   using DarwinPlatformKind = Darwin::DarwinPlatformKind;
+  using DarwinEnvironmentKind = Darwin::DarwinEnvironmentKind;
 
   DarwinPlatformKind getPlatform() const { return Platform; }
 
+  DarwinEnvironmentKind getEnvironment() const { return Environment; }
+
   StringRef getOSVersion() const {
 if (Kind == OSVersionArg)
   return Argument->getValue();
@@ -1234,8 +1237,17 @@ struct DarwinPlatform {
   }
 
   static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
- StringRef OSVersion, Arg *A) {
-return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion, A);
+ StringRef OSVersion, Arg *A,
+ llvm::Triple::EnvironmentType Env) {
+DarwinPlatform Result(TargetArg, getPlatformFromOS(OS), OSVersion, A);
+switch (Env) {
+case llvm::Triple::Simulator:
+  Result.Environment = DarwinEnvironmentKind::Simulator;
+  break;
+default:
+  break;
+}
+return Result;
   }
   static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
Arg *A) {
@@ -1282,6 +1294,7 @@ private:
 
   SourceKind Kind;
   DarwinPlatformKind Platform;
+  DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
   std::string OSVersion;
   Arg *Argument;
   StringRef EnvVarName;
@@ -1478,7 +1491,8 @@ Optional getDeploymentTa
 return None;
   std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
   return DarwinPlatform::createFromTarget(Triple.getOS(), OSVersion,
-  
Args.getLastArg(options::OPT_target));
+  Args.getLastArg(options::OPT_target),
+  Triple.getEnvironment());
 }
 
 } // namespace
@@ -1584,10 +1598,11 @@ void Darwin::AddDeploymentTarget(Derived
   } else
 llvm_unreachable("unknown kind of Darwin platform");
 
-  DarwinEnvironmentKind Environment = NativeEnvironment;
+  DarwinEnvironmentKind Environment = OSTarget->getEnvironment();
   // Recognize iOS targets with an x86 architecture as the iOS simulator.
-  if (Platform != MacOS && (getTriple().getArch() == llvm::Triple::x86 ||
-getTriple().getArch() == llvm::Triple::x86_64))
+  if (Environment == NativeEnvironment && Platform != MacOS &&
+  (getTriple().getArch() == llvm::Triple::x86 ||
+   getTriple().getArch() == llvm::Triple::x86_64))
 Environment = Simulator;
 
   setTarget(Platform, Environment, Major, Minor, Micro);

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=321102&r1=321101&r2=321102&view=diff
==
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Tue Dec 19 11:56:14 2017
@@ -262,3 +262,13 @@
 // RUN: %clang -target uknown-apple-macos10.11.2 -arch=armv7k -c %s -### 2>&1 
| \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TIGNORE-ARCH1 %s
 // CHECK-VERSION-TIGNORE-ARCH1: "unknown-apple-macosx10.11.2"
+
+// Target can be used to specify the environment:
+
+// RUN: %clang -target x86_64-apple-ios11-simulator -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TENV-SIM1 %s
+// CHECK-VERSION-TENV-SIM1: "x86_64-apple-ios11.0.0-simulator"
+
+// RUN: %clang -target armv7k-apple-ios10.1-simulator -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TENV-SIM2 %s
+// CHECK-VERSION-TENV-SIM2: "thumbv7k-apple-ios10.1.0-simulator"


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


r321145 - [darwin][driver] Warn about mismatching --version-min rather than

2017-12-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Dec 19 18:31:30 2017
New Revision: 321145

URL: http://llvm.org/viewvc/llvm-project?rev=321145&view=rev
Log:
[darwin][driver] Warn about mismatching --version-min rather than
superfluous --version-min compiler option

rdar://35813850

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=321145&r1=321144&r2=321145&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 18:31:30 2017
@@ -1523,12 +1523,29 @@ void Darwin::AddDeploymentTarget(Derived
   Optional OSTarget =
   getDeploymentTargetFromTargetArg(Args, getTriple(), getDriver());
   if (OSTarget) {
-// Warn about superfluous -m-version-min arg.
 Optional OSVersionArgTarget =
 getDeploymentTargetFromOSVersionArg(Args, getDriver());
-if (OSVersionArgTarget)
-  getDriver().Diag(clang::diag::warn_drv_unused_argument)
-  << OSVersionArgTarget->getAsString(Args, Opts);
+if (OSVersionArgTarget) {
+  unsigned TargetMajor, TargetMinor, TargetMicro;
+  bool TargetExtra;
+  unsigned ArgMajor, ArgMinor, ArgMicro;
+  bool ArgExtra;
+  if (OSTarget->getPlatform() != OSVersionArgTarget->getPlatform() ||
+  (Driver::GetReleaseVersion(OSTarget->getOSVersion(), TargetMajor,
+ TargetMinor, TargetMicro, TargetExtra) &&
+   Driver::GetReleaseVersion(OSVersionArgTarget->getOSVersion(),
+ ArgMajor, ArgMinor, ArgMicro, ArgExtra) &&
+   (VersionTuple(TargetMajor, TargetMinor, TargetMicro) !=
+VersionTuple(ArgMajor, ArgMinor, ArgMicro) ||
+TargetExtra != ArgExtra))) {
+// Warn about -m-version-min that doesn't match the OS version
+// that's specified in the target.
+std::string OSVersionArg = OSVersionArgTarget->getAsString(Args, Opts);
+std::string TargetArg = OSTarget->getAsString(Args, Opts);
+getDriver().Diag(clang::diag::warn_drv_overriding_flag_option)
+<< OSVersionArg << TargetArg;
+  }
+}
   } else {
 // The OS target can be specified using the -mversion-min argument.
 OSTarget = getDeploymentTargetFromOSVersionArg(Args, getDriver());

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=321145&r1=321144&r2=321145&view=diff
==
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Tue Dec 19 18:31:30 2017
@@ -197,11 +197,25 @@
 
 // RUN: %clang -target x86_64-apple-macos10.11.2 -mmacos-version-min=10.6 -c 
%s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TNO-OSV1 %s
-// CHECK-VERSION-TNO-OSV1: argument unused during compilation: 
'-mmacosx-version-min=10.6'
+// CHECK-VERSION-TNO-OSV1: overriding '-mmacosx-version-min=10.6' option with 
'--target=x86_64-apple-macos10.11.2'
 
 // RUN: %clang -target x86_64-apple-macos -miphoneos-version-min=9.1 -c %s 
-### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TNO-OSV2 %s
-// CHECK-VERSION-TNO-OSV2: argument unused during compilation: 
'-miphoneos-version-min=9.1'
+// CHECK-VERSION-TNO-OSV2: overriding '-miphoneos-version-min=9.1' option with 
'--target=x86_64-apple-macos'
+
+// RUN: %clang -target x86_64-apple-ios -miphonesimulator-version-min=10.0 -c 
%s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TNO-OSV3 %s
+// CHECK-VERSION-TNO-OSV3: overriding '-mios-simulator-version-min=10.0' 
option with '--target=x86_64-apple-ios'
+// CHECK-VERSION-TNO-OSV3-NOT: argument unused during compilation
+
+// RUN: %clang -target arm64-apple-ios10.1.0 -miphoneos-version-min=10.1.0.1 
-c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TNO-OSV4 %s
+// CHECK-VERSION-TNO-OSV4: overriding '-miphoneos-version-min=10.1.0.1' option 
with '--target=arm64-apple-ios10.1.0'
+
+// RUN: %clang -target x86_64-apple-macos10.6 -mmacos-version-min=10.6 -c %s 
-### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TNO-SAME %s
+// CHECK-VERSION-TNO-SAME-NOT: overriding
+// CHECK-VERSION-TNO-SAME-NOT: argument unused during compilation
 
 // Target with OS version is not overriden by -m-version-min variables:
 


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


r321222 - Fix an assertion failure regression in isDesignatorAtObjectEnd for

2017-12-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Dec 20 13:03:38 2017
New Revision: 321222

URL: http://llvm.org/viewvc/llvm-project?rev=321222&view=rev
Log:
Fix an assertion failure regression in isDesignatorAtObjectEnd for
__builtin_object_size with incomplete array type in struct

The commit r316245 introduced a regression that causes an assertion failure when
Clang tries to cast an IncompleteArrayType to a PointerType when evaluating
__builtin_object_size.

rdar://36094951

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/builtin-object-size.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=321222&r1=321221&r2=321222&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec 20 13:03:38 2017
@@ -7420,7 +7420,10 @@ static bool isDesignatorAtObjectEnd(cons
 // If we don't know the array bound, conservatively assume we're looking at
 // the final array element.
 ++I;
-BaseType = BaseType->castAs()->getPointeeType();
+if (BaseType->isIncompleteArrayType())
+  BaseType = Ctx.getAsArrayType(BaseType)->getElementType();
+else
+  BaseType = BaseType->castAs()->getPointeeType();
   }
 
   for (unsigned E = LVal.Designator.Entries.size(); I != E; ++I) {

Modified: cfe/trunk/test/Sema/builtin-object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-object-size.c?rev=321222&r1=321221&r2=321222&view=diff
==
--- cfe/trunk/test/Sema/builtin-object-size.c (original)
+++ cfe/trunk/test/Sema/builtin-object-size.c Wed Dec 20 13:03:38 2017
@@ -91,3 +91,22 @@ int pr31843() {
 
   return n;
 }
+
+typedef struct {
+  char string[512];
+} NestedArrayStruct;
+
+typedef struct {
+  int x;
+  NestedArrayStruct session[];
+} IncompleteArrayStruct;
+
+void rd36094951_IAS_builtin_object_size_assertion(IncompleteArrayStruct *p) {
+#define rd36094951_CHECK(mode) 
\
+  __builtin___strlcpy_chk(p->session[0].string, "ab", 2,   
\
+  __builtin_object_size(p->session[0].string, mode))
+  rd36094951_CHECK(0);
+  rd36094951_CHECK(1);
+  rd36094951_CHECK(2);
+  rd36094951_CHECK(3);
+}


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


r321559 - [driver][darwin] Take the OS version from -m-version-min argument when

2017-12-29 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Dec 29 09:42:40 2017
New Revision: 321559

URL: http://llvm.org/viewvc/llvm-project?rev=321559&view=rev
Log:
[driver][darwin] Take the OS version from -m-version-min argument when
-target has no OS version

This ensures that Clang won't warn about redundant -m-version-min
argument for an invocation like
`-target x86_64-apple-macos -mmacos-version-min=10.11`

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=321559&r1=321558&r2=321559&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Dec 29 09:42:40 2017
@@ -1192,6 +1192,13 @@ struct DarwinPlatform {
 return OSVersion;
   }
 
+  void setOSVersion(StringRef S) {
+assert(Kind == TargetArg && "Unexpected kind!");
+OSVersion = S;
+  }
+
+  bool hasOSVersion() const { return HasOSVersion; }
+
   /// Returns true if the target OS was explicitly specified.
   bool isExplicitlySpecified() const { return Kind <= DeploymentTargetEnv; }
 
@@ -1235,17 +1242,21 @@ struct DarwinPlatform {
 llvm_unreachable("Unsupported Darwin Source Kind");
   }
 
-  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
- StringRef OSVersion, Arg *A,
- llvm::Triple::EnvironmentType Env) {
-DarwinPlatform Result(TargetArg, getPlatformFromOS(OS), OSVersion, A);
-switch (Env) {
+  static DarwinPlatform createFromTarget(const llvm::Triple &TT,
+ StringRef OSVersion, Arg *A) {
+DarwinPlatform Result(TargetArg, getPlatformFromOS(TT.getOS()), OSVersion,
+  A);
+switch (TT.getEnvironment()) {
 case llvm::Triple::Simulator:
   Result.Environment = DarwinEnvironmentKind::Simulator;
   break;
 default:
   break;
 }
+unsigned Major, Minor, Micro;
+TT.getOSVersion(Major, Minor, Micro);
+if (Major == 0)
+  Result.HasOSVersion = false;
 return Result;
   }
   static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
@@ -1295,6 +1306,7 @@ private:
   DarwinPlatformKind Platform;
   DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
   std::string OSVersion;
+  bool HasOSVersion = true;
   Arg *Argument;
   StringRef EnvVarName;
 };
@@ -1489,9 +1501,8 @@ Optional getDeploymentTa
   Triple.getOS() == llvm::Triple::UnknownOS)
 return None;
   std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
-  return DarwinPlatform::createFromTarget(Triple.getOS(), OSVersion,
-  Args.getLastArg(options::OPT_target),
-  Triple.getEnvironment());
+  return DarwinPlatform::createFromTarget(Triple, OSVersion,
+  
Args.getLastArg(options::OPT_target));
 }
 
 } // namespace
@@ -1537,12 +1548,20 @@ void Darwin::AddDeploymentTarget(Derived
(VersionTuple(TargetMajor, TargetMinor, TargetMicro) !=
 VersionTuple(ArgMajor, ArgMinor, ArgMicro) ||
 TargetExtra != ArgExtra))) {
-// Warn about -m-version-min that doesn't match the OS version
-// that's specified in the target.
-std::string OSVersionArg = OSVersionArgTarget->getAsString(Args, Opts);
-std::string TargetArg = OSTarget->getAsString(Args, Opts);
-getDriver().Diag(clang::diag::warn_drv_overriding_flag_option)
-<< OSVersionArg << TargetArg;
+// Select the OS version from the -m-version-min argument when
+// the -target does not include an OS version.
+if (OSTarget->getPlatform() == OSVersionArgTarget->getPlatform() &&
+!OSTarget->hasOSVersion()) {
+  OSTarget->setOSVersion(OSVersionArgTarget->getOSVersion());
+} else {
+  // Warn about -m-version-min that doesn't match the OS version
+  // that's specified in the target.
+  std::string OSVersionArg =
+  OSVersionArgTarget->getAsString(Args, Opts);
+  std::string TargetArg = OSTarget->getAsString(Args, Opts);
+  getDriver().Diag(clang::diag::warn_drv_overriding_flag_option)
+  << OSVersionArg << TargetArg;
+}
   }
 }
   } else {

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=321559&r1=321558&r2=321559&view=diff
==
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Fri Dec 29 09:42:40 2017
@@ -205,7 +205,8 @@
 
 // RUN: %clang -targ

r321775 - PR35815: Separate out the ns-consumed diagnostic into an error and

2018-01-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  3 15:52:42 2018
New Revision: 321775

URL: http://llvm.org/viewvc/llvm-project?rev=321775&view=rev
Log:
PR35815: Separate out the ns-consumed diagnostic into an error and
a warning

This commit separates out the warn_nsconsumed_attribute_mismatch and
warn_nsreturns_retained_attribute_mismatch diagnostic into a warning and error.
This is needed to avoid a module import regression introduced by r313717 that
turned these errors into warnings and started promoting them only when needed,
which caused an error when importing a module as it had different warning
settings.

rdar://36265651

Added:
cfe/trunk/test/SemaObjC/Inputs/module.map
cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=321775&r1=321774&r2=321775&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan  3 15:52:42 
2018
@@ -8300,12 +8300,16 @@ def err_c99_array_usage_cxx : Error<
   "feature, not permitted in C++">;
 def err_type_unsupported : Error<
   "%0 is not supported on this target">;
-def warn_nsconsumed_attribute_mismatch : Warning<
+def err_nsconsumed_attribute_mismatch : Error<
   "overriding method has mismatched ns_consumed attribute on its"
-  " parameter">, InGroup;
-def warn_nsreturns_retained_attribute_mismatch : Warning<
+  " parameter">;
+def err_nsreturns_retained_attribute_mismatch : Error<
   "overriding method has mismatched ns_returns_%select{not_retained|retained}0"
-  " attributes">, InGroup;
+  " attributes">;
+def warn_nsconsumed_attribute_mismatch : Warning<
+  err_nsconsumed_attribute_mismatch.Text>, InGroup;
+def warn_nsreturns_retained_attribute_mismatch : Warning<
+  err_nsreturns_retained_attribute_mismatch.Text>, InGroup;
   
 def note_getter_unavailable : Note<
   "or because setter is declared here, but no getter method %0 is found">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=321775&r1=321774&r2=321775&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan  3 15:52:42 2018
@@ -156,23 +156,23 @@ void Sema::CheckObjCMethodOverride(ObjCM
   Diag(Overridden->getLocation(), 
diag::note_related_result_type_overridden);
   }
-  if (getLangOpts().ObjCAutoRefCount) {
-Diags.setSeverity(diag::warn_nsreturns_retained_attribute_mismatch,
-  diag::Severity::Error, SourceLocation());
-Diags.setSeverity(diag::warn_nsconsumed_attribute_mismatch,
-  diag::Severity::Error, SourceLocation());
-  }
 
   if ((NewMethod->hasAttr() !=
Overridden->hasAttr())) {
 Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 1;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+<< 1;
 Diag(Overridden->getLocation(), diag::note_previous_decl) << "method";
   }
   if ((NewMethod->hasAttr() !=
Overridden->hasAttr())) {
 Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 0;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+<< 0;
 Diag(Overridden->getLocation(), diag::note_previous_decl)  << "method";
   }
 
@@ -185,7 +185,10 @@ void Sema::CheckObjCMethodOverride(ObjCM
 ParmVarDecl *newDecl = (*ni);
 if (newDecl->hasAttr() !=
 oldDecl->hasAttr()) {
-  Diag(newDecl->getLocation(), diag::warn_nsconsumed_attribute_mismatch);
+  Diag(newDecl->getLocation(),
+   getLangOpts().ObjCAutoRefCount
+   ? diag::err_nsconsumed_attribute_mismatch
+   : diag::warn_nsconsumed_attribute_mismatch);
   Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter";
 }
 

Added: cfe/trunk/test/SemaObjC/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/Inputs/module.map?rev=321775&view=auto
==
--- cfe/trunk/test/SemaObjC/Inputs/module.map (added)
+++ cfe/trunk/test/SemaObjC/Inputs/module.map Wed Jan  3 15:52:42 2018
@@ -0,0 +1,3 @@
+module empty {
+  header "empty.h"
+}

Added: cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
URL: 
http://llvm.org/viewvc/llvm-project/

r327322 - [Tooling] Clear the PreambleSrcLocCache when preamble is discarded during reparsing

2018-03-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Mar 12 12:36:29 2018
New Revision: 327322

URL: http://llvm.org/viewvc/llvm-project?rev=327322&view=rev
Log:
[Tooling] Clear the PreambleSrcLocCache when preamble is discarded during 
reparsing

This ensures that diagnostics are not remapped to incorrect preamble locations 
after
the second reparse with a remapped header file occurs.

rdar://37502480

Added:
cfe/trunk/test/Index/Inputs/reparse-issue.h
cfe/trunk/test/Index/Inputs/reparse-issue.h-0
cfe/trunk/test/Index/Inputs/reparse-issue.h-1
cfe/trunk/test/Index/reparsed-live-issue.cpp
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=327322&r1=327321&r2=327322&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Mar 12 12:36:29 2018
@@ -1259,6 +1259,7 @@ ASTUnit::getMainBufferWithPrecompiledPre
   Preamble.reset();
   PreambleDiagnostics.clear();
   TopLevelDeclsInPreamble.clear();
+  PreambleSrcLocCache.clear();
   PreambleRebuildCounter = 1;
 }
   }

Added: cfe/trunk/test/Index/Inputs/reparse-issue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/reparse-issue.h?rev=327322&view=auto
==
--- cfe/trunk/test/Index/Inputs/reparse-issue.h (added)
+++ cfe/trunk/test/Index/Inputs/reparse-issue.h Mon Mar 12 12:36:29 2018
@@ -0,0 +1,3 @@
+
+asdf;
+

Added: cfe/trunk/test/Index/Inputs/reparse-issue.h-0
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/reparse-issue.h-0?rev=327322&view=auto
==
--- cfe/trunk/test/Index/Inputs/reparse-issue.h-0 (added)
+++ cfe/trunk/test/Index/Inputs/reparse-issue.h-0 Mon Mar 12 12:36:29 2018
@@ -0,0 +1,4 @@
+//
+//
+asdf;
+

Added: cfe/trunk/test/Index/Inputs/reparse-issue.h-1
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/reparse-issue.h-1?rev=327322&view=auto
==
--- cfe/trunk/test/Index/Inputs/reparse-issue.h-1 (added)
+++ cfe/trunk/test/Index/Inputs/reparse-issue.h-1 Mon Mar 12 12:36:29 2018
@@ -0,0 +1,5 @@
+//
+//
+//
+asdf;
+

Added: cfe/trunk/test/Index/reparsed-live-issue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/reparsed-live-issue.cpp?rev=327322&view=auto
==
--- cfe/trunk/test/Index/reparsed-live-issue.cpp (added)
+++ cfe/trunk/test/Index/reparsed-live-issue.cpp Mon Mar 12 12:36:29 2018
@@ -0,0 +1,4 @@
+// RUN: CINDEXTEST_EDITING=1 LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test 
-test-load-source-reparse 2 none 
-remap-file-0=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-0 
-remap-file-1=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-1 -- %s 2>&1 
| FileCheck %s
+#include "Inputs/reparse-issue.h"
+
+// CHECK: reparse-issue.h:4:1:{1:1-1:1}: error: C++ requires a type specifier 
for all declarations


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


r335063 - [Darwin] Add a warning for missing include path for libstdc++

2018-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 19 10:56:03 2018
New Revision: 335063

URL: http://llvm.org/viewvc/llvm-project?rev=335063&view=rev
Log:
[Darwin] Add a warning for missing include path for libstdc++

Xcode 10 removes support for libstdc++, but the users just get a confusing
include not file warning when including an STL header (when building for iOS6
which uses libstdc++ by default for example).
This patch adds a new warning that lets the user know that the libstdc++ include
path was not found to ensure that the user is more aware of why the error 
occurs.

rdar://40830462

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

Added:
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335063&r1=335062&r2=335063&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 19 
10:56:03 2018
@@ -236,4 +236,9 @@ def err_invalid_vfs_overlay : Error<
 
 def warn_option_invalid_ocl_version : Warning<
   "OpenCL version %0 does not support the option '%1'">, InGroup;
+
+def warn_stdlibcxx_not_found : Warning<
+  "include path for stdlibc++ headers not found; pass '-std=libc++' on the "
+  "command line to use the libc++ standard library instead">,
+  InGroup>;
 }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335063&r1=335062&r2=335063&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 10:56:03 2018
@@ -272,6 +272,8 @@ public:
   
   FileManager &getFileMgr() const { return FileMgr; }
 
+  DiagnosticsEngine &getDiags() const { return Diags; }
+
   /// Interface for setting the file search paths.
   void SetSearchPaths(const std::vector &dirs,
   unsigned angledDirIdx, unsigned systemDirIdx,

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335063&r1=335062&r2=335063&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 10:56:03 2018
@@ -14,6 +14,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Config/config.h" // C_INCLUDE_DIRS
+#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -55,11 +56,13 @@ public:
 
   /// AddPath - Add the specified path to the specified group list, prefixing
   /// the sysroot if used.
-  void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
+  /// Returns true if the path exists, false if it was ignored.
+  bool AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
 
   /// AddUnmappedPath - Add the specified path to the specified group list,
   /// without performing any sysroot remapping.
-  void AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
+  /// Returns true if the path exists, false if it was ignored.
+  bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework);
 
   /// AddSystemHeaderPrefix - Add the specified prefix to the system header
@@ -70,10 +73,9 @@ public:
 
   /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
   ///  libstdc++.
-  void AddGnuCPlusPlusIncludePaths(StringRef Base,
-   StringRef ArchDir,
-   StringRef Dir32,
-   StringRef Dir64,
+  /// Returns true if the \p Base path was found, false if it does not exist.
+  bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir,
+   StringRef Dir32, StringRef Dir64,
const llvm::Triple &triple);
 
   /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a 
MinGW
@@ -88,7 +90,8 @@ public:
 
   // AddDefaultCPlusPlusIncludePaths -  Add paths that should be searched when
   //  compiling c++.
-  void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple,
+  void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts,
+   const llvm::Triple &triple,
const HeaderSearchOptions &

r335073 - Revert r335063 as it causes bot failures

2018-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 19 12:43:07 2018
New Revision: 335073

URL: http://llvm.org/viewvc/llvm-project?rev=335073&view=rev
Log:
Revert r335063 as it causes bot failures

Removed:
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335073&r1=335072&r2=335073&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 19 
12:43:07 2018
@@ -236,9 +236,4 @@ def err_invalid_vfs_overlay : Error<
 
 def warn_option_invalid_ocl_version : Warning<
   "OpenCL version %0 does not support the option '%1'">, InGroup;
-
-def warn_stdlibcxx_not_found : Warning<
-  "include path for stdlibc++ headers not found; pass '-std=libc++' on the "
-  "command line to use the libc++ standard library instead">,
-  InGroup>;
 }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335073&r1=335072&r2=335073&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 12:43:07 2018
@@ -272,8 +272,6 @@ public:
   
   FileManager &getFileMgr() const { return FileMgr; }
 
-  DiagnosticsEngine &getDiags() const { return Diags; }
-
   /// Interface for setting the file search paths.
   void SetSearchPaths(const std::vector &dirs,
   unsigned angledDirIdx, unsigned systemDirIdx,

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335073&r1=335072&r2=335073&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 12:43:07 2018
@@ -14,7 +14,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Config/config.h" // C_INCLUDE_DIRS
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -56,13 +55,11 @@ public:
 
   /// AddPath - Add the specified path to the specified group list, prefixing
   /// the sysroot if used.
-  /// Returns true if the path exists, false if it was ignored.
-  bool AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
+  void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
 
   /// AddUnmappedPath - Add the specified path to the specified group list,
   /// without performing any sysroot remapping.
-  /// Returns true if the path exists, false if it was ignored.
-  bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
+  void AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework);
 
   /// AddSystemHeaderPrefix - Add the specified prefix to the system header
@@ -73,9 +70,10 @@ public:
 
   /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
   ///  libstdc++.
-  /// Returns true if the \p Base path was found, false if it does not exist.
-  bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir,
-   StringRef Dir32, StringRef Dir64,
+  void AddGnuCPlusPlusIncludePaths(StringRef Base,
+   StringRef ArchDir,
+   StringRef Dir32,
+   StringRef Dir64,
const llvm::Triple &triple);
 
   /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a 
MinGW
@@ -90,8 +88,7 @@ public:
 
   // AddDefaultCPlusPlusIncludePaths -  Add paths that should be searched when
   //  compiling c++.
-  void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts,
-   const llvm::Triple &triple,
+  void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts);
 
   /// AddDefaultSystemIncludePaths - Adds the default system include paths so
@@ -115,7 +112,7 @@ static bool CanPrefixSysroot(StringRef P
 #endif
 }
 
-bool InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group,
+void InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework) {
   // Add the path with sysroot prepended, if desired and this is a system 
header
   // gro

r335081 - Recommit r335063: [Darwin] Add a warning for missing include path for libstdc++

2018-06-19 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jun 19 15:47:53 2018
New Revision: 335081

URL: http://llvm.org/viewvc/llvm-project?rev=335081&view=rev
Log:
Recommit r335063: [Darwin] Add a warning for missing include path for libstdc++

The recommit ensures that the tests that failed on bots don't trigger the 
warning.

Xcode 10 removes support for libstdc++, but the users just get a confusing
include not file warning when including an STL header (when building for iOS6
which uses libstdc++ by default for example).
This patch adds a new warning that lets the user know that the libstdc++ include
path was not found to ensure that the user is more aware of why the error 
occurs.

rdar://40830462

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

Added:
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp
cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335081&r1=335080&r2=335081&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 19 
15:47:53 2018
@@ -236,4 +236,9 @@ def err_invalid_vfs_overlay : Error<
 
 def warn_option_invalid_ocl_version : Warning<
   "OpenCL version %0 does not support the option '%1'">, InGroup;
+
+def warn_stdlibcxx_not_found : Warning<
+  "include path for stdlibc++ headers not found; pass '-std=libc++' on the "
+  "command line to use the libc++ standard library instead">,
+  InGroup>;
 }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335081&r1=335080&r2=335081&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 15:47:53 2018
@@ -272,6 +272,8 @@ public:
   
   FileManager &getFileMgr() const { return FileMgr; }
 
+  DiagnosticsEngine &getDiags() const { return Diags; }
+
   /// Interface for setting the file search paths.
   void SetSearchPaths(const std::vector &dirs,
   unsigned angledDirIdx, unsigned systemDirIdx,

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335081&r1=335080&r2=335081&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 15:47:53 2018
@@ -14,6 +14,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Config/config.h" // C_INCLUDE_DIRS
+#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -55,11 +56,13 @@ public:
 
   /// AddPath - Add the specified path to the specified group list, prefixing
   /// the sysroot if used.
-  void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
+  /// Returns true if the path exists, false if it was ignored.
+  bool AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework);
 
   /// AddUnmappedPath - Add the specified path to the specified group list,
   /// without performing any sysroot remapping.
-  void AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
+  /// Returns true if the path exists, false if it was ignored.
+  bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework);
 
   /// AddSystemHeaderPrefix - Add the specified prefix to the system header
@@ -70,10 +73,9 @@ public:
 
   /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
   ///  libstdc++.
-  void AddGnuCPlusPlusIncludePaths(StringRef Base,
-   StringRef ArchDir,
-   StringRef Dir32,
-   StringRef Dir64,
+  /// Returns true if the \p Base path was found, false if it does not exist.
+  bool AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef ArchDir,
+   StringRef Dir32, StringRef Dir64,
const llvm::Triple &triple);
 
   /// AddMinGWCPlusPlusIncludePaths - Add the necessary paths to support a 
MinGW
@@ -88,7 +90,8 @@ public:
 
   // AddDefaultCPlusPlusIncludePaths -  Add paths that should be searched when
   //  compiling c++.
-  void AddDefaultCPlusPlusIncludePaths(const llv

r351459 - [ObjC] Follow-up r350768 and allow the use of unavailable methods that are

2019-01-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jan 17 10:12:45 2019
New Revision: 351459

URL: http://llvm.org/viewvc/llvm-project?rev=351459&view=rev
Log:
[ObjC] Follow-up r350768 and allow the use of unavailable methods that are
declared in a parent class from within the @implementation context

This commit extends r350768 and allows the use of methods marked as unavailable
that are declared in a parent class/category from within the @implementation of
the class where the method is marked as unavailable.
This allows users to call init that's marked as unavailable even if they don't
define it.

rdar://47134898

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

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
cfe/trunk/test/SemaObjC/infer-availability-from-init.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351459&r1=351458&r2=351459&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jan 17 10:12:45 2019
@@ -7365,13 +7365,11 @@ ShouldDiagnoseAvailabilityInContext(Sema
 return true;
 } else if (K == AR_Unavailable) {
   // It is perfectly fine to refer to an 'unavailable' Objective-C method
-  // when it's actually defined and is referenced from within the
-  // @implementation itself. In this context, we interpret unavailable as a
-  // form of access control.
+  // when it is referenced from within the @implementation itself. In this
+  // context, we interpret unavailable as a form of access control.
   if (const auto *MD = dyn_cast(OffendingDecl)) {
 if (const auto *Impl = dyn_cast(C)) {
-  if (MD->getClassInterface() == Impl->getClassInterface() &&
-  MD->isDefined())
+  if (MD->getClassInterface() == Impl->getClassInterface())
 return true;
 }
   }

Modified: cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=351459&r1=351458&r2=351459&view=diff
==
--- cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m (original)
+++ cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m Thu Jan 17 10:12:45 
2019
@@ -5,13 +5,24 @@
 + (instancetype)new;
 + (instancetype)alloc;
 
+- (void)declaredInSuper;
+
+@end
+
+@interface NSObject (Category)
+
+- (void)declaredInSuperCategory;
+
 @end
 
 @interface Sub: NSObject
 
 - (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' 
has been explicitly marked unavailable here}}
 
-- (void)notImplemented __attribute__((unavailable)); // expected-note 
{{'notImplemented' has been explicitly marked unavailable here}}
+- (void)notImplemented __attribute__((unavailable));
+
+- (void)declaredInSuper __attribute__((unavailable));
+- (void)declaredInSuperCategory __attribute__((unavailable));
 
 @end
 
@@ -34,7 +45,14 @@
 }
 
 - (void)reportUseOfUnimplemented {
-  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+  [self notImplemented];
+}
+
+- (void)allowSuperCallUsingSelf {
+  [self declaredInSuper];
+  [[Sub alloc] declaredInSuper];
+  [self declaredInSuperCategory];
+  [[Sub alloc] declaredInSuperCategory];
 }
 
 @end

Modified: cfe/trunk/test/SemaObjC/infer-availability-from-init.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/infer-availability-from-init.m?rev=351459&r1=351458&r2=351459&view=diff
==
--- cfe/trunk/test/SemaObjC/infer-availability-from-init.m (original)
+++ cfe/trunk/test/SemaObjC/infer-availability-from-init.m Thu Jan 17 10:12:45 
2019
@@ -47,12 +47,12 @@ void usenotmyobject() {
 }
 
 @interface FromSelf : NSObject
--(instancetype)init __attribute__((unavailable)); // expected-note {{'init' 
has been explicitly marked unavailable here}}
+-(instancetype)init __attribute__((unavailable));
 +(FromSelf*)another_one;
 @end
 
 @implementation FromSelf
 +(FromSelf*)another_one {
-  [self new]; // expected-error{{'new' is unavailable}}
+  [self new];
 }
 @end


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


r352084 - Add a priority field to availability attributes to prioritize explicit

2019-01-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jan 24 11:14:39 2019
New Revision: 352084

URL: http://llvm.org/viewvc/llvm-project?rev=352084&view=rev
Log:
Add a priority field to availability attributes to prioritize explicit
attributes from declaration over attributes from '#pragma clang attribute'

Before this commit users had an issue when using #pragma clang attribute with
availability attributes:

The explicit attribute that's specified next to the declaration is not
guaranteed to be preferred over the attribute specified in the pragma.

This commit fixes this by introducing a priority field to the availability
attribute to control how they're merged. Attributes with higher priority are
applied over attributes with lower priority for the same platform. The
implicitly inferred attributes are given the lower priority. This ensures that:

- explicit attributes are preferred over all other attributes.
- implicitly inferred attributes that are inferred from an explicit attribute
  are discarded if there's an explicit attribute or an attribute specified
  using a #pragma for the same platform.
- implicitly inferred attributes that are inferred from an attribute in the
  #pragma are not used if there's an explicit, explicit #pragma, or an
  implicit attribute inferred from an explicit attribute for the declaration.

This is the resulting ranking:

`platform availability > platform availability from pragma > inferred 
availability > inferred availability from pragma`

rdar://46390243

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

Added:
cfe/trunk/test/SemaObjC/attr-availability-priority.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=352084&r1=352083&r2=352084&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Jan 24 11:14:39 2019
@@ -717,7 +717,8 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
-  BoolArgument<"strict">, StringArgument<"replacement">];
+  BoolArgument<"strict">, StringArgument<"replacement">,
+  IntArgument<"priority">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=352084&r1=352083&r2=352084&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jan 24 11:14:39 2019
@@ -1152,11 +1152,14 @@ replacement=\ *string-literal*
   the deprecated declaration with the new declaration specified.
 
 Multiple availability attributes can be placed on a declaration, which may
-correspond to different platforms.  Only the availability attribute with the
-platform corresponding to the target platform will be used; any others will be
-ignored.  If no availability attribute specifies availability for the current
-target platform, the availability attributes are ignored.  Supported platforms
-are:
+correspond to different platforms. For most platforms, the availability
+attribute with the platform corresponding to the target platform will be used;
+any others will be ignored. However, the availability for ``watchOS`` and
+``tvOS`` can be implicitly inferred from an ``iOS`` availability attribute.
+Any explicit availability attributes for those platforms are still prefered 
over
+the implicitly inferred availability attributes. If no availability attribute
+specifies availability for the current target platform, the availability
+attributes are ignored. Supported platforms are:
 
 ``ios``
   Apple's iOS operating system.  The minimum deployment target is specified by
@@ -1229,6 +1232,63 @@ Starting with the macOS 10.12 SDK, the `
   - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
   @end
 
+Availability attributes can also be applied using a ``#pragma clang 
attribute``.
+Any explicit availability attribute whose platform corresponds to the target
+platform is applied to a declaration regardless of the availability attributes
+specified in the pragma. For example, in the code below,
+``hasExplicitAvailabilityAttribute`` will use the ``macOS`` availability
+attribute that is sp

r352125 - [clang-format] square parens with one token are not Objective-C message sends

2019-01-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jan 24 15:07:58 2019
New Revision: 352125

URL: http://llvm.org/viewvc/llvm-project?rev=352125&view=rev
Log:
[clang-format] square parens with one token are not Objective-C message sends

The commit r322690 introduced support for ObjC detection in header files.
Unfortunately some C headers that use designated initializers are now
incorrectly detected as Objective-C.
This commit fixes it by ensuring that `[ token ]` is not annotated as an
Objective-C message send.

rdar://45504376

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=352125&r1=352124&r2=352125&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jan 24 15:07:58 2019
@@ -494,9 +494,14 @@ private:
   if (CurrentToken->is(tok::r_square)) {
 if (IsCpp11AttributeSpecifier)
   CurrentToken->Type = TT_AttributeSquare;
-else if (CurrentToken->Next && CurrentToken->Next->is(tok::l_paren) &&
+else if (((CurrentToken->Next &&
+   CurrentToken->Next->is(tok::l_paren)) ||
+  (CurrentToken->Previous &&
+   CurrentToken->Previous->Previous == Left)) &&
  Left->is(TT_ObjCMethodExpr)) {
-  // An ObjC method call is rarely followed by an open parenthesis.
+  // An ObjC method call is rarely followed by an open parenthesis. It
+  // also can't be composed of just one token, unless it's a macro that
+  // will be expanded to more tokens.
   // FIXME: Do we incorrectly label ":" with this?
   StartsObjCMethodExpr = false;
   Left->Type = TT_Unknown;

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=352125&r1=352124&r2=352125&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Thu Jan 24 15:07:58 2019
@@ -165,6 +165,20 @@ TEST(FormatTestObjCStyle, DetectsObjCInH
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 }
 
+TEST(FormatTestObjCStyle, AvoidDetectingDesignatedInitializersAsObjCInHeaders) 
{
+  auto Style = getStyle("LLVM", "a.h", "none",
+"static const char *names[] = {[0] = \"foo\",\n"
+"[kBar] = \"bar\"};");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+
+  Style = getStyle("LLVM", "a.h", "none",
+   "static const char *names[] = {[0] EQ \"foo\",\n"
+   "[kBar] EQ \"bar\"};");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
+}
+
 TEST_F(FormatTestObjC, FormatObjCTryCatch) {
   verifyFormat("@try {\n"
"  f();\n"


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


r346822 - [HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory

2018-11-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Nov 13 17:08:03 2018
New Revision: 346822

URL: http://llvm.org/viewvc/llvm-project?rev=346822&view=rev
Log:
[HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory

Include search paths can be relative paths. The loadSubdirectoryModuleMaps 
function
should account for that and respect the -working-directory parameter given to 
Clang.

rdar://46045849

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

Added:
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/

cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/

cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h

cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=346822&r1=346821&r2=346822&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Nov 13 17:08:03 2018
@@ -1638,8 +1638,10 @@ void HeaderSearch::loadSubdirectoryModul
 return;
 
   std::error_code EC;
+  SmallString<128> Dir = SearchDir.getDir()->getName();
+  FileMgr.makeAbsolutePath(Dir);
   SmallString<128> DirNative;
-  llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
+  llvm::sys::path::native(Dir, DirNative);
   llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
   for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {

Added: 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h?rev=346822&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/h1.h
 Tue Nov 13 17:08:03 2018
@@ -0,0 +1 @@
+int bar();

Added: 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map?rev=346822&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/subdirectory-module-maps-working-dir/subdir_module/module.map
 Tue Nov 13 17:08:03 2018
@@ -0,0 +1,5 @@
+module ModuleInSubdir {
+header "h1.h"
+  export *
+}
+

Added: cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m?rev=346822&view=auto
==
--- cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m (added)
+++ cfe/trunk/test/Modules/subdirectory-module-maps-working-dir.m Tue Nov 13 
17:08:03 2018
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t \
+// RUN:-working-directory %S/Inputs \
+// RUN:-I subdirectory-module-maps-working-dir \
+// RUN:%s -Werror=implicit-function-declaration -Xclang -verify
+
+@import ModuleInSubdir;
+
+void foo() {
+  int x = bar();
+}
+
+// expected-no-diagnostics


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


r348448 - [darwin] remove version number check when enabling -fobjc-subscripting-legacy-runtime

2018-12-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Dec  5 18:44:23 2018
New Revision: 348448

URL: http://llvm.org/viewvc/llvm-project?rev=348448&view=rev
Log:
[darwin] remove version number check when enabling 
-fobjc-subscripting-legacy-runtime

This subscripting feature actually works on older OS versions anyway.

rdar://36287065

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/rewrite-legacy-objc.m

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348448&r1=348447&r2=348448&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Dec  5 18:44:23 2018
@@ -2828,7 +2828,6 @@ static void RenderObjCOptions(const Tool
   // When ObjectiveC legacy runtime is in effect on MacOSX, turn on the option
   // to do Array/Dictionary subscripting by default.
   if (Arch == llvm::Triple::x86 && T.isMacOSX() &&
-  !T.isMacOSXVersionLT(10, 7) &&
   Runtime.getKind() == ObjCRuntime::FragileMacOSX && 
Runtime.isNeXTFamily())
 CmdArgs.push_back("-fobjc-subscripting-legacy-runtime");
 

Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=348448&r1=348447&r2=348448&view=diff
==
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Wed Dec  5 18:44:23 2018
@@ -10,4 +10,4 @@
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 
-rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
 // TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" 
"-fdiagnostics-show-option"
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" 
"-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" 
"-fdiagnostics-show-option"


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


r348540 - [frontend][darwin] warn_stdlibcxx_not_found: supress warning for preprocessed input

2018-12-06 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  6 14:45:58 2018
New Revision: 348540

URL: http://llvm.org/viewvc/llvm-project?rev=348540&view=rev
Log:
[frontend][darwin] warn_stdlibcxx_not_found: supress warning for preprocessed 
input

Addresses second post-commit feedback for r335081 from Nico

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=348540&r1=348539&r2=348540&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Dec  6 14:45:58 2018
@@ -3240,6 +3240,7 @@ bool CompilerInvocation::CreateFromArgs(
   Res.getTargetOpts(), Res.getFrontendOpts());
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
 Res.getFileSystemOpts().WorkingDir);
+  llvm::Triple T(Res.getTargetOpts().Triple);
   if (DashX.getFormat() == InputKind::Precompiled ||
   DashX.getLanguage() == InputKind::LLVM_IR) {
 // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the
@@ -3260,6 +3261,12 @@ bool CompilerInvocation::CreateFromArgs(
   Res.getPreprocessorOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
+if (T.isOSDarwin() && DashX.isPreprocessed()) {
+  // Supress the darwin-specific 'stdlibcxx-not-found' diagnostic for
+  // preprocessed input as we don't expect it to be used with -std=libc++
+  // anyway.
+  Res.getDiagnosticOpts().Warnings.push_back("no-stdlibcxx-not-found");
+}
   }
 
   LangOpts.FunctionAlignment =
@@ -3291,7 +3298,6 @@ bool CompilerInvocation::CreateFromArgs(
   Res.getFrontendOpts().ProgramAction);
 
   // Turn on -Wspir-compat for SPIR target.
-  llvm::Triple T(Res.getTargetOpts().Triple);
   auto Arch = T.getArch();
   if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) {
 Res.getDiagnosticOpts().Warnings.push_back("spir-compat");

Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp?rev=348540&r1=348539&r2=348540&view=diff
==
--- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original)
+++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Thu Dec  6 14:45:58 
2018
@@ -1,5 +1,6 @@
 // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 
2>&1 | FileCheck %s
 // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist 
-stdlib=libc++ %s -verify
+// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot 
%S/doesnotexist %s -verify
 // CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' 
on the command line to use the libc++ standard library instead
 
 // expected-no-diagnostics


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


r356605 - Fix implicit ios -> watchOS availability version mapping for

2019-03-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Mar 20 13:02:00 2019
New Revision: 356605

URL: http://llvm.org/viewvc/llvm-project?rev=356605&view=rev
Log:
Fix implicit ios -> watchOS availability version mapping for
versions that have the major number only

rdar://48018651

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-availability-watchos.c

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=356605&r1=356604&r2=356605&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Mar 20 13:02:00 2019
@@ -2508,6 +2508,7 @@ static void handleAvailabilityAttr(Sema
   else
 return VersionTuple(NewMajor, Version.getMinor().getValue());
 }
+return VersionTuple(NewMajor);
   }
 
   return VersionTuple(2, 0);

Modified: cfe/trunk/test/Sema/attr-availability-watchos.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-watchos.c?rev=356605&r1=356604&r2=356605&view=diff
==
--- cfe/trunk/test/Sema/attr-availability-watchos.c (original)
+++ cfe/trunk/test/Sema/attr-availability-watchos.c Wed Mar 20 13:02:00 2019
@@ -52,3 +52,9 @@ void test_watchos() {
   f5c_watchos(0); // expected-warning {{'f5c_watchos' is deprecated: first 
deprecated in watchOS 2.0}}
   f6_watchos(0); // expected-warning {{'f6_watchos' is deprecated: first 
deprecated in watchOS 3.0}}
 }
+
+void deprecatedAfterIntroduced() 
__attribute__((availability(ios,introduced=9.3,deprecated=10))); // 
expected-note {{here}}
+
+void test_ios_correctly_map_to_watchos() {
+  deprecatedAfterIntroduced(); // expected-warning 
{{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
+}


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


r357740 - [test] Specify an explicit darwin version in a triple in

2019-04-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  4 18:48:11 2019
New Revision: 357740

URL: http://llvm.org/viewvc/llvm-project?rev=357740&view=rev
Log:
[test] Specify an explicit darwin version in a triple in
`test/Driver/debug-options.c` to ensure that the driver
selects the DWARF 2 version as intended by the test.

Fixes the `test/Driver/debug-options.c` test regression on GreenDragon
on macOS that started failing after r357713.

Modified:
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357740&r1=357739&r2=357740&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 18:48:11 2019
@@ -25,7 +25,7 @@
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
 // RUN: -check-prefix=G_LLDB %s


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


r359353 - [driver][macOS] Link libarclite from the default toolchain when clang

2019-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr 26 15:40:47 2019
New Revision: 359353

URL: http://llvm.org/viewvc/llvm-project?rev=359353&view=rev
Log:
[driver][macOS] Link libarclite from the default toolchain when clang
is running in a toolchain outside of xcode

'libarclite' usually lives in the same toolchain as 'clang'. However, the
Swift open source toolchains for macOS distribute Clang without 'libarclite'.
In that case, to allow the linker to find 'libarclite', we point to the
'libarclite' that should be in the XcodeDefault toolchain instead. The
path to the toolchain is inferred from the SDK path if it's specified.

https://bugs.swift.org/browse/SR-9972
rdar://49947573

Added:
cfe/trunk/test/Driver/arclite-link-external-toolchain.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=359353&r1=359352&r2=359353&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Apr 26 15:40:47 2019
@@ -893,6 +893,18 @@ void DarwinClang::addClangWarningOptions
   }
 }
 
+/// Take a path that speculatively points into Xcode and return the
+/// `XCODE/Contents/Developer` path if it is an Xcode path, or an empty path
+/// otherwise.
+static StringRef getXcodeDeveloperPath(StringRef PathIntoXcode) {
+  static constexpr llvm::StringLiteral XcodeAppSuffix(
+  ".app/Contents/Developer");
+  size_t Index = PathIntoXcode.find(XcodeAppSuffix);
+  if (Index == StringRef::npos)
+return "";
+  return PathIntoXcode.take_front(Index + XcodeAppSuffix.size());
+}
+
 void DarwinClang::AddLinkARCArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   // Avoid linking compatibility stubs on i386 mac.
@@ -905,10 +917,27 @@ void DarwinClang::AddLinkARCArgs(const A
   runtime.hasSubscripting())
 return;
 
-  CmdArgs.push_back("-force_load");
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+
+  // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
+  // Swift open source toolchains for macOS distribute Clang without 
libarclite.
+  // In that case, to allow the linker to find 'libarclite', we point to the
+  // 'libarclite' in the XcodeDefault toolchain instead.
+  if (getXcodeDeveloperPath(P).empty()) {
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  // Try to infer the path to 'libarclite' in the toolchain from the
+  // specified SDK path.
+  StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
+  if (!XcodePathForSDK.empty()) {
+P = XcodePathForSDK;
+llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
+  }
+}
+  }
+
+  CmdArgs.push_back("-force_load");
   llvm::sys::path::append(P, "lib", "arc", "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())

Added: cfe/trunk/test/Driver/arclite-link-external-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arclite-link-external-toolchain.c?rev=359353&view=auto
==
--- cfe/trunk/test/Driver/arclite-link-external-toolchain.c (added)
+++ cfe/trunk/test/Driver/arclite-link-external-toolchain.c Fri Apr 26 15:40:47 
2019
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t.tmpdir
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-macos10.10 -fobjc-link-runtime -lfoo \
+// RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: -lfoo
+// CHECK: 
.tmpdir/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a


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


r359356 - [clang][driver] Weaken the test from 359353 to appease Windows bots

2019-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr 26 15:58:31 2019
New Revision: 359356

URL: http://llvm.org/viewvc/llvm-project?rev=359356&view=rev
Log:
[clang][driver] Weaken the test from 359353 to appease Windows bots

Modified:
cfe/trunk/test/Driver/arclite-link-external-toolchain.c

Modified: cfe/trunk/test/Driver/arclite-link-external-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arclite-link-external-toolchain.c?rev=359356&r1=359355&r2=359356&view=diff
==
--- cfe/trunk/test/Driver/arclite-link-external-toolchain.c (original)
+++ cfe/trunk/test/Driver/arclite-link-external-toolchain.c Fri Apr 26 15:58:31 
2019
@@ -5,4 +5,4 @@
 // RUN:   %s 2>&1 | FileCheck %s
 
 // CHECK: -lfoo
-// CHECK: 
.tmpdir/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a


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


r360374 - NFC, make XFAIL work on macOS correctly for test/Driver/XRay/xray-instrument-os.c

2019-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu May  9 13:35:41 2019
New Revision: 360374

URL: http://llvm.org/viewvc/llvm-project?rev=360374&view=rev
Log:
NFC, make XFAIL work on macOS correctly for 
test/Driver/XRay/xray-instrument-os.c

The test 'test/Driver/XRay/xray-instrument-os.c' is supposed to XFAIL on 
-darwin triples.
However, LLVM can be configured to be built with a -macos triple instead, which 
is equivalent
to -darwin. This commit updates the XFAIL condition to also XFAIL with a -macos 
host triple.

Modified:
cfe/trunk/test/Driver/XRay/xray-instrument-os.c

Modified: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-os.c?rev=360374&r1=360373&r2=360374&view=diff
==
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c (original)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c Thu May  9 13:35:41 2019
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: -linux-, -freebsd, -darwin
+// XFAIL: -linux-, -freebsd, -darwin, -macos
 // REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;


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


r311778 - [Basic] Add a DiagnosticError llvm::ErrorInfo subclass

2017-08-25 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug 25 08:48:00 2017
New Revision: 311778

URL: http://llvm.org/viewvc/llvm-project?rev=311778&view=rev
Log:
[Basic] Add a DiagnosticError llvm::ErrorInfo subclass

Clang's DiagnosticError is an llvm::Error payload that stores a partial
diagnostic and its location. I'll be using it in the refactoring engine.

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

Added:
cfe/trunk/include/clang/Basic/DiagnosticError.h
Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/unittests/Basic/DiagnosticTest.cpp

Added: cfe/trunk/include/clang/Basic/DiagnosticError.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticError.h?rev=311778&view=auto
==
--- cfe/trunk/include/clang/Basic/DiagnosticError.h (added)
+++ cfe/trunk/include/clang/Basic/DiagnosticError.h Fri Aug 25 08:48:00 2017
@@ -0,0 +1,61 @@
+//===--- DiagnosticError.h - Diagnostic payload for llvm::Error -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_ERROR_H
+#define LLVM_CLANG_BASIC_DIAGNOSTIC_ERROR_H
+
+#include "clang/Basic/PartialDiagnostic.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+
+/// \brief Carries a Clang diagnostic in an llvm::Error.
+///
+/// Users should emit the stored diagnostic using the DiagnosticsEngine.
+class DiagnosticError : public llvm::ErrorInfo {
+public:
+  DiagnosticError(PartialDiagnosticAt Diag) : Diag(std::move(Diag)) {}
+
+  void log(raw_ostream &OS) const override { OS << "clang diagnostic"; }
+
+  PartialDiagnosticAt &getDiagnostic() { return Diag; }
+  const PartialDiagnosticAt &getDiagnostic() const { return Diag; }
+
+  /// Creates a new \c DiagnosticError that contains the given diagnostic at
+  /// the given location.
+  static llvm::Error create(SourceLocation Loc, PartialDiagnostic Diag) {
+return llvm::make_error(
+PartialDiagnosticAt(Loc, std::move(Diag)));
+  }
+
+  /// Extracts and returns the diagnostic payload from the given \c Error if
+  /// the error is a \c DiagnosticError. Returns none if the given error is not
+  /// a \c DiagnosticError.
+  static Optional take(llvm::Error &Err) {
+Optional Result;
+Err = llvm::handleErrors(std::move(Err), [&](DiagnosticError &E) {
+  Result = std::move(E.getDiagnostic());
+});
+return Result;
+  }
+
+  static char ID;
+
+private:
+  // Users are not expected to use error_code.
+  std::error_code convertToErrorCode() const override {
+return llvm::inconvertibleErrorCode();
+  }
+
+  PartialDiagnosticAt Diag;
+};
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_BASIC_DIAGNOSTIC_ERROR_H

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=311778&r1=311777&r2=311778&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Fri Aug 25 08:48:00 2017
@@ -11,8 +11,9 @@
 //
 
//===--===//
 
-#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/DiagnosticError.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/PartialDiagnostic.h"
@@ -1050,3 +1051,5 @@ PartialDiagnostic::StorageAllocator::~St
   llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
  "A partial is on the lam");
 }
+
+char DiagnosticError::ID;

Modified: cfe/trunk/unittests/Basic/DiagnosticTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/DiagnosticTest.cpp?rev=311778&r1=311777&r2=311778&view=diff
==
--- cfe/trunk/unittests/Basic/DiagnosticTest.cpp (original)
+++ cfe/trunk/unittests/Basic/DiagnosticTest.cpp Fri Aug 25 08:48:00 2017
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticError.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "gtest/gtest.h"
 
@@ -72,4 +73,25 @@ TEST(DiagnosticTest, suppressAfterFatalE
   }
 }
 
+TEST(DiagnosticTest, diagnosticError) {
+  DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions,
+  new IgnoringDiagConsumer());
+  PartialDiagnostic::StorageAllocator Alloc;
+  llvm::Expected> Value = DiagnosticError::create(
+  SourceLocation(), PartialDiagnostic(diag::err_cannot_open_file, Alloc)
+<< "file"
+ 

r311779 - [ObjC] Add a -Wobjc-messaging-id warning

2017-08-25 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug 25 09:12:17 2017
New Revision: 311779

URL: http://llvm.org/viewvc/llvm-project?rev=311779&view=rev
Log:
[ObjC] Add a -Wobjc-messaging-id warning

-Wobjc-messaging-id is a new, non-default warning that warns about
message sends to unqualified id in Objective-C. This warning is useful
for projects that would like to avoid any potential future compiler
errors/warnings, as the system frameworks might add a method with the same
selector which could make the message send to id ambiguous.

rdar://33303354

Added:
cfe/trunk/test/SemaObjC/warn-messaging-id.mm
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=311779&r1=311778&r2=311779&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Aug 25 09:12:17 2017
@@ -66,6 +66,12 @@ Improvements to Clang's diagnostics
 a non-default alignment that has been specified using a ``#pragma pack``
 directive prior to the ``#include``.
 
+- ``-Wobjc-messaging-id`` is a new, non-default warning that warns about
+  message sends to unqualified ``id`` in Objective-C. This warning is useful
+  for projects that would like to avoid any potential future compiler
+  errors/warnings, as the system frameworks might add a method with the same
+  selector which could make the message send to ``id`` ambiguous.
+
 Non-comprehensive list of changes in this release
 -
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=311779&r1=311778&r2=311779&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 25 09:12:17 
2017
@@ -1211,6 +1211,10 @@ def err_objc_method_unsupported_param_re
   "%0 %select{parameter|return}1 type is unsupported; "
   "support for vector types for this target is introduced in %2">;
 
+def warn_messaging_unqualified_id : Warning<
+  "messaging unqualified id">, DefaultIgnore,
+  InGroup>;
+
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=311779&r1=311778&r2=311779&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Aug 25 09:12:17 2017
@@ -2705,6 +2705,9 @@ ExprResult Sema::BuildInstanceMessage(Ex
 }
   }
 
+  if (ReceiverType->isObjCIdType() && !isImplicit)
+Diag(Receiver->getExprLoc(), diag::warn_messaging_unqualified_id);
+
   // There's a somewhat weird interaction here where we assume that we
   // won't actually have a method unless we also don't need to do some
   // of the more detailed type-checking on the receiver.

Added: cfe/trunk/test/SemaObjC/warn-messaging-id.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-messaging-id.mm?rev=311779&view=auto
==
--- cfe/trunk/test/SemaObjC/warn-messaging-id.mm (added)
+++ cfe/trunk/test/SemaObjC/warn-messaging-id.mm Fri Aug 25 09:12:17 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class 
-Wobjc-messaging-id %s
+
+@interface CallMeMaybe
+
+- (void)doThing:(int)intThing;
+
+@property int thing;
+
+@end
+
+template
+void instantiate(const T &x) {
+  [x setThing: 22]; // expected-warning {{messaging unqualified id}}
+}
+
+void fn() {
+  id myObject;
+  [myObject doThing: 10]; // expected-warning {{messaging unqualified id}}
+  [myObject setThing: 11]; // expected-warning {{messaging unqualified id}}
+  instantiate(myObject); // expected-note {{in instantiation}}
+}


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


r311884 - [refactor] initial support for refactoring action rules

2017-08-28 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 28 04:12:05 2017
New Revision: 311884

URL: http://llvm.org/viewvc/llvm-project?rev=311884&view=rev
Log:
[refactor] initial support for refactoring action rules

This patch implements the initial support for refactoring action rules. The
first rule that's supported is a "source change" rule that returns a set of
atomic changes. This patch is based on the ideas presented in my RFC:

http://lists.llvm.org/pipermail/cfe-dev/2017-July/054831.html

The following pieces from the RFC are added by this patch:

- `createRefactoringRule` (known as `apply` in the RFC)
- `requiredSelection` refactoring action rule requirement.
- `selection::SourceSelectionRange` selection constraint.

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h

cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringRuleContext.h
cfe/trunk/include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
cfe/trunk/lib/Tooling/Refactoring/SourceSelectionConstraints.cpp
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp
Modified:
cfe/trunk/include/clang/Basic/LLVM.h
cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/include/clang/Basic/LLVM.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LLVM.h?rev=311884&r1=311883&r2=311884&view=diff
==
--- cfe/trunk/include/clang/Basic/LLVM.h (original)
+++ cfe/trunk/include/clang/Basic/LLVM.h Mon Aug 28 04:12:05 2017
@@ -35,6 +35,7 @@ namespace llvm {
   template class SmallVector;
   template class SmallVectorImpl;
   template class Optional;
+  template  class Expected;
 
   template
   struct SaveAndRestore;
@@ -71,6 +72,9 @@ namespace clang {
   using llvm::SmallVectorImpl;
   using llvm::SaveAndRestore;
 
+  // Error handling.
+  using llvm::Expected;
+
   // Reference counting.
   using llvm::IntrusiveRefCntPtr;
   using llvm::IntrusiveRefCntPtrInfo;

Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=311884&r1=311883&r2=311884&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Mon Aug 28 
04:12:05 2017
@@ -46,6 +46,12 @@ public:
   AtomicChange(llvm::StringRef FilePath, llvm::StringRef Key)
   : Key(Key), FilePath(FilePath) {}
 
+  AtomicChange(AtomicChange &&) = default;
+  AtomicChange(const AtomicChange &) = default;
+
+  AtomicChange &operator=(AtomicChange &&) = default;
+  AtomicChange &operator=(const AtomicChange &) = default;
+
   /// \brief Returns the atomic change as a YAML string.
   std::string toYAMLString();
 
@@ -130,6 +136,8 @@ private:
   tooling::Replacements Replaces;
 };
 
+using AtomicChanges = std::vector;
+
 // Defines specs for applying changes.
 struct ApplyChangesSpec {
   // If true, cleans up redundant/erroneous code around changed code with

Added: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=311884&view=auto
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h (added)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Mon Aug 
28 04:12:05 2017
@@ -0,0 +1,70 @@
+//===--- RefactoringActionRule.h - Clang refactoring library -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
+#define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "llvm/Support/Error.h"
+#include 
+
+namespace clang {
+namespace tooling {
+
+class RefactoringRuleContext;
+
+/// A common refactoring action rule interface.
+class RefactoringActionRule {
+public:
+  enum RuleKind { SourceChangeRefactoringRuleKind };
+
+  RuleKind getRuleKind() const { return Kind; }
+
+  virtual

r311886 - Avoid missing std error code in RefactoringActionRulesTest.cpp

2017-08-28 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Aug 28 05:03:08 2017
New Revision: 311886

URL: http://llvm.org/viewvc/llvm-project?rev=311886&view=rev
Log:
Avoid missing std error code in RefactoringActionRulesTest.cpp

This should fix this bot:
http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux

Modified:
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=311886&r1=311885&r2=311886&view=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Mon Aug 28 
05:03:08 2017
@@ -111,7 +111,7 @@ TEST_F(RefactoringActionRulesTest, Retur
   Expected (*Func)(selection::SourceSelectionRange) =
   [](selection::SourceSelectionRange) -> Expected {
 return llvm::make_error(
-"Error", std::make_error_code(std::errc::bad_message));
+"Error", llvm::make_error_code(llvm::errc::invalid_argument));
   };
   auto Rule = createRefactoringRule(
   Func, requiredSelection(
@@ -139,7 +139,7 @@ TEST_F(RefactoringActionRulesTest, Retur
 Expected>
 evaluateSelection(selection::SourceSelectionRange Selection) const {
   return llvm::make_error(
-  "bad selection", std::make_error_code(std::errc::bad_message));
+  "bad selection", 
llvm::make_error_code(llvm::errc::invalid_argument));
 }
   };
   auto Rule = createRefactoringRule(


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


r312121 - [refactor] Examine the whole range for ObjC @implementation decls

2017-08-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 30 06:24:37 2017
New Revision: 312121

URL: http://llvm.org/viewvc/llvm-project?rev=312121&view=rev
Log:
[refactor] Examine the whole range for ObjC @implementation decls
when computing the AST selection

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=312121&r1=312120&r2=312121&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Wed Aug 30 06:24:37 2017
@@ -17,6 +17,21 @@ using ast_type_traits::DynTypedNode;
 
 namespace {
 
+CharSourceRange getLexicalDeclRange(Decl *D, const SourceManager &SM,
+const LangOptions &LangOpts) {
+  if (!isa(D))
+return CharSourceRange::getTokenRange(D->getSourceRange());
+  // Objective-C implementation declarations end at the '@' instead of the 
'end'
+  // keyword. Use the lexer to find the location right after 'end'.
+  SourceRange R = D->getSourceRange();
+  SourceLocation LocAfterEnd = Lexer::findLocationAfterToken(
+  R.getEnd(), tok::raw_identifier, SM, LangOpts,
+  /*SkipTrailingWhitespaceAndNewLine=*/false);
+  return LocAfterEnd.isValid()
+ ? CharSourceRange::getCharRange(R.getBegin(), LocAfterEnd)
+ : CharSourceRange::getTokenRange(R);
+}
+
 /// Constructs the tree of selected AST nodes that either contain the location
 /// of the cursor or overlap with the selection range.
 class ASTSelectionFinder
@@ -62,9 +77,8 @@ public:
 if (SM.getFileID(FileLoc) != TargetFile)
   return true;
 
-// FIXME (Alex Lorenz): Add location adjustment for ObjCImplDecls.
 SourceSelectionKind SelectionKind =
-selectionKindFor(CharSourceRange::getTokenRange(D->getSourceRange()));
+selectionKindFor(getLexicalDeclRange(D, SM, Context.getLangOpts()));
 SelectionStack.push_back(
 SelectedASTNode(DynTypedNode::create(*D), SelectionKind));
 LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=312121&r1=312120&r2=312121&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Aug 30 06:24:37 2017
@@ -494,4 +494,23 @@ void foo() {
   });
 }
 
+TEST(ASTSelectionFinder, CorrectEndForObjectiveCImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+@implementation I
+@ end
+)";
+  // Just after '@ end'
+  findSelectedASTNodes(Source, {5, 6}, None,
+   [](Optional Node) {
+ EXPECT_TRUE(Node);
+ EXPECT_EQ(Node->Children.size(), 1u);
+ checkNode(
+ Node->Children[0],
+ SourceSelectionKind::ContainsSelection);
+   },
+   SelectionFinderVisitor::Lang_OBJC);
+}
+
 } // end anonymous namespace


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


r312127 - [refactor] AST selection tree should contain syntactic form

2017-08-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 30 08:00:27 2017
New Revision: 312127

URL: http://llvm.org/viewvc/llvm-project?rev=312127&view=rev
Log:
[refactor] AST selection tree should contain syntactic form
of PseudoObjectExpr

The AST selection finder now constructs a selection tree that contains only the
syntactic form of PseudoObjectExpr. This form of selection tree is more
meaningful when doing downstream analysis as we're interested in the syntactic
features of the AST and the correct lexical parent relation.

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=312127&r1=312126&r2=312127&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Wed Aug 30 08:00:27 2017
@@ -10,6 +10,7 @@
 #include "clang/Tooling/Refactoring/ASTSelection.h"
 #include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
 using namespace tooling;
@@ -60,6 +61,21 @@ public:
 return std::move(Result);
   }
 
+  bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
+// Avoid traversing the semantic expressions. They should be handled by
+// looking through the appropriate opaque expressions in order to build
+// a meaningful selection tree.
+llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true);
+return TraverseStmt(E->getSyntacticForm());
+  }
+
+  bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
+if (!LookThroughOpaqueValueExprs)
+  return true;
+llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false);
+return TraverseStmt(E->getSourceExpr());
+  }
+
   bool TraverseDecl(Decl *D) {
 if (isa(D))
   return LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
@@ -97,6 +113,8 @@ public:
   bool TraverseStmt(Stmt *S) {
 if (!S)
   return true;
+if (auto *Opaque = dyn_cast(S))
+  return TraverseOpaqueValueExpr(Opaque);
 // FIXME (Alex Lorenz): Improve handling for macro locations.
 SourceSelectionKind SelectionKind =
 selectionKindFor(CharSourceRange::getTokenRange(S->getSourceRange()));
@@ -149,6 +167,10 @@ private:
   FileID TargetFile;
   const ASTContext &Context;
   std::vector SelectionStack;
+  /// Controls whether we can traverse through the OpaqueValueExpr. This is
+  /// typically enabled during the traversal of syntactic form for
+  /// PseudoObjectExprs.
+  bool LookThroughOpaqueValueExprs = false;
 };
 
 } // end anonymous namespace

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=312127&r1=312126&r2=312127&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Aug 30 08:00:27 2017
@@ -513,4 +513,140 @@ TEST(ASTSelectionFinder, CorrectEndForOb
SelectionFinderVisitor::Lang_OBJC);
 }
 
+const SelectedASTNode &checkFnBody(const Optional &Node,
+   StringRef Name) {
+  EXPECT_TRUE(Node);
+  EXPECT_EQ(Node->Children.size(), 1u);
+  const auto &Fn = checkNode(
+  Node->Children[0], SourceSelectionKind::ContainsSelection,
+  /*NumChildren=*/1, Name);
+  return checkNode(Fn.Children[0],
+ SourceSelectionKind::ContainsSelection,
+ /*NumChildren=*/1);
+}
+
+TEST(ASTSelectionFinder, SelectObjectiveCPseudoObjectExprs) {
+  StringRef Source = R"(
+@interface I
+@property(readwrite) int prop;
+@end
+void selectProp(I *i) {
+(void)i.prop;
+i.prop = 21;
+}
+
+typedef unsigned int size_t;
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+void selectSubscript(NSMutableArray *array, I *i) {
+  (void)array[10];
+  array[i.prop] = i;
+}
+)";
+  // Just 'i.prop'.
+  findSelectedASTNodes(
+  Source, {6, 7}, FileRange{{6, 7}, {6, 13}},
+  [](Optional Node) {
+const auto &CS = checkFnBody(Node, /*Name=*/"selectProp");
+const auto &CCast = checkNode(
+CS.Children[0], SourceSelectionKind::ContainsSelection,
+/*NumChildren=*/1);
+const auto &POE = checkNode(
+CCast.Children[0], SourceSelectionKind::ContainsSelection,
+/*NumChildren=*/1);
+const auto &PRE = checkNode(
+POE.Children[0], SourceSelectionKind::ContainsSelection,
+/*NumChildren=*/1);
+const auto &Cast = checkNode(
+PR

r312131 - Revert r312127 as the ObjC unittest code fails to compile on Linux

2017-08-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 30 08:11:45 2017
New Revision: 312131

URL: http://llvm.org/viewvc/llvm-project?rev=312131&view=rev
Log:
Revert r312127 as the ObjC unittest code fails to compile on Linux

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=312131&r1=312130&r2=312131&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Wed Aug 30 08:11:45 2017
@@ -10,7 +10,6 @@
 #include "clang/Tooling/Refactoring/ASTSelection.h"
 #include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
-#include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
 using namespace tooling;
@@ -61,21 +60,6 @@ public:
 return std::move(Result);
   }
 
-  bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
-// Avoid traversing the semantic expressions. They should be handled by
-// looking through the appropriate opaque expressions in order to build
-// a meaningful selection tree.
-llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true);
-return TraverseStmt(E->getSyntacticForm());
-  }
-
-  bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
-if (!LookThroughOpaqueValueExprs)
-  return true;
-llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false);
-return TraverseStmt(E->getSourceExpr());
-  }
-
   bool TraverseDecl(Decl *D) {
 if (isa(D))
   return LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
@@ -113,8 +97,6 @@ public:
   bool TraverseStmt(Stmt *S) {
 if (!S)
   return true;
-if (auto *Opaque = dyn_cast(S))
-  return TraverseOpaqueValueExpr(Opaque);
 // FIXME (Alex Lorenz): Improve handling for macro locations.
 SourceSelectionKind SelectionKind =
 selectionKindFor(CharSourceRange::getTokenRange(S->getSourceRange()));
@@ -167,10 +149,6 @@ private:
   FileID TargetFile;
   const ASTContext &Context;
   std::vector SelectionStack;
-  /// Controls whether we can traverse through the OpaqueValueExpr. This is
-  /// typically enabled during the traversal of syntactic form for
-  /// PseudoObjectExprs.
-  bool LookThroughOpaqueValueExprs = false;
 };
 
 } // end anonymous namespace

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=312131&r1=312130&r2=312131&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Aug 30 08:11:45 2017
@@ -513,140 +513,4 @@ TEST(ASTSelectionFinder, CorrectEndForOb
SelectionFinderVisitor::Lang_OBJC);
 }
 
-const SelectedASTNode &checkFnBody(const Optional &Node,
-   StringRef Name) {
-  EXPECT_TRUE(Node);
-  EXPECT_EQ(Node->Children.size(), 1u);
-  const auto &Fn = checkNode(
-  Node->Children[0], SourceSelectionKind::ContainsSelection,
-  /*NumChildren=*/1, Name);
-  return checkNode(Fn.Children[0],
- SourceSelectionKind::ContainsSelection,
- /*NumChildren=*/1);
-}
-
-TEST(ASTSelectionFinder, SelectObjectiveCPseudoObjectExprs) {
-  StringRef Source = R"(
-@interface I
-@property(readwrite) int prop;
-@end
-void selectProp(I *i) {
-(void)i.prop;
-i.prop = 21;
-}
-
-typedef unsigned int size_t;
-@interface NSMutableArray
-- (id)objectAtIndexedSubscript:(size_t)index;
-- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
-@end
-
-void selectSubscript(NSMutableArray *array, I *i) {
-  (void)array[10];
-  array[i.prop] = i;
-}
-)";
-  // Just 'i.prop'.
-  findSelectedASTNodes(
-  Source, {6, 7}, FileRange{{6, 7}, {6, 13}},
-  [](Optional Node) {
-const auto &CS = checkFnBody(Node, /*Name=*/"selectProp");
-const auto &CCast = checkNode(
-CS.Children[0], SourceSelectionKind::ContainsSelection,
-/*NumChildren=*/1);
-const auto &POE = checkNode(
-CCast.Children[0], SourceSelectionKind::ContainsSelection,
-/*NumChildren=*/1);
-const auto &PRE = checkNode(
-POE.Children[0], SourceSelectionKind::ContainsSelection,
-/*NumChildren=*/1);
-const auto &Cast = checkNode(
-PRE.Children[0], SourceSelectionKind::InsideSelection,
-/*NumChildren=*/1);
-checkNode(Cast.Children[0],
-   SourceSelectionKind::InsideSelection);
-  },
-  SelectionFinderVisitor::Lang_OBJC);
-  // Just 'i.prop = 21'
-  findSelectedASTNodes(
-  So

r312132 - Recommit r312127: [refactor] AST selection tree should contain syntactic

2017-08-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 30 08:28:01 2017
New Revision: 312132

URL: http://llvm.org/viewvc/llvm-project?rev=312132&view=rev
Log:
Recommit r312127: [refactor] AST selection tree should contain syntactic
form of PseudoObjectExpr

The new commit adjusts unittest test code compilation options so that the
Objective-C code in the unittest can be parsed on non-macOS platforms.

Original message:

The AST selection finder now constructs a selection tree that contains only the
syntactic form of PseudoObjectExpr. This form of selection tree is more
meaningful when doing downstream analysis as we're interested in the syntactic
features of the AST and the correct lexical parent relation.

Modified:
cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp?rev=312132&r1=312131&r2=312132&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/ASTSelection.cpp Wed Aug 30 08:28:01 2017
@@ -10,6 +10,7 @@
 #include "clang/Tooling/Refactoring/ASTSelection.h"
 #include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/Support/SaveAndRestore.h"
 
 using namespace clang;
 using namespace tooling;
@@ -60,6 +61,21 @@ public:
 return std::move(Result);
   }
 
+  bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
+// Avoid traversing the semantic expressions. They should be handled by
+// looking through the appropriate opaque expressions in order to build
+// a meaningful selection tree.
+llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true);
+return TraverseStmt(E->getSyntacticForm());
+  }
+
+  bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
+if (!LookThroughOpaqueValueExprs)
+  return true;
+llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false);
+return TraverseStmt(E->getSourceExpr());
+  }
+
   bool TraverseDecl(Decl *D) {
 if (isa(D))
   return LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
@@ -97,6 +113,8 @@ public:
   bool TraverseStmt(Stmt *S) {
 if (!S)
   return true;
+if (auto *Opaque = dyn_cast(S))
+  return TraverseOpaqueValueExpr(Opaque);
 // FIXME (Alex Lorenz): Improve handling for macro locations.
 SourceSelectionKind SelectionKind =
 selectionKindFor(CharSourceRange::getTokenRange(S->getSourceRange()));
@@ -149,6 +167,10 @@ private:
   FileID TargetFile;
   const ASTContext &Context;
   std::vector SelectionStack;
+  /// Controls whether we can traverse through the OpaqueValueExpr. This is
+  /// typically enabled during the traversal of syntactic form for
+  /// PseudoObjectExprs.
+  bool LookThroughOpaqueValueExprs = false;
 };
 
 } // end anonymous namespace

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=312132&r1=312131&r2=312132&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Aug 30 08:28:01 2017
@@ -513,4 +513,140 @@ TEST(ASTSelectionFinder, CorrectEndForOb
SelectionFinderVisitor::Lang_OBJC);
 }
 
+const SelectedASTNode &checkFnBody(const Optional &Node,
+   StringRef Name) {
+  EXPECT_TRUE(Node);
+  EXPECT_EQ(Node->Children.size(), 1u);
+  const auto &Fn = checkNode(
+  Node->Children[0], SourceSelectionKind::ContainsSelection,
+  /*NumChildren=*/1, Name);
+  return checkNode(Fn.Children[0],
+ SourceSelectionKind::ContainsSelection,
+ /*NumChildren=*/1);
+}
+
+TEST(ASTSelectionFinder, SelectObjectiveCPseudoObjectExprs) {
+  StringRef Source = R"(
+@interface I
+@property(readwrite) int prop;
+@end
+void selectProp(I *i) {
+(void)i.prop;
+i.prop = 21;
+}
+
+typedef unsigned int size_t;
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+void selectSubscript(NSMutableArray *array, I *i) {
+  (void)array[10];
+  array[i.prop] = i;
+}
+)";
+  // Just 'i.prop'.
+  findSelectedASTNodes(
+  Source, {6, 7}, FileRange{{6, 7}, {6, 13}},
+  [](Optional Node) {
+const auto &CS = checkFnBody(Node, /*Name=*/"selectProp");
+const auto &CCast = checkNode(
+CS.Children[0], SourceSelectionKind::ContainsSelection,
+/*NumChildren=*/1);
+const auto &POE = checkNode(
+CCast.Children[0], SourceSelectionKind::ContainsSelection,

r312133 - Avoid 'size_t' typedef in the unittest ObjC code

2017-08-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Aug 30 08:37:30 2017
New Revision: 312133

URL: http://llvm.org/viewvc/llvm-project?rev=312133&view=rev
Log:
Avoid 'size_t' typedef in the unittest ObjC code

This should fix
http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA

Modified:
cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp

Modified: cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp?rev=312133&r1=312132&r2=312133&view=diff
==
--- cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ASTSelectionTest.cpp Wed Aug 30 08:37:30 2017
@@ -535,10 +535,10 @@ void selectProp(I *i) {
 i.prop = 21;
 }
 
-typedef unsigned int size_t;
+
 @interface NSMutableArray
-- (id)objectAtIndexedSubscript:(size_t)index;
-- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+- (id)objectAtIndexedSubscript:(unsigned int)index;
+- (void)setObject:(id)object atIndexedSubscript:(unsigned int)index;
 @end
 
 void selectSubscript(NSMutableArray *array, I *i) {


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


[libunwind] r312240 - Build LLVM with -Wstrict-prototypes enabled

2017-08-31 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Aug 31 06:23:24 2017
New Revision: 312240

URL: http://llvm.org/viewvc/llvm-project?rev=312240&view=rev
Log:
Build LLVM with -Wstrict-prototypes enabled

Clang 5 supports -Wstrict-prototypes. We should use it to catch any C
declarations that declare a non-prototype function.

rdar://33705313

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

Modified:
libunwind/trunk/src/config.h
libunwind/trunk/src/unwind_ext.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=312240&r1=312239&r2=312240&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Thu Aug 31 06:23:24 2017
@@ -119,9 +119,9 @@
   #ifdef __cplusplus
 extern "C" {
   #endif
-extern  bool logAPIs();
-extern  bool logUnwinding();
-extern  bool logDWARF();
+extern  bool logAPIs(void);
+extern  bool logUnwinding(void);
+extern  bool logDWARF(void);
   #ifdef __cplusplus
 }
   #endif

Modified: libunwind/trunk/src/unwind_ext.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/unwind_ext.h?rev=312240&r1=312239&r2=312240&view=diff
==
--- libunwind/trunk/src/unwind_ext.h (original)
+++ libunwind/trunk/src/unwind_ext.h Thu Aug 31 06:23:24 2017
@@ -23,7 +23,7 @@ extern "C" {
 // implemented elsewhere.
 
 extern struct _Unwind_FunctionContext *
-__Unwind_SjLj_GetTopOfFunctionStack();
+__Unwind_SjLj_GetTopOfFunctionStack(void);
 
 extern void
 __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc);


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


[libunwind] r312246 - Revert r312240

2017-08-31 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Aug 31 08:51:23 2017
New Revision: 312246

URL: http://llvm.org/viewvc/llvm-project?rev=312246&view=rev
Log:
Revert r312240

The buildbots have shown that -Wstrict-prototypes behaves differently in GCC
and Clang so we should keep it disabled until Clang follows GCC's behaviour

Modified:
libunwind/trunk/src/config.h
libunwind/trunk/src/unwind_ext.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=312246&r1=312245&r2=312246&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Thu Aug 31 08:51:23 2017
@@ -119,9 +119,9 @@
   #ifdef __cplusplus
 extern "C" {
   #endif
-extern  bool logAPIs(void);
-extern  bool logUnwinding(void);
-extern  bool logDWARF(void);
+extern  bool logAPIs();
+extern  bool logUnwinding();
+extern  bool logDWARF();
   #ifdef __cplusplus
 }
   #endif

Modified: libunwind/trunk/src/unwind_ext.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/unwind_ext.h?rev=312246&r1=312245&r2=312246&view=diff
==
--- libunwind/trunk/src/unwind_ext.h (original)
+++ libunwind/trunk/src/unwind_ext.h Thu Aug 31 08:51:23 2017
@@ -23,7 +23,7 @@ extern "C" {
 // implemented elsewhere.
 
 extern struct _Unwind_FunctionContext *
-__Unwind_SjLj_GetTopOfFunctionStack(void);
+__Unwind_SjLj_GetTopOfFunctionStack();
 
 extern void
 __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc);


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


r312316 - [refactor] Use a RefactoringResultConsumer instead of tagged refactoring

2017-09-01 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Sep  1 02:16:02 2017
New Revision: 312316

URL: http://llvm.org/viewvc/llvm-project?rev=312316&view=rev
Log:
[refactor] Use a RefactoringResultConsumer instead of tagged refactoring
rule classes

This commit changes the way that the refactoring results are produced. Instead
of using different `RefactoringActionRule` subclasses for each result type,
Clang  now use a single `RefactoringResultConsumer`. This was suggested by
Manuel in https://reviews.llvm.org/D36075.

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=312316&r1=312315&r2=312316&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Fri Sep 
 1 02:16:02 2017
@@ -11,52 +11,25 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Tooling/Refactoring/AtomicChange.h"
-#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
 namespace tooling {
 
+class RefactoringResultConsumer;
 class RefactoringRuleContext;
 
 /// A common refactoring action rule interface.
 class RefactoringActionRule {
 public:
-  enum RuleKind { SourceChangeRefactoringRuleKind };
-
-  RuleKind getRuleKind() const { return Kind; }
-
   virtual ~RefactoringActionRule() {}
 
-protected:
-  RefactoringActionRule(RuleKind Kind) : Kind(Kind) {}
-
-private:
-  RuleKind Kind;
-};
-
-/// A type of refactoring action rule that produces source replacements in the
-/// form of atomic changes.
-///
-/// This action rule is typically used for local refactorings that replace
-/// source in a single AST unit.
-class SourceChangeRefactoringRule : public RefactoringActionRule {
-public:
-  SourceChangeRefactoringRule()
-  : RefactoringActionRule(SourceChangeRefactoringRuleKind) {}
-
-  /// Initiates and performs a refactoring action that modifies the sources.
+  /// Initiates and performs a specific refactoring action.
   ///
-  /// The specific rule must return an llvm::Error with a DiagnosticError
-  /// payload or None when the refactoring action couldn't be initiated/
-  /// performed, or \c AtomicChanges when the action was performed 
successfully.
-  virtual Expected>
-  createSourceReplacements(RefactoringRuleContext &Context) = 0;
-
-  static bool classof(const RefactoringActionRule *Rule) {
-return Rule->getRuleKind() == SourceChangeRefactoringRuleKind;
-  }
+  /// The specific rule will invoke an appropriate \c handle method on a
+  /// consumer to propagate the result of the refactoring action.
+  virtual void invoke(RefactoringResultConsumer &Consumer,
+  RefactoringRuleContext &Context) = 0;
 };
 
 /// A set of refactoring action rules that should have unique initiation

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h?rev=312316&r1=312315&r2=312316&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h 
(original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h Fri 
Sep  1 02:16:02 2017
@@ -42,15 +42,12 @@ std::unique_ptr
 createRefactoringRule(Expected (*RefactoringFunction)(
   typename RequirementTypes::OutputType...),
   const RequirementTypes &... Requirements) {
-  static_assert(
-  std::is_base_of<
-  RefactoringActionRule,
-  internal::SpecificRefactoringRuleAdapter>::value,
-  "invalid refactoring result type");
+  static_assert(tooling::traits::IsValidRefactoringResult::value,
+"invalid refactoring result type");
   static_assert(traits::IsRequirement::value,
 "invalid refactoring action rule requirement");
   return llvm::make_unique>(
+  decltype(RefactoringFunction), RequirementTypes...>>(
   RefactoringFunction, std::make_tuple(Requirements...));
 }
 

Modified: 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h?rev=312316&r1=312315&r2=312316&view=diff
===

  1   2   3   4   5   6   7   >