Re: [PATCH] D18957: clang-rename: add missing newline at the end of 'found name:'

2016-04-25 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

Looks good.


http://reviews.llvm.org/D18957



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


[PATCH] D19477: [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-25 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

MSVC doesn't report even warning for cast from private base class to derived.

http://reviews.llvm.org/D19477

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/SemaCXX/ext_ms_downcast.cpp

Index: test/SemaCXX/ext_ms_downcast.cpp
===
--- /dev/null
+++ test/SemaCXX/ext_ms_downcast.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
+
+// Minimal reproducer.
+class A {};
+class B : A {}; // expected-note 2 {{implicitly declared private here}}
+
+B* foo(A* p) {
+  return static_cast(p);
+#ifdef NO_MS_COMPATIBILITY
+  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
+#else
+  // expected-warning@-4 {{cast private base class 'A' to 'B' is a Microsoft 
extension}}
+#endif
+}
+
+A* bar(B* p) {
+  return static_cast(p); // expected-error {{cannot cast 'B' to its 
private base class 'A'}}
+}
+
+// from atlframe.h
+template 
+class CUpdateUI {
+public:
+  CUpdateUI() {
+T* pT = static_cast(this);
+#ifdef NO_MS_COMPATIBILITY
+// expected-error@-2 {{cannot cast private base class}}
+#else
+// expected-warning@-4 {{cast private base class 'CUpdateUI' to 
'CMDIFrame' is a Microsoft extension}}
+#endif
+  }
+};
+
+// from sample WTL/MDIDocVw (mainfrm.h
+class CMDIFrame : CUpdateUI {};
+// expected-note@-1 {{implicitly declared private here}}
+// expected-note@-2 {{in instantiation of member function}}
+
+CMDIFrame wndMain;
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -1344,10 +1344,11 @@
   }
 
   if (!CStyle) {
-switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
-  SrcType, DestType,
-  Paths.front(),
-diag::err_downcast_from_inaccessible_base)) {
+unsigned Diag = Self.getLangOpts().MSVCCompat
+? diag::ext_ms_downcast_from_inaccessible_base
+: diag::err_downcast_from_inaccessible_base;
+switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType, DestType,
+  Paths.front(), Diag)) {
 case Sema::AR_accessible:
 case Sema::AR_delayed: // be optimistic
 case Sema::AR_dependent:   // be optimistic
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5764,6 +5764,9 @@
   "cannot cast %0 to %1 via virtual base %2">;
 def err_downcast_from_inaccessible_base : Error<
   "cannot cast %select{private|protected}2 base class %1 to %0">;
+def ext_ms_downcast_from_inaccessible_base : ExtWarn<
+  "cast %select{private|protected}2 base class %1 to %0 is a Microsoft 
extension">,
+  InGroup;
 def err_upcast_to_inaccessible_base : Error<
   "cannot cast %0 to its %select{private|protected}2 base class %1">;
 def err_bad_dynamic_cast_not_ref_or_ptr : Error<


Index: test/SemaCXX/ext_ms_downcast.cpp
===
--- /dev/null
+++ test/SemaCXX/ext_ms_downcast.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
+
+// Minimal reproducer.
+class A {};
+class B : A {}; // expected-note 2 {{implicitly declared private here}}
+
+B* foo(A* p) {
+  return static_cast(p);
+#ifdef NO_MS_COMPATIBILITY
+  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
+#else
+  // expected-warning@-4 {{cast private base class 'A' to 'B' is a Microsoft extension}}
+#endif
+}
+
+A* bar(B* p) {
+  return static_cast(p); // expected-error {{cannot cast 'B' to its private base class 'A'}}
+}
+
+// from atlframe.h
+template 
+class CUpdateUI {
+public:
+  CUpdateUI() {
+T* pT = static_cast(this);
+#ifdef NO_MS_COMPATIBILITY
+// expected-error@-2 {{cannot cast private base class}}
+#else
+// expected-warning@-4 {{cast private base class 'CUpdateUI' to 'CMDIFrame' is a Microsoft extension}}
+#endif
+  }
+};
+
+// from sample WTL/MDIDocVw (mainfrm.h
+class CMDIFrame : CUpdateUI {};
+// expected-note@-1 {{implicitly declared private here}}
+// expected-note@-2 {{in instantiation of member function}}
+
+CMDIFrame wndMain;
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -1344,10 +1344,11 @@
   }
 
   if (!CStyle) {
-switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
-  SrcType, DestType,
-  

[PATCH] D19478: Remove assert mandating you can only use SPIR target with OpenCL

2016-04-25 Thread Neil Henning via cfe-commits
sheredom created this revision.
sheredom added reviewers: Anastasia, yaxunl, pxli168.
sheredom added a subscriber: cfe-commits.

Remove an assert mandating that OpenCL must be used with the SPIR target. We 
need to be able to use the SPIR target with non-OpenCL inputs, which worked 
perfectly well until commit 264241 introduced an assert that requires OpenCL be 
set in LangOpts.

http://reviews.llvm.org/D19478

Files:
  lib/CodeGen/TargetInfo.cpp

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7390,7 +7390,6 @@
 /// Emit SPIR specific metadata: OpenCL and SPIR version.
 void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
  CodeGen::CodeGenModule &CGM) const {
-  assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL");
   llvm::LLVMContext &Ctx = CGM.getModule().getContext();
   llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx);
   llvm::Module &M = CGM.getModule();


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7390,7 +7390,6 @@
 /// Emit SPIR specific metadata: OpenCL and SPIR version.
 void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
  CodeGen::CodeGenModule &CGM) const {
-  assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL");
   llvm::LLVMContext &Ctx = CGM.getModule().getContext();
   llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx);
   llvm::Module &M = CGM.getModule();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-25 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 54830.
courbet marked an inline comment as done.
courbet added a comment.

overridden_methods return ArrayRef instead of TinyPtrVector*


http://reviews.llvm.org/D19324

Files:
  docs/LibASTMatchersReference.html
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclCXX.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forStmt);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,12 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+const ArrayRef
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this)) return nullptr;
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1260,31 +1260,30 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
+  = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
 return nullptr;
-
   return Pos->second.end();
 }
 
 unsigned
 ASTContext::overridden_met

Re: [PATCH] D18957: clang-rename: add missing newline at the end of 'found name:'

2016-04-25 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Hi,

Can I help anything to get this reviewed, please?

Thanks,

Miklos


http://reviews.llvm.org/D18957



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


[PATCH] D19479: 26748 - clang-cl fails to compile atlctrlw.h header from WTL

2016-04-25 Thread Andrew V. Tischenko via cfe-commits
avt77 created this revision.
avt77 added a reviewer: rnk.
avt77 added a subscriber: cfe-commits.

This is the first patch to fix clang-cl incompatibility prohibited to compile 
the header file. The patch covers the following case:

class CCommandBarCtrlBase {
public:
  typedef int CMsgHookMap;
};

template 
class CCommandBarCtrlImpl : public T {
public:
  void foo() {
void *p = new CMsgHookMap; // "new typename T::CMsgHookMap" works fine
  }
};

void bar() {
  CCommandBarCtrlImpl x;
  x.foo();
}

http://reviews.llvm.org/D19479

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLookup.cpp
  test/Sema/dtp-lookup-in-base-classes.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -2995,6 +2995,27 @@
 TypeRep = Actions.ActOnDelayedDefaultTemplateArg(
 *Tok.getIdentifierInfo(), Tok.getLocation());
   }
+  if (!TypeRep && DSContext == DSC_type_specifier &&
+  Actions.CurContext->isDependentContext() &&
+  getLangOpts().MSVCCompat) {
+IdentifierInfo *II = Tok.getIdentifierInfo();
+Actions.DiagnoseUnknownTypeName(II, Tok.getLocation(), getCurScope(),
+nullptr, TypeRep, true);
+if (TypeRep) {
+  // The action has suggested that the type TypeRep could be used.
+  // Set that as the type in the declaration specifiers,
+  // consume the would-be type name token, and we're done.
+  const char *PrevSpec;
+  unsigned DiagID;
+  DS.SetTypeSpecType(DeclSpec::TST_typename, Tok.getLocation(),
+ PrevSpec, DiagID, TypeRep,
+ Actions.getASTContext().getPrintingPolicy());
+  DS.SetRangeEnd(Tok.getLocation());
+  ConsumeToken();
+  // There may be other declaration specifiers after this.
+  continue;
+}
+  }
 
   // If this is not a typedef name, don't parse it as part of the declspec,
   // it must be an implicit int or an error.
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -4437,13 +4437,6 @@
   DisableTypoCorrection)
 return nullptr;
 
-  // In Microsoft mode, don't perform typo correction in a template member
-  // function dependent context because it interferes with the "lookup into
-  // dependent bases of class templates" feature.
-  if (getLangOpts().MSVCCompat && CurContext->isDependentContext() &&
-  isa(CurContext))
-return nullptr;
-
   // We only attempt to correct typos for identifiers.
   IdentifierInfo *Typo = TypoName.getName().getAsIdentifierInfo();
   if (!Typo)
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -207,9 +207,15 @@
 if (RD && RD->getDescribedClassTemplate())
   FoundTypeDecl = lookupUnqualifiedTypeNameInBase(S, II, NameLoc, RD);
   }
-  if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
-return nullptr;
-
+  if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType) {
+ParsedType Result = nullptr;
+if (S.getLangOpts().MSVCCompat && S.CurContext->isDependentContext()) {
+  auto *II2 = const_cast(&II);
+  S.DiagnoseUnknownTypeName(II2, NameLoc, S.getCurScope(), nullptr, Result,
+false, true);
+}
+return Result;
+  }
   // We found some types in dependent base classes.  Recover as if the user
   // wrote 'typename MyClass::II' instead of 'II'.  We'll fully resolve the
   // lookup during template instantiation.
@@ -553,31 +559,31 @@
   return CurContext->isFunctionOrMethod() || S->isFunctionPrototypeScope();
 }
 
