[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good to me. Please fix the additional nits mentioned inline and commit!  
Also, make sure to do a pass to update the capitalization of variables 
throughout the file to match the LLVM coding standards. 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly




Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:1
+//==-- RetainCountChecker.cpp - Checks for leaks and other issues -*- C++ 
-*--//
+//

The file name and description here needs to be updated for this checker.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:10
+//
+//  Class definition for NonnullStringConstantsChecker.
+//  This checker adds an assumption that constant string-like globals are

I don't think the comment in the first line here is needed.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:22
+//  Checker uses are defined in the test file:
+//   - test/Analysis/nonnull-string-constants.mm
+//

We generally don't do this kind of cross-reference in comments since they tend 
to get stale fast when things get moved around. There is no tool support to 
keep them in sync.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:26
+
+//
+// This checker ensures that const string globals are assumed to be non-null.

Can this comment go?



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:53
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext ) const;

We usually put the oxygen comments on checkers on the implementation and not 
the interface since they aren't API and people reading the code generally look 
at the implementations. Can you move them to the implementations?



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:114
+  // Look through the typedefs.
+  while (const TypedefType *T = dyn_cast(type)) {
+type = T->getDecl()->getUnderlyingType();

To match the coding standards this should be `auto *` as well.



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:131
+
+  if (const ObjCObjectPointerType *T = dyn_cast(type)) {
+return T->getInterfaceDecl()->getIdentifier() == NSStringII;

Similar comment about `auto *`



Comment at: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp:133
+return T->getInterfaceDecl()->getIdentifier() == NSStringII;
+  } else if (const TypedefType *T = dyn_cast(type)) {
+return T->getDecl()->getIdentifier() == CFStringRefII;

Similar comment about `auto *`.



Comment at: test/Analysis/nonnull-string-constants.mm:5
+// Relies on the checker defined in
+// lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp.
+

We generally don't put file paths like this in comments since they tend to go 
stale. It is fine to to say that these are tests for the 
NonnullStringConstantsChecker though.


https://reviews.llvm.org/D38764



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Are there any further comments on this, or can someone of those who commented 
on it before approve it?


https://reviews.llvm.org/D38679



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


r315435 - Reorder.

2017-10-10 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Oct 10 21:54:05 2017
New Revision: 315435

URL: http://llvm.org/viewvc/llvm-project?rev=315435=rev
Log:
Reorder.

Modified:
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=315435=315434=315435=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Tue Oct 10 21:54:05 2017
@@ -5,8 +5,8 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
-  IncrementalProcessingTest.cpp
   CodeGenExternalTest.cpp
+  IncrementalProcessingTest.cpp
   )
 
 target_link_libraries(ClangCodeGenTests


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


r315428 - ClangCodeGenTests: Update libdeps in rL315392, +clangAST.

2017-10-10 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Oct 10 21:20:19 2017
New Revision: 315428

URL: http://llvm.org/viewvc/llvm-project?rev=315428=rev
Log:
ClangCodeGenTests: Update libdeps in rL315392, +clangAST.

Modified:
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=315428=315427=315428=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Tue Oct 10 21:20:19 2017
@@ -10,6 +10,7 @@ add_clang_unittest(ClangCodeGenTests
   )
 
 target_link_libraries(ClangCodeGenTests
+  clangAST
   clangBasic
   clangCodeGen
   clangFrontend


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


r315411 - Update cc1as_main for MCAsmBackend ownership change in r315410.

2017-10-10 Thread Lang Hames via cfe-commits
Author: lhames
Date: Tue Oct 10 18:58:08 2017
New Revision: 315411

URL: http://llvm.org/viewvc/llvm-project?rev=315411=rev
Log:
Update cc1as_main for MCAsmBackend ownership change in r315410.

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=315411=315410=315411=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Oct 10 18:58:08 2017
@@ -419,8 +419,8 @@ static bool ExecuteAssembler(AssemblerIn
   Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
-Opts.IncrementalLinkerCompatible,
+T, Ctx, std::unique_ptr(MAB), *Out, CE, *STI,
+Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }


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


r315408 - [modules] Fix visibility checking for using declarations via ADL.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 18:49:57 2017
New Revision: 315408

URL: http://llvm.org/viewvc/llvm-project?rev=315408=rev
Log:
[modules] Fix visibility checking for using declarations via ADL.

We want to check whether the using (shadow) declaration itself is visible, not
whether its target is visible.

Added:
cfe/trunk/test/Modules/adl.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=315408=315407=315408=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Oct 10 18:49:57 2017
@@ -3349,16 +3349,24 @@ void Sema::ArgumentDependentLookup(Decla
   continue;
   }
 
-  if (isa(D))
-D = cast(D)->getTargetDecl();
+  auto *Underlying = D;
+  if (auto *USD = dyn_cast(D))
+Underlying = USD->getTargetDecl();
 
-  if (!isa(D) && !isa(D))
+  if (!isa(Underlying) &&
+  !isa(Underlying))
 continue;
 
-  if (!isVisible(D) && !(D = findAcceptableDecl(*this, D)))
-continue;
+  if (!isVisible(D)) {
+D = findAcceptableDecl(*this, D);
+if (!D)
+  continue;
+if (auto *USD = dyn_cast(D))
+  Underlying = USD->getTargetDecl();
+  }
 
-  Result.insert(D);
+  // FIXME: Preserve D as the FoundDecl.
+  Result.insert(Underlying);
 }
   }
 }

Added: cfe/trunk/test/Modules/adl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/adl.cpp?rev=315408=auto
==
--- cfe/trunk/test/Modules/adl.cpp (added)
+++ cfe/trunk/test/Modules/adl.cpp Tue Oct 10 18:49:57 2017
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery 
-fno-spell-checking %s
+// RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -DONLY_Y %s
+
+#pragma clang module build a
+module a {
+  explicit module x {}
+  explicit module y {}
+}
+#pragma clang module contents
+#pragma clang module begin a.x
+namespace N {
+  template extern int f(T) { return 0; }
+}
+#pragma clang module end
+
+#pragma clang module begin a.y
+#pragma clang module import a.x
+using N::f;
+#pragma clang module end
+#pragma clang module endbuild
+
+namespace N { struct A {}; }
+struct B {};
+
+#ifndef ONLY_Y
+#pragma clang module import a.x
+void test1() {
+  f(N::A());
+  f(B()); // expected-error {{use of undeclared identifier 'f'}}
+}
+#else
+// expected-no-diagnostics
+#endif
+
+#pragma clang module import a.y
+void test2() {
+  // These are OK even if a.x is not imported.
+  f(N::A());
+  f(B());
+}


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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118522.
george.karpenkov added a comment.

Typo fix.


https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  test/Analysis/nonnull-string-constants.mm

Index: test/Analysis/nonnull-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnull-string-constants.mm
@@ -0,0 +1,91 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals.
+// Relies on the checker defined in
+// lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp.
+
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// char* const is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// Pointer value can be mutable.
+extern char *const CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointer itself should be immutable.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef char *const str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
+
+// And for NSString *.
+typedef NSString *const nstr1;
+typedef nstr1 nstr2;
+extern nstr2 nglobalStr2;
+void testNestedTypedefsForNSString() {
+  clang_analyzer_eval(nglobalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,141 @@
+//==-- RetainCountChecker.cpp - Checks for leaks and other issues -*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Class definition for NonnullStringConstantsChecker.
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//  Checker uses are defined in the test file:
+//   - test/Analysis/nonnull-string-constants.mm
+//
+//===--===//
+
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include 

[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Marking requests as "done".


https://reviews.llvm.org/D38764



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118521.
george.karpenkov marked 12 inline comments as done.
george.karpenkov added a comment.

Adhering to comments.


https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
  test/Analysis/nonnnull-string-constants.mm

Index: test/Analysis/nonnnull-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnnull-string-constants.mm
@@ -0,0 +1,91 @@
+// Nullability of const string-like globals.
+// Relies on the checker defined in
+// lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp.
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// char* const is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// Pointer value can be mutable.
+extern char *const CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointer itself should be immutable.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef char *const str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
+
+// And for NSString *.
+typedef NSString *const nstr1;
+typedef nstr1 nstr2;
+extern nstr2 nglobalStr2;
+void testNestedTypedefsForNSString() {
+  clang_analyzer_eval(nglobalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnullStringConstantsChecker.cpp
@@ -0,0 +1,141 @@
+//==-- RetainCountChecker.cpp - Checks for leaks and other issues -*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Class definition for NonnullStringConstantsChecker.
+//  This checker adds an assumption that constant string-like globals are
+//  non-null, as otherwise they generally do not convey any useful information.
+//  The assumption is useful, as many framework use such global const strings,
+//  and the analyzer might not be able to infer the global value if the
+//  definition is in a separate translation unit.
+//  The following types (and their typedef aliases) are considered string-like:
+//   - `char* const`
+//   - `const CFStringRef` from CoreFoundation
+//   - `NSString* const` from Foundation
+//
+//  Checker uses are defined in the test file:
+//   - test/Analysis/nonnull-string-constants.mm
+//
+//===--===//
+
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include 

r315402 - [modules] Only take visible using-directives into account during name lookup.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 18:19:11 2017
New Revision: 315402

URL: http://llvm.org/viewvc/llvm-project?rev=315402=rev
Log:
[modules] Only take visible using-directives into account during name lookup.

Added:
cfe/trunk/test/Modules/using-directive.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=315402=315401=315402=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Oct 10 18:19:11 2017
@@ -88,13 +88,15 @@ namespace {
   /// A collection of using directives, as used by C++ unqualified
   /// lookup.
   class UnqualUsingDirectiveSet {
+Sema 
+
 typedef SmallVector ListTy;
 
 ListTy list;
 llvm::SmallPtrSet visited;
 
   public:
-UnqualUsingDirectiveSet() {}
+UnqualUsingDirectiveSet(Sema ) : SemaRef(SemaRef) {}
 
 void visitScopeChain(Scope *S, Scope *InnermostFileScope) {
   // C++ [namespace.udir]p1:
@@ -113,7 +115,8 @@ namespace {
   visit(Ctx, Ctx);
 } else if (!Ctx || Ctx->isFunctionOrMethod()) {
   for (auto *I : S->using_directives())
-visit(I, InnermostFileDC);
+if (SemaRef.isVisible(I))
+  visit(I, InnermostFileDC);
 }
   }
 }
@@ -152,7 +155,7 @@ namespace {
   while (true) {
 for (auto UD : DC->using_directives()) {
   DeclContext *NS = UD->getNominatedNamespace();
-  if (visited.insert(NS).second) {
+  if (visited.insert(NS).second && SemaRef.isVisible(UD)) {
 addUsingDirective(UD, EffectiveDC);
 queue.push_back(NS);
   }
@@ -1085,7 +1088,7 @@ bool Sema::CppLookupName(LookupResult 
   //   }
   // }
   //
-  UnqualUsingDirectiveSet UDirs;
+  UnqualUsingDirectiveSet UDirs(*this);
   bool VisitedUsingDirectives = false;
   bool LeftStartingScope = false;
   DeclContext *OutsideOfTemplateParamDC = nullptr;
@@ -1868,22 +1871,19 @@ static bool LookupQualifiedNameInUsingDi
  DeclContext *StartDC) {
   assert(StartDC->isFileContext() && "start context is not a file context");
 
-  DeclContext::udir_range UsingDirectives = StartDC->using_directives();
-  if (UsingDirectives.begin() == UsingDirectives.end()) return false;
+  // We have not yet looked into these namespaces, much less added
+  // their "using-children" to the queue.
+  SmallVector Queue;
 
   // We have at least added all these contexts to the queue.
   llvm::SmallPtrSet Visited;
   Visited.insert(StartDC);
 
-  // We have not yet looked into these namespaces, much less added
-  // their "using-children" to the queue.
-  SmallVector Queue;
-
   // We have already looked into the initial namespace; seed the queue
   // with its using-children.
-  for (auto *I : UsingDirectives) {
+  for (auto *I : StartDC->using_directives()) {
 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
-if (Visited.insert(ND).second)
+if (Visited.insert(ND).second && S.isVisible(I))
   Queue.push_back(ND);
   }
 
@@ -1931,7 +1931,7 @@ static bool LookupQualifiedNameInUsingDi
 
 for (auto I : ND->using_directives()) {
   NamespaceDecl *Nom = I->getNominatedNamespace();
-  if (Visited.insert(Nom).second)
+  if (Visited.insert(Nom).second && S.isVisible(I))
 Queue.push_back(Nom);
 }
   }
@@ -3540,6 +3540,8 @@ static void LookupVisibleDecls(DeclConte
   if (QualifiedNameLookup) {
 ShadowContextRAII Shadow(Visited);
 for (auto I : Ctx->using_directives()) {
+  if (!Result.getSema().isVisible(I))
+continue;
   LookupVisibleDecls(I->getNominatedNamespace(), Result,
  QualifiedNameLookup, InBaseClass, Consumer, Visited,
  IncludeDependentBases);
@@ -3746,7 +3748,7 @@ void Sema::LookupVisibleDecls(Scope *S,
   // Determine the set of using directives available during
   // unqualified name lookup.
   Scope *Initial = S;
-  UnqualUsingDirectiveSet UDirs;
+  UnqualUsingDirectiveSet UDirs(*this);
   if (getLangOpts().CPlusPlus) {
 // Find the first namespace or translation-unit scope.
 while (S && !isNamespaceOrTranslationUnitScope(S))

Added: cfe/trunk/test/Modules/using-directive.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/using-directive.cpp?rev=315402=auto
==
--- cfe/trunk/test/Modules/using-directive.cpp (added)
+++ cfe/trunk/test/Modules/using-directive.cpp Tue Oct 10 18:19:11 2017
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fno-modules-error-recovery -fno-spell-checking -verify %s
+
+#pragma clang module build a
+module 

[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

To save reviewers some time. Incomplete array type is not the same as for 
zero-sized array, it is `c"^c\00"` while for zero-sized array it is 
`c"[0c]\00"`. Don't know if it matters, I haven't found any difference in 
behaviour. Though maybe I wasn't looking in the right place.


https://reviews.llvm.org/D38774



___
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=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=315397=315398=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=315397=315398=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 #>, 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


[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

This patch depends on sema change https://reviews.llvm.org/D38773


https://reviews.llvm.org/D38774



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


r315397 - [Modules TS] Diagnose missing/duplicate module-declaration.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 17:36:56 2017
New Revision: 315397

URL: http://llvm.org/viewvc/llvm-project?rev=315397=rev
Log:
[Modules TS] Diagnose missing/duplicate module-declaration.

Added:
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315397=315396=315397=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 10 17:36:56 
2017
@@ -8997,6 +8997,11 @@ def note_prev_module_definition_from_ast
 def err_module_not_defined : Error<
   "definition of module '%0' is not available; use -fmodule-file= to specify "
   "path to precompiled module interface">;
+def err_module_redeclaration : Error<
+  "translation unit contains multiple module declarations">;
+def note_prev_module_declaration : Note<"previous module declaration is here">;
+def err_module_declaration_missing : Error<
+  "missing 'export module' declaration in module interface unit">;
 def err_module_private_specialization : Error<
   "%select{template|partial|member}0 specialization cannot be "
   "declared __module_private__">;

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=315397=315396=315397=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Oct 10 17:36:56 2017
@@ -930,6 +930,17 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 
   if (TUKind == TU_Module) {
+// If we are building a module interface unit, we need to have seen the
+// module declaration by now.
+if (getLangOpts().getCompilingModule() ==
+LangOptions::CMK_ModuleInterface &&
+ModuleScopes.back().Module->Kind != Module::ModuleInterfaceUnit) {
+  // FIXME: Make a better guess as to where to put the module declaration.
+  Diag(getSourceManager().getLocForStartOfFile(
+   getSourceManager().getMainFileID()),
+   diag::err_module_declaration_missing);
+}
+
 // If we are building a module, resolve all of the exported declarations
 // now.
 if (Module *CurrentModule = PP.getCurrentModule()) {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315397=315396=315397=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 10 17:36:56 2017
@@ -16176,9 +16176,19 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
 return nullptr;
   }
 
+  assert(ModuleScopes.size() == 1 && "expected to be at global module scope");
+
   // FIXME: Most of this work should be done by the preprocessor rather than
   // here, in order to support macro import.
 
+  // Only one module-declaration is permitted per source file.
+  if (ModuleScopes.back().Module->Kind == Module::ModuleInterfaceUnit) {
+Diag(ModuleLoc, diag::err_module_redeclaration);
+Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module),
+ diag::note_prev_module_declaration);
+return nullptr;
+  }
+
   // Flatten the dots in a module name. Unlike Clang's hierarchical module map
   // modules, the dots here are just another character that can appear in a
   // module name.
@@ -16189,8 +16199,6 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
 ModuleName += Piece.first->getName();
   }
 
-  // FIXME: If we've already seen a module-declaration, report an error.
-
   // If a module name was explicitly specified on the command line, it must be
   // correct.
   if (!getLangOpts().CurrentModule.empty() &&
@@ -16205,8 +16213,6 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
   auto  = PP.getHeaderSearchInfo().getModuleMap();
   Module *Mod;
 
-  assert(ModuleScopes.size() == 1 && "expected to be at global module scope");
-
   switch (MDK) {
   case ModuleDeclKind::Interface: {
 // We can't have parsed or imported a definition of this module or parsed a
@@ -16240,7 +16246,9 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
/*IsIncludeDirective=*/false);
 if (!Mod) {
   Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
-  return nullptr;
+  // Create an empty module interface unit for error recovery.
+  Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
+ ModuleScopes.front().Module);
 }
 break;
   }

Modified: 

[PATCH] D38773: [Sema] Add support for flexible array members in Obj-C.

2017-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Previous discussion on the mailing list can be found at 
http://lists.llvm.org/pipermail/cfe-dev/2017-September/055548.html The 
implementation is not exactly like it was discussed, it has some changes.

There is another case when extra ivar is added at the end, it is for bitfields. 
But bitfields aren't compatible with flexible array members so I decided not to 
include them in tests.

I separated CodeGen change in a separate patch that can be found here 
.


https://reviews.llvm.org/D38773



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


[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.

2017-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

Fixes an assertion failure when ivar is a struct containing incomplete
array. Also completes support for direct flexible array members.

rdar://problem/21054495


https://reviews.llvm.org/D38774

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/test/CodeGenObjC/ivar-layout-flexible-array.m


Index: clang/test/CodeGenObjC/ivar-layout-flexible-array.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ivar-layout-flexible-array.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc 
-emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+@interface FlexibleArrayMember {
+  char flexible_array[];
+}
+@end
+@implementation FlexibleArrayMember
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"^c\00"
+
+
+struct Packet {
+  int size;
+  char data[];
+};
+
+@interface VariableSizeIvar {
+  struct Packet flexible_struct;
+}
+@end
+@implementation VariableSizeIvar
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} 
c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant 
{{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -5089,6 +5089,11 @@
 fieldType = arrayType->getElementType();
   }
 
+  if (isa(fieldType)) {
+numElts = 0;
+fieldType = fieldType->getAsArrayTypeUnsafe()->getElementType();
+  }
+
   assert(!fieldType->isArrayType() && "ivar of non-constant array type?");
 
   // If we ended up with a zero-sized array, we've done what we can do within


Index: clang/test/CodeGenObjC/ivar-layout-flexible-array.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/ivar-layout-flexible-array.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+@interface FlexibleArrayMember {
+  char flexible_array[];
+}
+@end
+@implementation FlexibleArrayMember
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"^c\00"
+
+
+struct Packet {
+  int size;
+  char data[];
+};
+
+@interface VariableSizeIvar {
+  struct Packet flexible_struct;
+}
+@end
+@implementation VariableSizeIvar
+@end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -5089,6 +5089,11 @@
 fieldType = arrayType->getElementType();
   }
 
+  if (isa(fieldType)) {
+numElts = 0;
+fieldType = fieldType->getAsArrayTypeUnsafe()->getElementType();
+  }
+
   assert(!fieldType->isArrayType() && "ivar of non-constant array type?");
 
   // If we ended up with a zero-sized array, we've done what we can do within
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38773: [Sema] Add support for flexible array members in Obj-C.

2017-10-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

Allow Obj-C ivars with incomplete array type but only as the last ivar.
Also add a requirement for ivars that contain a flexible array member to
be at the end of class too. It is possible to add in a subclass another
ivar at the end but we'll emit a warning in this case. Also we'll emit a
warning if a variable sized ivar is declared in class extension or in
implementation because subclasses won't know they should avoid adding
new ivars.

In ARC incomplete array objects are treated as __unsafe_unretained so
require them to be marked as such.

Prohibit synthesizing ivars with flexible array members because order of
synthesized ivars is not obvious and tricky to control. Spelling out
ivar explicitly gives control to developers and helps to avoid surprises
with unexpected ivar ordering.

For C and C++ changed diagnostic to tell explicitly a field is not the
last one and point to the next field. It is not as useful as in Obj-C
but it is an improvement and it is consistent with Obj-C. For C for
unions emit more specific err_flexible_array_union instead of generic
err_field_incomplete.

rdar://problem/21054495


https://reviews.llvm.org/D38773

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/test/Sema/transparent-union.c
  clang/test/SemaCXX/flexible-array-test.cpp
  clang/test/SemaObjC/flexible-array-arc.m
  clang/test/SemaObjC/flexible-array.m
  clang/test/SemaObjC/ivar-sem-check-1.m
  clang/test/SemaObjCXX/flexible-array.mm

Index: clang/test/SemaObjCXX/flexible-array.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/flexible-array.mm
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Test only flexible array member functionality specific to C++.
+
+union VariableSizeUnion {
+  int s;
+  char c[];
+};
+
+@interface LastUnionIvar {
+  VariableSizeUnion flexible;
+}
+@end
+
+@interface NotLastUnionIvar {
+  VariableSizeUnion flexible; // expected-error {{field 'flexible' with variable sized type 'VariableSizeUnion' is not at the end of class}}
+  int last; // expected-note {{next instance variable declaration is here}}
+}
+@end
+
+
+class VariableSizeClass {
+public:
+  int s;
+  char c[];
+};
+
+@interface LastClassIvar {
+  VariableSizeClass flexible;
+}
+@end
+
+@interface NotLastClassIvar {
+  VariableSizeClass flexible; // expected-error {{field 'flexible' with variable sized type 'VariableSizeClass' is not at the end of class}}
+  int last; // expected-note {{next instance variable declaration is here}}
+}
+@end
Index: clang/test/SemaObjC/ivar-sem-check-1.m
===
--- clang/test/SemaObjC/ivar-sem-check-1.m
+++ clang/test/SemaObjC/ivar-sem-check-1.m
@@ -6,14 +6,15 @@
 @interface INTF
 {
 	struct F {} JJ;
-	int arr[];  // expected-error {{field has incomplete type}}
+	int arr[];  // expected-error {{flexible array member 'arr' with type 'int []' is not at the end of class}}
 	struct S IC;  // expected-error {{field has incomplete type}}
+	  // expected-note@-1 {{next instance variable declaration is here}}
 	struct T { // expected-note {{previous definition is here}}
 	  struct T {} X;  // expected-error {{nested redefinition of 'T'}}
 	}YYY; 
 	FOOBADFUNC;  // expected-error {{field 'BADFUNC' declared as a function}}
 	int kaka;	// expected-note {{previous declaration is here}}
 	int kaka;	// expected-error {{duplicate member 'kaka'}}
-	char ch[];	// expected-error {{field has incomplete type}}
+	char ch[];
 }
 @end
Index: clang/test/SemaObjC/flexible-array.m
===
--- /dev/null
+++ clang/test/SemaObjC/flexible-array.m
@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// # Flexible array member.
+// ## Instance variables only in interface.
+@interface LastIvar {
+  char flexible[];
+}
+@end
+
+@interface NotLastIvar {
+  char flexible[]; // expected-error {{flexible array member 'flexible' with type 'char []' is not at the end of class}}
+  int last; // expected-note {{next instance variable declaration is here}}
+}
+@end
+
+// ## Instance variables in implementation.
+@interface LastIvarInImpl
+@end
+@implementation LastIvarInImpl {
+  char flexible[]; // expected-warning {{field 'flexible' with variable sized type 'char []' is not visible to subclasses and can conflict with their instance variables}}
+}
+@end
+
+@interface NotLastIvarInImpl
+@end
+@implementation NotLastIvarInImpl {
+  char flexible[]; // expected-error {{flexible array member 'flexible' with type 'char []' is not at the end of class}}
+  // expected-warning@-1 {{field 'flexible' with variable sized type 'char []' is not visible to subclasses and can conflict with their 

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D38599#893990, @jroelofs wrote:

> In https://reviews.llvm.org/D38599#893985, @danalbert wrote:
>
> > In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:
> >
> > > That reminds me... this does need a testcase or two.
> >
> >
> > Oh, also, any test I add is going to fail, since the case I'm trying to 
> > account for here is not the default behavior.
>
>
> That's what an `available_feature` + `// REQUIRES:` is for.


Which should be set (along with -D_LIBCXX_DYNAMIC_FALLBACK (possibly renamed to 
_LIBCXXABI_DYNAMIC_FALLBACK)) via a CMake flag... We shouldn't just be defining 
macros like this in CMAKE_CXX_FLAGS.


https://reviews.llvm.org/D38599



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


[PATCH] D38772: [refactor] allow the use of refactoring diagnostics

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: mgorny.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D38772

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
  include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
  include/clang/Tooling/Refactoring/RefactoringRuleContext.h
  lib/Basic/DiagnosticIDs.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/NoSymbolSelectedError.cpp
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  tools/clang-refactor/ToolRefactoringResultConsumer.h
  tools/diagtool/DiagnosticNames.cpp

Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -42,6 +42,7 @@
 #include "clang/Basic/DiagnosticCommentKinds.inc"
 #include "clang/Basic/DiagnosticSemaKinds.inc"
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
+#include "clang/Basic/DiagnosticRefactoringKinds.inc"
 #undef DIAG
 };
 
Index: tools/clang-refactor/ToolRefactoringResultConsumer.h
===
--- /dev/null
+++ tools/clang-refactor/ToolRefactoringResultConsumer.h
@@ -0,0 +1,48 @@
+//===--- ToolRefactoringResultConsumer.h - --*- 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_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+
+namespace clang {
+namespace refactor {
+
+/// A subclass of \c RefactoringResultConsumer that stores the reference to the
+/// TU-specific diagnostics engine.
+class ClangRefactorToolResultConsumer
+: public tooling::RefactoringResultConsumer {
+public:
+  /// Called when a TU is entered.
+  void beginTU(ASTContext ) {
+assert(!Diags && "Diags has been set");
+Diags = ();
+  }
+
+  /// Called when the tool is done with a TU.
+  void endTU() {
+assert(Diags && "Diags unset");
+Diags = nullptr;
+  }
+
+  DiagnosticsEngine () const {
+assert(Diags && "no diags");
+return *Diags;
+  }
+
+private:
+  DiagnosticsEngine *Diags = nullptr;
+};
+
+} // end namespace refactor
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
Index: tools/clang-refactor/TestSupport.h
===
--- tools/clang-refactor/TestSupport.h
+++ tools/clang-refactor/TestSupport.h
@@ -16,9 +16,9 @@
 #ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 #define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H
 
+#include "ToolRefactoringResultConsumer.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Error.h"
@@ -65,7 +65,7 @@
   bool foreachRange(const SourceManager ,
 llvm::function_ref Callback) const;
 
-  std::unique_ptr createConsumer() const;
+  std::unique_ptr createConsumer() const;
 
   void dump(llvm::raw_ostream ) const;
 };
Index: tools/clang-refactor/TestSupport.cpp
===
--- tools/clang-refactor/TestSupport.cpp
+++ tools/clang-refactor/TestSupport.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Basic/DiagnosticError.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
@@ -106,7 +107,7 @@
 }
 
 class TestRefactoringResultConsumer final
-: public tooling::RefactoringResultConsumer {
+: public ClangRefactorToolResultConsumer {
 public:
   TestRefactoringResultConsumer(const TestSelectionRangesInFile )
   : TestRanges(TestRanges) {
@@ -182,10 +183,15 @@
   std::string ErrorMessage;
   bool HasResult = !!Result;
   if (!HasResult) {
-// FIXME: Handle diagnostic error as well.
-handleAllErrors(Result.takeError(), [&](StringError ) {
-  ErrorMessage = Err.getMessage();
-});
+

[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Looks like a great start!

There are a bunch of minor nits inline.

The one big thing is that I think your handling of 'const char *' in 
`typeIsConstString()` isn't quite right. 'const char *' means that the 
pointed-to characters can't be modified but does allow modification of the 
variable holding the pointer. I don't think we want to treat such variables as 
holding non-null pointers, since anyone could assign them to NULL. On the other 
hand, we do want to treat variables of type 'char * const' as holding non-null 
pointers since the variable can't be reassigned and (presumably) it was 
initialized to a non-null value. In this second case the characters could 
potentially be modified, but that doesn't change whether the value of the 
pointer itself.




Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:1
+
+//

We need to have the license preamble here.



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:3
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//

It would be good to include a motivation for why this is the right thing to do 
and even an example of the declarations this will trigger on.



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:17
+
+class NonnilStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;

Since this applies to more than just Objective-C, I think it would be better to 
use 'null' instead of 'nil' in the name of the checker. Or even remove the 
'Nonnil' prefix. What about 'GlobalStringConstantsChecker'?



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:22
+public:
+  NonnilStringConstantsChecker(AnalyzerOptions ) {}
+

Does the constructor need to take an AnalyzerOptions?



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:53
+  SVal V = UnknownVal();
+  if (location.isValid()) {
+V = State->getSVal(location.castAs());

Should we just early return if `location` is not valid?



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:70
+
+bool NonnilStringConstantsChecker::isGlobalConstString(SVal val) const {
+  Optional regionVal = val.getAs();

Can you add doxygen-style comments to the implementations of these methods? I'd 
like to break with tradition and have comments for all new code.



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:71
+bool NonnilStringConstantsChecker::isGlobalConstString(SVal val) const {
+  Optional regionVal = val.getAs();
+  if (!regionVal)

Note that we use capital letters for variables and parameters in Clang/LLVM.



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:74
+return false;
+  const VarRegion *region = dyn_cast(regionVal->getAsRegion());
+  if (!region)

The convention Clang uses with dyn_cast and friends to to use 'auto *' in the 
variable declaration in order to not repeat the type name:
```
auto *Region = dyn_cast(RegionVal->getAsRegion());



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:93
+// to be classified const.
+hasOuterConst |= type.isConstQualified();
+if (typeIsConstString(type, hasOuterConst))

Do you really want a bit-wise or here?



Comment at: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp:113
+II = T->getDecl()->getIdentifier();
+  }
+

This will leave `II` as uninitialized if your `if/else if` is not exhaustive. 
Are you sure that it is?



Comment at: test/Analysis/nonnil-string-constants.mm:41
+// For char* we do not require a pointer itself to be immutable.
+extern const char *CharStarConst;
+void charStarCheckGlobal() {

What is the rationale for treating `const char *v` as non null?

In this scenario `v` can be reassigned, right?



Comment at: test/Analysis/nonnil-string-constants.mm:45
+}
+
+// But the pointed data should be.

I'd also like to see a test for treating `char * const v;` as non null.



Comment at: test/Analysis/nonnil-string-constants.mm:55
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}

```
typedef const char *str;
extern str globalStr;
```
allows the `globalStr` variable to be written to. 

Did you mean:
```
typedef char * const str;
extern str globalStr;
```




https://reviews.llvm.org/D38764



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


[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315392: Include getting generated struct offsets in 
CodegenABITypes (authored by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D38473?vs=117806=118505#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38473

Files:
  cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
  cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
  cfe/trunk/unittests/CodeGen/CMakeLists.txt
  cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp

Index: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
===
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
@@ -72,12 +72,19 @@
   FunctionType::ExtInfo info,
   RequiredArgs args);
 
-// Returns null if the function type is incomplete and can't be lowered.
+/// Returns null if the function type is incomplete and can't be lowered.
 llvm::FunctionType *convertFreeFunctionType(CodeGenModule ,
 const FunctionDecl *FD);
 
 llvm::Type *convertTypeForMemory(CodeGenModule , QualType T);
 
+/// Given a non-bitfield struct field, return its index within the elements of
+/// the struct's converted type.  The returned index refers to a field number in
+/// the complete object type which is returned by convertTypeForMemory.  FD must
+/// be a field in RD directly (i.e. not an inherited field).
+unsigned getLLVMFieldNumber(CodeGenModule ,
+const RecordDecl *RD, const FieldDecl *FD);
+
 }  // end namespace CodeGen
 }  // end namespace clang
 
Index: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
@@ -17,6 +17,7 @@
 //===--===//
 
 #include "clang/CodeGen/CodeGenABITypes.h"
+#include "CGRecordLayout.h"
 #include "CodeGenModule.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
@@ -80,3 +81,9 @@
 CodeGen::convertTypeForMemory(CodeGenModule , QualType T) {
   return CGM.getTypes().ConvertTypeForMem(T);
 }
+
+unsigned CodeGen::getLLVMFieldNumber(CodeGenModule ,
+ const RecordDecl *RD,
+ const FieldDecl *FD) {
+  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
+}
Index: cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
===
--- cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
+++ cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
@@ -0,0 +1,302 @@
+//===- unittests/CodeGen/CodeGenExternalTest.cpp - test external CodeGen -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/GlobalDecl.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+// Mocks up a language using Clang code generation as a library and
+// tests some basic functionality there.
+//   - CodeGen->GetAddrOfGlobal
+//   - CodeGen::convertTypeForMemory
+//   - CodeGen::getLLVMFieldNumber
+
+static const bool DebugThisTest = false;
+
+// forward declarations
+struct MyASTConsumer;
+static void test_codegen_fns(MyASTConsumer *my);
+static bool test_codegen_fns_ran;
+
+// This forwards the calls to the Clang CodeGenerator
+// so that we can test CodeGen functions while it is open.
+// It accumulates toplevel decls in HandleTopLevelDecl and
+// calls test_codegen_fns() in HandleTranslationUnit
+// before forwarding that function to the CodeGenerator.
+
+struct MyASTConsumer : public ASTConsumer {
+  std::unique_ptr Builder;
+  std::vector toplevel_decls;
+
+  MyASTConsumer(std::unique_ptr Builder_in)
+: ASTConsumer(), Builder(std::move(Builder_in))
+  {
+  }
+
+  ~MyASTConsumer() { }
+
+  void Initialize(ASTContext ) override;
+  void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) 

r315392 - Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Oct 10 16:54:21 2017
New Revision: 315392

URL: http://llvm.org/viewvc/llvm-project?rev=315392=rev
Log:
Include getting generated struct offsets in CodegenABITypes

This change adds a new function, CodeGen::getFieldNumber, that
enables a user of clang's code generation to get the field number
in a generated LLVM IR struct that corresponds to a particular field
in a C struct.

It is important to expose this information in Clang's code generation
interface because there is no reasonable way for users of Clang's code
generation to get this information. In particular:

LLVM struct types do not include field names.
Clang adds a non-trivial amount of logic to the code generation of LLVM IR 
types for structs, in particular to handle padding and bit fields.

Patch by Michael Ferguson!

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

Added:
cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=315392=315391=315392=diff
==
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Tue Oct 10 16:54:21 2017
@@ -72,12 +72,19 @@ const CGFunctionInfo 
   FunctionType::ExtInfo info,
   RequiredArgs args);
 
-// Returns null if the function type is incomplete and can't be lowered.
+/// Returns null if the function type is incomplete and can't be lowered.
 llvm::FunctionType *convertFreeFunctionType(CodeGenModule ,
 const FunctionDecl *FD);
 
 llvm::Type *convertTypeForMemory(CodeGenModule , QualType T);
 
+/// Given a non-bitfield struct field, return its index within the elements of
+/// the struct's converted type.  The returned index refers to a field number 
in
+/// the complete object type which is returned by convertTypeForMemory.  FD 
must
+/// be a field in RD directly (i.e. not an inherited field).
+unsigned getLLVMFieldNumber(CodeGenModule ,
+const RecordDecl *RD, const FieldDecl *FD);
+
 }  // end namespace CodeGen
 }  // end namespace clang
 

Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=315392=315391=315392=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Tue Oct 10 16:54:21 2017
@@ -17,6 +17,7 @@
 
//===--===//
 
 #include "clang/CodeGen/CodeGenABITypes.h"
+#include "CGRecordLayout.h"
 #include "CodeGenModule.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
@@ -80,3 +81,9 @@ llvm::Type *
 CodeGen::convertTypeForMemory(CodeGenModule , QualType T) {
   return CGM.getTypes().ConvertTypeForMem(T);
 }
+
+unsigned CodeGen::getLLVMFieldNumber(CodeGenModule ,
+ const RecordDecl *RD,
+ const FieldDecl *FD) {
+  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
+}

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=315392=315391=315392=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Tue Oct 10 16:54:21 2017
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
   IncrementalProcessingTest.cpp
+  CodeGenExternalTest.cpp
   )
 
 target_link_libraries(ClangCodeGenTests

Added: cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp?rev=315392=auto
==
--- cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp (added)
+++ cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp Tue Oct 10 16:54:21 2017
@@ -0,0 +1,302 @@
+//===- unittests/CodeGen/CodeGenExternalTest.cpp - test external CodeGen -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"

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

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

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

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

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

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

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

Thanks,

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


[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D38473



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


[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I can commit this for you if John is happy with it.


https://reviews.llvm.org/D38473



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D38599#893985, @danalbert wrote:

> In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:
>
> > That reminds me... this does need a testcase or two.
>
>
> Oh, also, any test I add is going to fail, since the case I'm trying to 
> account for here is not the default behavior.


That's what an `available_feature` + `// REQUIRES:` is for.


https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 118502.
danalbert edited the summary of this revision.
danalbert added a comment.

Added a (failing) test case. The test case will fail unless the default value 
of `_LIBCXX_DYNAMIC_FALLBACK` is changed.


https://reviews.llvm.org/D38599

Files:
  src/private_typeinfo.cpp
  test/dlopen_dynamic_cast.sh.cpp

Index: test/dlopen_dynamic_cast.sh.cpp
===
--- /dev/null
+++ test/dlopen_dynamic_cast.sh.cpp
@@ -0,0 +1,87 @@
+//=== dlopen_dynamic_cast.sh.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// type_infos are not coalesced across dlopen boundaries when RTLD_LOCAL is
+// used, as is common in plugin interfaces and JNI libraries. For dynamic_cast
+// to work across a dlopen boundary, we must use a string comparison of the type
+// names instead of a pointer comparison of the type_infos.
+// https://reviews.llvm.org/D38599
+
+// RUN: %cxx %flags %compile_flags -DBUILD_BASE -fPIC -c %s -o %T/base.o
+// RUN: %cxx %flags %link_flags -shared %T/base.o -o %T/libbase.so
+// RUN: %cxx %flags %compile_flags -DBUILD_TEST -fPIC -c %s -o %T/test.o
+// RUN: %cxx %flags %link_flags -shared %T/test.o -o %T/libtest.so -L%T -lbase
+// RUN: %cxx %flags %compile_flags -DBUILD_EXE -c %s -o %t.o
+// RUN: %cxx %flags %link_flags %t.o -o %t.exe -ldl
+// RUN: LD_LIBRARY_PATH=%T %t.exe
+
+class Base {
+public:
+  virtual ~Base(){};
+};
+
+class BaseImpl : public Base {
+public:
+  BaseImpl();
+};
+
+#ifdef BUILD_BASE
+BaseImpl::BaseImpl() {}
+#endif
+
+#ifdef BUILD_TEST
+extern "C" bool do_test() {
+  BaseImpl base_impl;
+  Base* base = _impl;
+  return dynamic_cast(base) != nullptr;
+}
+#endif
+
+#ifdef BUILD_EXE
+#include 
+#include 
+#include 
+
+typedef bool (*test_func)();
+
+void* load_library(const char* name) {
+  void* lib = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+  if (lib == nullptr) {
+fprintf(stderr, "dlopen %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return lib;
+}
+
+test_func load_func(void* lib, const char* name) {
+  test_func sym = reinterpret_cast(dlsym(lib, name));
+  if (sym == nullptr) {
+fprintf(stderr, "dlsym %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return sym;
+}
+
+int main(int argc, char**) {
+  // Explicitly loading libbase.so before libtest.so causes the test to fail
+  // because the type_infos do not get coalesced.
+  load_library("libbase.so");
+
+  void* libtest = load_library("libtest.so");
+  test_func do_test = load_func(libtest, "do_test");
+
+  if (!do_test()) {
+fprintf(stderr, "do_test() failed!\n");
+return EXIT_FAILURE;
+  } else {
+fprintf(stderr, "do_test() passed!\n");
+return EXIT_SUCCESS;
+  }
+}
+#endif
Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -10,39 +10,19 @@
 #include "private_typeinfo.h"
 
 // The flag _LIBCXX_DYNAMIC_FALLBACK is used to make dynamic_cast more
-// forgiving when type_info's mistakenly have hidden visibility and thus
-// multiple type_infos can exist for a single type.
-// 
+// forgiving when multiple type_infos exist for a single type. This happens if
+// the libraries are mistakenly built with the type_infos having hidden
+// visibility, but also occurs when the libraries are loaded with dlopen.
+//
 // When _LIBCXX_DYNAMIC_FALLBACK is defined, and only in the case where
 // there is a detected inconsistency in the type_info hierarchy during a
 // dynamic_cast, then the equality operation will fall back to using strcmp
 // on type_info names to determine type_info equality.
-// 
-// This change happens *only* under dynamic_cast, and only when
-// dynamic_cast is faced with the choice:  abort, or possibly give back the
-// wrong answer.  If when the dynamic_cast is done with this fallback
-// algorithm and an inconsistency is still detected, dynamic_cast will call
-// abort with an appropriate message.
-// 
-// The current implementation of _LIBCXX_DYNAMIC_FALLBACK requires a
-// printf-like function called syslog:
-// 
-// void syslog(int facility_priority, const char* format, ...);
-// 
-// If you want this functionality but your platform doesn't have syslog,
-// just implement it in terms of fprintf(stderr, ...).
-// 
+//
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
-
 #include 
 
-
-#ifdef _LIBCXX_DYNAMIC_FALLBACK
-#include "abort_message.h"
-#include 
-#endif
-
 // On Windows, typeids are different between DLLs and EXEs, so comparing
 // type_info* will work for typeids from the same compiled file but fail
 // for typeids from a DLL and an executable. Among other things, 

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:

> That reminds me... this does need a testcase or two.


Oh, also, any test I add is going to fail, since the case I'm trying to account 
for here is not the default behavior.

I could make the more invasive change and actually make libc++abi use the 
fallback by default like libsupc++ does, but I was willing to settle for just 
not spamming the user with warnings that they can't do anything about.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38717: Patch to Bugzilla 31373

2017-10-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please make sure the title (subject line) for a patch reflects the actual 
contents of the change, as opposed to referring to Bugzilla; a lot of people 
skim cfe-commits, so you want to make sure interested reviewers find you patch.

Needs a regression test to verify we generate the warning in cases we should, 
and don't generate the warning in cases where we shouldn't (probably want a few 
tests with variables whose type is a class with a non-trivial destructor, or a 
reference to a temporary with a non-trivial destructor; removing the variable 
could change the behavior in those cases).  There are plenty of examples to 
follow in "test/SemaCXX/" in the source.

I don't really like messing with the value of the "Used" bit; isUsed() is 
supposed to reflect whether a variable is odr-used, and getting it wrong can 
have weird implications for the way we type-check and emit code.  (Most of 
those implications don't really apply to local variables, but it's still 
confusing.)  isReferenced() is our "is this declaration doing anything useful" 
bit.  Can we somehow change the way we set and use the "Referenced" bit to come 
up with the right result here?


https://reviews.llvm.org/D38717



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


r315381 - [Modules TS] Diagnose attempts to enter module implementation units without the module interface being available.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 15:35:27 2017
New Revision: 315381

URL: http://llvm.org/viewvc/llvm-project?rev=315381=rev
Log:
[Modules TS] Diagnose attempts to enter module implementation units without the 
module interface being available.

Added:
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315381=315380=315381=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 10 15:35:27 
2017
@@ -8994,6 +8994,9 @@ def err_module_redefinition : Error<
   "redefinition of module '%0'">;
 def note_prev_module_definition : Note<"previously defined here">;
 def note_prev_module_definition_from_ast_file : Note<"module loaded from 
'%0'">;
+def err_module_not_defined : Error<
+  "definition of module '%0' is not available; use -fmodule-file= to specify "
+  "path to precompiled module interface">;
 def err_module_private_specialization : Error<
   "%select{template|partial|member}0 specialization cannot be "
   "declared __module_private__">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315381=315380=315381=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 10 15:35:27 2017
@@ -1533,7 +1533,8 @@ private:
TypeDiagnoser *Diagnoser);
 
   struct ModuleScope {
-clang::Module *Module;
+clang::Module *Module = nullptr;
+bool ModuleInterface = false;
 VisibleModuleSet OuterVisibleModules;
   };
   /// The modules we're currently parsing.
@@ -2051,9 +2052,9 @@ public:
   SourceLocation SemiLoc);
 
   enum class ModuleDeclKind {
-Module, ///< 'module X;'
+Interface,  ///< 'export module X;'
+Implementation, ///< 'module X;'
 Partition,  ///< 'module partition X;'
-Implementation, ///< 'module implementation X;'
   };
 
   /// The parser has processed a module-declaration that begins the definition

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=315381=315380=315381=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue Oct 10 15:35:27 2017
@@ -2048,7 +2048,7 @@ Parser::DeclGroupPtrTy Parser::ParseModu
   SourceLocation StartLoc = Tok.getLocation();
 
   Sema::ModuleDeclKind MDK = TryConsumeToken(tok::kw_export)
- ? Sema::ModuleDeclKind::Module
+ ? Sema::ModuleDeclKind::Interface
  : Sema::ModuleDeclKind::Implementation;
 
   assert(Tok.is(tok::kw_module) && "not a module declaration");
@@ -2057,7 +2057,7 @@ Parser::DeclGroupPtrTy Parser::ParseModu
   if (Tok.is(tok::identifier) && NextToken().is(tok::identifier) &&
   Tok.getIdentifierInfo()->isStr("partition")) {
 // If 'partition' is present, this must be a module interface unit.
-if (MDK != Sema::ModuleDeclKind::Module)
+if (MDK != Sema::ModuleDeclKind::Interface)
   Diag(Tok.getLocation(), diag::err_module_implementation_partition)
 << FixItHint::CreateInsertion(ModuleLoc, "export ");
 MDK = Sema::ModuleDeclKind::Partition;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315381=315380=315381=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 10 15:35:27 2017
@@ -16168,6 +16168,7 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
 // implementation unit. That indicates the 'export' is missing.
 Diag(ModuleLoc, diag::err_module_interface_implementation_mismatch)
   << FixItHint::CreateInsertion(ModuleLoc, "export ");
+MDK = ModuleDeclKind::Interface;
 break;
 
   case LangOptions::CMK_ModuleMap:
@@ -16207,7 +16208,7 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe
   assert(ModuleScopes.size() == 1 && "expected to be at global module scope");
 
   switch (MDK) {
-  case ModuleDeclKind::Module: {
+  case 

r315379 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 15:33:17 2017
New Revision: 315379

URL: http://llvm.org/viewvc/llvm-project?rev=315379=rev
Log:
[Modules TS] Module ownership semantics for redeclarations.

When declaring an entity in the "purview" of a module, it's never a
redeclaration of an entity in the purview of a default module or in no module
("in the global module"). Don't consider those other declarations as possible
redeclaration targets if they're not visible, and reject any cases where we
pick a prior visible declaration that violates this rule.

This reinstates r315251 and r315256, reverted in r315309 and r315308
respectively, tweaked to avoid triggering a linkage calculation when declaring
implicit special members (this exposed our pre-existing issue with typedef
names for linkage changing the linkage of types whose linkage has already been
computed and cached in more cases). A testcase for that regression has been
added in r315366.

Added:
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
  - copied unchanged from r315308, 
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
  - copied unchanged from r315308, 
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
  - copied unchanged from r315308, 
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
cfe/trunk/test/Modules/anon-linkage.cpp
  - copied unchanged from r315307, cfe/trunk/test/Modules/anon-linkage.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315379=315378=315379=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 10 15:33:17 2017
@@ -339,6 +339,12 @@ public:
 return clang::isExternallyVisible(getLinkageInternal());
   }
 
+  /// Determine whether this declaration can be redeclared in a
+  /// different translation unit.
+  bool isExternallyDeclarable() const {
+return isExternallyVisible() && !getOwningModuleForLinkage();
+  }
+
   /// \brief Determines the visibility of this entity.
   Visibility getVisibility() const {
 return getLinkageAndVisibility().getVisibility();
@@ -379,10 +385,6 @@ public:
 return hasCachedLinkage();
   }
 
-  /// Get the module that owns this declaration for linkage purposes.
-  /// There only ever is such a module under the C++ Modules TS.
-  Module *getOwningModuleForLinkage() const;
-
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// the underlying named decl.
   NamedDecl *getUnderlyingDecl() {

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315379=315378=315379=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Oct 10 15:33:17 2017
@@ -738,6 +738,13 @@ public:
 return isFromASTFile() ? getImportedOwningModule() : 
getLocalOwningModule();
   }
 
+  /// Get the module that owns this declaration for linkage purposes.
+  /// There only ever is such a module under the C++ Modules TS.
+  ///
+  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
+  /// all declarations in a global module fragment are unowned.
+  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
+
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns
   /// \c false, if the owning module is visible within the query context.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315379=315378=315379=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ 

[PATCH] D38770: AMDGPU: Use stricter bounds for workitem builtins

2017-10-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng.

https://reviews.llvm.org/D38770

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/CodeGenOpenCL/builtins-r600.cl

Index: test/CodeGenOpenCL/builtins-r600.cl
===
--- test/CodeGenOpenCL/builtins-r600.cl
+++ test/CodeGenOpenCL/builtins-r600.cl
@@ -52,4 +52,4 @@
 	}
 }
 
-// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}
+// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 256}
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -507,7 +507,7 @@
   *out = __builtin_amdgcn_s_getpc();
 }
 
-// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}
+// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 256}
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9115,22 +9115,28 @@
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
-return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(0));
   case AMDGPU::BI__builtin_amdgcn_workitem_id_y:
-return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_y, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_y, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(1));
   case AMDGPU::BI__builtin_amdgcn_workitem_id_z:
-return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_z, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_z, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(2));
 
   // r600 intrinsics
   case AMDGPU::BI__builtin_r600_recipsqrt_ieee:
   case AMDGPU::BI__builtin_r600_recipsqrt_ieeef:
 return emitUnaryBuiltin(*this, E, Intrinsic::r600_recipsqrt_ieee);
   case AMDGPU::BI__builtin_r600_read_tidig_x:
-return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_x, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_x, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(0));
   case AMDGPU::BI__builtin_r600_read_tidig_y:
-return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_y, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_y, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(1));
   case AMDGPU::BI__builtin_r600_read_tidig_z:
-return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_z, 0, 1024);
+return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_z, 0,
+  getContext().getTargetInfo().getOpenCLMaxWorkGroupSize(2));
   default:
 return nullptr;
   }
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -70,6 +70,10 @@
   bool hasLDEXPF : 1;
   const AddrSpace AS;
 
+  // The hardware limit is really 1024 or 2048, but the runtime currently only
+  // supports 256.
+  unsigned MaxWorkGroupSize = 1024;
+
   static bool hasFullSpeedFMAF32(StringRef GPUName) {
 return parseAMDGCNName(GPUName) >= GK_GFX9;
   }
@@ -279,6 +283,10 @@
 }
   }
 
+  unsigned getOpenCLMaxWorkGroupSize(unsigned Dim) const override {
+return MaxWorkGroupSize;
+  }
+
   llvm::Optional getConstantAddressSpace() const override {
 return LangAS::FirstTargetAddressSpace + AS.Constant;
   }
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -340,6 +340,10 @@
 void AMDGPUTargetInfo::adjust(LangOptions ) {
   TargetInfo::adjust(Opts);
   setAddressSpaceMap(Opts.OpenCL || !isAMDGCN(getTriple()));
+
+  // TODO: Add option to force hardware maximum.
+  if (Opts.OpenCL)
+MaxWorkGroupSize = 256;
 }
 
 ArrayRef AMDGPUTargetInfo::getTargetBuiltins() const {
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -1060,6 +1060,11 @@
   /// \brief Get address space for OpenCL type.
   virtual LangAS::ID getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// \returns Maximum device supported OpenCL workgroup size.
+  virtual unsigned getOpenCLMaxWorkGroupSize(unsigned Dim) const {
+return 0;
+  }
+
   /// \returns Target specific vtbl ptr address space.
   

[clang-tools-extra] r315378 - Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows.

2017-10-10 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue Oct 10 15:19:46 2017
New Revision: 315378

URL: http://llvm.org/viewvc/llvm-project?rev=315378=rev
Log:
Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile 
results on Windows.

This allows clients to avoid an unnecessary fs::status() call on each
directory entry. Because the information returned by FindFirstFileEx
is a subset of the information returned by a regular status() call,
I needed to extract a base class from file_status that contains only
that information.

On my machine, this reduces the time required to enumerate a ThinLTO
cache directory containing 520k files from almost 4 minutes to less
than 2 seconds.

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

Modified:
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp

Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=315378=315377=315378=diff
==
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Tue Oct 10 15:19:46 
2017
@@ -242,14 +242,15 @@ bool CoverageChecker::collectUmbrellaHea
 Directory = ".";
   // Walk the directory.
   std::error_code EC;
-  sys::fs::file_status Status;
   for (sys::fs::directory_iterator I(Directory.str(), EC), E; I != E;
 I.increment(EC)) {
 if (EC)
   return false;
 std::string File(I->path());
-I->status(Status);
-sys::fs::file_type Type = Status.type();
+llvm::ErrorOr Status = I->status();
+if (!Status)
+  return false;
+sys::fs::file_type Type = Status->type();
 // If the file is a directory, ignore the name and recurse.
 if (Type == sys::fs::file_type::directory_file) {
   if (!collectUmbrellaHeaders(File))
@@ -363,7 +364,6 @@ bool CoverageChecker::collectFileSystemH
 
   // Recursively walk the directory tree.
   std::error_code EC;
-  sys::fs::file_status Status;
   int Count = 0;
   for (sys::fs::recursive_directory_iterator I(Directory.str(), EC), E; I != E;
 I.increment(EC)) {
@@ -371,8 +371,10 @@ bool CoverageChecker::collectFileSystemH
   return false;
 //std::string file(I->path());
 StringRef file(I->path());
-I->status(Status);
-sys::fs::file_type type = Status.type();
+llvm::ErrorOr Status = I->status();
+if (!Status)
+  return false;
+sys::fs::file_type type = Status->type();
 // If the file is a directory, ignore the name (but still recurses).
 if (type == sys::fs::file_type::directory_file)
   continue;

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=315378=315377=315378=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Tue Oct 10 
15:19:46 2017
@@ -399,14 +399,15 @@ bool ModularizeUtilities::collectUmbrell
   SmallString<256> Directory(UmbrellaDirName);
   // Walk the directory.
   std::error_code EC;
-  llvm::sys::fs::file_status Status;
   for (llvm::sys::fs::directory_iterator I(Directory.str(), EC), E; I != E;
 I.increment(EC)) {
 if (EC)
   return false;
 std::string File(I->path());
-I->status(Status);
-llvm::sys::fs::file_type Type = Status.type();
+llvm::ErrorOr Status = I->status();
+if (!Status)
+  return false;
+llvm::sys::fs::file_type Type = Status->type();
 // If the file is a directory, ignore the name and recurse.
 if (Type == llvm::sys::fs::file_type::directory_file) {
   if (!collectUmbrellaHeaders(File, Dependents))


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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:

> That reminds me... this does need a testcase or two.


Didn't realize I could do multi binary test cases with this test runner. It'll 
be a little messy, but I'll try adding one.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


r315378 - Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile results on Windows.

2017-10-10 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue Oct 10 15:19:46 2017
New Revision: 315378

URL: http://llvm.org/viewvc/llvm-project?rev=315378=rev
Log:
Support: Have directory_iterator::status() return FindFirstFileEx/FindNextFile 
results on Windows.

This allows clients to avoid an unnecessary fs::status() call on each
directory entry. Because the information returned by FindFirstFileEx
is a subset of the information returned by a regular status() call,
I needed to extract a base class from file_status that contains only
that information.

On my machine, this reduces the time required to enumerate a ThinLTO
cache directory containing 520k files from almost 4 minutes to less
than 2 seconds.

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

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=315378=315377=315378=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Tue Oct 10 15:19:46 2017
@@ -244,7 +244,7 @@ public:
   RealFSDirIter(const Twine , std::error_code ) : Iter(Path, EC) {
 if (!EC && Iter != llvm::sys::fs::directory_iterator()) {
   llvm::sys::fs::file_status S;
-  EC = Iter->status(S);
+  EC = llvm::sys::fs::status(Iter->path(), S, true);
   CurrentEntry = Status::copyWithNewName(S, Iter->path());
 }
   }
@@ -258,7 +258,7 @@ public:
   CurrentEntry = Status();
 } else {
   llvm::sys::fs::file_status S;
-  EC = Iter->status(S);
+  EC = llvm::sys::fs::status(Iter->path(), S, true);
   CurrentEntry = Status::copyWithNewName(S, Iter->path());
 }
 return EC;


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


[PATCH] D26350: Keep invalid Switch in the AST

2017-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:1297
 
-  if (Switch.isInvalid()) {
-// Skip the switch body.
-// FIXME: This is not optimal recovery, but parsing the body is more
-// dangerous due to the presence of case and default statements, which
-// will have no place to connect back with the switch.
-if (Tok.is(tok::l_brace)) {
-  ConsumeBrace();
-  SkipUntil(tok::r_brace);
-} else
-  SkipUntil(tok::semi);
-return Switch;
-  }
+  assert(!Switch.isInvalid() && "ActOnStartOfSwitchStmt always succeed");
 

ogoffart wrote:
> aaron.ballman wrote:
> > succeed -> succeeds
> > 
> > Are the concerns pointed out in the FIXME addressed by code not in this 
> > patch?
> The FIXME is pointing out problems occuring if the parser found 'default' or 
> 'case' statement, but cannot connect it to the corresponding 'switch' 
> statement (because that switch statement did not exist as it was removed from 
> the AST). 
> 
> Now that we always keep the 'switch' statement, this is no longer a problem.
I'm uncomfortable about this; this change couples Parser to the implementation 
details of Sema. How about this: remove this assert and change 
`ActOnFinishSwitchStmt` to take a `StmtResult` instead (which might be 
invalid). Then you can tell from within `ActOnFinishSwitchStmt` whether to 
check the case statements against the condition based on whether the switch is 
in fact invalid.

(Alternatively: change `ActOnStartSwitchStmt` to return `void` and make 
`ActOnFinishSwitchStmt` pick up the switch statement from the `SwitchStack`.)



Comment at: lib/Sema/SemaStmt.cpp:672
+MakeFullExpr(new (Context) OpaqueValueExpr(SourceLocation(),
+   Context.IntTy, VK_RValue),
+ SwitchLoc),

Won't this result in warnings or errors later on if we have `case` labels with 
expressions of other types? (Eg, narrowing warnings/errors)

Please instead (somehow) track that the switch condition is invalid and skip 
those checks -- perhaps either by returning an invalid-but-not-null statement 
here and passing that back into `ActOnFinishSwitchStmt`, or by tracking an 
"invalid" flag on the `SwitchStack` entry.



Comment at: lib/Sema/SemaStmt.cpp:1173-1177
-  // FIXME: If the case list was broken is some way, we don't have a good 
system
-  // to patch it up.  Instead, just return the whole substmt as broken.
-  if (CaseListIsErroneous)
-return StmtError();
-

Hmm. Removing this will result in us producing invalid ASTs in some cases (with 
duplicate `case` or `default` labels). That's a condition that it would be 
reasonable for AST consumers to assert on currently, so this is concerning.

That said... it's inevitable that this work to keep more invalid constructs in 
the AST will result in such changes. Perhaps what we need is just a marker to 
say "beyond this point the AST does not necessarily correspond to any valid 
source code" for `Stmt` nodes, analogous to the `Invalid` marker on 
declarations. (Maybe a wrapper `InvalidStmt` node, so that tree traversals can 
easily avoid walking through it.)

Let's try this change out as-is. It may be that this concern is baseless.


https://reviews.llvm.org/D26350



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118493.

https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
  test/Analysis/nonnil-string-constants.mm

Index: test/Analysis/nonnil-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnil-string-constants.mm
@@ -0,0 +1,80 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals.
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// Const char* is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// For char* we do not require a pointer itself to be immutable.
+extern const char *CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointed data should be.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef const char *str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
@@ -0,0 +1,121 @@
+
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnilStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII = nullptr;
+  mutable IdentifierInfo *CFStringRefII = nullptr;
+
+public:
+  NonnilStringConstantsChecker(AnalyzerOptions ) {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext ) const;
+
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext ) const;
+  bool typeIsConstString(QualType type, bool isConstQualified) const;
+  bool isGlobalConstString(SVal val) const;
+};
+
+} // namespace
+
+void NonnilStringConstantsChecker::initIdentifierInfo(ASTContext ) const {
+  if (NSStringII)
+return;
+
+  NSStringII = ("NSString");
+  CFStringRefII = ("CFStringRef");
+}
+
+void NonnilStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext ) const {
+  initIdentifierInfo(C.getASTContext());
+  if (!isLoad)
+return;
+
+  ProgramStateRef State = C.getState();
+  SVal V = UnknownVal();
+  if (location.isValid()) {
+V = State->getSVal(location.castAs());
+  }
+
+  if (isGlobalConstString(location)) {
+Optional Constr = 

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

That reminds me... this does need a testcase or two.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

Some relevant code links:

- 
https://github.com/llvm-mirror/clang/blob/8c9bf999aa40ab6077b958b5edcf587b9d76ce24/lib/CodeGen/ItaniumCXXABI.cpp#L359
 ==> iOS64CXXABI overrides shouldRTTIBeUnique to return false.
- 
https://github.com/llvm-mirror/libcxx/blob/ca79c159d8bfbe190a6cbfce74eb2d050697d8b9/include/typeinfo#L176
 ==> libc++ type_info::operator== uses string comparison, but only if 
_LIBCPP_NONUNIQUE_RTTI_BIT has been OR'ed into the __type_name pointers of both 
type_info objects
- 
https://github.com/llvm-mirror/libcxx/blob/ca79c159d8bfbe190a6cbfce74eb2d050697d8b9/include/__config#L879
 ==> use the highest bit for ARM64 iOS


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

2017-10-10 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun, mgorny.

https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
  test/Analysis/nonnil-string-constants.mm

Index: test/Analysis/nonnil-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnil-string-constants.mm
@@ -0,0 +1,80 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals.
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// Const char* is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// For char* we do not require a pointer itself to be immutable.
+extern const char *CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointed data should be.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef const char *str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
@@ -0,0 +1,120 @@
+
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnilStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII;
+  mutable IdentifierInfo *CFStringRefII;
+
+public:
+  NonnilStringConstantsChecker(AnalyzerOptions ) {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext ) const;
+
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext ) const;
+  bool typeIsConstString(QualType type, bool isConstQualified) const;
+  bool isGlobalConstString(SVal val) const;
+};
+
+} // namespace
+
+void NonnilStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext ) const {
+  initIdentifierInfo(C.getASTContext());
+  if (!isLoad)
+return;
+
+  ProgramStateRef State = C.getState();
+  SVal V = UnknownVal();
+  if (location.isValid()) {
+V = State->getSVal(location.castAs());
+  }
+
+  if (isGlobalConstString(location)) {
+Optional Constr = V.getAs();
+
+if (Constr) {
+
+  // Assume that the variable is non-null.
+  ProgramStateRef OutputState = State->assume(*Constr, true);
+  

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

Here's the Clang bug I filed: https://bugs.llvm.org/show_bug.cgi?id=34907


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

I assume std::type_info::operator== also needs to be adjusted to compare string 
names? It looks like libc++'s version of the function does string comparisons 
for ARM64 iOS, but only on some classes (e.g. public(?) ones). Look for the 
_LIBCPP_HAS_NONUNIQUE_TYPEINFO and _LIBCPP_NONUNIQUE_RTTI_BIT flags. I wonder 
if ARM64 iOS also sets _LIBCXX_DYNAMIC_FALLBACK for libc++abi.

I noticed that Clang on GNU/Linux is treating two classes defined in separate 
anonymous namespaces as equal for std::type_info::operator== and dynamic_cast, 
which I *think* is a Clang bug. G++ marks the typeinfo names with an asterisk 
to disable the string comparisons. I'd expect that enabling 
_LIBCXX_DYNAMIC_FALLBACK would introduce the same bug into the Android 
toolchain.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-10 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 118482.
Nebiroth added a comment.

Rebased on master.


https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -5,18 +5,21 @@
 Content-Length: 143
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -5,16 +5,17 @@
 Content-Length: 142
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":"","rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+# CHECK: Content-Length: 580
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
+# CHECK:   "codeActionProvider": true,
+# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
+# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
+# CHECK: }}}
+#
+
+Content-Length: 455
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "kind": 1},{"range": {"start": {"line": 17, "character": 0}, "end": {"line": 17, "character": 7}}, "kind": 1}]}
+
+Content-Length: 157
+

[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

@rjmccall Do you have any more comments?


https://reviews.llvm.org/D38473



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


[PATCH] D36955: [libclang] Visit attributes for function and class templates

2017-10-10 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

LGTM

Would you like me to commit this for you?


https://reviews.llvm.org/D36955



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


[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-10-10 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

LGTM

Would you like me to commit this for you?


https://reviews.llvm.org/D36973



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


[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315367: Fix indexer crash for default template template 
parameter value (authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38755?vs=118451=118476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38755

Files:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/test/Index/index-template-template-param.cpp


Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
Index: cfe/trunk/test/Index/index-template-template-param.cpp
===
--- cfe/trunk/test/Index/index-template-template-param.cpp
+++ cfe/trunk/test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |


Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
Index: cfe/trunk/test/Index/index-template-template-param.cpp
===
--- cfe/trunk/test/Index/index-template-template-param.cpp
+++ cfe/trunk/test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315367 - Fix indexer crash for default template template parameter value

2017-10-10 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct 10 14:09:49 2017
New Revision: 315367

URL: http://llvm.org/viewvc/llvm-project?rev=315367=rev
Log:
Fix indexer crash for default template template parameter value

rdar://33058798

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

Added:
cfe/trunk/test/Index/index-template-template-param.cpp
Modified:
cfe/trunk/lib/Index/IndexDecl.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=315367=315366=315367=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Oct 10 14:09:49 2017
@@ -666,7 +666,6 @@ public:
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@ public:
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }

Added: cfe/trunk/test/Index/index-template-template-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-template-template-param.cpp?rev=315367=auto
==
--- cfe/trunk/test/Index/index-template-template-param.cpp (added)
+++ cfe/trunk/test/Index/index-template-template-param.cpp Tue Oct 10 14:09:49 
2017
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |


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


r315366 - Add test for regression caused by reverted patch r315251.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 14:07:44 2017
New Revision: 315366

URL: http://llvm.org/viewvc/llvm-project?rev=315366=rev
Log:
Add test for regression caused by reverted patch r315251.

Modified:
cfe/trunk/test/SemaCXX/linkage2.cpp

Modified: cfe/trunk/test/SemaCXX/linkage2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage2.cpp?rev=315366=315365=315366=diff
==
--- cfe/trunk/test/SemaCXX/linkage2.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage2.cpp Tue Oct 10 14:07:44 2017
@@ -218,3 +218,34 @@ namespace PR18964 {
   unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference 
of type}}
   extern struct {} *foo; // don't assert
 }
+
+namespace typedef_name_for_linkage {
+  template struct Use {};
+
+  struct A { A(); A(const A&); ~A(); };
+
+  typedef struct {
+A a;
+  } B;
+
+  struct C {
+typedef struct {
+  A a;
+} D;
+  };
+
+  typedef struct {
+void f() { static int n; struct Inner {};}
+  } E;
+
+  // FIXME: Ideally this would be accepted in all modes. In C++98, we trigger a
+  // linkage calculation to drive the "internal linkage type as template
+  // argument" warning.
+  typedef struct {
+void f() { struct Inner {}; Use ui; }
+  } F;
+#if __cplusplus < 201103L
+  // expected-error@-2 {{unsupported: typedef changes linkage of anonymous 
type, but linkage was already computed}}
+  // expected-note@-5 {{use a tag name here}}
+#endif
+}


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


r315358 - [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via cfe-commits
Author: carrot
Date: Tue Oct 10 13:31:27 2017
New Revision: 315358

URL: http://llvm.org/viewvc/llvm-project?rev=315358=rev
Log:
[CGExprScalar] In EmitCompare trunc the result if it has different type as 
E->getType()

Usually compare expression should return i1 type, so EmitScalarConversion is 
called before return

return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), 
E->getExprLoc());

But when ppc intrinsic is called to compare vectors, the ppc intrinsic can 
return i32 even E->getType() is BoolTy, in this case EmitScalarConversion does 
nothing, an i32 type result is returned and causes crash later.

This patch detects this case and truncates the result before return.

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


Added:
cfe/trunk/test/CodeGen/ppc-vector-compare.cc
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=315358=315357=315358=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Oct 10 13:31:27 2017
@@ -3214,6 +3214,16 @@ Value *ScalarExprEmitter::EmitCompare(co
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }

Added: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc-vector-compare.cc?rev=315358=auto
==
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc (added)
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc Tue Oct 10 13:31:27 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+


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


[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D38755



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


[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D38402



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


[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 118471.
arphaman marked 6 inline comments as done.
arphaman added a comment.

Address review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D38402

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

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Frontend/CommandLineSourceLoc.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
@@ -54,7 +55,7 @@
 
   /// Prints any additional state associated with the selection argument to
   /// the given output stream.
-  virtual void print(raw_ostream ) = 0;
+  virtual void print(raw_ostream ) {}
 
   /// Returns a replacement refactoring result consumer (if any) that should
   /// consume the results of a refactoring operation.
@@ -99,6 +100,41 @@
   TestSelectionRangesInFile TestSelections;
 };
 
+/// Stores the parsed -selection=filename:line:column[-line:column] option.
+class SourceRangeSelectionArgument final : public SourceSelectionArgument {
+public:
+  SourceRangeSelectionArgument(ParsedSourceRange Range)
+  : Range(std::move(Range)) {}
+
+  bool forAllRanges(const SourceManager ,
+llvm::function_ref Callback) override {
+const FileEntry *FE = SM.getFileManager().getFile(Range.FileName);
+FileID FID = FE ? SM.translateFile(FE) : FileID();
+if (!FE || FID.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName
+   << ":... : given file is not in the target TU\n";
+  return true;
+}
+
+SourceLocation Start = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.Begin.first, Range.Begin.second));
+SourceLocation End = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.End.first, Range.End.second));
+if (Start.isInvalid() || End.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName << ':'
+   << Range.Begin.first << ':' << Range.Begin.second << '-'
+   << Range.End.first << ':' << Range.End.second
+   << " : invalid source location\n";
+  return true;
+}
+Callback(SourceRange(Start, End));
+return false;
+  }
+
+private:
+  ParsedSourceRange Range;
+};
+
 std::unique_ptr
 SourceSelectionArgument::fromString(StringRef Value) {
   if (Value.startswith("test:")) {
@@ -110,10 +146,12 @@
 return llvm::make_unique(
 std::move(*ParsedTestSelection));
   }
-  // FIXME: Support true selection ranges.
+  Optional Range = ParsedSourceRange::fromString(Value);
+  if (Range)
+return llvm::make_unique(std::move(*Range));
   llvm::errs() << "error: '-selection' option must be specified using "
   ":: or "
-  "::-: format";
+  "::-: format\n";
   return nullptr;
 }
 
@@ -268,11 +306,18 @@
 
 class ClangRefactorConsumer : public RefactoringResultConsumer {
 public:
-  void handleError(llvm::Error Err) {
+  void handleError(llvm::Error Err) override {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
 
-  // FIXME: Consume atomic changes and apply them to files.
+  void handle(AtomicChanges Changes) override {
+SourceChanges.insert(SourceChanges.begin(), Changes.begin(), Changes.end());
+  }
+
+  const AtomicChanges () const { return SourceChanges; }
+
+private:
+  AtomicChanges SourceChanges;
 };
 
 class ClangRefactorTool {
@@ -352,6 +397,39 @@
 }
   }
 
+  bool applySourceChanges(const AtomicChanges ) {
+std::set Files;
+for (const auto  : Replacements)
+  Files.insert(Change.getFilePath());
+// FIXME: Add automatic formatting support as well.
+tooling::ApplyChangesSpec Spec;
+// FIXME: We should probably cleanup the result by default as well.
+Spec.Cleanup = false;
+for (const auto  : Files) {
+  llvm::ErrorOr BufferErr =
+  llvm::MemoryBuffer::getFile(File);
+  if (!BufferErr) {
+llvm::errs() << "error: failed to open " << File << " for rewriting\n";
+return true;
+  }
+  auto Result = tooling::applyAtomicChanges(File, (*BufferErr)->getBuffer(),
+Replacements, Spec);
+  if (!Result) {
+llvm::errs() << toString(Result.takeError());
+return true;
+  }
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text);
+  if (EC) {
+llvm::errs() << EC.message() << "\n";
+return true;
+  }
+  OS << 

[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315358: [CGExprScalar] In EmitCompare trunc the result if it 
has different type as E… (authored by Carrot).

Changed prior to commit:
  https://reviews.llvm.org/D38656?vs=118236=118464#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38656

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/ppc-vector-compare.cc


Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
===
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }


Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
===
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(),
   E->getExprLoc());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Thanks for the pointer to that patch, I'll take a look tomorrow.




Comment at: src/UnwindRegistersRestore.S:492
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersRestore.S:543
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersSave.S:90
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersSave.S:125
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64
+

Needs checking for soft-float.


https://reviews.llvm.org/D38110



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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/CodeCompletion/qualifiers-as-written.cpp:29
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar 
c#>, <#ns::baz d#>
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz 
c#>
+}

arphaman wrote:
> Sorry, I see the issue now. However, I don't think that we'd like to change 
> the signature for a function like this, as we'd still prefer to show `func 
> (foo::type, ns::bar, ns::baz);` on this line.
> 
> In Xcode we actually avoid the problem with `std::vector<>`s that you've 
> pointed out entirely by using `value_type`. I'll check what our solution does.
> 
> Btw, maybe using things like `value_type` is completely wrong (with or 
> without the qualifier)? If we have `std::vector` shouldn't we rather 
> show `push_back(int _Value)`, rather than the `value_type`? Perhaps this kind 
> of change should be discussed with a wider community somehow to find out 
> what's best for all users.
Using `int _Value` may be good in case of `vector`, but it would probably 
loose typedefs, i.e. `vector` would still have `int`, which may be 
undesirable.
Also, for `vector`, the type inside `push_back` would probably end 
up being `vector`. 


As for the current vs new behavior, I can totally see why you want to see more 
context in completion items. 

I would argue that the current code does not do a great job there, as it only 
adds qualifiers to unqualified references. But the context may be missing for 
qualified references as well.
For example, in the following code:
```
  template >
  struct vector {
typedef T value_type;

typename value_type::some_type foo();
value_type bar()
  };
```

Completion item for `vector::bar` will have return type `vector::value_type`. However, completion item for `vector::foo` will have return type `value_type::some_type` (note 
that no `vector` qualifier was added).

I would also question the intent of the current implementation. The following 
line suggest that adding those qualifers was not intended in the first place:
```
  Policy.SuppressUnwrittenScope = true;
```
But that's just a wild guess, I may be completely wrong.


That being said, I don't think there is one right preference, different people 
may prefer different options. We can surely discuss that in a wider community, 
though.

Would you be open to adding an option for that in completion and keeping the 
current behavior as a default?




https://reviews.llvm.org/D38538



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


[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.

fix + testcase


https://reviews.llvm.org/D38755

Files:
  lib/Index/IndexDecl.cpp
  test/Index/index-template-template-param.cpp


Index: test/Index/index-template-template-param.cpp
===
--- /dev/null
+++ test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }


Index: test/Index/index-template-template-param.cpp
===
--- /dev/null
+++ test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 118437.
bader added a comment.

Applied comments.


https://reviews.llvm.org/D33681

Files:
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/func.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/func.cl
===
--- test/SemaOpenCL/func.cl
+++ test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple 
spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -5989,7 +5989,8 @@
 else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);
 
-HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+|| getLangOpts().OpenCL;
 
 // If we have the closing ')', eat it.
 Tracker.consumeClose();


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/func.cl
===
--- test/SemaOpenCL/func.cl
+++ test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus

[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:144
+  if (auto *I = dyn_cast(V)) {
+// If the block literal is emitted as an instruction, it is an alloca
+// and the block invoke function is stored to GEP of this alloca.

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Why do we need to replace original block calls with the kernels? I think 
> > > in case of calling a block we could use the original block function and 
> > > only for enqueue use the kernel that would call the block function 
> > > inside. The pointer to the kernel wrapper could be passed as an 
> > > additional parameter to `enqueue_kernel` calls. We won't need to iterate 
> > > through all IR then.
> > `CGF.EmitScalarExpr(Block)` returns the block literal structure which 
> > contains the size/align/invoke_function/captures. The block invoke function 
> > is stored to the struct by a `StoreInst`. To create the wrapper kernel, we 
> > need to get the block invoke function, therefore we have to iterate through 
> > IR.
> > 
> > Since we need to find the store instruction any way, it is simpler to just 
> > replace the stored function with the kernel and pass the block literal 
> > struct, instead of passing the kernel separately.
> So we cann't get the invoke function from the block literal structure passed 
> into the kernel wrapper directly knowing its offset? Iterating through IR 
> adds extra time and also I am not sure how reliable this is wrt different 
> corner cases of IR.
Unfortunately the invoke function is not returned directly. Instead, it is 
buried in an LLVM value. And to extract the invoke function from the LLVM value 
we have to wade through a bunch of LLVM IRs.

There is one way to get the invoke function directly instead of going through 
IRs, but we need to change the functions for generating code for the blocks a 
little bit so that they return the block invoke function.


https://reviews.llvm.org/D38134



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


[libclc] r315342 - travis: Enable external function call checks on llvm-{4, 5}

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:24 2017
New Revision: 315342

URL: http://llvm.org/viewvc/llvm-project?rev=315342=rev
Log:
travis: Enable external function call checks on llvm-{4,5}

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=315342=315341=315342=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Tue Oct 10 11:10:24 2017
@@ -28,6 +28,7 @@ matrix:
 - LABEL="make gcc LLVM-4.0"
 - LLVM_VERSION=4.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
   addons:
 apt:
   sources:
@@ -42,6 +43,7 @@ matrix:
 - LABEL="make gcc LLVM-5.0"
 - LLVM_VERSION=5.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
   addons:
 apt:
   sources:


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


[libclc] r315341 - Make image builtins r600/llvm-3.9 only

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:21 2017
New Revision: 315341

URL: http://llvm.org/viewvc/llvm-project?rev=315341=rev
Log:
Make image builtins r600/llvm-3.9 only

The implementation uses r600 sepcific intrinsics
LLVM-4 switched to _ro_t and _rw_t image types
Portions of the code can be moved back as more targets/llvm versions add image 
support

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/r600/lib/SOURCES_3.9
  - copied, changed from r315235, libclc/trunk/amdgpu/lib/SOURCES
libclc/trunk/r600/lib/image/get_image_attributes_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
libclc/trunk/r600/lib/image/get_image_channel_data_type.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_channel_data_type.cl
libclc/trunk/r600/lib/image/get_image_channel_order.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_channel_order.cl
libclc/trunk/r600/lib/image/get_image_depth.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_depth.cl
libclc/trunk/r600/lib/image/get_image_dim.cl
  - copied, changed from r315235, 
libclc/trunk/generic/lib/image/get_image_dim.cl
libclc/trunk/r600/lib/image/get_image_height.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_height.cl
libclc/trunk/r600/lib/image/get_image_width.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_width.cl
libclc/trunk/r600/lib/image/read_image_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_image_impl.ll
libclc/trunk/r600/lib/image/read_imagef.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imagef.cl
libclc/trunk/r600/lib/image/read_imagei.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imagei.cl
libclc/trunk/r600/lib/image/read_imageui.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imageui.cl
libclc/trunk/r600/lib/image/write_image_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_image_impl.ll
libclc/trunk/r600/lib/image/write_imagef.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imagef.cl
libclc/trunk/r600/lib/image/write_imagei.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imagei.cl
libclc/trunk/r600/lib/image/write_imageui.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imageui.cl
Removed:
libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
libclc/trunk/amdgpu/lib/image/get_image_channel_data_type.cl
libclc/trunk/amdgpu/lib/image/get_image_channel_order.cl
libclc/trunk/amdgpu/lib/image/get_image_depth.cl
libclc/trunk/amdgpu/lib/image/get_image_height.cl
libclc/trunk/amdgpu/lib/image/get_image_width.cl
libclc/trunk/amdgpu/lib/image/read_image_impl.ll
libclc/trunk/amdgpu/lib/image/read_imagef.cl
libclc/trunk/amdgpu/lib/image/read_imagei.cl
libclc/trunk/amdgpu/lib/image/read_imageui.cl
libclc/trunk/amdgpu/lib/image/write_image_impl.ll
libclc/trunk/amdgpu/lib/image/write_imagef.cl
libclc/trunk/amdgpu/lib/image/write_imagei.cl
libclc/trunk/amdgpu/lib/image/write_imageui.cl
libclc/trunk/generic/lib/image/get_image_dim.cl
Modified:
libclc/trunk/amdgpu/lib/SOURCES
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/amdgpu/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES?rev=315341=315340=315341=diff
==
--- libclc/trunk/amdgpu/lib/SOURCES (original)
+++ libclc/trunk/amdgpu/lib/SOURCES Tue Oct 10 11:10:21 2017
@@ -1,16 +1,2 @@
 math/nextafter.cl
 math/sqrt.cl
-image/get_image_width.cl
-image/get_image_height.cl
-image/get_image_depth.cl
-image/get_image_channel_data_type.cl
-image/get_image_channel_order.cl
-image/get_image_attributes_impl.ll
-image/read_imagef.cl
-image/read_imagei.cl
-image/read_imageui.cl
-image/read_image_impl.ll
-image/write_imagef.cl
-image/write_imagei.cl
-image/write_imageui.cl
-image/write_image_impl.ll

Removed: libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll?rev=315340=auto
==
--- libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll (original)
+++ libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll (removed)
@@ -1,87 +0,0 @@
-%opencl.image2d_t = type opaque
-%opencl.image3d_t = type opaque
-
-declare i32 @llvm.OpenCL.image.get.resource.id.2d(
-  %opencl.image2d_t addrspace(1)*) nounwind readnone
-declare i32 @llvm.OpenCL.image.get.resource.id.3d(
-  %opencl.image3d_t 

[libclc] r315343 - travis: enable checks of nvptx libraries

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:25 2017
New Revision: 315343

URL: http://llvm.org/viewvc/llvm-project?rev=315343=rev
Log:
travis: enable checks of nvptx libraries

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=315343=315342=315343=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Tue Oct 10 11:10:25 2017
@@ -13,7 +13,7 @@ matrix:
 - LABEL="make gcc LLVM-3.9"
 - LLVM_VERSION=3.9
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:
@@ -28,7 +28,7 @@ matrix:
 - LABEL="make gcc LLVM-4.0"
 - LLVM_VERSION=4.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:
@@ -43,7 +43,7 @@ matrix:
 - LABEL="make gcc LLVM-5.0"
 - LLVM_VERSION=5.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:


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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/CodeCompletion/qualifiers-as-written.cpp:29
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar 
c#>, <#ns::baz d#>
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz 
c#>
+}

Sorry, I see the issue now. However, I don't think that we'd like to change the 
signature for a function like this, as we'd still prefer to show `func 
(foo::type, ns::bar, ns::baz);` on this line.

In Xcode we actually avoid the problem with `std::vector<>`s that you've 
pointed out entirely by using `value_type`. I'll check what our solution does.

Btw, maybe using things like `value_type` is completely wrong (with or without 
the qualifier)? If we have `std::vector` shouldn't we rather show 
`push_back(int _Value)`, rather than the `value_type`? Perhaps this kind of 
change should be discussed with a wider community somehow to find out what's 
best for all users.


https://reviews.llvm.org/D38538



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


r315339 - [clang-fuzzer] Build proto-to-cxx with fuzzer-no-link.

2017-10-10 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Oct 10 10:59:37 2017
New Revision: 315339

URL: http://llvm.org/viewvc/llvm-project?rev=315339=rev
Log:
[clang-fuzzer] Build proto-to-cxx with fuzzer-no-link.

Makes it possible to build with any sanitizer or none at all.

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315339=315338=315339=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Oct 10 10:59:37 2017
@@ -3,6 +3,7 @@ set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
 endif()
 


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


r315338 - [lit] Add host_cxx to lit config

2017-10-10 Thread Francis Ricci via cfe-commits
Author: fjricci
Date: Tue Oct 10 10:53:45 2017
New Revision: 315338

URL: http://llvm.org/viewvc/llvm-project?rev=315338=rev
Log:
[lit] Add host_cxx to lit config

Summary: This is required to get the clang version for sanitized builds.

Reviewers: zturner

Subscribers: llvm-commits

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

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

Modified: cfe/trunk/test/lit.site.cfg.py.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.py.in?rev=315338=315337=315338=diff
==
--- cfe/trunk/test/lit.site.cfg.py.in (original)
+++ cfe/trunk/test/lit.site.cfg.py.in Tue Oct 10 10:53:45 2017
@@ -14,6 +14,7 @@ config.clang_src_dir = "@CLANG_SOURCE_DI
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @HAVE_LIBZ@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@


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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


https://reviews.llvm.org/D33681



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


[PATCH] D38642: [clang-fuzzer] Allow building without coverage instrumentation.

2017-10-10 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315336: [clang-fuzzer] Allow building without coverage 
instrumentation. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38642?vs=118097=118420#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38642

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp

Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,60 +1,65 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )
Index: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
@@ -17,6 +17,8 @@
 
 using namespace clang_fuzzer;
 
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; }
+
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);
   HandleCXX(s, {"-O2"});
Index: cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
+++ 

r315336 - [clang-fuzzer] Allow building without coverage instrumentation.

2017-10-10 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Oct 10 10:41:43 2017
New Revision: 315336

URL: http://llvm.org/viewvc/llvm-project?rev=315336=rev
Log:
[clang-fuzzer] Allow building without coverage instrumentation.

Summary:
Compile with DummyClangFuzzer.cpp as entry point rather than
libFuzzer's main when coverage instrumentation is missing.

https://llvm.org/pr34314

Reviewers: kcc, bogner, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, mgorny

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

Added:
cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315336=315335=315336=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Oct 10 10:41:43 2017
@@ -1,60 +1,65 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )

Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=315336=315335=315336=diff
==
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (original)
+++ 

[PATCH] D38567: [config] Warn when POSIX_C_SOURCE breaks threading support on Darwin

2017-10-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk abandoned this revision.
vsk added a comment.

For those following along, Alex worked out that this doesn't affect apple-clang 
802. We took a closer look and found that the build break just affects 
clang-900, and was introduced in this r290889. The fix (r293167) didn't make it 
into clang-900. Adding a warning here wouldn't be the right solution, since it 
would be better to just cherry pick r293167.


https://reviews.llvm.org/D38567



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


[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot added a comment.

In https://reviews.llvm.org/D38656#892740, @nemanjai wrote:

> In https://reviews.llvm.org/D38656#892072, @Carrot wrote:
>
> > I worked on a similar bug as 31161, and then found this one, it should be 
> > same as in comment7.
> >  What is the current status of the work on that bug?
>
>
> No one has had time to finalize a fix to it. Please go ahead with this patch. 
> If this patch indeed fixes the bug, please close it.


This patch fixes the second part of bug 31161 described in comment7. I will 
check it in soon.
For the first part of the bug, I will retest your patch in comment1, plus 
incorrect handling of type long in our case, and then send it out.


https://reviews.llvm.org/D38656



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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

I would prefer to merge the new test with test/SemaOpenCL/func.cl, but 
otherwise LGTM! Thanks!


https://reviews.llvm.org/D33681



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> (*) I know that you aren't considering OpenCL C++ yet, but often these 
> representation/model questions are easier to answer when thinking about C++ 
> instead of C because type differences are so much more directly important in 
> C++.  In OpenCL C++, I assume it will be important to distinguish between 
>  and <__private int> as template arguments.  That tells us straight up 
> that __private needs to be represented differently from a lack of qualifier.  
> Note that the result, where certain type representations (e.g. an unqualified 
> int*) become basically meaningless and should never be constructed by Sema, 
> is already precedented in Clang: ObjC ARC does the same thing to unqualified 
> ObjC pointer types, like id*.

It's pretty complicated in OpenCL as `int` and `private int` won't be 
different, but  `int*` and `private int*` would be different only in OpenCL2.0. 
The rules are pretty convoluted and I have summarized them in the table 
earlier: https://reviews.llvm.org/D35082#inline-327303. The issue is that there 
is not anything like this in other languages and therefore we have this issue 
trying to fit this concept with something similar but not exactly the same. I 
thought you and Sam decided to use implicit AS flag to make printing messages 
consistent with the original source code. I am fine with this approach, 
however, I would prefer to just keep no AS qualifier in the default AS mode 
instead of deducing it during parcing in `processTypeAttrs`, and only to add 
the AS to the IR at the end of the CodeGen phase. I think it would be a lot 
easier to understand. However, as Sam has pointed out a lot of code in Sema has 
been written assuming the deduction of AS and is using AS qualifiers explicitly 
and therefore it seems like it would be a bigger change to go for. At the same 
type we have refactored the deduction of default AS now in the parcing phase 
and it looks a lot better than I thought it would be. So I don't mind if we 
continue this way.


https://reviews.llvm.org/D35082



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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

2017-10-10 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: sanjoy, jholewinski.

https://reviews.llvm.org/D38742

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-sm_70.cu

Index: clang/test/CodeGen/builtins-nvptx-sm_70.cu
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-sm_70.cu
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_70 \
+// RUN:-fcuda-is-device -target-feature +ptx60 \
+// RUN:-S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_60 \
+// RUN:   -fcuda-is-device -S -o /dev/null -x cuda -verify %s
+
+#if !defined(CUDA_VERSION)
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+typedef unsigned long long uint64_t;
+#endif
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: nvvm_wmma
+__device__ void nvvm_wmma(int *src, int *dst,
+  float *fsrc, float *fdst,
+  int ldm) {
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src+1, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src+2, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.col.row.m16n16k16.f16.f16
+  // expected-error@+1 

r315330 - For dllexport class templates, export specializations of member functions (PR34849) (take 2)

2017-10-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Oct 10 09:53:25 2017
New Revision: 315330

URL: http://llvm.org/viewvc/llvm-project?rev=315330=rev
Log:
For dllexport class templates, export specializations of member functions 
(PR34849) (take 2)

This is a re-commit of r315025, but making sure to only apply this to
specializations of class template member functions; i.e. not when the function
itself is a template.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315330=315329=315330=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 10 09:53:25 2017
@@ -6041,6 +6041,22 @@ static void checkDLLAttributeRedeclarati
diag::warn_dllimport_dropped_from_inline_function)
 << NewDecl << OldImportAttr;
   }
+
+  // A specialization of a class template member function is processed here
+  // since it's a redeclaration. If the parent class is dllexport, the
+  // specialization inherits that attribute. This doesn't happen automatically
+  // since the parent class isn't instantiated until later.
+  if (const CXXMethodDecl *MD = dyn_cast(NewDecl)) {
+if (MD->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+!NewImportAttr && !NewExportAttr) {
+  if (const DLLExportAttr *ParentExportAttr =
+  MD->getParent()->getAttr()) {
+DLLExportAttr *NewAttr = ParentExportAttr->clone(S.Context);
+NewAttr->setInherited(true);
+NewDecl->addAttr(NewAttr);
+  }
+}
+  }
 }
 
 /// Given that we are within the definition of the given function,

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=315330=315329=315330=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Oct 10 09:53:25 2017
@@ -831,6 +831,21 @@ template  struct ExplicitIns
 template struct __declspec(dllexport) __declspec(dllimport) 
ExplicitInstantiationTwoAttributes;
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
 
+namespace pr34849 {
+// Specializations of exported class template member functions get exported.
+template  struct __declspec(dllexport) ExportedClassTemplate { void 
foo(); };
+template<> void ExportedClassTemplate::foo() {}
+template struct ExportedClassTemplate;
+// M32-DAG: define dllexport x86_thiscallcc void 
@"\01?foo@?$ExportedClassTemplate@H@pr34849@@QAEXXZ"
+
+// Specializations of exported class member template functions do not get 
exported.
+struct __declspec(dllexport) ExportedClass { template  void bar() ; 
};
+template<> void ExportedClass::bar() {}
+// M32-DAG: define x86_thiscallcc void 
@"\01??$bar@H@ExportedClass@pr34849@@QAEXXZ"
+template  struct __declspec(dllexport) ExportedClassTemplate2 { 
template  void baz(); };
+template<> template<> void ExportedClassTemplate2::baz() {}
+// M32-DAG: define x86_thiscallcc void 
@"\01??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
+}
 
 
//===--===//
 // Classes with template base classes


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


[PATCH] D38567: [config] Warn when POSIX_C_SOURCE breaks threading support on Darwin

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/__threading_support:26
 
+#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && 
(__MAC_OS_X_VERSION_MIN_REQUIRED < 101300)) \
+|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && 
(__IPHONE_OS_VERSION_MIN_REQUIRED < 11)) \

Please add a brief comment that describes why the check and the warning are 
needed.


https://reviews.llvm.org/D38567



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


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:144
+  if (auto *I = dyn_cast(V)) {
+// If the block literal is emitted as an instruction, it is an alloca
+// and the block invoke function is stored to GEP of this alloca.

yaxunl wrote:
> Anastasia wrote:
> > Why do we need to replace original block calls with the kernels? I think in 
> > case of calling a block we could use the original block function and only 
> > for enqueue use the kernel that would call the block function inside. The 
> > pointer to the kernel wrapper could be passed as an additional parameter to 
> > `enqueue_kernel` calls. We won't need to iterate through all IR then.
> `CGF.EmitScalarExpr(Block)` returns the block literal structure which 
> contains the size/align/invoke_function/captures. The block invoke function 
> is stored to the struct by a `StoreInst`. To create the wrapper kernel, we 
> need to get the block invoke function, therefore we have to iterate through 
> IR.
> 
> Since we need to find the store instruction any way, it is simpler to just 
> replace the stored function with the kernel and pass the block literal 
> struct, instead of passing the kernel separately.
So we cann't get the invoke function from the block literal structure passed 
into the kernel wrapper directly knowing its offset? Iterating through IR adds 
extra time and also I am not sure how reliable this is wrt different corner 
cases of IR.



Comment at: lib/CodeGen/TargetInfo.cpp:8949
+  Builder.restoreIP(IP);
+  return F;
+}

yaxunl wrote:
> Anastasia wrote:
> > Wondering if we should add the kernel metadata (w/o args) since it was used 
> > for long time to indicate the kernel.
> Currently (before this change), clang already does not generate kernel 
> metadata if there is no vec_type_hint, work_group_size_hint, 
> reqd_work_group_size. Remember last time we made the change to use function 
> metadata to represent these attributes. Whether a function is a kernel can be 
> determined by its calling convention.
Ok, let's leave it for now. We can always add it in on request. 



Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:297
+// COMMON: define internal spir_kernel void [[INVG5]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
+// COMMON: define internal spir_kernel void [[INVG6]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}}, i8 addrspace(3)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define internal spir_kernel void [[INVG7]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})

Perhaps we could check the body of this one too since it has a different 
prototype.


https://reviews.llvm.org/D38134



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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-10 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

I keep running into issues trying to cross-build LLVM (it keeps wanting to use 
/usr/bin/cc or host libraries even though cross-compiling is enabled).  I 
wonder if the failures you saw Simon might be due to 
https://bugs.llvm.org/show_bug.cgi?id=33858?  Could you try applying the patch 
from https://reviews.llvm.org/D37484 along with this patchset to see if it 
fixes the test failures for you?


https://reviews.llvm.org/D38110



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


[clang-tools-extra] r315325 - [clangd] Use UniqueFunction for deferred computations.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:54 2017
New Revision: 315325

URL: http://llvm.org/viewvc/llvm-project?rev=315325=rev
Log:
[clangd] Use UniqueFunction for deferred computations.

Previsouly, `std::future` that were results of
`std::async(std::launch::deferred, ...` were used.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=315325=315324=315325=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Oct 10 09:12:54 2017
@@ -413,8 +413,9 @@ std::future ClangdServer::schedule
 Tagged TaggedFS) {
 
   assert(Contents.Draft && "Draft must have contents");
-  std::future> DeferredRebuild =
-  Resources->deferRebuild(*Contents.Draft, TaggedFS.Value);
+  UniqueFunction()>
+  DeferredRebuild =
+  Resources->deferRebuild(*Contents.Draft, TaggedFS.Value);
   std::promise DonePromise;
   std::future DoneFuture = DonePromise.get_future();
 
@@ -423,7 +424,7 @@ std::future ClangdServer::schedule
   VFSTag Tag = TaggedFS.Tag;
   auto ReparseAndPublishDiags =
   [this, FileStr, Version,
-   Tag](std::future>
+   Tag](UniqueFunction()>
 DeferredRebuild,
 std::promise DonePromise) -> void {
 FulfillPromiseGuard Guard(DonePromise);
@@ -432,7 +433,7 @@ std::future ClangdServer::schedule
 if (CurrentVersion != Version)
   return; // This request is outdated
 
-auto Diags = DeferredRebuild.get();
+auto Diags = DeferredRebuild();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
 
@@ -467,11 +468,11 @@ ClangdServer::scheduleCancelRebuild(std:
 return DoneFuture;
   }
 
-  std::future DeferredCancel = Resources->deferCancelRebuild();
+  UniqueFunction DeferredCancel = Resources->deferCancelRebuild();
   auto CancelReparses = [Resources](std::promise DonePromise,
-std::future DeferredCancel) {
+UniqueFunction DeferredCancel) {
 FulfillPromiseGuard Guard(DonePromise);
-DeferredCancel.get();
+DeferredCancel();
   };
   WorkScheduler.addToFront(std::move(CancelReparses), std::move(DonePromise),
std::move(DeferredCancel));

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=315325=315324=315325=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Oct 10 09:12:54 2017
@@ -1121,9 +1121,9 @@ CppFile::CppFile(PathRef FileName, tooli
   ASTFuture = ASTPromise.get_future();
 }
 
-void CppFile::cancelRebuild() { deferCancelRebuild().get(); }
+void CppFile::cancelRebuild() { deferCancelRebuild()(); }
 
-std::future CppFile::deferCancelRebuild() {
+UniqueFunction CppFile::deferCancelRebuild() {
   std::unique_lock Lock(Mutex);
   // Cancel an ongoing rebuild, if any, and wait for it to finish.
   unsigned RequestRebuildCounter = ++this->RebuildCounter;
@@ -1143,7 +1143,7 @@ std::future CppFile::deferCancelRe
   RebuildCond.notify_all();
 
   std::shared_ptr That = shared_from_this();
-  return std::async(std::launch::deferred, [That, RequestRebuildCounter]() {
+  return [That, RequestRebuildCounter]() {
 std::unique_lock Lock(That->Mutex);
 CppFile *This = &*That;
 This->RebuildCond.wait(Lock, [This, RequestRebuildCounter]() {
@@ -1158,16 +1158,16 @@ std::future CppFile::deferCancelRe
 // Set empty results for Promises.
 That->PreamblePromise.set_value(nullptr);
 That->ASTPromise.set_value(std::make_shared(llvm::None));
-  });
+  };
 }
 
 llvm::Optional
 CppFile::rebuild(StringRef NewContents,
  IntrusiveRefCntPtr VFS) {
-  return deferRebuild(NewContents, std::move(VFS)).get();
+  return deferRebuild(NewContents, std::move(VFS))();
 }
 
-std::future>
+UniqueFunction()>
 CppFile::deferRebuild(StringRef NewContents,
   IntrusiveRefCntPtr VFS) {
   std::shared_ptr OldPreamble;
@@ -1315,7 +1315,7 @@ CppFile::deferRebuild(StringRef NewConte
 return Diagnostics;
   };
 
-  return std::async(std::launch::deferred, FinishRebuild, NewContents.str());
+  return BindWithForward(FinishRebuild, NewContents.str());
 }
 
 std::shared_future

Modified: 

[clang-tools-extra] r315323 - [clangd] Added forgotten return in UniqueFunction.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:47 2017
New Revision: 315323

URL: http://llvm.org/viewvc/llvm-project?rev=315323=rev
Log:
[clangd] Added forgotten return in UniqueFunction.

This hasn't bitten us because we only used functions returning
'void'.

Modified:
clang-tools-extra/trunk/clangd/Function.h

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315323=315322=315323=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Tue Oct 10 09:12:47 2017
@@ -46,7 +46,7 @@ public:
 
   Ret operator()(Args... As) {
 assert(CallablePtr);
-CallablePtr->Call(std::forward(As)...);
+return CallablePtr->Call(std::forward(As)...);
   }
 
 private:


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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Eric Liu via cfe-commits
No :( I tried reverting only r315256 but still got the errors.

On Tue, Oct 10, 2017 at 6:10 PM Richard Smith  wrote:

> On 10 Oct 2017 05:41, "Eric Liu via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm
> seeing "unsupported: typedef changes linkage of anonymous type, but
> linkage was already computed" error for many `struct`s defined with
> typedef. I'm not sure if it is user code or clang that needs fixing;
> however, as there are likely many more struct definitions that would cause
> the same failure, I'll revert this commit as well as r315256, which depends
> on this. Sorry about that.
>
>
> r315256 should have fixed those errors. Did it not?
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> +  Module *getOwningModuleForLinkage() const;
>> +
>>/// \brief Determine whether this declaration might be hidden from name
>>/// lookup. Note that the declaration might be visible even if this
>> returns
>>/// \c false, if the owning module is visible within the query context.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> 

[clang-tools-extra] r315324 - [clangd] Added missing #includes to Function.h

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:50 2017
New Revision: 315324

URL: http://llvm.org/viewvc/llvm-project?rev=315324=rev
Log:
[clangd] Added missing #includes to Function.h

Modified:
clang-tools-extra/trunk/clangd/Function.h

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315324=315323=315324=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Tue Oct 10 09:12:50 2017
@@ -14,6 +14,9 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
 
+#include "llvm/ADT/STLExtras.h"
+#include 
+#include 
 #include 
 #include 
 #include 


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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Richard Smith via cfe-commits
On 10 Oct 2017 05:41, "Eric Liu via cfe-commits" 
wrote:

Hi Richard,

This is breaking the boostrap stage in the internal integration. I'm seeing
"unsupported: typedef changes linkage of anonymous type, but linkage was
already computed" error for many `struct`s defined with typedef. I'm not
sure if it is user code or clang that needs fixing; however, as there are
likely many more struct definitions that would cause the same failure, I'll
revert this commit as well as r315256, which depends on this. Sorry about
that.


r315256 should have fixed those errors. Did it not?

I'll also send you the repros separately.

Regards,
Eric

On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 16:42:09 2017
> New Revision: 315251
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
> Log:
> [Modules TS] Module ownership semantics for redeclarations.
>
> When declaring an entity in the "purview" of a module, it's never a
> redeclaration of an entity in the purview of a default module or in no
> module
> ("in the global module"). Don't consider those other declarations as
> possible
> redeclaration targets if they're not visible, and reject any cases where we
> pick a prior visible declaration that violates this rule.
>
> Added:
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-
> vs-module.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-
> vs-global.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-
> vs-module.cpp
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Lookup.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclBase.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExprMember.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Decl.h?rev=315251=315250=315251=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
> @@ -339,6 +339,12 @@ public:
>  return clang::isExternallyVisible(getLinkageInternal());
>}
>
> +  /// Determine whether this declaration can be redeclared in a
> +  /// different translation unit.
> +  bool isExternallyDeclarable() const {
> +return isExternallyVisible() && !getOwningModuleForLinkage();
> +  }
> +
>/// \brief Determines the visibility of this entity.
>Visibility getVisibility() const {
>  return getLinkageAndVisibility().getVisibility();
> @@ -379,10 +385,6 @@ public:
>  return hasCachedLinkage();
>}
>
> -  /// Get the module that owns this declaration for linkage purposes.
> -  /// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> -
>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>/// the underlying named decl.
>NamedDecl *getUnderlyingDecl() {
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclBase.h?rev=315251=315250=315251=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
> @@ -738,6 +738,10 @@ public:
>  return isFromASTFile() ? getImportedOwningModule() :
> getLocalOwningModule();
>}
>
> +  /// Get the module that owns this declaration for linkage purposes.
> +  /// There only ever is such a module under the C++ Modules TS.
> +  Module *getOwningModuleForLinkage() const;
> +
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>/// \c false, if the owning module is visible within the query context.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=315251=315250=315251=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ 

Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Hans Wennborg via cfe-commits
Thanks for reverting.

We saw build failures in Chromium too. E.g. from
https://build.chromium.org/p/chromium.clang/builders/ToTLinux/builds/134:

In file included from
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.cc:34:
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.h:51:3:
error: unsupported: typedef changes linkage of anonymous type, but
linkage was already computed
} Options;
  ^
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.h:44:15:
note: use a tag name here to establish linkage prior to definition
typedef struct {
  ^
   Options


On Tue, Oct 10, 2017 at 5:41 AM, Eric Liu via cfe-commits
 wrote:
> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm seeing
> "unsupported: typedef changes linkage of anonymous type, but linkage was
> already computed" error for many `struct`s defined with typedef. I'm not
> sure if it is user code or clang that needs fixing; however, as there are
> likely many more struct definitions that would cause the same failure, I'll
> revert this commit as well as r315256, which depends on this. Sorry about
> that.
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> + 

[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/StaticAnalyzer/Core/IssueHash.cpp:39
+  // primary template.
+  if (const FunctionDecl *InstantiatedFrom =
+  Target->getInstantiatedFromMemberFunction())

Could we use here FunctionDecl::getPrimaryTemplate() ? That seems more general, 
it handles both specializations and instantiations.



Comment at: test/Analysis/bug_hash_test.cpp:61
 
-// CHECK: diagnostics
+template 
+T f(T i) {

We could add a few more test cases:
- a function template in class template
- specializations vs instantiations
- the combination of the above two (?)




Comment at: test/Analysis/bug_hash_test.cpp:1363
 // CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   path

I am not sure if this is possible, but could we add unit test just for the 
`GetSignature` function? Instead of these huge plist files?

I am thinking something like this:
https://github.com/martong/friend-stats/blob/ed0c69ea3669c933204c799f59b85cd7b2507c34/ut/FriendFunctionsTest.cpp#L31


Repository:
  rL LLVM

https://reviews.llvm.org/D38728



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


[PATCH] D38737: [X86] test/testn intrinsics lowering to IR. clang side

2017-10-10 Thread Uriel Korach via Phabricator via cfe-commits
uriel.k created this revision.

Changed Header files of the intrinsics fro lowering test and testn intrinsics 
to IR code.
Removed test and testn builtins from clang

this is the clang side, the llvm side revision is D38736 
.


https://reviews.llvm.org/D38737

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c

Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2481,97 +2481,121 @@
 }
 __mmask16 test_mm_test_epi8_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i8> %{{.*}}, %{{.*}}
   return _mm_test_epi8_mask(__A, __B); 
 }
 
 __mmask16 test_mm_mask_test_epi8_mask(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_test_epi8_mask(__U, __A, __B); 
 }
 
 __mmask32 test_mm256_test_epi8_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <32 x i8> %{{.*}}, %{{.*}}
   return _mm256_test_epi8_mask(__A, __B); 
 }
 
 __mmask32 test_mm256_mask_test_epi8_mask(__mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <32 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_test_epi8_mask(__U, __A, __B); 
 }
 
 __mmask8 test_mm_test_epi16_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <8 x i16> %{{.*}}, %{{.*}}
   return _mm_test_epi16_mask(__A, __B); 
 }
 
 __mmask8 test_mm_mask_test_epi16_mask(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: and <8 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_test_epi16_mask(__U, __A, __B); 
 }
 
 __mmask16 test_mm256_test_epi16_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i16> %{{.*}}, %{{.*}}
   return _mm256_test_epi16_mask(__A, __B); 
 }
 
 __mmask16 test_mm256_mask_test_epi16_mask(__mmask16 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_test_epi16_mask(__U, __A, __B); 
 }
 
 __mmask16 test_mm_testn_epi8_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <16 x i8> %{{.*}}, %{{.*}}
   return _mm_testn_epi8_mask(__A, __B); 
 }
 
 __mmask16 test_mm_mask_testn_epi8_mask(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_testn_epi8_mask(__U, __A, __B); 
 }
 
 __mmask32 test_mm256_testn_epi8_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <32 x i8> %{{.*}}, %{{.*}}
   return _mm256_testn_epi8_mask(__A, __B); 
 }
 
 __mmask32 test_mm256_mask_testn_epi8_mask(__mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <32 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_testn_epi8_mask(__U, __A, __B); 
 }
 
 __mmask8 test_mm_testn_epi16_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_testn_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, 

[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

2017-10-10 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

This patch enables explicit generation of TBAA information in all cases where 
LValue base info is propagated or constructed in non-trivial ways. Eventually, 
we will consider each of these cases to make sure the TBAA information is 
correct and not too conservative. For now, we just fall back to generating TBAA 
info from the access type.

This patch should not bring in any functional changes.

This is part of https://reviews.llvm.org/D38126 reworked to be a separate patch 
to simplify review.


Repository:
  rL LLVM

https://reviews.llvm.org/D38733

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1917,9 +1917,9 @@
 CGM.getTBAAAccessInfo(T));
   }
 
-  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo) {
-return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
-CGM.getTBAAAccessInfo(T));
+  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo,
+TBAAAccessInfo TBAAInfo) {
+return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
@@ -1930,25 +1930,28 @@
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-LValueBaseInfo BaseInfo) {
+LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
-BaseInfo, CGM.getTBAAAccessInfo(T));
+BaseInfo, TBAAInfo);
   }
 
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
   CharUnits getNaturalTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-LValueBaseInfo *BaseInfo = nullptr);
+LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates an alloca and inserts it into the entry
@@ -3327,7 +3330,8 @@
   Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
   llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   ReturnValueSlot ReturnValue);
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -120,12 +120,17 @@
 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo) {
   return getNaturalTypeAlignment(T->getPointeeType(), BaseInfo,
- /*forPointee*/ true);
+ /* TBAAInfo= */ nullptr,
+ /* forPointeeType= */ true);
 }
 
 CharUnits CodeGenFunction::getNaturalTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo,
+   TBAAAccessInfo *TBAAInfo,
bool forPointeeType) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(T);
+
   // Honor alignment typedef attributes even on incomplete types.
   // We also honor them straight for C++ class types, even as pointees;
   // there's an 

[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Michael Ferguson via Phabricator via cfe-commits
mppf added a comment.

Since I don't have commit access, could somebody commit this for me please? 
Thanks.


https://reviews.llvm.org/D38473



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


[clang-tools-extra] r315317 - [clangd] clang-format the source code. NFC.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 07:21:04 2017
New Revision: 315317

URL: http://llvm.org/viewvc/llvm-project?rev=315317=rev
Log:
[clangd] clang-format the source code. NFC.

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=315317=315316=315317=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Tue Oct 10 
07:21:04 2017
@@ -40,7 +40,7 @@ tooling::CompileCommand getDefaultCompil
 DirectoryBasedGlobalCompilationDatabase::
 DirectoryBasedGlobalCompilationDatabase(
 clangd::Logger , llvm::Optional CompileCommandsDir)
-: Logger(Logger), CompileCommandsDir(std::move(CompileCommandsDir)) {}
+: Logger(Logger), CompileCommandsDir(std::move(CompileCommandsDir)) {}
 
 std::vector
 DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=315317=315316=315317=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Oct 10 07:21:04 2017
@@ -182,7 +182,8 @@ std::string Location::unparse(const Loca
 }
 
 llvm::Optional
-TextDocumentItem::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
) {
+TextDocumentItem::parse(llvm::yaml::MappingNode *Params,
+clangd::Logger ) {
   TextDocumentItem Result;
   for (auto  : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -552,7 +553,8 @@ TextDocumentContentChangeEvent::parse(ll
 }
 
 llvm::Optional
-FormattingOptions::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
) {
+FormattingOptions::parse(llvm::yaml::MappingNode *Params,
+ clangd::Logger ) {
   FormattingOptions Result;
   for (auto  : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -767,7 +769,8 @@ llvm::Optional Diagnostic::p
 }
 
 llvm::Optional
-CodeActionContext::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
) {
+CodeActionContext::parse(llvm::yaml::MappingNode *Params,
+ clangd::Logger ) {
   CodeActionContext Result;
   for (auto  : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -800,7 +803,8 @@ CodeActionContext::parse(llvm::yaml::Map
 }
 
 llvm::Optional
-CodeActionParams::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
) {
+CodeActionParams::parse(llvm::yaml::MappingNode *Params,
+clangd::Logger ) {
   CodeActionParams Result;
   for (auto  : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=315317=315316=315317=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Tue Oct 10 07:21:04 2017
@@ -265,8 +265,8 @@ private:
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher ,
- JSONOutput ,
- ProtocolCallbacks ) {
+  JSONOutput ,
+  ProtocolCallbacks ) {
   Dispatcher.registerHandler(
   "initialize", llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler(


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


[PATCH] D38731: [clangd] Allow to pass code completion opts to ClangdServer.

2017-10-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D38731

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -135,6 +135,33 @@
 namespace clangd {
 namespace {
 
+struct StringWithPos {
+  std::string Text;
+  clangd::Position MarkerPos;
+};
+
+/// Returns location of "{mark}" substring in \p Text and removes it from \p
+/// Text. Note that \p Text must contain exactly one occurence of "{mark}".
+///
+/// Marker name can be configured using \p MarkerName parameter.
+StringWithPos parseTextMarker(StringRef Text, StringRef MarkerName = "mark") {
+  SmallString<16> Marker;
+  Twine("{" + MarkerName + "}").toVector(/*ref*/ Marker);
+
+  std::size_t MarkerOffset = Text.find(Marker);
+  assert(MarkerOffset != StringRef::npos && "{mark} wasn't found in Text.");
+
+  std::string WithoutMarker;
+  WithoutMarker += Text.take_front(MarkerOffset);
+  WithoutMarker += Text.drop_front(MarkerOffset + Marker.size());
+  assert(StringRef(WithoutMarker).find(Marker) == StringRef::npos &&
+ "There were multiple occurences of {mark} inside Text");
+
+  clangd::Position MarkerPos =
+  clangd::offsetToPosition(WithoutMarker, MarkerOffset);
+  return {std::move(WithoutMarker), MarkerPos};
+}
+
 // Don't wait for async ops in clangd test more than that to avoid blocking
 // indefinitely in case of bugs.
 static const std::chrono::seconds DefaultFutureTimeout =
@@ -305,7 +332,7 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false,
+clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto  : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
@@ -369,7 +396,8 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -414,7 +442,8 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -461,7 +490,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -495,7 +524,7 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -544,7 +573,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -589,22 +618,32 @@
 
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
-  bool ContainsItem(std::vector const , StringRef Name) {
+  template 
+  bool ContainsItemPred(std::vector const ,
+Predicate Pred) {
 for (const auto  : Items) {
-  if (Item.insertText == Name)
+  if (Pred(Item))
 return true;
 }
 return false;
   }
+
+  bool ContainsItem(std::vector const , StringRef Name) {
+return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
+  return Item.insertText == Name;
+});
+return false;
+  }
 };
 
 TEST_F(ClangdCompletionTest, CheckContentsOverride) {
   

r315315 - [OPENMP] Add default codegen|tests for 'target parallel for[ simd]'

2017-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct 10 07:14:43 2017
New Revision: 315315

URL: http://llvm.org/viewvc/llvm-project?rev=315315=rev
Log:
[OPENMP] Add default codegen|tests for 'target parallel for[ simd]'
constructs.

Added default codegen for 'target parallel for' construct + tests for
default codegen of 'target parallel for[ simd]' constructs.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=315315=315314=315315=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Oct 10 07:14:43 2017
@@ -4126,7 +4126,14 @@ void CodeGenFunction::EmitOMPTargetParal
 
 void CodeGenFunction::EmitOMPTargetParallelForDirective(
 const OMPTargetParallelForDirective ) {
-  // TODO: codegen for target parallel for.
+  OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
+  CGM.getOpenMPRuntime().emitInlinedDirective(
+  *this, OMPD_target_parallel_for,
+  [](CodeGenFunction , PrePostActionTy &) {
+OMPLoopScope PreInitScope(CGF, S);
+CGF.EmitStmt(
+cast(S.getAssociatedStmt())->getCapturedStmt());
+  });
 }
 
 /// Emit a helper variable and return corresponding lvalue.

Added: cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp?rev=315315=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp Tue Oct 10 07:14:43 
2017
@@ -0,0 +1,232 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+long long get_val() { return 0; }
+double *g_ptr;
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}simple{{.*}}(float* {{.+}}, float* 
{{.+}}, float* {{.+}}, float* {{.+}})
+void simple(float *a, float *b, float *c, float *d) {
+  // CHECK: store i32 3, i32* %
+  // CHECK: icmp slt i32 %{{.+}}, 32
+  // CHECK: fmul float
+  // CHECK: fmul float
+  // CHECK: add nsw i32 %{{.+}}, 5
+  #pragma omp target parallel for device((int)*a)
+  for (int i = 3; i < 32; i += 5) {
+a[i] = b[i] * c[i] * d[i];
+  }
+
+  // CHECK: call i{{.+}} @{{.+}}get_val{{.+}}()
+  // CHECK: store i32 10, i32* %
+  // CHECK: icmp sgt i32 %{{.+}}, 1
+  // CHECK: fadd float %{{.+}}, 1.00e+00
+  // CHECK: add nsw {{.+}} %{{.+}}, 3
+  // CHECK: add nsw i32 %{{.+}}, -1
+  long long k = get_val();
+  #pragma omp target parallel for linear(k : 3) schedule(dynamic)
+  for (int i = 10; i > 1; i--) {
+a[k]++;
+k = k + 3;
+  }
+
+  // CHECK: store i32 12, i32* %
+  // CHECK: store i{{.+}} 2000, i{{.+}}* %
+  // CHECK: icmp uge i{{.+}} %{{.+}}, 600
+  // CHECK: store double 0.00e+00,
+  // CHECK: fadd float %{{.+}}, 1.00e+00
+  // CHECK: sub i{{.+}} %{{.+}}, 400
+  int lin = 12;
+  #pragma omp target parallel for linear(lin : get_val()), linear(g_ptr)
+  for (unsigned long long it = 2000; it >= 600; it-=400) {
+*g_ptr++ = 0.0;
+a[it + lin]++;
+  }
+
+  // CHECK: store i{{.+}} 6, i{{.+}}* %
+  // CHECK: icmp sle i{{.+}} %{{.+}}, 20
+  // CHECK: sub nsw i{{.+}} %{{.+}}, -4
+  #pragma omp target parallel for
+  for (short it = 6; it <= 20; it-=-4) {
+  }
+
+  // CHECK: store i8 122, i8* %
+  // CHECK: icmp sge i32 %{{.+}}, 97
+  // CHECK: add nsw i32 %{{.+}}, -1
+  #pragma omp target parallel for
+  for (unsigned char it = 'z'; it >= 'a'; it+=-1) {
+  }
+
+  // CHECK: store i32 100, i32* %
+  // CHECK: icmp ult i32 %{{.+}}, 10
+  // CHECK: add i32 %{{.+}}, 10
+  #pragma omp target parallel for
+  for (unsigned i=100; i<10; i+=10) {
+  }
+
+  int A;
+  {
+  A = -1;
+  // CHECK: store i{{.+}} -10, i{{.+}}* %
+  // CHECK: icmp slt i{{.+}} %{{.+}}, 10
+  // CHECK: add nsw i{{.+}} %{{.+}}, 3
+  #pragma omp target parallel for lastprivate(A)
+  for (long long i = -10; i < 10; i += 3) {
+A = i;
+  }
+  }
+  int R;
+  {
+  R = -1;
+  // CHECK: store i{{.+}} -10, i{{.+}}* %
+  // CHECK: icmp slt i{{.+}} %{{.+}}, 10
+  // CHECK: add nsw 

r315314 - Fix a (slightly weird) 'comma operator within array index expression' warning on VS builds. NFCI.

2017-10-10 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Oct 10 06:56:17 2017
New Revision: 315314

URL: http://llvm.org/viewvc/llvm-project?rev=315314=rev
Log:
Fix a (slightly weird) 'comma operator within array index expression' warning 
on VS builds. NFCI.

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=315314=315313=315314=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Oct 10 06:56:17 2017
@@ -5728,7 +5728,8 @@ void ASTReader::ReadPragmaDiagnosticMapp
 
   // Preserve the property that the imaginary root file describes the
   // current state.
-  auto  = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions;
+  FileID NullFile;
+  auto  = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
   if (T.empty())
 T.push_back({CurState, 0});
   else


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


[PATCH] D38723: [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with nits.




Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:163
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName are known to be
+// ignored.

s/are known to/should be/ ?



Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:166
+// For example, if it is true and NewName is "a::b::foo", then the symbol
+// will be renamed to "foo".
+bool IgnorePrefixQualifers;

maybe "... for both symbol references and symbol definitions", just for clarity?



Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:443
+  size_t LastColonPos = NewName.find_last_of(':');
+  if (LastColonPos != std::string::npos) {
+ReplacedName = NewName.substr(LastColonPos + 1);

nit: no braces


https://reviews.llvm.org/D38723



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


[PATCH] D38452: Mark test as a long-test

2017-10-10 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Friendly ping :)


https://reviews.llvm.org/D38452



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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread NAKAMURA Takumi via cfe-commits
FYI, I tweaked the tree in rL315283. Shall we restore it?

On Tue, Oct 10, 2017 at 9:41 PM Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm
> seeing "unsupported: typedef changes linkage of anonymous type, but
> linkage was already computed" error for many `struct`s defined with
> typedef. I'm not sure if it is user code or clang that needs fixing;
> however, as there are likely many more struct definitions that would cause
> the same failure, I'll revert this commit as well as r315256, which depends
> on this. Sorry about that.
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251=315250=315251=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> +  Module *getOwningModuleForLinkage() const;
>> +
>>/// \brief Determine whether this declaration might be hidden from name
>>/// lookup. Note that the declaration might be visible even if this
>> returns
>>/// \c false, if the owning module is visible within the query context.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315251=315250=315251=diff
>>
>> 

r315309 - Revert "[Modules TS] Module ownership semantics for redeclarations."

2017-10-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct 10 06:09:40 2017
New Revision: 315309

URL: http://llvm.org/viewvc/llvm-project?rev=315309=rev
Log:
Revert "[Modules TS] Module ownership semantics for redeclarations."

This reverts commit r315251. See the original commit thread for reason.

Removed:
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315309=315308=315309=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 10 06:09:40 2017
@@ -339,12 +339,6 @@ public:
 return clang::isExternallyVisible(getLinkageInternal());
   }
 
-  /// Determine whether this declaration can be redeclared in a
-  /// different translation unit.
-  bool isExternallyDeclarable() const {
-return isExternallyVisible() && !getOwningModuleForLinkage();
-  }
-
   /// \brief Determines the visibility of this entity.
   Visibility getVisibility() const {
 return getLinkageAndVisibility().getVisibility();
@@ -385,6 +379,10 @@ public:
 return hasCachedLinkage();
   }
 
+  /// Get the module that owns this declaration for linkage purposes.
+  /// There only ever is such a module under the C++ Modules TS.
+  Module *getOwningModuleForLinkage() const;
+
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// the underlying named decl.
   NamedDecl *getUnderlyingDecl() {

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315309=315308=315309=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Oct 10 06:09:40 2017
@@ -738,10 +738,6 @@ public:
 return isFromASTFile() ? getImportedOwningModule() : 
getLocalOwningModule();
   }
 
-  /// Get the module that owns this declaration for linkage purposes.
-  /// There only ever is such a module under the C++ Modules TS.
-  Module *getOwningModuleForLinkage() const;
-
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns
   /// \c false, if the owning module is visible within the query context.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315309=315308=315309=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 10 06:09:40 
2017
@@ -4801,9 +4801,6 @@ def err_thread_non_thread : Error<
 def err_thread_thread_different_kind : Error<
   "thread-local declaration of %0 with %select{static|dynamic}1 initialization 
"
   "follows declaration with %select{dynamic|static}1 initialization">;
-def err_mismatched_owning_module : Error<
-  "declaration of %0 in %select{the global module|module %2}1 follows "
-  "declaration in %select{the global module|module %4}3">;
 def err_redefinition_different_type : Error<
   "redefinition of %0 with a different type%diff{: $ vs $|}1,2">;
 def err_redefinition_different_kind : Error<

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=315309=315308=315309=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Tue Oct 10 06:09:40 2017
@@ -139,7 +139,6 @@ public:
   LookupKind(LookupKind),
   IDNS(0),
   Redecl(Redecl != Sema::NotForRedeclaration),
-  ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
   HideTags(true),
   Diagnose(Redecl == Sema::NotForRedeclaration),
   AllowHidden(false),
@@ -162,7 +161,6 

[PATCH] D38683: [X86][AVX512] lowering broadcastm intrinsic - clang part

2017-10-10 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/avx512cdintrin.c:106
+  // CHECK: insertelement <16 x i32> %{{.*}}, i32 %{{.*}}
+  return _mm512_broadcastmw_epi32(_mm512_cmpeq_epi32_mask ( a, b)); 
 }

Any reason why you can't use the actual insertion indices instead of regexps?


https://reviews.llvm.org/D38683



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


r315308 - Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module."

2017-10-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct 10 06:00:18 2017
New Revision: 315308

URL: http://llvm.org/viewvc/llvm-project?rev=315308=rev
Log:
Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext 
for a declaration in the global module."

This reverts commit r315256. See the original commit thread for reason.

Removed:
cfe/trunk/test/Modules/anon-linkage.cpp
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315308=315307=315308=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Oct 10 06:00:18 2017
@@ -740,10 +740,7 @@ public:
 
   /// Get the module that owns this declaration for linkage purposes.
   /// There only ever is such a module under the C++ Modules TS.
-  ///
-  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
-  /// all declarations in a global module fragment are unowned.
-  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
+  Module *getOwningModuleForLinkage() const;
 
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315308=315307=315308=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 10 06:00:18 2017
@@ -3051,11 +3051,8 @@ public:
 
   RedeclarationKind forRedeclarationInCurContext() {
 // A declaration with an owning module for linkage can never link against
-// anything that is not visible. We don't need to check linkage here; if
-// the context has internal linkage, redeclaration lookup won't find things
-// from other TUs, and we can't safely compute linkage yet in general.
-if (cast(CurContext)
-->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
+// anything that is not visible.
+if (cast(CurContext)->getOwningModuleForLinkage())
   return ForVisibleRedeclaration;
 return ForExternalRedeclaration;
   }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=315308=315307=315308=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 10 06:00:18 2017
@@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLink
 : NamedDecl::VisibilityForValue));
 }
 
-Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
+Module *Decl::getOwningModuleForLinkage() const {
   Module *M = getOwningModule();
   if (!M)
 return nullptr;
@@ -1413,8 +1413,6 @@ Module *Decl::getOwningModuleForLinkage(
 // for linkage purposes. But internal linkage declarations in the global
 // module fragment of a particular module are owned by that module for
 // linkage purposes.
-if (IgnoreLinkage)
-  return nullptr;
 bool InternalLinkage;
 if (auto *ND = dyn_cast(this))
   InternalLinkage = !ND->hasExternalFormalLinkage();

Removed: cfe/trunk/test/Modules/anon-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/anon-linkage.cpp?rev=315307=auto
==
--- cfe/trunk/test/Modules/anon-linkage.cpp (original)
+++ cfe/trunk/test/Modules/anon-linkage.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
-
-typedef struct {
-  int c;
-  union {
-int n;
-char c[4];
-  } v;
-} mbstate;
-
-export module M;
-export using ::mbstate;


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


Re: r315256 - [Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module.

2017-10-10 Thread Eric Liu via cfe-commits
I am reverting this commit as it depends on r315251. See r315251 thread for
reason.

On Tue, Oct 10, 2017 at 2:49 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 17:49:38 2017
> New Revision: 315256
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315256=rev
> Log:
> [Modules TS] Avoid computing the linkage of the enclosing DeclContext for
> a declaration in the global module.
>
> This works around a language issue where adding a typedef name for linkage
> purposes changes the linkage of an already-defined class after it becomes
> complete.
>
> Added:
> cfe/trunk/test/Modules/anon-linkage.cpp
> Modified:
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315256=315255=315256=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 17:49:38 2017
> @@ -740,7 +740,10 @@ public:
>
>/// Get the module that owns this declaration for linkage purposes.
>/// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> +  ///
> +  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
> +  /// all declarations in a global module fragment are unowned.
> +  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
>
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315256=315255=315256=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct  9 17:49:38 2017
> @@ -3051,8 +3051,11 @@ public:
>
>RedeclarationKind forRedeclarationInCurContext() {
>  // A declaration with an owning module for linkage can never link
> against
> -// anything that is not visible.
> -if (cast(CurContext)->getOwningModuleForLinkage())
> +// anything that is not visible. We don't need to check linkage here;
> if
> +// the context has internal linkage, redeclaration lookup won't find
> things
> +// from other TUs, and we can't safely compute linkage yet in general.
> +if (cast(CurContext)
> +->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
>return ForVisibleRedeclaration;
>  return ForExternalRedeclaration;
>}
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=315256=315255=315256=diff
>
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Mon Oct  9 17:49:38 2017
> @@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLink
>  :
> NamedDecl::VisibilityForValue));
>  }
>
> -Module *Decl::getOwningModuleForLinkage() const {
> +Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
>Module *M = getOwningModule();
>if (!M)
>  return nullptr;
> @@ -1413,6 +1413,8 @@ Module *Decl::getOwningModuleForLinkage(
>  // for linkage purposes. But internal linkage declarations in the
> global
>  // module fragment of a particular module are owned by that module for
>  // linkage purposes.
> +if (IgnoreLinkage)
> +  return nullptr;
>  bool InternalLinkage;
>  if (auto *ND = dyn_cast(this))
>InternalLinkage = !ND->hasExternalFormalLinkage();
>
> Added: cfe/trunk/test/Modules/anon-linkage.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/anon-linkage.cpp?rev=315256=auto
>
> ==
> --- cfe/trunk/test/Modules/anon-linkage.cpp (added)
> +++ cfe/trunk/test/Modules/anon-linkage.cpp Mon Oct  9 17:49:38 2017
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
> +
> +typedef struct {
> +  int c;
> +  union {
> +int n;
> +char c[4];
> +  } v;
> +} mbstate;
> +
> +export module M;
> +export using ::mbstate;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Eric Liu via cfe-commits
Hi Richard,

This is breaking the boostrap stage in the internal integration. I'm seeing
"unsupported: typedef changes linkage of anonymous type, but linkage was
already computed" error for many `struct`s defined with typedef. I'm not
sure if it is user code or clang that needs fixing; however, as there are
likely many more struct definitions that would cause the same failure, I'll
revert this commit as well as r315256, which depends on this. Sorry about
that.

I'll also send you the repros separately.

Regards,
Eric

On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 16:42:09 2017
> New Revision: 315251
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
> Log:
> [Modules TS] Module ownership semantics for redeclarations.
>
> When declaring an entity in the "purview" of a module, it's never a
> redeclaration of an entity in the purview of a default module or in no
> module
> ("in the global module"). Don't consider those other declarations as
> possible
> redeclaration targets if they're not visible, and reject any cases where we
> pick a prior visible declaration that violates this rule.
>
> Added:
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Lookup.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclBase.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExprMember.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251=315250=315251=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
> @@ -339,6 +339,12 @@ public:
>  return clang::isExternallyVisible(getLinkageInternal());
>}
>
> +  /// Determine whether this declaration can be redeclared in a
> +  /// different translation unit.
> +  bool isExternallyDeclarable() const {
> +return isExternallyVisible() && !getOwningModuleForLinkage();
> +  }
> +
>/// \brief Determines the visibility of this entity.
>Visibility getVisibility() const {
>  return getLinkageAndVisibility().getVisibility();
> @@ -379,10 +385,6 @@ public:
>  return hasCachedLinkage();
>}
>
> -  /// Get the module that owns this declaration for linkage purposes.
> -  /// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> -
>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>/// the underlying named decl.
>NamedDecl *getUnderlyingDecl() {
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251=315250=315251=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
> @@ -738,6 +738,10 @@ public:
>  return isFromASTFile() ? getImportedOwningModule() :
> getLocalOwningModule();
>}
>
> +  /// Get the module that owns this declaration for linkage purposes.
> +  /// There only ever is such a module under the C++ Modules TS.
> +  Module *getOwningModuleForLinkage() const;
> +
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>/// \c false, if the owning module is visible within the query context.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315251=315250=315251=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct  9
> 16:42:09 2017
> @@ -4801,6 +4801,9 @@ def err_thread_non_thread : Error<
>  def err_thread_thread_different_kind : Error<
>"thread-local 

  1   2   >