-void Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
-   SourceLocation IILoc,
-   Scope *S,
-   CXXScopeSpec *SS,
+void Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc,
+   Scope *S, CXXScopeSpec *SS,
ParsedType &SuggestedType,
-   bool AllowClassTemplates) {
+   bool AllowClassTemplates,
+   bool AllowInvalid) {
   // We don't have anything to suggest (yet).
   SuggestedType = nullptr;
 
   // There may have been a typo in the name of the type. Look up typo
   // results, in case we have something that we can suggest.
   if (TypoCorrection Corrected =
   CorrectTypo(DeclarationNameInfo(II, IILoc), LookupOrdinaryName, S, SS,
   llvm::make_unique(
-  false, false, AllowClassTemplates),
+  AllowInvali

Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-25 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:89
@@ +88,3 @@
+
+/// Returns true if ValueType is allowed to fold into InitType, i.e. if:
+///   static_cast(ValueType{some_value})

alexfh wrote:
> Is "fold" a commonly used term in this context? At least, it's not a language 
> standard jargon and not something I heard of frequently. Maybe we should try 
> to find a more clear word?
The terminology is from functional programming 
(https://en.wikipedia.org/wiki/Fold_(higher-order_function)), I don't really 
have a better name for these. Do you have anything to suggest ?


http://reviews.llvm.org/D18442



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


Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-25 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 54833.
courbet marked 3 inline comments as done.
courbet added a comment.

Refactoring matchers & cosmetics.


http://reviews.llvm.org/D18442

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/FoldInitTypeCheck.cpp
  clang-tidy/misc/FoldInitTypeCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-fold-init-type.rst
  test/clang-tidy/misc-fold-init-type.cpp

Index: test/clang-tidy/misc-fold-init-type.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-fold-init-type.cpp
@@ -0,0 +1,158 @@
+// RUN: %check_clang_tidy %s misc-fold-init-type %t
+
+namespace std {
+template 
+T accumulate(InputIt first, InputIt last, T init);
+
+template 
+T reduce(InputIt first, InputIt last, T init);
+template 
+T reduce(ExecutionPolicy &&policy,
+ InputIt first, InputIt last, T init);
+
+struct parallel_execution_policy {};
+constexpr parallel_execution_policy par{};
+
+template 
+T inner_product(InputIt1 first1, InputIt1 last1,
+InputIt2 first2, T value);
+
+template 
+T inner_product(ExecutionPolicy &&policy, InputIt1 first1, InputIt1 last1,
+InputIt2 first2, T value);
+
+} // namespace std
+
+struct FloatIterator {
+  typedef float value_type;
+};
+template 
+struct TypedefTemplateIterator { typedef ValueType value_type; };
+template 
+struct UsingTemplateIterator { using value_type = ValueType; };
+template 
+struct DependentTypedefTemplateIterator { typedef typename ValueType::value_type value_type; };
+template 
+struct DependentUsingTemplateIterator : public TypedefTemplateIterator { using typename TypedefTemplateIterator::value_type; };
+using TypedeffedIterator = FloatIterator;
+
+// Positives.
+
+int accumulatePositive1() {
+  float a[1] = {0.5f};
+  return std::accumulate(a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive2() {
+  FloatIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive3() {
+  double a[1] = {0.0};
+  return std::accumulate(a, a + 1, 0.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'double' into type 'float'
+}
+
+int accumulatePositive4() {
+  TypedefTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive5() {
+  UsingTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive6() {
+  DependentTypedefTemplateIterator> it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive7() {
+  TypedeffedIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive8() {
+  DependentUsingTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // FIXME: this one should trigger too.
+}
+
+int reducePositive1() {
+  float a[1] = {0.5f};
+  return std::reduce(a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int reducePositive2() {
+  float a[1] = {0.5f};
+  return std::reduce(std::par, a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int innerProductPositive1() {
+  float a[1] = {0.5f};
+  int b[1] = {1};
+  return std::inner_product(std::par, a, a + 1, b, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int innerProductPositive2() {
+  float a[1] = {0.5f};
+  int b[1] = {1};
+  return std::inner_product(std::par, a, a + 1, b, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+// Negatives.
+
+int negative1() {
+  float a[1] = {0.5f};
+  // This is OK because types match.
+  return std::accumulate(a, a + 1, 0.0);
+}
+
+int negative2() {
+  float a[1] = {0.5f};
+  // This is OK because double is bigger than float.
+  return std::accumulate(a, a + 1, 0.0);
+}
+
+int negative3() {
+  float a[1] = {0.5f};
+  // This is OK because the user explicitly specified T.
+  return std::accumulate(a, a + 1, 0);
+}
+
+int negative4() {
+  TypedefTemplateIterator it;
+  // For now this is OK.
+  return std::accumulate(it, it, 0.0);
+}
+
+int negative5() {
+  float a[1] = {0.5f};
+  float b[1] = {1.0f};
+  return std::inner_product(std::par, a, a + 1, b, 0.0f);
+}
+
+namespace blah {
+namespace std {
+template 
+T accumulate(InputIt, InputIt, T); // We should not care about this one.
+}
+
+int negative5() {
+  float a[1] = {0.5f};
+  // Note that this is using blah::std::accumulate.
+  return s

Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-25 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/AST/OpenMPClause.cpp:546
@@ +545,3 @@
+  for (auto *D : Declarations) {
+if (Cache.count(D))
+  continue;

I think you'd better to count and to store canonical decls rather than the 
decls themselves. It will resolves issues for decls, where one decl is declared 
as an alias to another decl


http://reviews.llvm.org/D19382



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54837.
ioeric added a comment.

- Refactored - added Environment class.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\n\nnamespace C {\n"
+ "namespace D int i; }\n   \n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Set th

r267395 - [OPENMP 4.5] Codegen for 'taskloop' directive.

2016-04-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr 25 07:22:29 2016
New Revision: 267395

URL: http://llvm.org/viewvc/llvm-project?rev=267395&view=rev
Log:
[OPENMP 4.5] Codegen for 'taskloop' directive.

The taskloop construct specifies that the iterations of one or more associated 
loops will be executed in parallel using OpenMP tasks. The iterations are 
distributed across tasks created by the construct and scheduled to be executed.
The next code will be generated for the taskloop directive:
#pragma omp taskloop num_tasks(N) lastprivate(j)
for( i=0; ishareds;
psh->pth_counter = &th_counter;
psh->pcounter = &counter;
psh->pj = &j;
task->lb = 0;
task->ub = N*GRAIN*STRIDE-2;
task->st = STRIDE;
__kmpc_taskloop(
NULL, // location
gtid, // gtid
task, // task structure
1,// if clause value
&task->lb,// lower bound
&task->ub,// upper bound
STRIDE,   // loop increment
0,// 1 if nogroup specified
2,// schedule type: 0-none, 1-grainsize, 2-num_tasks
N,// schedule value (ignored for type 0)
(void*)&__task_dup_entry // tasks duplication routine
);

Added:
cfe/trunk/test/OpenMP/taskloop_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=267395&r1=267394&r2=267395&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Apr 25 07:22:29 2016
@@ -608,9 +608,13 @@ enum OpenMPRTLFunction {
   // Call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32 global_tid,
   // kmp_int32 num_teams, kmp_int32 thread_limit);
   OMPRTL__kmpc_push_num_teams,
-  /// \brief Call to void __kmpc_fork_teams(ident_t *loc, kmp_int32 argc,
-  /// kmpc_micro microtask, ...);
+  // Call to void __kmpc_fork_teams(ident_t *loc, kmp_int32 argc, kmpc_micro
+  // microtask, ...);
   OMPRTL__kmpc_fork_teams,
+  // Call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int
+  // if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int nogroup, int
+  // sched, kmp_uint64 grainsize, void *task_dup);
+  OMPRTL__kmpc_taskloop,
 
   //
   // Offloading related calls
@@ -842,10 +846,11 @@ llvm::Value *CGOpenMPRuntime::emitTaskOu
   assert(!ThreadIDVar->getType()->isPointerType() &&
  "thread id variable must be of type kmp_int32 for tasks");
   auto *CS = cast(D.getAssociatedStmt());
+  auto *TD = dyn_cast(&D);
   CodeGenFunction CGF(CGM, true);
-  CGOpenMPTaskOutlinedRegionInfo CGInfo(
-  *CS, ThreadIDVar, CodeGen, InnermostKind,
-  cast(D).hasCancel(), Action);
+  CGOpenMPTaskOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen,
+InnermostKind,
+TD ? TD->hasCancel() : false, Action);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
   auto *Res = CGF.GenerateCapturedStmtFunction(*CS);
   if (!Tied)
@@ -1433,6 +1438,26 @@ CGOpenMPRuntime::createRuntimeFunction(u
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_fork_teams");
 break;
   }
+  case OMPRTL__kmpc_taskloop: {
+// Build void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int
+// if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int nogroup, int
+// sched, kmp_uint64 grainsize, void *task_dup);
+llvm::Type *TypeParams[] = {getIdentTyPointerTy(),
+CGM.IntTy,
+CGM.VoidPtrTy,
+CGM.IntTy,
+CGM.Int64Ty->getPointerTo(),
+CGM.Int64Ty->getPointerTo(),
+CGM.Int64Ty,
+CGM.IntTy,
+CGM.IntTy,
+CGM.Int64Ty,
+CGM.VoidPtrTy};
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_taskloop");
+break;
+  }
   case OMPRTL__tgt_target: {
 // Build int32_t __tgt_target(int32_t device_id, void *host_ptr, int32_t
 // arg_num, void** args_base, void **args, size_t *arg_sizes, int32_t
@@ -2492,6 +2517,14 @@ enum KmpTaskTFields {
   KmpTaskTPartId,
   /// \brief Function with call of destructors for private variables.
   KmpTaskTDestructors,
+  /// (Taskloops only) Lower bound.
+  KmpTaskTLowerBound,
+  /// (Taskloops only) Upper bound.
+  KmpTaskTUpperBound,
+  /// (Taskloops only) Stride.
+  KmpTaskTStride,
+  /// (Taskloops only) Is last i

Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-25 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.


Comment at: docs/clang-tidy/checks/misc-fold-init-type.rst:16-17
@@ +15,4 @@
+
+.. code:: c++
+  auto a = {0.5f, 0.5f, 0.5f, 0.5f};
+  return std::accumulate(std::begin(a), std::end(a), 0);

Doesn't .. code node need new line?


http://reviews.llvm.org/D18442



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


r267398 - [Clang][AVX512][BUILTIN] Adding intrinsics for VSCATTERPF{1|0}{DPS|QPS|DPD|QPD} instruction set

2016-04-25 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 25 08:01:40 2016
New Revision: 267398

URL: http://llvm.org/viewvc/llvm-project?rev=267398&view=rev
Log:
[Clang][AVX512][BUILTIN] Adding intrinsics for VSCATTERPF{1|0}{DPS|QPS|DPD|QPD} 
instruction set

Differential Revision: http://reviews.llvm.org/D19313


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512pfintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512pf-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=267398&r1=267397&r2=267398&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 25 08:01:40 2016
@@ -6617,6 +6617,86 @@ __builtin_ia32_gathersiv8di ((__v8di) __
   __addr, (__v8si) __index, __mask , __scale);\
 })
 
+#define _mm512_i64scatter_ps(__addr,__index, __v1, __scale) __extension__ ({\
+__builtin_ia32_scatterdiv16sf(__addr, (__mmask8) -1,\
+ (__v8di) __index, (__v8sf) __v1, __scale);\
+})
+
+#define _mm512_mask_i64scatter_ps(__addr, __mask,__index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scatterdiv16sf(__addr, __mask,\
+ (__v8di) __index, (__v8sf) __v1, __scale);\
+})
+
+#define _mm512_i64scatter_epi32(__addr, __index, __v1, __scale) __extension__ 
({\
+__builtin_ia32_scatterdiv16si (__addr, (__mmask8) -1,\
+  (__v8di) __index, (__v8si) __v1, __scale);\
+})
+
+#define _mm512_mask_i64scatter_epi32(__addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scatterdiv16si (__addr, __mask, (__v8di) __index,\
+  (__v8si) __v1, __scale);\
+})
+
+#define _mm512_i64scatter_pd( __addr, __index, __v1, __scale) __extension__ ({\
+__builtin_ia32_scatterdiv8df (__addr, (__mmask8) -1,\
+ (__v8di) __index, (__v8df) __v1, __scale);\
+})
+
+#define _mm512_mask_i64scatter_pd( __addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scatterdiv8df (__addr, __mask, (__v8di) __index,\
+ (__v8df) __v1, __scale);\
+})
+
+#define _mm512_i64scatter_epi64( __addr, __index, __v1, __scale) __extension__ 
({\
+__builtin_ia32_scatterdiv8di (__addr, (__mmask8) -1,\
+ (__v8di) __index, (__v8di) __v1, __scale);\
+})
+
+#define _mm512_mask_i64scatter_epi64( __addr, __mask, __index,  __v1,  
__scale) __extension__ ({\
+__builtin_ia32_scatterdiv8di(__addr, __mask, (__v8di) __index,\
+(__v8di) __v1, __scale);\
+})
+
+#define _mm512_i32scatter_ps( __addr, __index, __v1, __scale) __extension__ ({\
+__builtin_ia32_scattersiv16sf (__addr, (__mmask16) -1,\
+  (__v16si) __index, (__v16sf) __v1, __scale);\
+})
+
+#define _mm512_mask_i32scatter_ps( __addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scattersiv16sf (__addr, __mask, (__v16si) __index,\
+  (__v16sf) __v1, __scale);\
+})
+
+#define _mm512_i32scatter_epi32( __addr, __index, __v1, __scale) __extension__ 
({\
+__builtin_ia32_scattersiv16si (__addr, (__mmask16) -1,\
+  (__v16si) __index, (__v16si) __v1, __scale);\
+})
+
+#define _mm512_mask_i32scatter_epi32( __addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scattersiv16si (__addr, __mask, (__v16si) __index,\
+  (__v16si) __v1, __scale);\
+})
+
+#define _mm512_i32scatter_pd( __addr, __index, __v1, __scale) __extension__ ({\
+__builtin_ia32_scattersiv8df (__addr, (__mmask8) -1,\
+ (__v8si) __index, (__v8df) __v1, __scale);\
+})
+
+#define _mm512_mask_i32scatter_pd( __addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scattersiv8df (__addr, __mask, (__v8si) __index,\
+ (__v8df) __v1, __scale);\
+})
+
+#define _mm512_i32scatter_epi64( __addr, __index, __v1, __scale) __extension__ 
({\
+__builtin_ia32_scattersiv8di (__addr, (__mmask8) -1,\
+ (__v8si) __index, (__v8di) __v1, __scale);\
+})
+
+#define _mm512_mask_i32scatter_epi64( __addr, __mask, __index, __v1, __scale) 
__extension__ ({\
+__builtin_ia32_scattersiv8di (__addr, __mask, (__v8si) __index,\
+ (__v8di) __v1, __scale);\
+})
+
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) 
 {

Modified: cfe/trunk/lib/Headers/avx512pfintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512pfintrin.h?rev=267398&r1=267397&r2=267398&view=diff
==
--- cfe/trunk/lib/Headers/avx512pfintrin.h (original)
+++ cfe/trunk/lib/Headers

Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-04-25 Thread Gonzalo BG via cfe-commits
Dear Richard Smith and Faisal Vali,

this patch broke my code. I've filled a bug report here:
https://llvm.org/bugs/show_bug.cgi?id=27507

I tried to reduce the testcase with delta but over the weekend it only
managed to reduce it from 500k LOC to 300k LOC, sorry for that.

If there is anything I can do to help please let me know.

Keep up the good work!
Gonzalo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19460: Fix incorrect redundant expression in target AMDGPU.

2016-04-25 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

Thanks for catching this.


http://reviews.llvm.org/D19460



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


Re: [PATCH] D19478: Remove assert mandating you can only use SPIR target with OpenCL

2016-04-25 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

LGTM


http://reviews.llvm.org/D19478



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


Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-04-25 Thread Faisal Vali via cfe-commits
I can't access the cpp file- tried cloning the respository - but got
an error - perhaps you can email it to me as a text file?
Faisal Vali



On Mon, Apr 25, 2016 at 8:29 AM, Gonzalo BG  wrote:
> Dear Richard Smith and Faisal Vali,
>
> this patch broke my code. I've filled a bug report here:
> https://llvm.org/bugs/show_bug.cgi?id=27507
>
> I tried to reduce the testcase with delta but over the weekend it only
> managed to reduce it from 500k LOC to 300k LOC, sorry for that.
>
> If there is anything I can do to help please let me know.
>
> Keep up the good work!
> Gonzalo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54848.
ioeric added a comment.

- Merged VirtualEnvironment into Environment.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\n\nnamespace C {\n"
+ "namespace D int i; }\n   \n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // 

Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A few nits.



Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:90
@@ +89,3 @@
+  // It's OK to fold an int into:
+  //  - an int of the same size and signedness.
+  //  - a bigger int, regardless of signedness.

No, I don't have a better name. The fp reference fixes my confusion ;) Maybe 
add this link to the user-facing documentation to tune the readers on the right 
frequency?


Comment at: docs/clang-tidy/checks/misc-fold-init-type.rst:8
@@ +7,3 @@
+result in loss of precision.
+`std::accumulate` folds an input range into a initial value using the type of
+the latter, with `operator+` by default. This can cause loss of precision

s/a initial value/an initial value/


Comment at: docs/clang-tidy/checks/misc-fold-init-type.rst:16-17
@@ +15,4 @@
+
+.. code:: c++
+  auto a = {0.5f, 0.5f, 0.5f, 0.5f};
+  return std::accumulate(std::begin(a), std::end(a), 0);

Prazek wrote:
> Doesn't .. code node need new line?
Yes, it needs a new-line. Also, please verify the documentation actually builds 
with sphinx. On Ubuntu it should boil down to these commands:

  $ sudo apt-get install python-sphinx
  $ mkdir -p /some/build/directory && cd /some/build/directory
  $ cmake /path/to/llvm/ -DLLVM_ENABLE_SPHINX=ON
  $ make docs-clang-tools-html



http://reviews.llvm.org/D18442



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


Re: [PATCH] D19057: [analyzer] Let TK_PreserveContents span across the whole base region.

2016-04-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267413: [analyzer] Let TK_PreserveContents span across the 
whole base region. (authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D19057?vs=53551&id=54852#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19057

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/test/Analysis/call-invalidation.cpp
  cfe/trunk/test/Analysis/malloc.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -177,7 +177,7 @@
 // below for efficiency.
 if (PreserveArgs.count(Idx))
   if (const MemRegion *MR = getArgSVal(Idx).getAsRegion())
-ETraits.setTrait(MR->StripCasts(),
+ETraits.setTrait(MR->getBaseRegion(),
 RegionAndSymbolInvalidationTraits::TK_PreserveContents);
 // TODO: Factor this out + handle the lower level const pointers.
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -920,7 +920,7 @@
 // Invalidate and escape only indirect regions accessible through the source
 // buffer.
 if (IsSourceBuffer) {
-  ITraits.setTrait(R,
+  ITraits.setTrait(R->getBaseRegion(),
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
   ITraits.setTrait(R, RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
   CausesPointerEscape = true;
Index: cfe/trunk/test/Analysis/malloc.c
===
--- cfe/trunk/test/Analysis/malloc.c
+++ cfe/trunk/test/Analysis/malloc.c
@@ -1750,6 +1750,19 @@
   fake_rb_tree_insert_node(rbt, data); // no warning
 }
 
+struct IntAndPtr {
+  int x;
+  int *p;
+};
+
+void constEscape(const void *ptr);
+
+void testConstEscapeThroughAnotherField() {
+  struct IntAndPtr s;
+  s.p = malloc(sizeof(int));
+  constEscape(&(s.x)); // could free s->p!
+} // no-warning
+
 // 
 // False negatives.
 
@@ -1769,3 +1782,9 @@
   // FIXME: This is a leak: if we think a system function won't free p, it
   // won't free (p-1) either.
 }
+
+void testMallocIntoMalloc() {
+  StructWithPtr *s = malloc(sizeof(StructWithPtr));
+  s->memP = malloc(sizeof(int));
+  free(s);
+} // FIXME: should warn here
Index: cfe/trunk/test/Analysis/call-invalidation.cpp
===
--- cfe/trunk/test/Analysis/call-invalidation.cpp
+++ cfe/trunk/test/Analysis/call-invalidation.cpp
@@ -118,3 +118,50 @@
 }
 
 
+struct PlainStruct {
+  int x, y;
+  mutable int z;
+};
+
+PlainStruct glob;
+
+void useAnything(void *);
+void useAnythingConst(const void *);
+
+void testInvalidationThroughBaseRegionPointer() {
+  PlainStruct s1;
+  s1.x = 1;
+  s1.z = 1;
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  // Not only passing a structure pointer through const pointer parameter,
+  // but also passing a field pointer through const pointer parameter
+  // should preserve the contents of the structure.
+  useAnythingConst(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  // FIXME: Should say "UNKNOWN", because it is not uncommon to
+  // modify a mutable member variable through const pointer.
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  useAnything(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{UNKNOWN}}
+}
+
+
+void useFirstConstSecondNonConst(const void *x, void *y);
+void useFirstNonConstSecondConst(void *x, const void *y);
+
+void testMixedConstNonConstCalls() {
+  PlainStruct s2;
+  s2.x = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.x = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267414 - [Clang][Builtin][AVX512]Adding intrinsics for vfpclass{sd|ss} vfpclass{pd|ps} instruction set

2016-04-25 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 25 09:48:23 2016
New Revision: 267414

URL: http://llvm.org/viewvc/llvm-project?rev=267414&view=rev
Log:
[Clang][Builtin][AVX512]Adding intrinsics for vfpclass{sd|ss} vfpclass{pd|ps} 
instruction set

Differential Revision: http://reviews.llvm.org/D19476

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=267414&r1=267413&r2=267414&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 25 09:48:23 2016
@@ -2169,6 +2169,14 @@ TARGET_BUILTIN(__builtin_ia32_permvardf2
 TARGET_BUILTIN(__builtin_ia32_permvardi256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_permvarsf256_mask, 
"V8fV8fV8iV8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_permvarsi256_mask, 
"V8iV8iV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_fpclasspd128_mask, 
"UcV2dIiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_fpclasspd256_mask, 
"UcV4dIiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_fpclassps128_mask, 
"UcV4fIiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_fpclassps256_mask, 
"UcV8fIiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_fpclassps512_mask, "UsV16fIiUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_fpclasspd512_mask, "UcV8dIiUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_fpclasssd_mask, "UcV2dIiUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_fpcla_mask, "UcV4fIiUc","","avx512dq")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=267414&r1=267413&r2=267414&view=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Mon Apr 25 09:48:23 2016
@@ -1099,6 +1099,45 @@ __builtin_ia32_inserti64x2_512_mask ((__
 (__mmask8) ( __U));\
 })
 
+#define _mm512_mask_fpclass_ps_mask( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclassps512_mask ((__v16sf)( __A),\
+  ( __imm),\
+  ( __U));\
+})
+
+#define _mm512_fpclass_ps_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclassps512_mask ((__v16sf)( __A),\
+   ( __imm),\
+   (__mmask16) -1);\
+})
+
+#define _mm512_mask_fpclass_pd_mask( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd512_mask ((__v8df)( __A),\
+  ( __imm),( __U));\
+})
+
+#define _mm512_fpclass_pd_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd512_mask ((__v8df)( __A),\
+  ( __imm),\
+  (__mmask8) -1);\
+})
+
+#define _mm_fpclass_sd_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasssd_mask ((__v2df)( __A), ( __imm), (__mmask8) -1);\
+})
+
+#define _mm_mask_fpclass_sd_mask( __U,__A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasssd_mask ((__v2df)( __A), ( __imm), (__mmask8) __U);\
+})
+
+#define _mm_fpclass_ss_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpcla_mask ((__v4sf)( __A), ( __imm), (__mmask8) -1);\
+})
+
+#define _mm_mask_fpclass_ss_mask(__U ,__A, __imm) __extension__ ({ \
+__builtin_ia32_fpcla_mask ((__v4sf)( __A), ( __imm), (__mmask8) __U);\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vldqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vldqintrin.h?rev=267414&r1=267413&r2=267414&view=diff
==
--- cfe/trunk/lib/Headers/avx512vldqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vldqintrin.h Mon Apr 25 09:48:23 2016
@@ -1206,6 +1206,50 @@ __builtin_ia32_inserti64x2_256_mask ((__
   (__mmask8) ( __U));\
 })
 
+#define _mm_mask_fpclass_pd_mask( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd128_mask ((__v2df)( __A),\
+ ( __imm),( __U));\
+})
+
+#define _mm_fpclass_pd_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd128_mask ((__v2df)( __A),\
+  ( __imm),\
+  (__mmask8) -1);\
+})
+
+#define _mm256_mask_fpclass_pd_mask( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd256_mask ((__v4df)( __A),\
+  ( __imm),( __U));\
+})
+
+#define _mm256_fpclass_pd_mask( __A, __imm) __extension__ ({ \
+__builtin_ia32_fpclasspd256_mask ((__v4df)( __A),\
+  ( __imm),\
+  (__mmask8) -1);\
+})
+
+#define _

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a reviewer: klimek.
klimek added a comment.
This revision is now accepted and ready to land.

We'll probably want Daniel to also take another look over it, as it's a pretty 
substantial change that will haunt us for a while, but I think this now pretty 
much looks like I expect it to look.



Comment at: lib/Format/Format.cpp:1509
@@ +1508,3 @@
+// above.
+IntrusiveRefCntPtr SourceMgr(
+new SourceManager(*Diagnostics, *FileMgr));

Don't name it SourceMgr, as there is a class of that name. Unfortunately we'll 
probably want to name it SM, like everywhere else in clang :(


Comment at: lib/Format/Format.cpp:1454
@@ -1450,8 +1453,3 @@
 public:
-  Formatter(const FormatStyle &Style, SourceManager &SourceMgr, FileID ID,
-ArrayRef Ranges)
-  : Style(Style), ID(ID), SourceMgr(SourceMgr),
-Whitespaces(SourceMgr, Style,
-inputUsesCRLF(SourceMgr.getBufferData(ID))),
-Ranges(Ranges.begin(), Ranges.end()), UnwrappedLines(1),
-Encoding(encoding::detectEncoding(SourceMgr.getBufferData(ID))) {
+  Environment() = delete;
+

Won't deleting this line have the same effect?


Comment at: lib/Format/Format.cpp:1489-1490
@@ +1488,4 @@
+new DiagnosticOptions));
+// This will be passed to the base class `Environment` as reference, so the
+// pointer has to be stored in `Environment` due to the same reason above.
+std::unique_ptr VirtualSM(

There is no base class any more.


Comment at: lib/Format/Format.cpp:1872
@@ +1871,3 @@
+  // it does not make the namespace non-empty.
+  // TODO: error handling if there is no left brace.
+  if (!AnnotatedLines[++CurrentLine]->startsWith(tok::l_brace)) {

In LLVM TODOs are spelled FIXME.


http://reviews.llvm.org/D18551



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


r267413 - [analyzer] Let TK_PreserveContents span across the whole base region.

2016-04-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Apr 25 09:44:25 2016
New Revision: 267413

URL: http://llvm.org/viewvc/llvm-project?rev=267413&view=rev
Log:
[analyzer] Let TK_PreserveContents span across the whole base region.

If an address of a field is passed through a const pointer,
the whole structure's base region should receive the
TK_PreserveContents trait and avoid invalidation.

Additionally, include a few FIXME tests shown up during testing.

Differential Revision: http://reviews.llvm.org/D19057

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/call-invalidation.cpp
cfe/trunk/test/Analysis/malloc.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=267413&r1=267412&r2=267413&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Mon Apr 25 
09:44:25 2016
@@ -920,7 +920,7 @@ ProgramStateRef CStringChecker::Invalida
 // Invalidate and escape only indirect regions accessible through the 
source
 // buffer.
 if (IsSourceBuffer) {
-  ITraits.setTrait(R,
+  ITraits.setTrait(R->getBaseRegion(),
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
   ITraits.setTrait(R, 
RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
   CausesPointerEscape = true;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=267413&r1=267412&r2=267413&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Mon Apr 25 09:44:25 2016
@@ -177,7 +177,7 @@ ProgramStateRef CallEvent::invalidateReg
 // below for efficiency.
 if (PreserveArgs.count(Idx))
   if (const MemRegion *MR = getArgSVal(Idx).getAsRegion())
-ETraits.setTrait(MR->StripCasts(),
+ETraits.setTrait(MR->getBaseRegion(),
 
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
 // TODO: Factor this out + handle the lower level const pointers.
 

Modified: cfe/trunk/test/Analysis/call-invalidation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call-invalidation.cpp?rev=267413&r1=267412&r2=267413&view=diff
==
--- cfe/trunk/test/Analysis/call-invalidation.cpp (original)
+++ cfe/trunk/test/Analysis/call-invalidation.cpp Mon Apr 25 09:44:25 2016
@@ -118,3 +118,50 @@ void testPureConst() {
 }
 
 
+struct PlainStruct {
+  int x, y;
+  mutable int z;
+};
+
+PlainStruct glob;
+
+void useAnything(void *);
+void useAnythingConst(const void *);
+
+void testInvalidationThroughBaseRegionPointer() {
+  PlainStruct s1;
+  s1.x = 1;
+  s1.z = 1;
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  // Not only passing a structure pointer through const pointer parameter,
+  // but also passing a field pointer through const pointer parameter
+  // should preserve the contents of the structure.
+  useAnythingConst(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  // FIXME: Should say "UNKNOWN", because it is not uncommon to
+  // modify a mutable member variable through const pointer.
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  useAnything(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{UNKNOWN}}
+}
+
+
+void useFirstConstSecondNonConst(const void *x, void *y);
+void useFirstNonConstSecondConst(void *x, const void *y);
+
+void testMixedConstNonConstCalls() {
+  PlainStruct s2;
+  s2.x = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.x = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+}

Modified: cfe/trunk/test/Analysis/malloc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=267413&r1=267412&r2=267413&view=diff
==
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Mon Apr 25 09:44:25 2016
@@ -1750,6 +1750,19 @@ void testEscapeThroughSystemCallTakingVo
   fake_rb_tree_insert_node(rbt, 

r267416 - Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Apr 25 10:09:22 2016
New Revision: 267416

URL: http://llvm.org/viewvc/llvm-project?rev=267416&view=rev
Log:
Added Fixer implementation and fix() interface in clang-format for removing 
redundant code.

Summary:
After applying replacements, redundant code like extra commas or empty 
namespaces
might be introduced. Fixer can detect and remove any redundant code introduced 
by replacements.
The current implementation only handles redundant commas.

Reviewers: djasper, klimek

Subscribers: ioeric, mprobst, klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D18551

Added:
cfe/trunk/lib/Format/AffectedRangeManager.cpp
cfe/trunk/lib/Format/AffectedRangeManager.h
cfe/trunk/unittests/Format/CleanupTest.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.h
cfe/trunk/unittests/Format/CMakeLists.txt
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=267416&r1=267415&r2=267416&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Apr 25 10:09:22 2016
@@ -771,6 +771,12 @@ tooling::Replacements formatReplacements
  const tooling::Replacements &Replaces,
  const FormatStyle &Style);
 
+/// \brief Returns the replacements corresponding to applying \p Replaces and
+/// cleaning up the code after that.
+tooling::Replacements
+cleanupAroundReplacements(StringRef Code, const tooling::Replacements 
&Replaces,
+  const FormatStyle &Style);
+
 /// \brief Reformats the given \p Ranges in the file \p ID.
 ///
 /// Each range is extended on either end to its next bigger logic unit, i.e.
@@ -796,6 +802,22 @@ tooling::Replacements reformat(const For
StringRef FileName = "",
bool *IncompleteFormat = nullptr);
 
+/// \brief Clean up any erroneous/redundant code in the given \p Ranges in the
+/// file \p ID.
+///
+/// Returns the ``Replacements`` that clean up all \p Ranges in the file \p ID.
+tooling::Replacements cleanup(const FormatStyle &Style,
+  SourceManager &SourceMgr, FileID ID,
+  ArrayRef Ranges);
+
+/// \brief Clean up any erroneous/redundant code in the given \p Ranges in \p
+/// Code.
+///
+/// Otherwise identical to the cleanup() function using a file ID.
+tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
+  ArrayRef Ranges,
+  StringRef FileName = "");
+
 /// \brief Returns the ``LangOpts`` that the formatter expects you to set.
 ///
 /// \param Style determines specific settings for lexing mode.

Added: cfe/trunk/lib/Format/AffectedRangeManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.cpp?rev=267416&view=auto
==
--- cfe/trunk/lib/Format/AffectedRangeManager.cpp (added)
+++ cfe/trunk/lib/Format/AffectedRangeManager.cpp Mon Apr 25 10:09:22 2016
@@ -0,0 +1,150 @@
+//===--- AffectedRangeManager.cpp - Format C++ code 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements AffectRangeManager class.
+///
+//===--===//
+
+#include "AffectedRangeManager.h"
+
+#include "FormatToken.h"
+#include "TokenAnnotator.h"
+
+namespace clang {
+namespace format {
+
+bool AffectedRangeManager::computeAffectedLines(
+SmallVectorImpl::iterator I,
+SmallVectorImpl::iterator E) {
+  bool SomeLineAffected = false;
+  const AnnotatedLine *PreviousLine = nullptr;
+  while (I != E) {
+AnnotatedLine *Line = *I;
+Line->LeadingEmptyLinesAffected = affectsLeadingEmptyLines(*Line->First);
+
+// If a line is part of a preprocessor directive, it needs to be formatted
+// if any token within the directive is affected.
+if (Line->InPPDirective) {
+  FormatToken *Last = Line->Last;
+  SmallVectorImpl::iterator PPEnd = I + 1;
+  while (PPEnd != E && !(*PPEnd)->First->HasUnescapedNewline) {
+Last = (*PPEnd)->Last;
+++PPEnd;
+  }
+
+  if (affectsTokenRange(*Line->First, *Last,
+/*IncludeLeadingNewlines=*/false)) {
+SomeLineAffected = true;
+markA

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267416: Added Fixer implementation and fix() interface in 
clang-format for removing… (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D18551?vs=54855&id=54857#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18551

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/AffectedRangeManager.cpp
  cfe/trunk/lib/Format/AffectedRangeManager.h
  cfe/trunk/lib/Format/CMakeLists.txt
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/TokenAnnotator.h
  cfe/trunk/unittests/Format/CMakeLists.txt
  cfe/trunk/unittests/Format/CleanupTest.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/unittests/Format/CMakeLists.txt
===
--- cfe/trunk/unittests/Format/CMakeLists.txt
+++ cfe/trunk/unittests/Format/CMakeLists.txt
@@ -3,6 +3,7 @@
   )
 
 add_clang_unittest(FormatTests
+  CleanupTest.cpp
   FormatTest.cpp
   FormatTestJava.cpp
   FormatTestJS.cpp
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
@Daniel, sorry that I forgot to have you look at the final version before
submitting it...

On Mon, Apr 25, 2016 at 5:15 PM Eric Liu  wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL267416: Added Fixer implementation and fix() interface
> in clang-format for removing… (authored by ioeric).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D18551?vs=54855&id=54857#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D18551
>
> Files:
>   cfe/trunk/include/clang/Format/Format.h
>   cfe/trunk/lib/Format/AffectedRangeManager.cpp
>   cfe/trunk/lib/Format/AffectedRangeManager.h
>   cfe/trunk/lib/Format/CMakeLists.txt
>   cfe/trunk/lib/Format/Format.cpp
>   cfe/trunk/lib/Format/TokenAnnotator.h
>   cfe/trunk/unittests/Format/CMakeLists.txt
>   cfe/trunk/unittests/Format/CleanupTest.cpp
>   cfe/trunk/unittests/Format/FormatTest.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54855.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- Addressed comments.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\n\nnamespace C {\n"
+ "namespace D int i; }\n   \n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Eric Liu via cfe-commits
ioeric added a comment.

@Daniel, sorry that I forgot to have you look at the final version before
submitting it...


Repository:
  rL LLVM

http://reviews.llvm.org/D18551



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


Re: [PATCH] D19458: Add address space 258 to Clang documentation

2016-04-25 Thread Michael LeMay via cfe-commits
mlemay-intel added a comment.

In http://reviews.llvm.org/D19458#410042, @mkuper wrote:

> LGTM with a small nit - can you change the heading from "Memory references 
> off the GS segment" to something more general?


Good idea! Thanks for noticing that inconsistency.


http://reviews.llvm.org/D19458



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


Re: [PATCH] D19270: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing constructor bodies.

2016-04-25 Thread Haojian Wu via cfe-commits
hokein added a comment.

@michael_miller

You fixing is not completed. The crash still happens, the test case see 
https://llvm.org/bugs/show_bug.cgi?id=27419.

Could you please take a look on it? Thanks very much.


Repository:
  rL LLVM

http://reviews.llvm.org/D19270



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


[PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-04-25 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader.
yaxunl added subscribers: cfe-commits, pxli168, tstellarAMD.

Add supported OpenCL extensions to target info. It serves as default values to 
save the users of the burden setting each supported extensions and optional 
core features in command line.

In the future a command line option may be added to allow enable/disable each 
supported extension or optional core feature individually.

http://reviews.llvm.org/D19484

Files:
  include/clang/Basic/LangOptions.h
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  lib/Basic/Targets.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/Sema.cpp
  test/CodeGenOpenCL/builtins-r600.cl
  test/Parser/opencl-atomics-cl20.cl
  test/SemaOpenCL/extension-fp64-cl1.1.cl
  test/SemaOpenCL/extension-fp64.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- /dev/null
+++ test/SemaOpenCL/extensions.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
+
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void f2(void) {
+  double d;
+  (void) 1.0;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : disable
+
+void f3(void) {
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+}
Index: test/SemaOpenCL/extension-fp64.cl
===
--- test/SemaOpenCL/extension-fp64.cl
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-
-void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-}
Index: test/SemaOpenCL/extension-fp64-cl1.1.cl
===
--- test/SemaOpenCL/extension-fp64-cl1.1.cl
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
-
-void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
-}
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -44,15 +44,14 @@
 // expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') requires cl_khr_int64_extended_atomics extension to be enabled}}
 // expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_base_atomics extension to be enabled}}
 // expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error@-29 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_fp64 extension to be enabled}}
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-/

Re: [PATCH] D19183: [clang-tidy] Add modernize-make-shared check

2016-04-25 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: test/clang-tidy/modernize-make-shared.cpp:81
@@ +80,3 @@
+
+  std::shared_ptr R(new int());
+

Prazek wrote:
> hokein wrote:
> > Why can't this case convert to  `std::shared_ptr R = 
> > std::make_shared(new int())`?
> You mean std::shared_ptr R = std::make_shared()?
Sorry, I misunderstood this statement before. Just Ignore the comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D19183



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


Re: [PATCH] D19393: Move Checkers.inc to clang/include/.../Checkers

2016-04-25 Thread Chih-Hung Hsieh via cfe-commits
chh marked 2 inline comments as done.
chh added a comment.

I used "svn mv" to move the file and "svn diff --show-copies-as-adds" to 
generate the diff.
If I didn't use "--show-copies-as-adds", the new file was not included/shown by 
phabricator at all.

Please let me know if there is better way to generate and display such diff in 
phabricator.
Thanks.


http://reviews.llvm.org/D19393



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


Re: [PATCH] D19479: 26748 - clang-cl fails to compile atlctrlw.h header from WTL

2016-04-25 Thread Reid Kleckner via cfe-commits
rnk requested changes to this revision.
rnk added a comment.
This revision now requires changes to proceed.

We definitely should not rely on typo correction or other error recovery 
mechanisms to do this for us. Otherwise we can end up accepting ill-formed 
programs like this one:

  struct MyStruct { };
  template 
  struct A : T {
MyStruct * f() { return new MyStructX; } // typo correction will recover to 
MyStruct
  };

I think the right way to do this is to form a dependent AST node like a 
DependentScopeDeclRefExpr. We do the same thing elsewhere under 
-fms-compatibility. This way, we can redo lookup at instantiation time.

The recovered AST of the test case you gave would resemble the source code `new 
typename CCommandBarCtrlImpl::CMsgHookMap`. By using the derived class name 
`CCommandBarCtrlImpl` instead of `T`, we don't have to guess which dependent 
base `CMsgHookMap` is coming from.



Comment at: lib/Sema/SemaLookup.cpp:4440
@@ -4439,3 +4439,1 @@
 
-  // In Microsoft mode, don't perform typo correction in a template member
-  // function dependent context because it interferes with the "lookup into

This is a dangerous change, and should be done as a separate change if we still 
want to do it. I have seen cases where typo correction and -fms-compatibility 
end up fighting, and I don't think they've all been fixed.


http://reviews.llvm.org/D19479



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


r267425 - [Clang][Builtin][AVX512]Adding k-register logic intrinsics KAND, KANDN, KOR, KORTEST, KXNOR, KXOR, KUNPACK instruction set.

2016-04-25 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 25 11:42:29 2016
New Revision: 267425

URL: http://llvm.org/viewvc/llvm-project?rev=267425&view=rev
Log:
[Clang][Builtin][AVX512]Adding k-register logic intrinsics KAND, KANDN, KOR, 
KORTEST, KXNOR, KXOR, KUNPACK instruction set.

Differential Revision: http://reviews.llvm.org/D19466


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=267425&r1=267424&r2=267425&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 25 11:42:29 2016
@@ -2177,6 +2177,14 @@ TARGET_BUILTIN(__builtin_ia32_fpclassps5
 TARGET_BUILTIN(__builtin_ia32_fpclasspd512_mask, "UcV8dIiUc","","avx512dq")
 TARGET_BUILTIN(__builtin_ia32_fpclasssd_mask, "UcV2dIiUc","","avx512dq")
 TARGET_BUILTIN(__builtin_ia32_fpcla_mask, "UcV4fIiUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_kandhi, "UsUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kandnhi, "UsUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_korhi, "UsUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kortestchi, "iUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kortestzhi, "iUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kunpckhi, "UsUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kxnorhi, "UsUsUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_kxorhi, "UsUsUs","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=267425&r1=267424&r2=267425&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 25 11:42:29 2016
@@ -7274,7 +7274,55 @@ _mm512_mask_permutexvar_epi32 (__m512i _
  __M);
 }
 
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kand (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kandhi ((__mmask16) __A, (__mmask16) __B);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kandn (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kandnhi ((__mmask16) __A, (__mmask16) __B);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kor (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_korhi ((__mmask16) __A, (__mmask16) __B);
+}
+
+static __inline__ int __DEFAULT_FN_ATTRS
+_mm512_kortestc (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kortestchi ((__mmask16) __A,
+(__mmask16) __B);
+}
 
+static __inline__ int __DEFAULT_FN_ATTRS
+_mm512_kortestz (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kortestzhi ((__mmask16) __A,
+(__mmask16) __B);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kunpackb (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) 
__B);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kxnor (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kxnorhi ((__mmask16) __A, (__mmask16) __B);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_kxor (__mmask16 __A, __mmask16 __B)
+{
+  return (__mmask16) __builtin_ia32_kxorhi ((__mmask16) __A, (__mmask16) __B);
+}
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=267425&r1=267424&r2=267425&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Apr 25 11:42:29 2016
@@ -5005,3 +5005,51 @@ __m512i test_mm512_mask_permutexvar_epi3
   // CHECK: @llvm.x86.avx512.mask.permvar.si.512
   return _mm512_mask_permutexvar_epi32(__W, __M, __X, __Y); 
 }
+
+__mmask16 test_mm512_kand(__mmask16 __A, __mmask16 __B) {
+  // CHECK-LABEL: @test_mm512_kand
+  // CHECK: @llvm.x86.avx512.kand.w
+  return _mm512_kand(__A, __B); 
+}
+
+__mmask16 test_mm512_kandn(__mmask16 __A, __mmask16 __B) {
+  // CHECK-LABEL: @test_mm512_kandn
+  // CHECK: @llvm.x86.avx512.kandn.w
+  return _mm512_kandn(__A, __B); 
+}
+
+__mmask16 test_mm512_kor(__mmask16 __A, __mmask16 __B) {
+  // CHECK-LABEL: @test_mm512_kor
+  // CHECK: @llvm.x86.avx512.kor.w
+  return _mm512_kor(__A, __B); 
+}
+
+int test_mm512_kortestc(__mmask16 __A, __mmask16 __B) {
+  // CHECK-LABEL: @test_mm512_kortestc
+  // CHECK: @llvm.x86.avx512.kortestc.w
+  return _mm512_kortestc(__A, __B); 
+}
+
+int test_mm512_kortestz(__mmask16 __A, __mmask16 __B) {
+  // CHEC

Re: [PATCH] D19443: Module Debugging: Fix the condition for determining whether a template instantiation is in a module.

2016-04-25 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

Yeah, this LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D19443



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


Re: [PATCH] D19336: Repair redeclaration chain of friend template functions.

2016-04-25 Thread Serge Pavlov via cfe-commits
2016-04-21 2:57 GMT+06:00 Richard Smith :

> rsmith added a comment.
>
> Sorry, I don't think this approach can work. Consider:
>
>   template struct X {
> template friend void f(T);
> template friend void f(U);
>   };
>
> These two friend declarations declare different friend function templates,
> but this transformation would incorrectly make them have the same type and
> be redeclarations of each other.
>
>  Yes, it's true, thank you for the example. I think dependent friend
template functions should not be added into redeclaration chains.

I think the right thing here is to just accept that a friend function
> template declared within a class template will not be part of the
> corresponding redeclaration chain. But that's fine, so long as we don't try
> to inject the function template into the surrounding scope -- when we come
> to instantiate the class template, the instantiated friend function
> template will have the right type and will be part of the relevant
> redeclaration chain.
>
> Redeclaration chain of templates are useful for checking semantics of
templates, not instantiated entities, which have own redeclaration chains.
Particular task for which this fix should be useful is implementation of
default template arguments of friend functions. Now clang do not allow to
specify them, but the standard allow [temp.parap]p9 : "... If a friend
function template declaration specifies a default template-argument, that
declaration shall be a definition and shall be the only declaration of the
function template in the translation unit". The mentioned condition could
be checked using redeclaration chain of templates, if the chain was built
correctly.

The main problem related to the redeclaration chains is similar to that
solved by http://reviews.llvm.org/D16989. Clang and GCC now treat friend
function definitions differently. The following code:

template void func();

template
struct C1 {
  template friend void func() {}
};

int main(int argc, char *argv[]) {
  func();
}


produces error at link stage if GCC is used, due to unresolved reference to
func().  Clang compiles this code successfully, it sees the definition
of func inside struct C1. GCC sees it only if host template is instantiated.

It makes sense to finish http://reviews.llvm.org/D16989 first. Many of
problems related to not-template friend functions seem to be applicable to
templates as well.

Thanks,
--Serge



Без
вирусов. www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19477: [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-25 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5768
@@ +5767,3 @@
+def ext_ms_downcast_from_inaccessible_base : ExtWarn<
+  "cast %select{private|protected}2 base class %1 to %0 is a Microsoft 
extension">,
+  InGroup;

Maybe:
  casting from %select{private|protected}2 base class %1 to derived class %0 is 
a Microsoft extension


http://reviews.llvm.org/D19477



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


Re: [PATCH] D19459: Cleanup redundant expression in InstCombineAndOrXor.

2016-04-25 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

FYI David Majnemer is a good reviewer for InstCombine.


http://reviews.llvm.org/D19459



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


Re: [PATCH] D19425: driver: Add a `--rsp-quoting` flag to choose which unquoting behavior to use in rsp files.

2016-04-25 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good



Comment at: tools/driver/driver.cpp:350
@@ +349,3 @@
+  for (const char *F : argv) {
+if (strcmp(F, "--rsp-quoting=posix") == 0)
+  RSPQuoting = POSIX;

Should we call it "posix" or "gnu"? The reference implementation we are trying 
to match is part of libiberty, which is why I called the tokenizer 
TokenizeGNUCommandLine.


http://reviews.llvm.org/D19425



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-04-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:8611-8612
@@ -8609,3 +8610,4 @@
 } else {
-  // This needs to happen first so that 'inline' propagates.
-  NewFD->setPreviousDeclaration(cast(OldDecl));
+  if (NewFD->isOutOfLine() &&
+  NewFD->getLexicalDeclContext()->isDependentContext() &&
+  IsDefinition)

Please factor this check out into a suitably-named function, 
`shouldLinkDependentDeclWithPrevious` or similar, and pass in `OldDecl` as 
well. I imagine we'll want to call this from multiple places (for instance, 
when handling `VarDecl`s), and I can see a few ways of making it return `true` 
in more cases, which would allow us to provide more precise diagnostics in a 
few more cases.

(For instance, if the old and new declarations are in the same lexical context, 
we can mark them as redeclarations, and more generally I think we can do so if 
the new declaration has no more template parameters in scope than the old one 
did and the old declaration is declared within the current instantiation of the 
new declaration).


Comment at: lib/Sema/SemaDecl.cpp:8613
@@ +8612,3 @@
+  NewFD->getLexicalDeclContext()->isDependentContext() &&
+  IsDefinition)
+// Do not put friend function definitions found in template classes to

I don't think it makes sense to check whether the template declaration is a 
definition. It should not be added to the redeclaration chain regardless of 
whether it's a definition.


Comment at: lib/Sema/SemaDecl.cpp:10951-10956
@@ -10941,1 +10950,8 @@
SkipBodyInfo *SkipBody) {
+  // Don't complain if the given declaration corresponds to the friend function
+  // declared in a template class. Such declaration defines the function only 
if
+  // the template is instantiated, in the latter case the definition must be
+  // found in corresponding class instantiation.
+  if (FD->isOutOfLine() && FD->getLexicalDeclContext()->isDependentContext())
+return;
+

Is this change necessary? If we're not putting dependent templates into 
redeclaration chains any more, we shouldn't find an existing definition ...


Comment at: lib/Sema/SemaDecl.cpp:10962
@@ -10945,3 +10961,3 @@
   if (!Definition)
 if (!FD->isDefined(Definition))
   return;

... down here.


Comment at: lib/Sema/SemaDeclCXX.cpp:12663-12673
@@ -12662,1 +12662,13 @@
 
+  // If a friend non-dependent function is declared in a dependent context, do
+  // not put it into redeclaration chain of corresponding file level
+  // declarations. Such function will be available when the template will be
+  // instantiated.
+  } else if (CurContext->isDependentContext() &&
+ (D.getName().getKind() != UnqualifiedId::IK_TemplateId) &&
+ (SS.isInvalid() || !SS.isSet())) {
+DC = CurContext;
+while (!DC->isFileContext())
+  DC = DC->getParent();
+LookupName(Previous, S);
+

What do these changes have to do with avoiding putting the declaration into the 
redeclaration chain? This looks equivalent to what the following `if` block 
will do, except that (a) it uses `LookupName` instead of `LookupQualifiedName` 
(which might be a bug fix but doesn't seem related to whether the context was 
dependent), and (b) it forgets to set `DCScope` (which looks like a bug).


http://reviews.llvm.org/D16989



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


Re: [PATCH] D11397: [libcxx] Add first bits of

2016-04-25 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

I've been working on this a bunch and will repost it with the new changes later 
next week.


http://reviews.llvm.org/D11397



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


r267444 - When deducing template parameters from base classes of an argument type, don't

2016-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 25 14:09:05 2016
New Revision: 267444

URL: http://llvm.org/viewvc/llvm-project?rev=267444&view=rev
Log:
When deducing template parameters from base classes of an argument type, don't
preserve any deduced types from a failed deduction to a subsequent attempt at
deduction. Patch by Erik Pilkington!

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=267444&r1=267443&r2=267444&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Apr 25 14:09:05 2016
@@ -1418,87 +1418,94 @@ DeduceTemplateArgumentsByTypeMatch(Sema
 // TT
 // TT<>
 case Type::TemplateSpecialization: {
-  const TemplateSpecializationType *SpecParam
-= cast(Param);
+  const TemplateSpecializationType *SpecParam =
+  cast(Param);
 
-  // Try to deduce template arguments from the template-id.
-  Sema::TemplateDeductionResult Result
-= DeduceTemplateArguments(S, TemplateParams, SpecParam, Arg,
-  Info, Deduced);
-
-  if (Result && (TDF & TDF_DerivedClass)) {
-// C++ [temp.deduct.call]p3b3:
-//   If P is a class, and P has the form template-id, then A can be a
-//   derived class of the deduced A. Likewise, if P is a pointer to a
-//   class of the form template-id, A can be a pointer to a derived
-//   class pointed to by the deduced A.
-//
-// More importantly:
-//   These alternatives are considered only if type deduction would
-//   otherwise fail.
-if (const RecordType *RecordT = Arg->getAs()) {
-  // We cannot inspect base classes as part of deduction when the type
-  // is incomplete, so either instantiate any templates necessary to
-  // complete the type, or skip over it if it cannot be completed.
-  if (!S.isCompleteType(Info.getLocation(), Arg))
-return Result;
-
-  // Use data recursion to crawl through the list of base classes.
-  // Visited contains the set of nodes we have already visited, while
-  // ToVisit is our stack of records that we still need to visit.
-  llvm::SmallPtrSet Visited;
-  SmallVector ToVisit;
-  ToVisit.push_back(RecordT);
-  bool Successful = false;
-  SmallVector DeducedOrig(Deduced.begin(),
-  Deduced.end());
-  while (!ToVisit.empty()) {
-// Retrieve the next class in the inheritance hierarchy.
-const RecordType *NextT = ToVisit.pop_back_val();
-
-// If we have already seen this type, skip it.
-if (!Visited.insert(NextT).second)
-  continue;
-
-// If this is a base class, try to perform template argument
-// deduction from it.
-if (NextT != RecordT) {
-  TemplateDeductionInfo BaseInfo(Info.getLocation());
-  Sema::TemplateDeductionResult BaseResult
-= DeduceTemplateArguments(S, TemplateParams, SpecParam,
-  QualType(NextT, 0), BaseInfo,
-  Deduced);
-
-  // If template argument deduction for this base was successful,
-  // note that we had some success. Otherwise, ignore any 
deductions
-  // from this base class.
-  if (BaseResult == Sema::TDK_Success) {
-Successful = true;
-DeducedOrig.clear();
-DeducedOrig.append(Deduced.begin(), Deduced.end());
-Info.Param = BaseInfo.Param;
-Info.FirstArg = BaseInfo.FirstArg;
-Info.SecondArg = BaseInfo.SecondArg;
-  }
-  else
-Deduced = DeducedOrig;
-}
-
-// Visit base classes
-CXXRecordDecl *Next = cast(NextT->getDecl());
-for (const auto &Base : Next->bases()) {
-  assert(Base.getType()->isRecordType() &&
- "Base class that isn't a record?");
-  ToVisit.push_back(Base.getType()->getAs());
-}
-  }
-
-  if (Successful)
-return Sema::TDK_Success;
+  // When Arg cannot be a derived class, we can just try to deduce template
+  // arguments from the template-id.
+  const RecordType *RecordT = Arg->getAs();
+  if (!(TDF & TDF_DerivedClass) || !RecordT)
+return DeduceTemplateArguments(S, TemplateParams, SpecParam, Arg, Info,
+   Deduced);
+
+  Sm

Re: [PATCH] D19194: fix for clang-tidy modernize-pass-by-value on copy constructor

2016-04-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

This test doesn't fail without your fix.



Comment at: clang-tidy/modernize/PassByValueCheck.cpp:155
@@ -155,1 +154,3 @@
+.bind("Initializer")),
+ unless(isCopyConstructor()))
 .bind("Ctor"),

This submatcher is much cheaper, so it should go first to make the whole 
matcher more efficient.


http://reviews.llvm.org/D19194



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


Re: [PATCH] D19425: driver: Add a `--rsp-quoting` flag to choose which unquoting behavior to use in rsp files.

2016-04-25 Thread Nico Weber via cfe-commits
thakis added a comment.

Thanks!



Comment at: tools/driver/driver.cpp:350
@@ +349,3 @@
+  for (const char *F : argv) {
+if (strcmp(F, "--rsp-quoting=posix") == 0)
+  RSPQuoting = POSIX;

rnk wrote:
> Should we call it "posix" or "gnu"? The reference implementation we are 
> trying to match is part of libiberty, which is why I called the tokenizer 
> TokenizeGNUCommandLine.
I figured the reference implementation tries to implement 
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html from 
posix, but I don't care much about the name. If you prefer gnu, I'm happy to 
use gnu. (In the same vein: Do you have an opinion on "windows" vs "cl" vs 
"msvc"?)


http://reviews.llvm.org/D19425



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


Re: [PATCH] D19478: Remove assert mandating you can only use SPIR target with OpenCL

2016-04-25 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

LGTM, just wondering other languages will compile to SPIR too?


http://reviews.llvm.org/D19478



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-25 Thread Yaxun Liu via cfe-commits
yaxunl marked 12 inline comments as done.
yaxunl added a comment.

Changed file name to opencl-c.h and updated comments.

Addressed Anastasia's early comments.

I am thinking we may need several more patches to address remaining issues to 
keep the changes manageable.



Comment at: lib/Headers/opencl-12.h:585
@@ +584,3 @@
+double16 const_func __attribute__((overloadable)) cbrt(double16);
+//half const_func __attribute__((overloadable)) cbrt(half);
+//half2 const_func __attribute__((overloadable)) cbrt(half2);

Anastasia wrote:
> Why commented code here?
Fixed.


Comment at: lib/Headers/opencl-20.h:4150
@@ +4149,3 @@
+ */
+#define as_char(x) __builtin_astype((x), char)
+#define as_char2(x) __builtin_astype((x), char2)

Anastasia wrote:
> I think we should have a normal declaration of these BIFs, because otherwise 
> this won't appear as a symbol anywhere and would prevent for example error 
> reporting with the original OpenCL function name.
> 
> An implementation of the builtin function can just call the Clang builtin 
> __builtin_astype in its definition. This is also more general approach in 
> case some implementations will decide to do something else here. 
as_type is defined as operators in v1.2 s6.2.4.2 instead of as builtin 
functions in 6.12. 


Comment at: lib/Headers/opencl-20.h:9866
@@ +9865,3 @@
+
+// TODO: fast_normalize(half)?
+

Anastasia wrote:
> There is a TODO here!
Fixed.


Comment at: lib/Headers/opencl-20.h:11213
@@ +11212,3 @@
+#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
+#define CLK_NULL_RESERVE_ID 
(__builtin_astype(((void*)(~PIPE_RESERVE_ID_VALID_BIT)), reserve_id_t))
+bool __attribute__((overloadable)) is_valid_reserve_id(reserve_id_t 
reserve_id);

Anastasia wrote:
> This doesn't come directly from Spec.
s6.13.16 requires macro CLK_NULL_RESERVE_ID to be defined.


Comment at: lib/Headers/opencl-20.h:11222
@@ +11221,3 @@
+#define MAX_WORK_DIM3
+typedef struct {
+unsigned int workDimension;

Anastasia wrote:
> This isn't defined by Spec but it seems sensible to define it this way.
> 
> However, there is a conflict here as ndrange_t is already added as a Clang 
> builtin type:
> https://llvm.org/svn/llvm-project/cfe/trunk@247676
>  and it is compiled to opaque type in IR. However, considering that we can 
> have local variables and returns of this type, we might remove it from Clang 
> type then and add it here in a header.
> 
> Any thoughts?
We need another patch to address this. For now I suggest keep the clang 
definition of ndrange_t and remove this from header.


Comment at: lib/Headers/opencl-20.h:11251
@@ +11250,3 @@
+int __attribute__((overloadable))
+enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags,
+   const ndrange_t ndrange, void (^block)(local void *, ...),

Anastasia wrote:
> I think I would prefer to add an enqueue kernel as a Clang builtin because it 
> requires custom check of type of variadic arguments as well as block 
> arguments.
need another patch for this work.


Comment at: lib/Headers/opencl-20.h:11263
@@ +11262,3 @@
+uint __attribute__((overloadable)) get_kernel_work_group_size(void 
(^block)(void));
+uint __attribute__((overloadable)) get_kernel_work_group_size(void 
(^block)(local void *, ...));
+uint __attribute__((overloadable)) 
get_kernel_preferred_work_group_size_multiple(void (^block)(void));

Anastasia wrote:
> Also here we need a special check of parameters to block, and therefore it 
> should be added as a Clang builtin.
need another patch


Comment at: lib/Headers/opencl-20.h:11572
@@ +11571,3 @@
+
+#define ATOMIC_VAR_INIT(x) (x)
+

Anastasia wrote:
> I think this should be target specific?
We need a uniform representation for this macro in SPIR. As far as I know this 
works fine on different platforms. If a target needs special handling of this 
macro condition macro maybe added.


Comment at: lib/Headers/opencl-20.h:11605
@@ +11604,3 @@
+
+#define atomic_init_prototype(TYPE) \
+atomic_init_prototype_addrspace(TYPE, generic)

Anastasia wrote:
> Could you change atomic_init_prototype to upper case letters to match the 
> style?
> 
> The same below.
> 
> Also it seems like some BIFs are declared with macros and some not. Any 
> system there?
Fixed.

The newly added builtin functions of opencl 2.0 are using macros.



Comment at: lib/Headers/opencl-20.h:11886
@@ +11885,3 @@
+
+__global  void* __attribute__((overloadable)) to_global(void*);
+__local   void* __attribute__((overloadable)) to_local(void*);

Anastasia wrote:
> This isn't correct prototype according to Spec though. It should take any 
> pointer type and not a void*.
> 
> This approach will introduce extra type conversions and might lead 

r267447 - [Docs] Clarify what the object-size sanitizer does.

2016-04-25 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Apr 25 14:21:45 2016
New Revision: 267447

URL: http://llvm.org/viewvc/llvm-project?rev=267447&view=rev
Log:
[Docs] Clarify what the object-size sanitizer does.

Currently, the UBSan docs make it sound like the object-size sanitizer
will only detect out-of-bounds reads/writes. It also catches some
operations that don't necessarily access memory (invalid downcasts,
calls of methods on invalid pointers, ...). This patch adds a note
about this behavior in the docs.


Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=267447&r1=267446&r2=267447&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Apr 25 14:21:45 2016
@@ -92,11 +92,14 @@ Available checks are:
  parameter which is declared to never be null.
   -  ``-fsanitize=null``: Use of a null pointer or creation of a null
  reference.
-  -  ``-fsanitize=object-size``: An attempt to use bytes which the
- optimizer can determine are not part of the object being
- accessed. The sizes of objects are determined using
- ``__builtin_object_size``, and consequently may be able to detect
- more problems at higher optimization levels.
+  -  ``-fsanitize=object-size``: An attempt to potentially use bytes which
+the optimizer can determine are not part of the object being accessed.
+This will also detect some types of undefined behavior that may not
+directly access memory, but are provably incorrect given the size of
+the objects involved, such as invalid downcasts and calling methods on
+invalid pointers. These checks are made in terms of
+``__builtin_object_size``, and consequently may be able to detect more
+problems at higher optimization levels.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer


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


Re: [PATCH] D19459: Cleanup redundant expression in InstCombineAndOrXor.

2016-04-25 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

thx Reid. added the appropriate reviewer.


http://reviews.llvm.org/D19459



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


r267453 - Refactor traversal of bases in deduction of template parameters from base

2016-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 25 14:28:08 2016
New Revision: 267453

URL: http://llvm.org/viewvc/llvm-project?rev=267453&view=rev
Log:
Refactor traversal of bases in deduction of template parameters from base
classes of an argument to use CXXRecordDecl::forallBases. Fix forallBases to
only visit each base class once.

Modified:
cfe/trunk/lib/AST/CXXInheritance.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=267453&r1=267452&r2=267453&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Mon Apr 25 14:28:08 2016
@@ -137,6 +137,7 @@ CXXRecordDecl::isCurrentInstantiation(co
 bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
 bool AllowShortCircuit) const {
   SmallVector Queue;
+  llvm::SmallPtrSet Enqueued;
 
   const CXXRecordDecl *Record = this;
   bool AllMatches = true;
@@ -158,12 +159,14 @@ bool CXXRecordDecl::forallBases(ForallBa
 AllMatches = false;
 continue;
   }
-  
-  Queue.push_back(Base);
-  if (!BaseMatches(Base)) {
-if (AllowShortCircuit) return false;
-AllMatches = false;
-continue;
+
+  if (Enqueued.insert(Base).second) {
+Queue.push_back(Base);
+if (!BaseMatches(Base)) {
+  if (AllowShortCircuit) return false;
+  AllMatches = false;
+  continue;
+}
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=267453&r1=267452&r2=267453&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Apr 25 14:28:08 2016
@@ -1454,54 +1454,35 @@ DeduceTemplateArgumentsByTypeMatch(Sema
   //   otherwise fail. If they yield more than one possible deduced A, the
   //   type deduction fails.
 
-  // Reset the incorrectly deduced argument from above.
-  Deduced = DeducedOrig;
-
-  // Use data recursion to crawl through the list of base classes.
-  // Visited contains the set of nodes we have already visited, while
-  // ToVisit is our stack of records that we still need to visit.
-  llvm::SmallPtrSet Visited;
-  SmallVector ToVisit;
-  ToVisit.push_back(RecordT);
   bool Successful = false;
-  while (!ToVisit.empty()) {
-// Retrieve the next class in the inheritance hierarchy.
-const RecordType *NextT = ToVisit.pop_back_val();
-
-// If we have already seen this type, skip it.
-if (!Visited.insert(NextT).second)
-  continue;
-
-// If this is a base class, try to perform template argument
-// deduction from it.
-if (NextT != RecordT) {
-  TemplateDeductionInfo BaseInfo(Info.getLocation());
-  Sema::TemplateDeductionResult BaseResult =
-  DeduceTemplateArguments(S, TemplateParams, SpecParam,
-  QualType(NextT, 0), BaseInfo, Deduced);
-
-  // If template argument deduction for this base was successful,
-  // note that we had some success. Otherwise, ignore any deductions
-  // from this base class.
-  if (BaseResult == Sema::TDK_Success) {
-Successful = true;
-DeducedOrig.clear();
-DeducedOrig.append(Deduced.begin(), Deduced.end());
-Info.Param = BaseInfo.Param;
-Info.FirstArg = BaseInfo.FirstArg;
-Info.SecondArg = BaseInfo.SecondArg;
-  } else
-Deduced = DeducedOrig;
+  RecordT->getAsCXXRecordDecl()->forallBases([&](
+  const CXXRecordDecl *Base) {
+// Start with a fresh copy of the old deduced arguments.
+SmallVector 
DeducedBase(DeducedOrig.begin(),
+DeducedOrig.end());
+
+TemplateDeductionInfo BaseInfo(Info.getLocation());
+Sema::TemplateDeductionResult BaseResult =
+DeduceTemplateArguments(S, TemplateParams, SpecParam,
+S.Context.getRecordType(Base),
+BaseInfo, DeducedBase);
+
+// If template argument deduction for this base was successful,
+// note that we had some success. Otherwise, ignore any deductions
+// from this base class.
+if (BaseResult == Sema::TDK_Success) {
+  // FIXME: If we've already been successful, deduction should fail
+  // due to ambiguity.
+  Successful = true;
+  Deduced.swap(DeducedBase);
+  Info.Param = BaseInfo.Param;
+  Info.FirstArg = BaseInfo.FirstArg;
+ 

Re: [PATCH] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

2016-04-25 Thread Richard Smith via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Committed as r267444.

I refactored it to use `CXXRecordDecl::forallBases` instead of a hand-rolled 
traversal of the base classes in r267453.


http://reviews.llvm.org/D18868



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


r267454 - Implement support for conditional between xvalues of reference-compatible

2016-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 25 14:30:37 2016
New Revision: 267454

URL: http://llvm.org/viewvc/llvm-project?rev=267454&view=rev
Log:
Implement support for conditional between xvalues of reference-compatible
types. Patch by Erik Pilkington!

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/conditional-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=267454&r1=267453&r2=267454&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Apr 25 14:30:37 2016
@@ -4795,7 +4795,7 @@ QualType Sema::CheckPointerToMemberOpera
   return Result;
 }
 
-/// \brief Try to convert a type to another according to C++0x 5.16p3.
+/// \brief Try to convert a type to another according to C++11 5.16p3.
 ///
 /// This is part of the parameter validation for the ? operator. If either
 /// value operand is a class type, the two operands are attempted to be
@@ -4811,17 +4811,21 @@ static bool TryClassUnification(Sema &Se
 
   InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(),
SourceLocation());
-  // C++0x 5.16p3
+  // C++11 5.16p3
   //   The process for determining whether an operand expression E1 of type T1
   //   can be converted to match an operand expression E2 of type T2 is defined
   //   as follows:
-  //   -- If E2 is an lvalue:
-  bool ToIsLvalue = To->isLValue();
-  if (ToIsLvalue) {
-//   E1 can be converted to match E2 if E1 can be implicitly converted to
-//   type "lvalue reference to T2", subject to the constraint that in the
-//   conversion the reference must bind directly to E1.
-QualType T = Self.Context.getLValueReferenceType(ToType);
+  //   -- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly converted to type "lvalue reference to T2", subject to the
+  //  constraint that in the conversion the reference must bind directly to
+  //  an lvalue.
+  //   -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be
+  //  implicitly conveted to the type "rvalue reference to R2", subject to
+  //  the constraint that the reference must bind directly.
+  if (To->isLValue() || To->isXValue()) {
+QualType T = To->isLValue() ? Self.Context.getLValueReferenceType(ToType)
+: Self.Context.getRValueReferenceType(ToType);
+
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
 
 InitializationSequence InitSeq(Self, Entity, Kind, From);

Modified: cfe/trunk/test/SemaCXX/conditional-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conditional-expr.cpp?rev=267454&r1=267453&r2=267454&view=diff
==
--- cfe/trunk/test/SemaCXX/conditional-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/conditional-expr.cpp Mon Apr 25 14:30:37 2016
@@ -384,3 +384,12 @@ namespace PR17052 {
 int &test() { return b_ ? i_ : throw 1; }
   };
 }
+
+namespace PR26448 {
+struct Base {};
+struct Derived : Base {};
+Base b;
+Derived d;
+typedef decltype(true ? static_cast(b) : static_cast(d)) x;
+typedef Base &&x;
+}


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


Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-04-25 Thread Richard Smith via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Committed as r267454.


http://reviews.llvm.org/D17451



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


Re: [PATCH] D19425: driver: Add a `--rsp-quoting` flag to choose which unquoting behavior to use in rsp files.

2016-04-25 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: tools/driver/driver.cpp:350
@@ +349,3 @@
+  for (const char *F : argv) {
+if (strcmp(F, "--rsp-quoting=posix") == 0)
+  RSPQuoting = POSIX;

thakis wrote:
> rnk wrote:
> > Should we call it "posix" or "gnu"? The reference implementation we are 
> > trying to match is part of libiberty, which is why I called the tokenizer 
> > TokenizeGNUCommandLine.
> I figured the reference implementation tries to implement 
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html from 
> posix, but I don't care much about the name. If you prefer gnu, I'm happy to 
> use gnu. (In the same vein: Do you have an opinion on "windows" vs "cl" vs 
> "msvc"?)
I buy that reasoning, let's use "posix" then.

I also like "windows" for the other style. The algorithm documented at 
https://msdn.microsoft.com/en-us/library/17w5ykft(v=vs.85).aspx is pretty 
standard. New versions of mingw use the exact same algorithm.


http://reviews.llvm.org/D19425



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


Re: r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-25 Thread Reid Kleckner via cfe-commits
On Fri, Apr 22, 2016 at 1:58 PM, Richard Smith 
wrote:
>
> This seems like a fragile thing to rely on. What about template
> instantiation performed at end of TU? (I /think/ that case is currently
> fine because all the kinds of template we instantiate ultimately do result
> in a call to HandleTopLevelDecl or some other ASTConsumer callback, but I
> don't really like relying on that.)
>
> Could we trigger processing of any remaining deferred declarations in
> HandleTranslationUnit?
>

We could, but we already have this assert in the destructor:
  // There should normally not be any leftover inline method
definitions.
  assert(DeferredInlineMethodDefinitions.empty() ||
 Diags.hasErrorOccurred());

If we ever break the invariant that HandleTopLevelDecl will be called some
time after deferring a decl, we will find out about it eventually.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19459: Cleanup redundant expression in InstCombineAndOrXor.

2016-04-25 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.

LGTM


http://reviews.llvm.org/D19459



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


Re: r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-25 Thread Richard Smith via cfe-commits
On Mon, Apr 25, 2016 at 1:04 PM, Reid Kleckner  wrote:

> On Fri, Apr 22, 2016 at 1:58 PM, Richard Smith 
> wrote:
>>
>> This seems like a fragile thing to rely on. What about template
>> instantiation performed at end of TU? (I /think/ that case is currently
>> fine because all the kinds of template we instantiate ultimately do result
>> in a call to HandleTopLevelDecl or some other ASTConsumer callback, but I
>> don't really like relying on that.)
>>
>> Could we trigger processing of any remaining deferred declarations in
>> HandleTranslationUnit?
>>
>
> We could, but we already have this assert in the destructor:
>   // There should normally not be any leftover inline method
> definitions.
>   assert(DeferredInlineMethodDefinitions.empty() ||
>  Diags.hasErrorOccurred());
>
> If we ever break the invariant that HandleTopLevelDecl will be called some
> time after deferring a decl, we will find out about it eventually.
>

OK. This seems like a fairly arbitrary thing to have in the ASTConsumer
contract, but in practice it does seem like it ought to hold.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19458: Add address space 258 to Clang documentation

2016-04-25 Thread Michael LeMay via cfe-commits
mlemay-intel updated this revision to Diff 54877.
mlemay-intel added a comment.

Update heading.


http://reviews.llvm.org/D19458

Files:
  docs/LanguageExtensions.rst

Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1912,12 +1912,13 @@
 
 The X86 backend has these language extensions:
 
-Memory references off the GS segment
-
+Memory references to specified segments
+^^^
 
 Annotating a pointer with address space #256 causes it to be code generated
-relative to the X86 GS segment register, and address space #257 causes it to be
-relative to the X86 FS segment.  Note that this is a very very low-level
+relative to the X86 GS segment register, address space #257 causes it to be
+relative to the X86 FS segment, and address space #258 causes it to be
+relative to the X86 SS segment.  Note that this is a very very low-level
 feature that should only be used if you know what you're doing (for example in
 an OS kernel).
 


Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1912,12 +1912,13 @@
 
 The X86 backend has these language extensions:
 
-Memory references off the GS segment
-
+Memory references to specified segments
+^^^
 
 Annotating a pointer with address space #256 causes it to be code generated
-relative to the X86 GS segment register, and address space #257 causes it to be
-relative to the X86 FS segment.  Note that this is a very very low-level
+relative to the X86 GS segment register, address space #257 causes it to be
+relative to the X86 FS segment, and address space #258 causes it to be
+relative to the X86 SS segment.  Note that this is a very very low-level
 feature that should only be used if you know what you're doing (for example in
 an OS kernel).
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267464 - Module Debugging: Fix the condition for determining whether a template

2016-04-25 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Apr 25 15:52:40 2016
New Revision: 267464

URL: http://llvm.org/viewvc/llvm-project?rev=267464&view=rev
Log:
Module Debugging: Fix the condition for determining whether a template
instantiation is in a module.

This patch fixes the condition for determining whether the debug info for a
template instantiation will exist in an imported clang module by:

- checking whether the ClassTemplateSpecializationDecl is complete and
- checking that the instantiation was in a module by looking at the first field.

I also added a negative check to make sure that a typedef to a forward-declared
template (with the definition outside of the module) is handled correctly.

http://reviews.llvm.org/D19443
rdar://problem/25553724

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464&r1=267463&r2=267464&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
@@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
   return false;
 }
 
+/// Does a type definition exist in an imported clang module?
+static bool isDefinedInClangModule(const RecordDecl *RD) {
+  if (!RD->isFromASTFile())
+return false;
+  if (!RD->getDefinition())
+return false;
+  if (!RD->isExternallyVisible() && RD->getName().empty())
+return false;
+  if (auto *CTSD = dyn_cast(RD)) {
+if (!CTSD->isCompleteDefinition())
+  return false;
+// Make sure the instantiation is actually in a module.
+if (CTSD->field_begin() != CTSD->field_end())
+  return CTSD->field_begin()->isFromASTFile();
+  }
+  return true;
+}
+
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
  bool DebugTypeExtRefs, const RecordDecl *RD,
  const LangOptions &LangOpts) {
-  // Does the type exist in an imported clang module?
-  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
-  (RD->isExternallyVisible() || !RD->getName().empty()))
+  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
 return true;
 
   if (DebugKind > codegenoptions::LimitedDebugInfo)

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267464&r1=267463&r2=267464&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Mon Apr 25 15:52:40 2016
@@ -2,7 +2,7 @@
 // Test that only forward declarations are emitted for types dfined in modules.
 
 // Modules:
-// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited \
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \
 // RUN: -dwarf-ext-refs -fmodules   \
 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
 // RUN: -triple %itanium_abi_triple \
@@ -13,7 +13,7 @@
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs 
\
 // RUN: -triple %itanium_abi_triple \
 // RUN: -o %t.pch %S/Inputs/DebugCXX.h
-// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited \
+// RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone \
 // RUN: -dwarf-ext-refs -fmodule-format=obj \
 // RUN: -triple %itanium_abi_triple \
 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
@@ -30,7 +30,9 @@ Struct s;
 DebugCXX::Enum e;
 DebugCXX::Template implicitTemplate;
 DebugCXX::Template explicitTemplate;
-DebugCXX::FloatInstatiation typedefTemplate;
+DebugCXX::FloatInstantiation typedefTemplate;
+DebugCXX::B anchoredTemplate;
+
 int Struct::static_member = -1;
 enum {
   e3 = -1
@@ -41,6 +43,11 @@ char _anchor = anon_enum + conflicting_u
 TypedefUnion tdu;
 TypedefEnum tde;
 TypedefStruct tds;
+TypedefTemplate tdt;
+Template1 explicitTemplate1;
+
+template  class FwdDeclTemplate { T t; };
+TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
@@ -48,7 +55,8 @@ void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
 
-// CHECK: ![[STRUCT:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, 
name: "Struct",
+
+// CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: 
"Struct",
 // CHECK-SAME: scope: ![[NS:[0-9]+]],
 // CHECK-SAME: flags: DIFlagFwdDecl,
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
@@ -61,25 +69,69 @@ void foo() {
 // CHECK-SAME: flags: DIFlagFwdDecl,
 // CHECK-SAME: identifier:  "_ZTSN8DebugCXX4EnumE")
 
-// CHECK: !DIComposite

r267474 - driver: Add a `--rsp-quoting` flag to pick response file quoting.

2016-04-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Apr 25 16:15:49 2016
New Revision: 267474

URL: http://llvm.org/viewvc/llvm-project?rev=267474&view=rev
Log:
driver: Add a `--rsp-quoting` flag to pick response file quoting.

Currently, clang-cl always uses Windows style for unquoting, and clang always
uses POSIX style for unquoting.

With this flag, it's possible to change these defaults.

In general, response file quoting should match the shell the response file is
used in.  On Windows, it's possible to run clang-cl in a bash shell, or clang in
cmd.exe, so a flag for overriding the default behavior is natural there.

On non-Windows, Windows quoting probably never makes sense (except maybe in
Wine), but having clang-cl behave differently based on the host OS seems
strange too.  So require that people who want to use posix-style response
files with clang-cl on non-Windows pass --rsp-quoting=posix.

http://reviews.llvm.org/D19425

Added:
cfe/trunk/test/Driver/at_file_win.c
cfe/trunk/test/Driver/at_file_win.c.args
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=267474&r1=267473&r2=267474&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Apr 25 16:15:49 2016
@@ -152,6 +152,9 @@ class InternalDriverOpt : Group;
+def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
+  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  HelpText<"Set the rsp quoting to either 'posix', or 'windows'">;
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=267474&r1=267473&r2=267474&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Apr 25 16:15:49 2016
@@ -1813,8 +1813,9 @@ void Driver::BuildJobs(Compilation &C) c
   // Claim -### here.
   (void)C.getArgs().hasArg(options::OPT__HASH_HASH_HASH);
 
-  // Claim --driver-mode, it was handled earlier.
+  // Claim --driver-mode, --rsp-quoting, it was handled earlier.
   (void)C.getArgs().hasArg(options::OPT_driver_mode);
+  (void)C.getArgs().hasArg(options::OPT_rsp_quoting);
 
   for (Arg *A : C.getArgs()) {
 // FIXME: It would be nice to be able to send the argument to the

Added: cfe/trunk/test/Driver/at_file_win.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/at_file_win.c?rev=267474&view=auto
==
--- cfe/trunk/test/Driver/at_file_win.c (added)
+++ cfe/trunk/test/Driver/at_file_win.c Mon Apr 25 16:15:49 2016
@@ -0,0 +1,34 @@
+// RUN: %clang --rsp-quoting=windows -E %s @%s.args -o %t.log
+// RUN: FileCheck --input-file=%t.log %s
+
+// CHECK: bar1
+// CHECK-NEXT: bar2 zed2
+// CHECK-NEXT: bar3 zed3
+// CHECK-NEXT: bar4 zed4
+// CHECK-NEXT: bar5 zed5
+// CHECK-NEXT: 'bar6 zed6'
+// CHECK-NEXT: 'bar7 zed7'
+// CHECK-NEXT: foo8bar8zed8
+// CHECK-NEXT: foo9\'bar9\'zed9
+// CHECK-NEXT: foo10"bar10"zed10
+// CHECK: bar
+// CHECK: zed12
+// CHECK: one\two
+// CHECK: c:\foo\bar.c
+
+foo1
+foo2
+foo3
+foo4
+foo5
+foo6
+foo7
+foo8
+foo9
+foo10
+#ifdef foo11
+bar
+#endif
+foo12
+foo13
+foo14

Added: cfe/trunk/test/Driver/at_file_win.c.args
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/at_file_win.c.args?rev=267474&view=auto
==
--- cfe/trunk/test/Driver/at_file_win.c.args (added)
+++ cfe/trunk/test/Driver/at_file_win.c.args Mon Apr 25 16:15:49 2016
@@ -0,0 +1,13 @@
+-Dfoo1=bar1 -Dfoo2="bar2 zed2"
+-Dfoo3="bar3 zed3"
+"-Dfoo4=bar4 zed4"
+"-Dfoo5=bar5 zed5"
+-Dfoo6="'bar6 zed6'"
+-Dfoo7='"bar7 zed7"'
+-Dfoo8=foo8"bar8"zed8
+-Dfoo9=foo9\'bar9\'zed9
+-Dfoo10=foo10\"bar10\"zed10
+-D foo11
+-Dfoo12=zed12
+-Dfoo13=one\two
+-Dfoo14=c:\foo\bar.c

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=267474&r1=267473&r2=267474&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Mon Apr 25 16:15:49 2016
@@ -345,17 +345,24 @@ int main(int argc_, const char **argv_)
   }) != argv.end()) {
 ClangCLMode = true;
   }
+  enum { Default, POSIX, Windows } RSPQuoting = Default;
+  for (const char *F : argv) {
+if (strcmp(F, "--rsp-quoting=posix") == 0)
+  RSPQuoting = POSIX;
+else if (strcmp(F, "--rsp-quoting=windows") == 0)
+  RSPQuoting = Windows

[PATCH] D19497: [clang-tidy] Enhance misc-suspicious-string-compare to move down false-positives.

2016-04-25 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

The checker was noisy when running over llvm code base.
This patch is impriving the way string-compare functions are matched.

1) By default, do not report !strcmp(...) unless it's activate by the user,
2) Only match suspicious expression over a subset of expression (binary 
operator),
3) Added matching of macro wrapper used with clang on linux.

See bug: 27465.

http://reviews.llvm.org/D19497

Files:
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  test/clang-tidy/misc-suspicious-string-compare.c
  test/clang-tidy/misc-suspicious-string-compare.cpp

Index: test/clang-tidy/misc-suspicious-string-compare.cpp
===
--- test/clang-tidy/misc-suspicious-string-compare.cpp
+++ test/clang-tidy/misc-suspicious-string-compare.cpp
@@ -15,6 +15,8 @@
 static const unsigned char V[] = "xyz";
 static const wchar_t W[] = L"abc";
 
+int strlen(const char *);
+
 int memcmp(const void *, const void *, size);
 int wmemcmp(const wchar_t *, const wchar_t *, size);
 int memicmp(const void *, const void *, size);
@@ -297,3 +299,39 @@
 
   return 1;
 }
+
+int strcmp_wrapper1(const char* a, const char* b) {
+  return strcmp(a, b);
+}
+
+int strcmp_wrapper2(const char* a, const char* b) {
+  return (a && b) ? strcmp(a, b) : 0;
+}
+
+#define macro_strncmp(s1, s2, n)  \
+  (__extension__ (__builtin_constant_p (n)\
+  && ((__builtin_constant_p (s1)  \
+   && strlen (s1) < ((size) (n))) \
+  || (__builtin_constant_p (s2)   \
+  && strlen (s2) < ((size) (n \
+  ? strcmp (s1, s2) : strncmp (s1, s2, n)))
+
+int strncmp_macro(const char* a, const char* b) {
+  if (macro_strncmp(a, b, 4))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
+
+  if (macro_strncmp(a, b, 4) == 2)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (macro_strncmp(a, b, 4) <= .0)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
+
+  if (macro_strncmp(a, b, 4) + 0)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: suspicious usage of function 'strcmp'
+
+  return 1;
+}
Index: test/clang-tidy/misc-suspicious-string-compare.c
===
--- test/clang-tidy/misc-suspicious-string-compare.c
+++ test/clang-tidy/misc-suspicious-string-compare.c
@@ -64,3 +64,16 @@
   if (strcmp(A, "a") == strcmp(A, "b")) return 0;
   return 1;
 }
+
+int wrapper(const char* a, const char* b) {
+  return strcmp(a, b);
+}
+
+int assignment_wrapper(const char* a, const char* b) {
+  int cmp = strcmp(a, b);
+  return cmp;
+}
+
+int condexpr_wrapper(const char* a, const char* b) {
+  return (a < b) ? strcmp(a, b) : strcmp(b, a);
+}
Index: clang-tidy/misc/SuspiciousStringCompareCheck.cpp
===
--- clang-tidy/misc/SuspiciousStringCompareCheck.cpp
+++ clang-tidy/misc/SuspiciousStringCompareCheck.cpp
@@ -11,17 +11,14 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "../utils/Matchers.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-AST_MATCHER(BinaryOperator, isComparisonOperator) {
-  return Node.isComparisonOp();
-}
-
 static const char KnownStringCompareFunctions[] = "__builtin_memcmp;"
   "__builtin_strcasecmp;"
   "__builtin_strcmp;"
@@ -84,7 +81,7 @@
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   WarnOnImplicitComparison(Options.get("WarnOnImplicitComparison", 1)),
-  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 1)),
+  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 0)),
   StringCompareLikeFunctions(
   Options.get("StringCompareLikeFunctions", "")) {}
 
@@ -98,57 +95,45 @@
 void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
   // Match relational operators.
   const auto ComparisonUnaryOperator = unaryOperator(hasOperatorName("!"));
-  const auto ComparisonBinaryOperator = binaryOperator(isComparisonOperator());
+  const auto ComparisonBinaryOperator =
+  binaryOperator(matchers::isComparisonOperator());
   const auto ComparisonOperator =
   expr(anyOf(ComparisonUnaryOperator, ComparisonBinaryOperator));
 
   // Add the list of known string compare-like f

Re: [PATCH] D19425: driver: Add a `--rsp-quoting` flag to choose which unquoting behavior to use in rsp files.

2016-04-25 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

Landed the new flag and its tests in r267474, thanks! (Didn't land the test 
updates needed after http://reviews.llvm.org/D19417 yet, since that's not in 
yet.)


http://reviews.llvm.org/D19425



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


Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 54941.
sfantao added a comment.

- Use canonical declarations associated with mappable expressions.


http://reviews.llvm.org/D19382

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -2021,13 +2021,26 @@
 
 void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
   Record.push_back(C->varlist_size());
+  Record.push_back(C->getUniqueDeclarationsNum());
+  Record.push_back(C->getTotalComponentListNum());
+  Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
   Record.push_back(C->getMapTypeModifier());
   Record.push_back(C->getMapType());
   Record.AddSourceLocation(C->getMapLoc());
   Record.AddSourceLocation(C->getColonLoc());
-  for (auto *VE : C->varlists())
-Record.AddStmt(VE);
+  for (auto *E : C->varlists())
+Record.AddStmt(E);
+  for (auto *D : C->all_decls())
+Record.AddDeclRef(D);
+  for (auto N : C->all_num_lists())
+Record.push_back(N);
+  for (auto N : C->all_lists_sizes())
+Record.push_back(N);
+  for (auto &M : C->all_components()) {
+Record.AddStmt(M.getAssociatedExpression());
+Record.AddDeclRef(M.getAssociatedDeclaration());
+  }
 }
 
 void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1861,9 +1861,15 @@
   case OMPC_device:
 C = new (Context) OMPDeviceClause();
 break;
-  case OMPC_map:
-C = OMPMapClause::CreateEmpty(Context, Record[Idx++]);
+  case OMPC_map: {
+unsigned NumVars = Record[Idx++];
+unsigned NumDeclarations = Record[Idx++];
+unsigned NumLists = Record[Idx++];
+unsigned NumComponents = Record[Idx++];
+C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+  NumComponents);
 break;
+  }
   case OMPC_num_teams:
 C = new (Context) OMPNumTeamsClause();
 break;
@@ -2225,12 +2231,45 @@
   C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
   auto NumVars = C->varlist_size();
+  auto UniqueDecls = C->getUniqueDeclarationsNum();
+  auto TotalLists = C->getTotalComponentListNum();
+  auto TotalComponents = C->getTotalComponentsNum();
+
   SmallVector Vars;
   Vars.reserve(NumVars);
-  for (unsigned i = 0; i != NumVars; ++i) {
+  for (unsigned i = 0; i != NumVars; ++i)
 Vars.push_back(Reader->Reader.ReadSubExpr());
-  }
   C->setVarRefs(Vars);
+
+  SmallVector Decls;
+  Decls.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+Decls.push_back(
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx));
+  C->setUniqueDecls(Decls);
+
+  SmallVector ListsPerDecl;
+  ListsPerDecl.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+ListsPerDecl.push_back(Record[Idx++]);
+  C->setDeclNumLists(ListsPerDecl);
+
+  SmallVector ListSizes;
+  ListSizes.reserve(TotalLists);
+  for (unsigned i = 0; i < TotalLists; ++i)
+ListSizes.push_back(Record[Idx++]);
+  C->setComponentListSizes(ListSizes);
+
+  SmallVector Components;
+  Components.reserve(TotalComponents);
+  for (unsigned i = 0; i < TotalComponents; ++i) {
+Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
+ValueDecl *AssociatedDecl =
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx);
+Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+AssociatedExpr, AssociatedDecl));
+  }
+  C->setComponents(Components, ListSizes);
 }
 
 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -81,8 +81,6 @@
   };
 
 private:
-  typedef SmallVector MapInfo;
-
   struct DSAInfo {
 OpenMPClauseKind Attributes;
 Expr *RefExpr;
@@ -92,14 +90,16 @@
   typedef llvm::DenseMap AlignedMapTy;
   typedef std::pair LCDeclInfo;
   typedef llvm::DenseMap LoopControlVariablesMapTy;
-  typedef llvm::DenseMap MappedDeclsTy;
+  typedef llvm::DenseMap<
+  ValueDecl *, OMPClauseMappableExprCommon::MappableExprComponentLists>
+  MappedExprComponentsTy;
   typedef llvm::StringMap>
   CriticalsWithHintsTy;
 
   struct SharingMapTy {
 DeclSAMapTy SharingMap;
 AlignedMapTy AlignedMap;
-MappedDeclsTy MappedDecls;
+MappedExprComponentsTy MappedExprComponents;
 LoopControlVariablesMapTy LCVMap;
 DefaultDataSharingAttributes DefaultAttr;
 SourceLocation DefaultAttrLoc;
@@ -340,11 +

Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-25 Thread Samuel Antao via cfe-commits
sfantao marked an inline comment as done.


Comment at: lib/AST/OpenMPClause.cpp:546
@@ +545,3 @@
+  for (auto *D : Declarations) {
+assert(
+(!D || D->isCanonicalDecl()) &&

Ok, using canonical declarations now. 



http://reviews.llvm.org/D19382



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


r267496 - [lanai] Update handling of structs in arguments to be passed in registers.

2016-04-25 Thread Jacques Pienaar via cfe-commits
Author: jpienaar
Date: Mon Apr 25 19:09:29 2016
New Revision: 267496

URL: http://llvm.org/viewvc/llvm-project?rev=267496&view=rev
Log:
[lanai] Update handling of structs in arguments to be passed in registers.

Previously aggregate types were passed byval, change the ABI to pass these in 
registers instead.


Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/lanai-arguments.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267496&r1=267495&r2=267496&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 19:09:29 2016
@@ -6691,6 +6691,7 @@ public:
   I.info = classifyArgumentType(I.type, State);
   }
 
+  ABIArgInfo getIndirectResult(QualType Ty, bool ByVal, CCState &State) const;
   ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
 };
 } // end anonymous namespace
@@ -6712,21 +6713,72 @@ bool LanaiABIInfo::shouldUseInReg(QualTy
   return true;
 }
 
+ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty, bool ByVal,
+   CCState &State) const {
+  if (!ByVal) {
+if (State.FreeRegs) {
+  --State.FreeRegs; // Non-byval indirects just use one pointer.
+  return getNaturalAlignIndirectInReg(Ty);
+}
+return getNaturalAlignIndirect(Ty, false);
+  }
+
+  // Compute the byval alignment.
+  constexpr unsigned MinABIStackAlignInBytes = 4;
+  unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
+ /*Realign=*/TypeAlign >
+ MinABIStackAlignInBytes);
+}
+
 ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
   CCState &State) const {
-  if (isAggregateTypeForABI(Ty))
-return getNaturalAlignIndirect(Ty);
+  // Check with the C++ ABI first.
+  const RecordType *RT = Ty->getAs();
+  if (RT) {
+CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
+if (RAA == CGCXXABI::RAA_Indirect) {
+  return getIndirectResult(Ty, /*ByVal=*/false, State);
+} else if (RAA == CGCXXABI::RAA_DirectInMemory) {
+  return getNaturalAlignIndirect(Ty, /*ByRef=*/true);
+}
+  }
+
+  if (isAggregateTypeForABI(Ty)) {
+// Structures with flexible arrays are always indirect.
+if (RT && RT->getDecl()->hasFlexibleArrayMember())
+  return getIndirectResult(Ty, /*ByVal=*/true, State);
+
+// Ignore empty structs/unions.
+if (isEmptyRecord(getContext(), Ty, true))
+  return ABIArgInfo::getIgnore();
+
+llvm::LLVMContext &LLVMContext = getVMContext();
+unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
+if (SizeInRegs <= State.FreeRegs) {
+  llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
+  SmallVector Elements(SizeInRegs, Int32);
+  llvm::Type *Result = llvm::StructType::get(LLVMContext, Elements);
+  State.FreeRegs -= SizeInRegs;
+  return ABIArgInfo::getDirectInReg(Result);
+} else {
+  State.FreeRegs = 0;
+}
+return getIndirectResult(Ty, true, State);
+  }
 
   // Treat an enum type as its underlying type.
   if (const auto *EnumTy = Ty->getAs())
 Ty = EnumTy->getDecl()->getIntegerType();
 
-  if (shouldUseInReg(Ty, State))
-return ABIArgInfo::getDirectInReg();
-
-  if (Ty->isPromotableIntegerType())
+  bool InReg = shouldUseInReg(Ty, State);
+  if (Ty->isPromotableIntegerType()) {
+if (InReg)
+  return ABIArgInfo::getDirectInReg();
 return ABIArgInfo::getExtend();
-
+  }
+  if (InReg)
+return ABIArgInfo::getDirectInReg();
   return ABIArgInfo::getDirect();
 }
 

Modified: cfe/trunk/test/CodeGen/lanai-arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lanai-arguments.c?rev=267496&r1=267495&r2=267496&view=diff
==
--- cfe/trunk/test/CodeGen/lanai-arguments.c (original)
+++ cfe/trunk/test/CodeGen/lanai-arguments.c Mon Apr 25 19:09:29 2016
@@ -10,7 +10,7 @@ typedef struct {
   int aa;
   int bb;
 } s1;
-// CHECK: define void @f1(%struct.s1* byval align 4 %i)
+// CHECK: define void @f1(i32 inreg %i.coerce0, i32 inreg %i.coerce1)
 void f1(s1 i) {}
 
 typedef struct {
@@ -61,8 +61,8 @@ union simple_union {
   int a;
   char b;
 };
-// Unions should be passed as byval structs.
-// CHECK: define void @f9(%union.simple_union* byval align 4 %s)
+// Unions should be passed inreg.
+// CHECK: define void @f9(i32 inreg %s.coerce)
 void f9(union simple_union s) {}
 
 typedef struct {
@@ -70,6 +70,6 @@ typedef struct {
   int b3 : 3;
   int b8 : 8;
 } bitfield1;
-// Bitfields should be passed as byval structs.
-// CHECK: define void @f10(%struct.bitfield1* byval align 4 %bf1)
+// Bitfields

Re: r267447 - [Docs] Clarify what the object-size sanitizer does.

2016-04-25 Thread Nico Weber via cfe-commits
Looks like this broke
http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/13793/steps/docs-clang-html/logs/stdio


/home/llvmbb/llvm-build-dir/clang-sphinx-docs/llvm/src/tools/clang/docs/UndefinedBehaviorSanitizer.rst:96:
WARNING: Bullet list ends without a blank line; unexpected unindent.


On Mon, Apr 25, 2016 at 3:21 PM, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Mon Apr 25 14:21:45 2016
> New Revision: 267447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267447&view=rev
> Log:
> [Docs] Clarify what the object-size sanitizer does.
>
> Currently, the UBSan docs make it sound like the object-size sanitizer
> will only detect out-of-bounds reads/writes. It also catches some
> operations that don't necessarily access memory (invalid downcasts,
> calls of methods on invalid pointers, ...). This patch adds a note
> about this behavior in the docs.
>
>
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=267447&r1=267446&r2=267447&view=diff
>
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Apr 25 14:21:45 2016
> @@ -92,11 +92,14 @@ Available checks are:
>   parameter which is declared to never be null.
>-  ``-fsanitize=null``: Use of a null pointer or creation of a null
>   reference.
> -  -  ``-fsanitize=object-size``: An attempt to use bytes which the
> - optimizer can determine are not part of the object being
> - accessed. The sizes of objects are determined using
> - ``__builtin_object_size``, and consequently may be able to detect
> - more problems at higher optimization levels.
> +  -  ``-fsanitize=object-size``: An attempt to potentially use bytes which
> +the optimizer can determine are not part of the object being accessed.
> +This will also detect some types of undefined behavior that may not
> +directly access memory, but are provably incorrect given the size of
> +the objects involved, such as invalid downcasts and calling methods on
> +invalid pointers. These checks are made in terms of
> +``__builtin_object_size``, and consequently may be able to detect more
> +problems at higher optimization levels.
>-  ``-fsanitize=return``: In C++, reaching the end of a
>   value-returning function without returning a value.
>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>
>
> ___
> 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: r267464 - Module Debugging: Fix the condition for determining whether a template

2016-04-25 Thread Richard Smith via cfe-commits
On Mon, Apr 25, 2016 at 1:52 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Apr 25 15:52:40 2016
> New Revision: 267464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267464&view=rev
> Log:
> Module Debugging: Fix the condition for determining whether a template
> instantiation is in a module.
>
> This patch fixes the condition for determining whether the debug info for a
> template instantiation will exist in an imported clang module by:
>
> - checking whether the ClassTemplateSpecializationDecl is complete and
> - checking that the instantiation was in a module by looking at the first
> field.
>
> I also added a negative check to make sure that a typedef to a
> forward-declared
> template (with the definition outside of the module) is handled correctly.
>
> http://reviews.llvm.org/D19443
> rdar://problem/25553724
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464&r1=267463&r2=267464&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
> @@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
>return false;
>  }
>
> +/// Does a type definition exist in an imported clang module?
> +static bool isDefinedInClangModule(const RecordDecl *RD) {
> +  if (!RD->isFromASTFile())
> +return false;
> +  if (!RD->getDefinition())
> +return false;
> +  if (!RD->isExternallyVisible() && RD->getName().empty())
> +return false;
> +  if (auto *CTSD = dyn_cast(RD)) {
>

The same issue also affects member classes of class template
specializations (you can detect them with
RD->getInstantiatedFromMemberClass(), or detect all the relevant cases at
once with RD->getTemplateSpecializationKind()).

+if (!CTSD->isCompleteDefinition())
> +  return false;
>

You already checked this a few lines above. Actually, the two checks do
different things depending on whether RD or some other declaration is the
definition; did you really mean to treat a (non-template) class that's
defined locally but forward-declared within a module as being defined in
that module? (It might make more sense to map to the definition upfront and
do all your queries on that if that's what you intend to check.)


> +// Make sure the instantiation is actually in a module.
> +if (CTSD->field_begin() != CTSD->field_end())
> +  return CTSD->field_begin()->isFromASTFile();
> +  }
> +  return true;
> +}
> +
>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>   bool DebugTypeExtRefs, const RecordDecl
> *RD,
>   const LangOptions &LangOpts) {
> -  // Does the type exist in an imported clang module?
> -  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
> -  (RD->isExternallyVisible() || !RD->getName().empty()))
> +  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
>  return true;
>
>if (DebugKind > codegenoptions::LimitedDebugInfo)
>
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267464&r1=267463&r2=267464&view=diff
>
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Mon Apr 25 15:52:40 2016
> @@ -2,7 +2,7 @@
>  // Test that only forward declarations are emitted for types dfined in
> modules.
>
>  // Modules:
> -// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited \
> +// RUN: %clang_cc1 -x objective-c++ -std=c++11
> -debug-info-kind=standalone \
>  // RUN: -dwarf-ext-refs -fmodules   \
>  // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
>  // RUN: -triple %itanium_abi_triple \
> @@ -13,7 +13,7 @@
>  // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch
> -I%S/Inputs \
>  // RUN: -triple %itanium_abi_triple \
>  // RUN: -o %t.pch %S/Inputs/DebugCXX.h
> -// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited \
> +// RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone \
>  // RUN: -dwarf-ext-refs -fmodule-format=obj \
>  // RUN: -triple %itanium_abi_triple \
>  // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
> @@ -30,7 +30,9 @@ Struct s;
>  DebugCXX::Enum e;
>  DebugCXX::Template implicitTemplate;
>  DebugCXX::Template explicitTemplate;
> -DebugCXX::FloatInstatiation typedefTemplate;
> +DebugCXX::FloatInstantiation typedefTemplate;
> +DebugCXX::B anchoredTem

r267501 - [Docs] Fix indentation error introduced by r267447.

2016-04-25 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Apr 25 19:31:29 2016
New Revision: 267501

URL: http://llvm.org/viewvc/llvm-project?rev=267501&view=rev
Log:
[Docs] Fix indentation error introduced by r267447.

Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=267501&r1=267500&r2=267501&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Apr 25 19:31:29 2016
@@ -93,13 +93,13 @@ Available checks are:
   -  ``-fsanitize=null``: Use of a null pointer or creation of a null
  reference.
   -  ``-fsanitize=object-size``: An attempt to potentially use bytes which
-the optimizer can determine are not part of the object being accessed.
-This will also detect some types of undefined behavior that may not
-directly access memory, but are provably incorrect given the size of
-the objects involved, such as invalid downcasts and calling methods on
-invalid pointers. These checks are made in terms of
-``__builtin_object_size``, and consequently may be able to detect more
-problems at higher optimization levels.
+ the optimizer can determine are not part of the object being accessed.
+ This will also detect some types of undefined behavior that may not
+ directly access memory, but are provably incorrect given the size of
+ the objects involved, such as invalid downcasts and calling methods on
+ invalid pointers. These checks are made in terms of
+ ``__builtin_object_size``, and consequently may be able to detect more
+ problems at higher optimization levels.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer


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


Re: r267447 - [Docs] Clarify what the object-size sanitizer does.

2016-04-25 Thread George Burgess IV via cfe-commits
My bad :)

Attempt to fix committed as r267501.

On Mon, Apr 25, 2016 at 5:31 PM, Nico Weber  wrote:

> Looks like this broke
> http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/13793/steps/docs-clang-html/logs/stdio
>
>
> /home/llvmbb/llvm-build-dir/clang-sphinx-docs/llvm/src/tools/clang/docs/UndefinedBehaviorSanitizer.rst:96:
> WARNING: Bullet list ends without a blank line; unexpected unindent.
>
>
> On Mon, Apr 25, 2016 at 3:21 PM, George Burgess IV via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: gbiv
>> Date: Mon Apr 25 14:21:45 2016
>> New Revision: 267447
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267447&view=rev
>> Log:
>> [Docs] Clarify what the object-size sanitizer does.
>>
>> Currently, the UBSan docs make it sound like the object-size sanitizer
>> will only detect out-of-bounds reads/writes. It also catches some
>> operations that don't necessarily access memory (invalid downcasts,
>> calls of methods on invalid pointers, ...). This patch adds a note
>> about this behavior in the docs.
>>
>>
>> Modified:
>> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>>
>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=267447&r1=267446&r2=267447&view=diff
>>
>> ==
>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Apr 25 14:21:45 2016
>> @@ -92,11 +92,14 @@ Available checks are:
>>   parameter which is declared to never be null.
>>-  ``-fsanitize=null``: Use of a null pointer or creation of a null
>>   reference.
>> -  -  ``-fsanitize=object-size``: An attempt to use bytes which the
>> - optimizer can determine are not part of the object being
>> - accessed. The sizes of objects are determined using
>> - ``__builtin_object_size``, and consequently may be able to detect
>> - more problems at higher optimization levels.
>> +  -  ``-fsanitize=object-size``: An attempt to potentially use bytes
>> which
>> +the optimizer can determine are not part of the object being
>> accessed.
>> +This will also detect some types of undefined behavior that may not
>> +directly access memory, but are provably incorrect given the size of
>> +the objects involved, such as invalid downcasts and calling methods
>> on
>> +invalid pointers. These checks are made in terms of
>> +``__builtin_object_size``, and consequently may be able to detect
>> more
>> +problems at higher optimization levels.
>>-  ``-fsanitize=return``: In C++, reaching the end of a
>>   value-returning function without returning a value.
>>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>>
>>
>> ___
>> 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


r267503 - CGOpenMPRuntime.h: Prune '\param IfCond' in r267395. [-Wdocumentation]

2016-04-25 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Apr 25 19:45:00 2016
New Revision: 267503

URL: http://llvm.org/viewvc/llvm-project?rev=267503&view=rev
Log:
CGOpenMPRuntime.h: Prune '\param IfCond' in r267395. [-Wdocumentation]

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=267503&r1=267502&r2=267503&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Mon Apr 25 19:45:00 2016
@@ -467,8 +467,6 @@ private:
   /// \param SharedsTy A type which contains references the shared variables.
   /// \param Shareds Context with the list of shared variables from the \p
   /// TaskFunction.
-  /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
-  /// otherwise.
   /// \param PrivateVars List of references to private variables for the task
   /// directive.
   /// \param PrivateCopies List of private copies for each private variable in


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


Re: [PATCH] D19003: Set C99 as default C Standard for PS4 target

2016-04-25 Thread Douglas Yung via cfe-commits
dyung updated this revision to Diff 54956.
dyung added a comment.

Updated diff to fix up the comments based on Paul's feedback. Also tightened up 
one of the #if blocks to not include something that did not require C11.


http://reviews.llvm.org/D19003

Files:
  include/clang/Frontend/CompilerInvocation.h
  lib/Frontend/CompilerInvocation.cpp
  test/FixIt/fixit-errors.c
  test/Preprocessor/init.c
  test/Sema/attr-deprecated.c
  test/Sema/nullability.c
  test/SemaObjC/objcbridge-attribute-arc.m

Index: test/SemaObjC/objcbridge-attribute-arc.m
===
--- test/SemaObjC/objcbridge-attribute-arc.m
+++ test/SemaObjC/objcbridge-attribute-arc.m
@@ -23,7 +23,10 @@
 
 typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
 
-typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
+// This error requires C11.
+#if __STDC_VERSION__ > 199901L
+typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
+#endif
 
 typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
 
Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -8,7 +8,11 @@
 typedef int * int_ptr;
 
 // Parse nullability type specifiers.
-typedef int * _Nonnull nonnull_int_ptr; // expected-note{{'_Nonnull' specified here}}
+// This note requires C11.
+#if __STDC_VERSION__ > 199901L
+// expected-note@+2{{'_Nonnull' specified here}}
+#endif
+typedef int * _Nonnull nonnull_int_ptr;
 typedef int * _Nullable nullable_int_ptr;
 typedef int * _Null_unspecified null_unspecified_int_ptr;
 
@@ -23,9 +27,14 @@
 typedef nonnull_int_ptr _Nonnull redundant_okay_1;
 
 // Conflicting nullability specifiers via a typedef are not.
+// Some of these errors require C11.
+#if __STDC_VERSION__ > 199901L
 typedef nonnull_int_ptr _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
+#endif
 typedef nonnull_int_ptr nonnull_int_ptr_typedef;
+#if __STDC_VERSION__ > 199901L
 typedef nonnull_int_ptr_typedef _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
+#endif
 typedef nonnull_int_ptr_typedef nonnull_int_ptr_typedef_typedef;
 typedef nonnull_int_ptr_typedef_typedef _Null_unspecified conflicting_3; // expected-error{{nullability specifier '_Null_unspecified' conflicts with existing specifier '_Nonnull'}}
 
@@ -69,8 +78,11 @@
 
 // Nullability is not part of the canonical type.
 typedef int * _Nonnull ambiguous_int_ptr;
+// Redefining a typedef is a C11 feature.
+#if __STDC_VERSION__ > 199901L
 typedef int * ambiguous_int_ptr;
 typedef int * _Nullable ambiguous_int_ptr;
+#endif
 
 // Printing of nullability.
 float f;
Index: test/Sema/attr-deprecated.c
===
--- test/Sema/attr-deprecated.c
+++ test/Sema/attr-deprecated.c
@@ -122,5 +122,10 @@
 };
 
 typedef int test23_ty __attribute((deprecated));
+// Redefining a typedef is a C11 feature.
+#if __STDC_VERSION__ <= 199901L
+// expected-note@-3 {{'test23_ty' has been explicitly marked deprecated here}}
+#else
 typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}}
+#endif
 test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -88,7 +88,6 @@
 // COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234
 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412
 // COMMON:#define __STDC_HOSTED__ 1
-// COMMON:#define __STDC_VERSION__ 201112L
 // COMMON:#define __STDC__ 1
 // COMMON:#define __VERSION__ {{.*}}
 // COMMON:#define __clang__ 1
@@ -98,7 +97,13 @@
 // COMMON:#define __clang_version__ {{.*}}
 // COMMON:#define __llvm__ 1
 //
+// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-win32 < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
+// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
+// RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
+// RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
 // 
+// C-DEFAULT:#define __STDC_VERSION__ 201112L
+//
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/nu

[libunwind] r267509 - unwind: remove last instance of -Wexpansion-to-defined

2016-04-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Apr 25 20:11:29 2016
New Revision: 267509

URL: http://llvm.org/viewvc/llvm-project?rev=267509&view=rev
Log:
unwind: remove last instance of -Wexpansion-to-defined

This unifies the definition of _LIBUNWIND_BUILD_SJLJ_APIS.  It also further
generalises the definition to allow building these APIs on non-Apple targets
when `-fsjlj-excceptions` is used.  The header is now clean of macros which
expand to defined checks.

Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=267509&r1=267508&r2=267509&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Mon Apr 25 20:11:29 2016
@@ -30,8 +30,6 @@
 
 // Platform specific configuration defines.
 #ifdef __APPLE__
-  #define _LIBUNWIND_BUILD_SJLJ_APIS  defined(__arm__)
-
   #if defined(FOR_DYLD)
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   0
@@ -42,8 +40,6 @@
 #define _LIBUNWIND_SUPPORT_DWARF_INDEX0
   #endif
 #else
-  #define _LIBUNWIND_BUILD_SJLJ_APIS  0
-
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
@@ -59,6 +55,12 @@
 #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
 #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
 
+#if (defined(__APPLE__) && defined(__arm__)) || 
defined(__USING_SJLJ_EXCEPTIONS__)
+#define _LIBUNWIND_BUILD_SJLJ_APIS 1
+#else
+#define _LIBUNWIND_BUILD_SJLJ_APIS 0
+#endif
+
 #if defined(__i386__) || defined(__x86_64__)
 #define _LIBUNWIND_SUPPORT_FRAME_APIS 1
 #else


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


Re: r267496 - [lanai] Update handling of structs in arguments to be passed in registers.

2016-04-25 Thread Kostya Serebryany via cfe-commits
+rnk

On Mon, Apr 25, 2016 at 5:09 PM, Jacques Pienaar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jpienaar
> Date: Mon Apr 25 19:09:29 2016
> New Revision: 267496
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267496&view=rev
> Log:
> [lanai] Update handling of structs in arguments to be passed in registers.
>
> Previously aggregate types were passed byval, change the ABI to pass these
> in registers instead.
>
>
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> cfe/trunk/test/CodeGen/lanai-arguments.c
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267496&r1=267495&r2=267496&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 19:09:29 2016
> @@ -6691,6 +6691,7 @@ public:
>I.info = classifyArgumentType(I.type, State);
>}
>
> +  ABIArgInfo getIndirectResult(QualType Ty, bool ByVal, CCState &State)
> const;
>ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
>  };
>  } // end anonymous namespace
> @@ -6712,21 +6713,72 @@ bool LanaiABIInfo::shouldUseInReg(QualTy
>return true;
>  }
>
> +ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty, bool ByVal,
> +   CCState &State) const {
> +  if (!ByVal) {
> +if (State.FreeRegs) {
> +  --State.FreeRegs; // Non-byval indirects just use one pointer.
> +  return getNaturalAlignIndirectInReg(Ty);
> +}
> +return getNaturalAlignIndirect(Ty, false);
> +  }
> +
> +  // Compute the byval alignment.
> +  constexpr unsigned MinABIStackAlignInBytes = 4;
>

This broke the build on Windows;

C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\TargetInfo.cpp(6727)
: error C2065: 'constexpr' : undeclared identifier





> +  unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
> +  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4),
> /*ByVal=*/true,
> + /*Realign=*/TypeAlign >
> + MinABIStackAlignInBytes);
> +}
> +
>  ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
>CCState &State) const {
> -  if (isAggregateTypeForABI(Ty))
> -return getNaturalAlignIndirect(Ty);
> +  // Check with the C++ ABI first.
> +  const RecordType *RT = Ty->getAs();
> +  if (RT) {
> +CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
> +if (RAA == CGCXXABI::RAA_Indirect) {
> +  return getIndirectResult(Ty, /*ByVal=*/false, State);
> +} else if (RAA == CGCXXABI::RAA_DirectInMemory) {
> +  return getNaturalAlignIndirect(Ty, /*ByRef=*/true);
> +}
> +  }
> +
> +  if (isAggregateTypeForABI(Ty)) {
> +// Structures with flexible arrays are always indirect.
> +if (RT && RT->getDecl()->hasFlexibleArrayMember())
> +  return getIndirectResult(Ty, /*ByVal=*/true, State);
> +
> +// Ignore empty structs/unions.
> +if (isEmptyRecord(getContext(), Ty, true))
> +  return ABIArgInfo::getIgnore();
> +
> +llvm::LLVMContext &LLVMContext = getVMContext();
> +unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
> +if (SizeInRegs <= State.FreeRegs) {
> +  llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
> +  SmallVector Elements(SizeInRegs, Int32);
> +  llvm::Type *Result = llvm::StructType::get(LLVMContext, Elements);
> +  State.FreeRegs -= SizeInRegs;
> +  return ABIArgInfo::getDirectInReg(Result);
> +} else {
> +  State.FreeRegs = 0;
> +}
> +return getIndirectResult(Ty, true, State);
> +  }
>
>// Treat an enum type as its underlying type.
>if (const auto *EnumTy = Ty->getAs())
>  Ty = EnumTy->getDecl()->getIntegerType();
>
> -  if (shouldUseInReg(Ty, State))
> -return ABIArgInfo::getDirectInReg();
> -
> -  if (Ty->isPromotableIntegerType())
> +  bool InReg = shouldUseInReg(Ty, State);
> +  if (Ty->isPromotableIntegerType()) {
> +if (InReg)
> +  return ABIArgInfo::getDirectInReg();
>  return ABIArgInfo::getExtend();
> -
> +  }
> +  if (InReg)
> +return ABIArgInfo::getDirectInReg();
>return ABIArgInfo::getDirect();
>  }
>
>
> Modified: cfe/trunk/test/CodeGen/lanai-arguments.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lanai-arguments.c?rev=267496&r1=267495&r2=267496&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/lanai-arguments.c (original)
> +++ cfe/trunk/test/CodeGen/lanai-arguments.c Mon Apr 25 19:09:29 2016
> @@ -10,7 +10,7 @@ typedef struct {
>int aa;
>int bb;
>  } s1;
> -// CHECK: define void @f1(%struct.s1* byval align 4 %i)
> +// CHECK: define void @f1(i32 inreg %i.coerce0, i32 inreg %i.coerce1)
>  void f1(s1 i) {}
>
>  typedef struct {
>

r267513 - trying to fix the windows build broken by r267496

2016-04-25 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Mon Apr 25 20:53:49 2016
New Revision: 267513

URL: http://llvm.org/viewvc/llvm-project?rev=267513&view=rev
Log:
trying to fix the windows build broken by r267496

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267513&r1=267512&r2=267513&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 20:53:49 2016
@@ -6724,7 +6724,7 @@ ABIArgInfo LanaiABIInfo::getIndirectResu
   }
 
   // Compute the byval alignment.
-  constexpr unsigned MinABIStackAlignInBytes = 4;
+  const unsigned MinABIStackAlignInBytes = 4;
   unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
   return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
  /*Realign=*/TypeAlign >


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


Re: r267496 - [lanai] Update handling of structs in arguments to be passed in registers.

2016-04-25 Thread Kostya Serebryany via cfe-commits
Hopefully fixed by r267513.

On Mon, Apr 25, 2016 at 6:46 PM, Kostya Serebryany  wrote:

> +rnk
>
> On Mon, Apr 25, 2016 at 5:09 PM, Jacques Pienaar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: jpienaar
>> Date: Mon Apr 25 19:09:29 2016
>> New Revision: 267496
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267496&view=rev
>> Log:
>> [lanai] Update handling of structs in arguments to be passed in registers.
>>
>> Previously aggregate types were passed byval, change the ABI to pass
>> these in registers instead.
>>
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> cfe/trunk/test/CodeGen/lanai-arguments.c
>>
>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267496&r1=267495&r2=267496&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 19:09:29 2016
>> @@ -6691,6 +6691,7 @@ public:
>>I.info = classifyArgumentType(I.type, State);
>>}
>>
>> +  ABIArgInfo getIndirectResult(QualType Ty, bool ByVal, CCState &State)
>> const;
>>ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
>>  };
>>  } // end anonymous namespace
>> @@ -6712,21 +6713,72 @@ bool LanaiABIInfo::shouldUseInReg(QualTy
>>return true;
>>  }
>>
>> +ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty, bool ByVal,
>> +   CCState &State) const {
>> +  if (!ByVal) {
>> +if (State.FreeRegs) {
>> +  --State.FreeRegs; // Non-byval indirects just use one pointer.
>> +  return getNaturalAlignIndirectInReg(Ty);
>> +}
>> +return getNaturalAlignIndirect(Ty, false);
>> +  }
>> +
>> +  // Compute the byval alignment.
>> +  constexpr unsigned MinABIStackAlignInBytes = 4;
>>
>
> This broke the build on Windows;
>
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\TargetInfo.cpp(6727)
>  : error C2065: 'constexpr' : undeclared identifier
>
>
>
>
>
>> +  unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
>> +  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4),
>> /*ByVal=*/true,
>> + /*Realign=*/TypeAlign >
>> + MinABIStackAlignInBytes);
>> +}
>> +
>>  ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
>>CCState &State) const {
>> -  if (isAggregateTypeForABI(Ty))
>> -return getNaturalAlignIndirect(Ty);
>> +  // Check with the C++ ABI first.
>> +  const RecordType *RT = Ty->getAs();
>> +  if (RT) {
>> +CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
>> +if (RAA == CGCXXABI::RAA_Indirect) {
>> +  return getIndirectResult(Ty, /*ByVal=*/false, State);
>> +} else if (RAA == CGCXXABI::RAA_DirectInMemory) {
>> +  return getNaturalAlignIndirect(Ty, /*ByRef=*/true);
>> +}
>> +  }
>> +
>> +  if (isAggregateTypeForABI(Ty)) {
>> +// Structures with flexible arrays are always indirect.
>> +if (RT && RT->getDecl()->hasFlexibleArrayMember())
>> +  return getIndirectResult(Ty, /*ByVal=*/true, State);
>> +
>> +// Ignore empty structs/unions.
>> +if (isEmptyRecord(getContext(), Ty, true))
>> +  return ABIArgInfo::getIgnore();
>> +
>> +llvm::LLVMContext &LLVMContext = getVMContext();
>> +unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
>> +if (SizeInRegs <= State.FreeRegs) {
>> +  llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
>> +  SmallVector Elements(SizeInRegs, Int32);
>> +  llvm::Type *Result = llvm::StructType::get(LLVMContext, Elements);
>> +  State.FreeRegs -= SizeInRegs;
>> +  return ABIArgInfo::getDirectInReg(Result);
>> +} else {
>> +  State.FreeRegs = 0;
>> +}
>> +return getIndirectResult(Ty, true, State);
>> +  }
>>
>>// Treat an enum type as its underlying type.
>>if (const auto *EnumTy = Ty->getAs())
>>  Ty = EnumTy->getDecl()->getIntegerType();
>>
>> -  if (shouldUseInReg(Ty, State))
>> -return ABIArgInfo::getDirectInReg();
>> -
>> -  if (Ty->isPromotableIntegerType())
>> +  bool InReg = shouldUseInReg(Ty, State);
>> +  if (Ty->isPromotableIntegerType()) {
>> +if (InReg)
>> +  return ABIArgInfo::getDirectInReg();
>>  return ABIArgInfo::getExtend();
>> -
>> +  }
>> +  if (InReg)
>> +return ABIArgInfo::getDirectInReg();
>>return ABIArgInfo::getDirect();
>>  }
>>
>>
>> Modified: cfe/trunk/test/CodeGen/lanai-arguments.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lanai-arguments.c?rev=267496&r1=267495&r2=267496&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGen/lanai-arguments.c (original)
>> +++ cfe/trunk/test/CodeGen/lanai-arguments.c Mon Apr 25 19:09:29 2016
>> @@ -10,7 +1

Re: [PATCH] D19478: Remove assert mandating you can only use SPIR target with OpenCL

2016-04-25 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

LGTM.


http://reviews.llvm.org/D19478



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-25 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: cfe/trunk/lib/Format/AffectedRangeManager.h:59
@@ +58,3 @@
+ const AnnotatedLine *PreviousLine);
+  SourceManager &SourceMgr;
+  const SmallVector Ranges;

And an empty line between functions and data members here.


Comment at: cfe/trunk/lib/Format/AffectedRangeManager.h:66
@@ +65,2 @@
+
+#endif // LLVM_CLANG_LIB_FORMAT_WHITESPACEMANAGER_H

Fix header guard comment


Comment at: cfe/trunk/lib/Format/Format.cpp:1355
@@ -1352,2 +1354,3 @@
   std::find(ForEachMacros.begin(), ForEachMacros.end(),
-FormatTok->Tok.getIdentifierInfo()) != 
ForEachMacros.end()) {
+FormatTok->Tok.getIdentifierInfo()) !=
+  ForEachMacros.end()) {

What happened here?


Comment at: cfe/trunk/lib/Format/Format.cpp:1463
@@ +1462,3 @@
+  std::unique_ptr Diagnostics,
+  std::vector CharRanges)
+  : Style(Style), ID(ID), CharRanges(CharRanges.begin(), CharRanges.end()),

Hand in CharRanges as ArrayRef or const vector&.


Comment at: cfe/trunk/lib/Format/Format.cpp:1471
@@ +1470,3 @@
+  static std::unique_ptr
+  CreateVirtualEnvironment(const FormatStyle &Style, StringRef Code,
+   StringRef FileName,

Why don't you do this in the constructor? Seems asymmetric to just call a 
constructor in the one codepath but a factory function in the other one.


Comment at: cfe/trunk/lib/Format/Format.cpp:1519
@@ +1518,3 @@
+
+  SourceManager &getSourceManager() { return SM; }
+

Would it be sufficient to return a const SourceManager&? I guess not, but I'd 
like to understand where it breaks. If we could return a const source manager 
here, that would enable us to pass around a "const Environment&" at a few 
places.


Repository:
  rL LLVM

http://reviews.llvm.org/D18551



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


Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/AST/OpenMPClause.cpp:546
@@ +545,3 @@
+  for (auto *D : Declarations) {
+assert(
+(!D || D->isCanonicalDecl()) &&

sfantao wrote:
> Ok, using canonical declarations now. 
> 
No, I mean you'd better to check and store canonical decls in Cache, like:
```
if (Cache.count(D->getCaonicalDecl())
```
```
Cache.insert(D->getCanonicalDecl());
```



http://reviews.llvm.org/D19382



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