[PATCH] D59013: [CMake][runtimes] Move libunwind, libc++abi and libc++ to lib/ and include/

2019-03-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: libcxx/CMakeLists.txt:420-421
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-  set(DEFAULT_INSTALL_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
-  set(DEFAULT_INSTALL_HEADER_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/)
-  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXX_LIBDIR_SUFFIX})

These two variables are unused now, right? (and their equivalents in libcxxabi 
and libunwind)



Comment at: libcxx/CMakeLists.txt:424-425
+  if(LIBCXX_LIBDIR_SUBDIR)
+set(LIBCXX_LIBRARY_DIR ${LIBCXX_LIBRARY_DIR}/${LIBCXX_LIBDIR_SUBDIR})
+set(LIBCXX_INSTALL_LIBRARY_DIR 
${LIBCXX_INSTALL_LIBRARY_DIR}/${LIBCXX_LIBDIR_SUBDIR})
+  endif()

`string(APPEND)` could be used here – I don't know why that's so uncommon (I 
only see one instance of it in the entirety of llvm-project right now).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59013/new/

https://reviews.llvm.org/D59013



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


[PATCH] D58665: [analyzer] Handle comparison between non-default AS symbol and constant

2019-03-07 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

Thanks for the review! I'll submit this shortly then.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58665/new/

https://reviews.llvm.org/D58665



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


[PATCH] D45978: dllexport const variables must have external linkage.

2019-03-07 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 189659.
zahiraam marked 3 inline comments as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45978/new/

https://reviews.llvm.org/D45978

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeGen/dllexport-1.c
  test/Sema/dllexport-1.cpp
  test/Sema/dllexport-2.cpp
  test/SemaCXX/dllexport.cpp
  test/SemaCXX/dllimport.cpp

Index: test/SemaCXX/dllimport.cpp
===
--- test/SemaCXX/dllimport.cpp
+++ test/SemaCXX/dllimport.cpp
@@ -121,7 +121,12 @@
 // External linkage is required.
 __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}}
 __declspec(dllimport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllimport'}}
-namespace{ __declspec(dllimport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}}
+#ifdef MS
+// expected-nodiagnostics
+#else
+// expected-error@+1{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllimport'}}
+namespace{ __declspec(dllimport) int InternalGlobal; }
+#endif
 namespace ns { __declspec(dllimport) int ExternalGlobal; }
 
 __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}}
@@ -213,7 +218,12 @@
 // External linkage is required.
 template __declspec(dllimport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllimport'}}
 template __declspec(dllimport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllimport'}}
-namespace{ template __declspec(dllimport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}}
+#ifdef MS
+// expected-nodiagnostics
+#else
+// expected-error@+2{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllimport'}}
+#endif
+namespace{ template __declspec(dllimport) int InternalVarTmpl; }
 namespace ns { template __declspec(dllimport) int ExternalVarTmpl; }
 
 template __declspec(dllimport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{definition of dllimport data}} // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllimport'}}
Index: test/SemaCXX/dllexport.cpp
===
--- test/SemaCXX/dllexport.cpp
+++ test/SemaCXX/dllexport.cpp
@@ -69,7 +69,12 @@
 // External linkage is required.
 __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
 __declspec(dllexport) Internal InternalTypeGlobal; // expected-error{{'InternalTypeGlobal' must have external linkage when declared 'dllexport'}}
-namespace{ __declspec(dllexport) int InternalGlobal; } // expected-error{{'(anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllexport'}}
+#ifdef MS
+// expected-nodiagnostics
+#else
+// expected-error@+1{{anonymous namespace)::InternalGlobal' must have external linkage when declared 'dllexport'}}
+namespace{ __declspec(dllexport) int InternalGlobal; }
+#endif
 namespace ns { __declspec(dllexport) int ExternalGlobal; }
 
 __declspec(dllexport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllexport'}}
@@ -124,7 +129,12 @@
 // External linkage is required.
 template __declspec(dllexport) static int StaticVarTmpl; // expected-error{{'StaticVarTmpl' must have external linkage when declared 'dllexport'}}
 template __declspec(dllexport) Internal InternalTypeVarTmpl; // expected-error{{'InternalTypeVarTmpl' must have external linkage when declared 'dllexport'}}
-namespace{ template __declspec(dllexport) int InternalVarTmpl; } // expected-error{{'(anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllexport'}}
+#ifdef MS
+// expected-nodiagnostics
+#else
+// expected-error@+1{{anonymous namespace)::InternalVarTmpl' must have external linkage when declared 'dllexport'}}
+namespace{ template __declspec(dllexport) int InternalVarTmpl; }
+#endif
 namespace ns { template __declspec(dllexport) int ExternalVarTmpl = 1; }
 
 template __declspec(dllexport) auto InternalAutoTypeVarTmpl = Internal(); // expected-error{{'InternalAutoTypeVarTmpl' must have external linkage when declared 'dllexport'}}
Index: test/Sema/dllexport-2.cpp
===
--- /dev/null
+++ test/Sema/dllexport-2.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -fms-extensions -verify 

[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

> Anyways, this looks good in this state.
> Thank you for working on this!

Thanks!

> If you don't intend to immediately work on fixing the rest of , cases here,
> *please* do file a bug so it won't get lost. (and link it here)

I already extended this in order to support the rest of direct mutations.




Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:27
 
+AST_MATCHER_P(Expr, skipCommaOps,
+ ast_matchers::internal::Matcher, InnerMatcher) {

lebedev.ri wrote:
> djtodoro wrote:
> > lebedev.ri wrote:
> > > djtodoro wrote:
> > > > lebedev.ri wrote:
> > > > > (Can anyone suggest a better name maybe?
> > > > > I'm not sure this is the most correct name, but i can't suggest a 
> > > > > better alternative.)
> > > > Maybe `evalCommaExpr`?
> > > Ah, yes, `eval` sounds better.
> > > But, it won't always eval comma op or bailout.
> > > It will eval if it is there.
> > > So maybe `maybeEvalCommaExpr` (pun intended!).
> > Sure, `maybeEvalCommaExpr ` sounds better.
> > Or, one more suggestion is `tryEvalCommaExpr` ?
> `try`, at least to me, has the same meaning as `evalCommaExpr`, i.e. one 
> might expect that if it fails, it will fail.
> So not sure.
Hmm, I agree. You are right. Let it be `maybeEvalCommaExpr` (for now), if there 
is no better suggestion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



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


[PATCH] D59013: [CMake][runtimes] Move libunwind, libc++abi and libc++ to lib/ and include/

2019-03-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek marked an inline comment as done.
phosek added inline comments.



Comment at: libcxx/CMakeLists.txt:420-421
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-  set(DEFAULT_INSTALL_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/)
-  set(DEFAULT_INSTALL_HEADER_PREFIX 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/)
-  set(LIBCXX_LIBRARY_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE}/lib${LIBCXX_LIBDIR_SUFFIX})

smeenai wrote:
> These two variables are unused now, right? (and their equivalents in 
> libcxxabi and libunwind)
Yes, this is something I actually introduced in previous iterations of the 
runtimes build efforts. We could consider deleting them altogether, but I don't 
know how to find out if there are any users of these. I could send an email to 
libcxx-dev and see if anyone responds.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59013/new/

https://reviews.llvm.org/D59013



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


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 189661.
djtodoro added a comment.

-add support for the rest of direct mutation cases


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894

Files:
  include/clang/AST/Expr.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -881,6 +881,137 @@
   EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
+TEST(ExprMutationAnalyzerTest, CommaExprWithAnAssigment) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y) = 5; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithDecOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y)++; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithNonConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() { mem ++; } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() const  { } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithCallExpr) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f(A &O1) {} };"
+   "void fn() { A o1, o2; o2.f((o2, o1)); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithCallUnresolved) {
+  auto AST = buildASTFromCodeWithArgs(
+  "template  struct S;"
+  "template  void f() { S s; int x, y; s.mf((y, x)); }",
+  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+
+  AST = buildASTFromCodeWithArgs(
+  "template  void f(T t) { int x, y; g(t, (y, x)); }",
+  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprParmRef) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "extern void fn(A &o1);"
+   "void fn2 () { A o1, o2; fn((o2, o1)); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithAmpersandOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "void fn () { A o1, o2;"
+   "void *addr = &(o2, o1); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprAsReturnAsValue) {
+  auto AST = buildASTFromCodeWithArgs("int f() { int x, y; return (x, y); }",
+  {"-Wno-unused-value"});
+  auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaEpxrAsReturnAsNonConstRef) {
+  const auto AST =
+  buildASTFromCodeWithArgs("int& f() { int x, y; return (y, x); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContex

[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.

Still LG.
I'm sure you have verified that there is test coverage for all the 
newly-supported cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



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


r355585 - [IR][ARM] Add function pointer alignment to datalayout

2019-03-07 Thread Michael Platings via cfe-commits
Author: michaelplatings
Date: Thu Mar  7 01:15:23 2019
New Revision: 355585

URL: http://llvm.org/viewvc/llvm-project?rev=355585&view=rev
Log:
[IR][ARM] Add function pointer alignment to datalayout

Use this feature to fix a bug on ARM where 4 byte alignment is
incorrectly assumed.

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

Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/test/CodeGen/armv7k-abi.c
cfe/trunk/test/CodeGen/target-data.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=355585&r1=355584&r2=355585&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Thu Mar  7 01:15:23 2019
@@ -40,13 +40,14 @@ void ARMTargetInfo::setABIAAPCS() {
   // so set preferred for small types to 32.
   if (T.isOSBinFormatMachO()) {
 resetDataLayout(BigEndian
-? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-: "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+: 
"e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
   } else if (T.isOSWindows()) {
 assert(!BigEndian && "Windows on ARM does not support big endian");
 resetDataLayout("e"
 "-m:w"
 "-p:32:32"
+"-Fi8"
 "-i64:64"
 "-v128:64:128"
 "-a:0:32"
@@ -54,11 +55,11 @@ void ARMTargetInfo::setABIAAPCS() {
 "-S64");
   } else if (T.isOSNaCl()) {
 assert(!BigEndian && "NaCl on ARM does not support big endian");
-resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128");
+resetDataLayout("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S128");
   } else {
 resetDataLayout(BigEndian
-? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+: 
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
   }
 
   // FIXME: Enumerated types are variable width in straight AAPCS.
@@ -87,17 +88,17 @@ void ARMTargetInfo::setABIAPCS(bool IsAA
 
   if (T.isOSBinFormatMachO() && IsAAPCS16) {
 assert(!BigEndian && "AAPCS16 does not support big-endian");
-resetDataLayout("e-m:o-p:32:32-i64:64-a:0:32-n32-S128");
+resetDataLayout("e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128");
   } else if (T.isOSBinFormatMachO())
 resetDataLayout(
 BigEndian
-? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
-: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
+? 
"E-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+: 
"e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
   else
 resetDataLayout(
 BigEndian
-? "E-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
-: "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
+? 
"E-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+: 
"e-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
 
   // FIXME: Override "preferred align" for double and long long.
 }
@@ -1055,7 +1056,7 @@ CygwinARMTargetInfo::CygwinARMTargetInfo
   this->WCharType = TargetInfo::UnsignedShort;
   TLSSupported = false;
   DoubleAlign = LongLongAlign = 64;
-  resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
+  resetDataLayout("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
 }
 
 void CygwinARMTargetInfo::getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/test/CodeGen/armv7k-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/armv7k-abi.c?rev=355585&r1=355584&r2=355585&view=diff
==
--- cfe/trunk/test/CodeGen/armv7k-abi.c (original)
+++ cfe/trunk/test/CodeGen/armv7k-abi.c Thu Mar  7 01:15:23 2019
@@ -4,7 +4,7 @@
 
 // Make sure 64 and 128 bit types are naturally aligned by the v7k ABI:
 
-// CHECK: target datalayout = "e-m:o-p:32:32-i64:64-a:0:32-n32-S128"
+// CHECK: target datalayout = "e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128"
 
 typedef struct {
   float arr[4];

Modified: cfe/trunk/test/CodeGen/target-data.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=355585&r1=355584&r2=355585&view=diff
==
--- cfe/trunk/test/CodeGen/target-data.c (original)
+++ cfe/trunk/test/CodeGen/target-data.c Thu Mar  7 01:15:23 2019
@@ -96,7 +96,7 @@
 
 // RUN: %clang_cc1

[PATCH] D59079: [clang][Tooling] Delete dots and dotdots when generating absolute paths

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GetAllFiles interface returns absolute paths, but keeps dots and dot
dots. This patch makes those paths canonical by deleting them.


Repository:
  rC Clang

https://reviews.llvm.org/D59079

Files:
  lib/Tooling/JSONCompilationDatabase.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -88,12 +88,17 @@
   expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file2", PathStorage);
   expected_files.push_back(PathStorage.str());
+  llvm::sys::path::native("//net/file1", PathStorage);
+  expected_files.push_back(PathStorage.str());
   EXPECT_EQ(expected_files,
 getAllFiles("[{\"directory\":\"//net/dir\","
 "\"command\":\"command\","
 "\"file\":\"file1\"},"
 " {\"directory\":\"//net/dir\","
 "\"command\":\"command\","
+"\"file\":\"../file1\"},"
+" {\"directory\":\"//net/dir\","
+"\"command\":\"command\","
 "\"file\":\"file2\"}]",
 ErrorMessage, JSONCommandLineSyntax::Gnu))
   << ErrorMessage;
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -370,6 +370,7 @@
   SmallString<128> AbsolutePath(
   Directory->getValue(DirectoryStorage));
   llvm::sys::path::append(AbsolutePath, FileName);
+  llvm::sys::path::remove_dots(AbsolutePath, true);
   llvm::sys::path::native(AbsolutePath, NativeFilePath);
 } else {
   llvm::sys::path::native(FileName, NativeFilePath);


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -88,12 +88,17 @@
   expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file2", PathStorage);
   expected_files.push_back(PathStorage.str());
+  llvm::sys::path::native("//net/file1", PathStorage);
+  expected_files.push_back(PathStorage.str());
   EXPECT_EQ(expected_files,
 getAllFiles("[{\"directory\":\"//net/dir\","
 "\"command\":\"command\","
 "\"file\":\"file1\"},"
 " {\"directory\":\"//net/dir\","
 "\"command\":\"command\","
+"\"file\":\"../file1\"},"
+" {\"directory\":\"//net/dir\","
+"\"command\":\"command\","
 "\"file\":\"file2\"}]",
 ErrorMessage, JSONCommandLineSyntax::Gnu))
   << ErrorMessage;
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -370,6 +370,7 @@
   SmallString<128> AbsolutePath(
   Directory->getValue(DirectoryStorage));
   llvm::sys::path::append(AbsolutePath, FileName);
+  llvm::sys::path::remove_dots(AbsolutePath, true);
   llvm::sys::path::native(AbsolutePath, NativeFilePath);
 } else {
   llvm::sys::path::native(FileName, NativeFilePath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 189665.
martong marked 6 inline comments as done.
martong added a comment.

- Add asserts


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58494/new/

https://reviews.llvm.org/D58494

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -4197,9 +4197,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
@@ -4214,9 +4213,8 @@
 RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition)
@@ -4230,9 +4228,7 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedPrototype)
@@ -4245,9 +4241,7 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitionAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportDefinitionAfterImportedPrototype)
@@ -4260,9 +4254,7 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedDefinition)
@@ -4274,9 +4266,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, , ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypes)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_, ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypes)
 // FIXME This does not pass, possible error with Spec import.
@@ -4289,9 +4280,8 @@
 ImportDefinitions)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitions)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function

[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:4967
+template  static auto getTemplateDefinition(T *D) -> T * {
+  auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
   if (!ToTemplatedDef)

shafik wrote:
> shafik wrote:
> > Can we guarantee that `D->getTemplatedDecl()` will always return a valid 
> > pointer? 
> What other types besides `CXXRecordDecl` do we expect here? 
> Can we guarantee that D->getTemplatedDecl() will always return a valid 
> pointer?

Actually, we always call this function on a `ClassTemplateDecl` or on a 
`FunctionTemplateDecl` which should return with a valid pointer. Still it is a 
good idea to put an assert at the beginning of the function, so I just did that.
```
  assert(D->getTemplatedDecl() && "Should be called on templates only");
```

> What other types besides CXXRecordDecl do we expect here?

`FunctionDecl` can be there too when we call this on a `FunctiomTemplateDecl` 
param.




Comment at: lib/AST/ASTImporter.cpp:5544
   // type, and in the same context as the function we're importing.
+  // FIXME Split this into a separate function.
   if (!LexicalDC->isFunctionOrMethod()) {

shafik wrote:
> Would it make sense to do the split into a separate function in the PR?
I'd rather do that in another patch where we could address the similar issues 
in other visit functions too. Actually, most of the visit functions start with 
a lookup and then continue with a loop over the lookup results; this part could 
be split into a separate function everywhere.



Comment at: lib/AST/ASTImporter.cpp:5595
+  auto *PrevTemplated =
+  FoundByLookup->getTemplatedDecl()->getMostRecentDecl();
+  if (TemplatedFD != PrevTemplated)

shafik wrote:
> Can we guarantee that `FoundByLookup->getTemplatedDecl()` will always return 
> a valid pointer? 
This is a good catch, thanks.
The `FoundByLookup` variable's type is `FunctionTemplateDecl`. Either the found 
Decl is created by the parser then it must have set up a templated decl, or it 
is created by the ASTImporter and we should have a templated decl set.
In the second case, however, we may not be 100% sure that the templated is 
really set.
So I have added an assert here too.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58494/new/

https://reviews.llvm.org/D58494



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


[PATCH] D48866: [clang-tidy] Add incorrect-pointer-cast checker

2019-03-07 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

@hgabii Are you planning on finishing this? If not, I'd happily commandeer if 
not.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D48866/new/

https://reviews.llvm.org/D48866



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


[PATCH] D59079: [clang][Tooling] Delete dots and dotdots when generating absolute paths

2019-03-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Tooling/JSONCompilationDatabase.cpp:373
   llvm::sys::path::append(AbsolutePath, FileName);
+  llvm::sys::path::remove_dots(AbsolutePath, true);
   llvm::sys::path::native(AbsolutePath, NativeFilePath);

nit: add the `/*remove_dot_dot=*/` for the `true` parameter.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59079/new/

https://reviews.llvm.org/D59079



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


r355586 - [libclang] Fix CXTranslationUnit_KeepGoing

2019-03-07 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Thu Mar  7 02:13:50 2019
New Revision: 355586

URL: http://llvm.org/viewvc/llvm-project?rev=355586&view=rev
Log:
[libclang] Fix CXTranslationUnit_KeepGoing

Since
  commit 56f5487e4387a69708f70724d00e9e076153
  [modules] Round-trip -Werror flag through explicit module build.
the behavior of CXTranslationUnit_KeepGoing changed:
Unresolved #includes are fatal errors again. As a consequence, some
templates are not instantiated and lead to confusing errors.

Revert to the old behavior: With CXTranslationUnit_KeepGoing fatal
errors are mapped to errors.

Patch by Nikolai Kosjar.

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

Added:
cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h
cfe/trunk/test/Index/keep-going-template-instantiations.cpp
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/test/Index/keep-going.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/Basic/DiagnosticTest.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=355586&r1=355585&r2=355586&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Mar  7 02:13:50 2019
@@ -209,8 +209,8 @@ private:
   // Used by __extension__
   unsigned char AllExtensionsSilenced = 0;
 
-  // Suppress diagnostics after a fatal error?
-  bool SuppressAfterFatalError = true;
+  // Treat fatal errors like errors.
+  bool FatalsAsError = false;
 
   // Suppress all diagnostics.
   bool SuppressAllDiagnostics = false;
@@ -614,9 +614,11 @@ public:
   void setErrorsAsFatal(bool Val) { GetCurDiagState()->ErrorsAsFatal = Val; }
   bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; }
 
-  /// When set to true (the default), suppress further diagnostics after
-  /// a fatal error.
-  void setSuppressAfterFatalError(bool Val) { SuppressAfterFatalError = Val; }
+  /// \brief When set to true, any fatal error reported is made an error.
+  ///
+  /// This setting takes precedence over the setErrorsAsFatal setting above.
+  void setFatalsAsError(bool Val) { FatalsAsError = Val; }
+  bool getFatalsAsError() const { return FatalsAsError; }
 
   /// When set to true mask warnings that come from system headers.
   void setSuppressSystemWarnings(bool Val) {

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=355586&r1=355585&r2=355586&view=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Mar  7 02:13:50 2019
@@ -481,6 +481,11 @@ DiagnosticIDs::getDiagnosticSeverity(uns
   Result = diag::Severity::Fatal;
   }
 
+  // If explicitly requested, map fatal errors to errors.
+  if (Result == diag::Severity::Fatal &&
+  Diag.CurDiagID != diag::fatal_too_many_errors && Diag.FatalsAsError)
+Result = diag::Severity::Error;
+
   // Custom diagnostics always are emitted in system headers.
   bool ShowInSystemHeader =
   !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;
@@ -660,7 +665,7 @@ bool DiagnosticIDs::ProcessDiag(Diagnost
 
   // If a fatal error has already been emitted, silence all subsequent
   // diagnostics.
-  if (Diag.FatalErrorOccurred && Diag.SuppressAfterFatalError) {
+  if (Diag.FatalErrorOccurred) {
 if (DiagLevel >= DiagnosticIDs::Error &&
 Diag.Client->IncludeInDiagnosticCounts()) {
   ++Diag.NumErrors;

Added: cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h?rev=355586&view=auto
==
--- cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h (added)
+++ cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h Thu Mar  7 
02:13:50 2019
@@ -0,0 +1,3 @@
+template struct c {};
+using d = c;
+struct foo : public d {};

Added: cfe/trunk/test/Index/keep-going-template-instantiations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/keep-going-template-instantiations.cpp?rev=355586&view=auto
==
--- cfe/trunk/test/Index/keep-going-template-instantiations.cpp (added)
+++ cfe/trunk/test/Index/keep-going-template-instantiations.cpp Thu Mar  7 
02:13:50 2019
@@ -0,0 +1,5 @@
+#include "missing.h"
+#include 
+
+// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -test-load-source none 
-I%S/Inputs %s 2>&1 | FileCheck %s
+// CHECK-NOT: error: expected class name

Modified: cfe/trunk/test/Index/keep-going.cpp
URL: 
http://llvm.org/viewvc/llvm-

[PATCH] D58501: [libclang] Fix CXTranslationUnit_KeepGoing

2019-03-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355586: [libclang] Fix CXTranslationUnit_KeepGoing (authored 
by yvvan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58501?vs=187765&id=189668#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58501/new/

https://reviews.llvm.org/D58501

Files:
  cfe/trunk/include/clang/Basic/Diagnostic.h
  cfe/trunk/lib/Basic/DiagnosticIDs.cpp
  cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h
  cfe/trunk/test/Index/keep-going-template-instantiations.cpp
  cfe/trunk/test/Index/keep-going.cpp
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/unittests/Basic/DiagnosticTest.cpp

Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
===
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp
@@ -481,6 +481,11 @@
   Result = diag::Severity::Fatal;
   }
 
+  // If explicitly requested, map fatal errors to errors.
+  if (Result == diag::Severity::Fatal &&
+  Diag.CurDiagID != diag::fatal_too_many_errors && Diag.FatalsAsError)
+Result = diag::Severity::Error;
+
   // Custom diagnostics always are emitted in system headers.
   bool ShowInSystemHeader =
   !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;
@@ -660,7 +665,7 @@
 
   // If a fatal error has already been emitted, silence all subsequent
   // diagnostics.
-  if (Diag.FatalErrorOccurred && Diag.SuppressAfterFatalError) {
+  if (Diag.FatalErrorOccurred) {
 if (DiagLevel >= DiagnosticIDs::Error &&
 Diag.Client->IncludeInDiagnosticCounts()) {
   ++Diag.NumErrors;
Index: cfe/trunk/unittests/Basic/DiagnosticTest.cpp
===
--- cfe/trunk/unittests/Basic/DiagnosticTest.cpp
+++ cfe/trunk/unittests/Basic/DiagnosticTest.cpp
@@ -46,13 +46,13 @@
   EXPECT_FALSE(Diags.hasUnrecoverableErrorOccurred());
 }
 
-// Check that SuppressAfterFatalError works as intended
-TEST(DiagnosticTest, suppressAfterFatalError) {
-  for (unsigned Suppress = 0; Suppress != 2; ++Suppress) {
+// Check that FatalsAsError works as intended
+TEST(DiagnosticTest, fatalsAsError) {
+  for (unsigned FatalsAsError = 0; FatalsAsError != 2; ++FatalsAsError) {
 DiagnosticsEngine Diags(new DiagnosticIDs(),
 new DiagnosticOptions,
 new IgnoringDiagConsumer());
-Diags.setSuppressAfterFatalError(Suppress);
+Diags.setFatalsAsError(FatalsAsError);
 
 // Diag that would set UnrecoverableErrorOccurred and ErrorOccurred.
 Diags.Report(diag::err_cannot_open_file) << "file" << "error";
@@ -62,16 +62,15 @@
 Diags.Report(diag::warn_mt_message) << "warning";
 
 EXPECT_TRUE(Diags.hasErrorOccurred());
-EXPECT_TRUE(Diags.hasFatalErrorOccurred());
+EXPECT_EQ(Diags.hasFatalErrorOccurred(), FatalsAsError ? 0u : 1u);
 EXPECT_TRUE(Diags.hasUncompilableErrorOccurred());
 EXPECT_TRUE(Diags.hasUnrecoverableErrorOccurred());
 
 // The warning should be emitted and counted only if we're not suppressing
 // after fatal errors.
-EXPECT_EQ(Diags.getNumWarnings(), Suppress ? 0u : 1u);
+EXPECT_EQ(Diags.getNumWarnings(), FatalsAsError);
   }
 }
-
 TEST(DiagnosticTest, diagnosticError) {
   DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions,
   new IgnoringDiagConsumer());
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -3408,7 +3408,7 @@
 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
 
   if (options & CXTranslationUnit_KeepGoing)
-Diags->setSuppressAfterFatalError(false);
+Diags->setFatalsAsError(true);
 
   // Recover resources if we crash before exiting this function.
   llvm::CrashRecoveryContextCleanupRegistrarErrorsAsFatal = Val; }
   bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; }
 
-  /// When set to true (the default), suppress further diagnostics after
-  /// a fatal error.
-  void setSuppressAfterFatalError(bool Val) { SuppressAfterFatalError = Val; }
+  /// \brief When set to true, any fatal error reported is made an error.
+  ///
+  /// This setting takes precedence over the setErrorsAsFatal setting above.
+  void setFatalsAsError(bool Val) { FatalsAsError = Val; }
+  bool getFatalsAsError() const { return FatalsAsError; }
 
   /// When set to true mask warnings that come from system headers.
   void setSuppressSystemWarnings(bool Val) {
Index: cfe/trunk/test/Index/keep-going-template-instantiations.cpp
===
--- cfe/trunk/test/Index/keep-going-template-instantiations.cpp
+++ cfe/trunk/test/Index/k

[PATCH] D57891: [analyzer] Fix infinite recursion in printing macros

2019-03-07 Thread Tibor Brunner via Phabricator via cfe-commits
bruntib updated this revision to Diff 189670.
bruntib added a comment.
Herald added subscribers: Charusso, jdoerfert, whisperity.

I added a test case for this recursive case. There is also a TODO in the code 
indicating the place where an additional fix will be required.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57891/new/

https://reviews.llvm.org/D57891

Files:
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
  test/Analysis/plist-macros-with-expansion.cpp

Index: test/Analysis/plist-macros-with-expansion.cpp
===
--- test/Analysis/plist-macros-with-expansion.cpp
+++ test/Analysis/plist-macros-with-expansion.cpp
@@ -440,3 +440,14 @@
 }
 // CHECK: nameYET_ANOTHER_SET_TO_NULL
 // CHECK-NEXT: expansionprint((void *)5); print((void *)"Remember the Vasa"); ptr = nullptr;
+
+int garbage_value;
+
+#define REC_MACRO_FUNC(REC_MACRO_PARAM) garbage_##REC_MACRO_PARAM
+#define value REC_MACRO_FUNC(value)
+
+void recursiveMacroUser() {
+  if (value == 0)
+1 / value; // expected-warning{{Division by zero}}
+   // expected-warning@-1{{expression result unused}}
+}
Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
===
--- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
+++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
@@ -5443,6 +5443,140 @@

   
   
+  
+   path
+   
+
+ kindcontrol
+ edges
+  
+   
+start
+ 
+  
+   line450
+   col3
+   file0
+  
+  
+   line450
+   col4
+   file0
+  
+ 
+end
+ 
+  
+   line450
+   col7
+   file0
+  
+  
+   line450
+   col11
+   file0
+  
+ 
+   
+  
+
+
+ kindevent
+ location
+ 
+  line450
+  col7
+  file0
+ 
+ ranges
+ 
+   
+
+ line450
+ col7
+ file0
+
+
+ line450
+ col16
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Assuming 'garbage_value' is equal to 0
+ message
+ Assuming 'garbage_value' is equal to 0
+
+
+ kindevent
+ location
+ 
+  line451
+  col7
+  file0
+ 
+ ranges
+ 
+   
+
+ line451
+ col5
+ file0
+
+
+ line451
+ col13
+ file0
+
+   
+ 
+ depth0
+ extended_message
+ Division by zero
+ message
+ Division by zero
+
+   
+   macro_expansions
+   
+
+ location
+ 
+  line450
+  col7
+  file0
+ 
+ namevalue
+ expansiongarbage_
+
+   
+   descriptionDivision by zero
+   categoryLogic error
+   typeDivision by zero
+   check_namecore.DivideZero
+   
+   issue_hash_content_of_line_in_context1f3c94860e67b6b863e956bd67e49f1d
+  issue_context_kindfunction
+  issue_contextrecursiveMacroUser
+  issue_hash_function_offset2
+  location
+  
+   line451
+   col7
+   file0
+  
+  ExecutedLines
+  
+   0
+   
+449
+450
+451
+   
+  
+  
  
  files
  
Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -22,6 +22,7 @@
 #include "clang/StaticAnalyzer/Core/IssueHash.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 
@@ -776,10 +777,20 @@
 /// As we expand the last line, we'll immediately replace PRINT(str) with
 /// print(x). The information that both 'str' and 'x' refers to the same string
 /// is an information we have to forward, hence the argument \p PrevArgs.
-static std::string getMacroNameAndPrintExpansion(TokenPrinter &Printer,
- SourceLocation MacroLoc,
- const Preprocessor &PP,
- const MacroArgMap &PrevArgs);
+///
+/// To avoid infinite recursion we maintain the already processed tokens in
+/// a set. This is carried as a parameter through the recursive calls. The set
+/// is extended with the currently processed token and after processing it, the
+/// token is removed. If the token is already in the set, then recursion stops:
+///
+/// #define f(y) x
+/// #define x f(x)
+static std::string getMacroNameAndPrintExpansion(
+TokenPrinter &Printer,
+SourceLocation MacroLoc,
+const

[PATCH] D57891: [analyzer] Fix infinite recursion in printing macros

2019-03-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Well, yea, getting rid of a crash is great, it's kind of bummer that can't 
expand the macro properly in the testfile. I really fear that we need a far 
greater overhaul of this entire effort to support them properly -- which should 
be the task of another patch.

Thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57891/new/

https://reviews.llvm.org/D57891



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


[PATCH] D59083: [clangd] Store explicit template specializations in index for code navigation purposes

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: hokein, gribozavr.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.
Herald added a project: clang.

This introduces ~4k new symbols, and ~10k refs for LLVM. We need that
information for providing better code navigation support, like find references,
children/base classes etc.

Number of symbols: 378574 -> 382784
Number of refs: 5098857 -> 5110689


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59083

Files:
  clangd/CodeComplete.cpp
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -392,17 +392,24 @@
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(
-// Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
-template <> struct Tmpl {};
-extern template struct Tmpl;
-template struct Tmpl;
+// Template and explicit specialization is indexed, instantiation is not.
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
+template <> struct $specdecl[[Tmpl]] {};
+template  struct $partspecdecl[[Tmpl]] {};
+extern template struct Tmpl;
+template struct Tmpl;
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
   EXPECT_THAT(Symbols,
-  UnorderedElementsAreArray(
-  {AllOf(QName("Tmpl"), DeclRange(Header.range())),
-   AllOf(QName("Tmpl::x"), 
DeclRange(Header.range("xdecl")))}));
+  UnorderedElementsAre(
+  AllOf(QName("Tmpl"), DeclRange(Header.range()),
+ForCodeCompletion(true)),
+  AllOf(QName("Tmpl"), DeclRange(Header.range("specdecl")),
+ForCodeCompletion(false)),
+  AllOf(QName("Tmpl"), DeclRange(Header.range("partspecdecl")),
+ForCodeCompletion(false)),
+  AllOf(QName("Tmpl::x"), DeclRange(Header.range("xdecl")),
+ForCodeCompletion(false;
 }
 
 TEST_F(SymbolCollectorTest, ObjCSymbols) {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -221,13 +221,6 @@
   return static_cast(static_cast(RefKind::All) & Roles);
 }
 
-template  bool explicitTemplateSpecialization(const NamedDecl &ND) {
-  if (const auto *TD = dyn_cast(&ND))
-if (TD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
-  return true;
-  return false;
-}
-
 } // namespace
 
 SymbolCollector::SymbolCollector(Options Opts) : Opts(std::move(Opts)) {}
@@ -279,10 +272,6 @@
 if (!isa(DeclCtx))
   return false;
   }
-  if (explicitTemplateSpecialization(ND) ||
-  explicitTemplateSpecialization(ND) ||
-  explicitTemplateSpecialization(ND))
-return false;
 
   // Avoid indexing internal symbols in protobuf generated headers.
   if (isPrivateProtoDecl(ND))
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1510,6 +1510,13 @@
   }
 };
 
+template  bool explicitTemplateSpecialization(const NamedDecl &ND) {
+  if (const auto *TD = dyn_cast(&ND))
+if (TD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+  return true;
+  return false;
+}
+
 } // namespace
 
 clang::CodeCompleteOptions CodeCompleteOptions::getClangCompleteOpts() const {
@@ -1603,6 +1610,13 @@
 };
 return false;
   };
+  // We index explicit template specializations merely for code navigation
+  // support.
+  if (explicitTemplateSpecialization(ND) ||
+  explicitTemplateSpecialization(ND) ||
+  explicitTemplateSpecialization(ND))
+return false;
+
   if (InTopLevelScope(ND))
 return true;
 


Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -392,17 +392,24 @@
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(
-// Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
-template <> struct Tmpl {};
-extern template struct Tmpl;
-template struct Tmpl;
+// Template and explicit specialization is indexed, instantiation is not.
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
+template <> struct $specdecl[[Tmpl]] {};
+template  struct $partspecdecl[[Tmpl]] {};
+extern template struct Tmpl;
+template struct Tmpl;
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
   EXPECT_THAT(Symbols,
-  

[PATCH] D59084: [clangd] Remove ./ and ../ in the file paths

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59084

Files:
  clangd/index/Background.cpp


Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -121,6 +121,7 @@
   } else {
 AbsolutePath = Cmd.Directory;
 llvm::sys::path::append(AbsolutePath, Cmd.Filename);
+llvm::sys::path::remove_dots(AbsolutePath, true);
   }
   return AbsolutePath;
 }


Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -121,6 +121,7 @@
   } else {
 AbsolutePath = Cmd.Directory;
 llvm::sys::path::append(AbsolutePath, Cmd.Filename);
+llvm::sys::path::remove_dots(AbsolutePath, true);
   }
   return AbsolutePath;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59038: [8.0 Regression] Fix handling of `__builtin_constant_p` inside the enable_if attribute.

2019-03-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I think I'll have to defer to Richard for reviewing this, since I'm not 
familiar with the code. Since it's a regression we probably want to merge it to 
clang 8. Can you give any guidance to how bad a regression this is, e.g. does 
it break some important piece of code?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59038/new/

https://reviews.llvm.org/D59038



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


[PATCH] D59083: [clangd] Store explicit template specializations in index for code navigation purposes

2019-03-07 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/CodeComplete.cpp:1513
 
+template  bool explicitTemplateSpecialization(const NamedDecl &ND) {
+  if (const auto *TD = dyn_cast(&ND))

isExplicitTemplateSpecialization?



Comment at: unittests/clangd/SymbolCollectorTests.cpp:395
   Annotations Header(R"(
-// Template is indexed, specialization and instantiation is not.
-template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};
-template <> struct Tmpl {};
-extern template struct Tmpl;
-template struct Tmpl;
+// Template and explicit specialization is indexed, instantiation is not.
+template  struct [[Tmpl]] {T $xdecl[[x]] = 0;};

"Template" -> "Primary template"

"is indexed" -> "are indexed"


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59083/new/

https://reviews.llvm.org/D59083



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: gribozavr, hokein.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.
Herald added a project: clang.

As can be seen in 
https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same 
GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.

This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.

Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59086

Files:
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -23,8 +23,8 @@
   DirectoryBasedGlobalCompilationDatabase DB(None);
   auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
   EXPECT_EQ(Cmd.Directory, testPath("foo"));
-  EXPECT_THAT(Cmd.CommandLine, ElementsAre(
-EndsWith("clang"), testPath("foo/bar.cc")));
+  EXPECT_THAT(Cmd.CommandLine,
+  ElementsAre(EndsWith("clang"), testPath("foo/bar.cc")));
   EXPECT_EQ(Cmd.Output, "");
 
   // .h files have unknown language, so they are parsed liberally as obj-c++.
@@ -66,15 +66,17 @@
 TEST_F(OverlayCDBTest, GetCompileCommand) {
   OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
-Base->getCompileCommand(testPath("foo.cc")));
+CDB.adjustArguments(*Base->getCompileCommand(testPath("foo.cc";
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
 
   auto Override = cmd(testPath("foo.cc"), "-DA=3");
   CDB.setCompileCommand(testPath("foo.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
+CDB.adjustArguments(Override));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
   CDB.setCompileCommand(testPath("missing.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")),
+CDB.adjustArguments(Override));
 }
 
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
@@ -88,6 +90,7 @@
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
+  Override = CDB.adjustArguments(Override);
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -11,6 +11,8 @@
 
 #include "Function.h"
 #include "Path.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include 
@@ -110,6 +112,9 @@
   setCompileCommand(PathRef File,
 llvm::Optional CompilationCommand);
 
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -19,25 +19,6 @@
 namespace clangd {
 namespace {
 
-void adjustArguments(tooling::CompileCommand &Cmd,
- llvm::StringRef ResourceDir) {
-  // Clangd does not generate dependency file.
-  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(
-  Cmd.CommandLine, Cmd.Filename);
-  // Strip plugin related command line arguments. Clangd does
-  // not support plugins currently. Therefore it breaks if
-  // compiler tries to load plugins.
-  Cmd.CommandLine =
-  tooling::getStripPluginsAdjuster()(Cmd.CommandLine, Cmd.Filename);
-
-  Cmd.CommandLine =
-  tooling::getClangSyntaxOnlyAdjuster()(Cmd.CommandLine, Cmd.Filename);
-  // Inject the resource dir.
-  // FIXME: Don't overwrite it if it's already there.
-  if (!ResourceDir.empty())
-Cmd.CommandLine.push_back(("-resource-dir=" + ResourceDir).str());
-}
-
 st

[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 189682.
kadircet added a comment.

- Update the diff, sorry for the confusion


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086

Files:
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -23,8 +23,8 @@
   DirectoryBasedGlobalCompilationDatabase DB(None);
   auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
   EXPECT_EQ(Cmd.Directory, testPath("foo"));
-  EXPECT_THAT(Cmd.CommandLine, ElementsAre(
-EndsWith("clang"), testPath("foo/bar.cc")));
+  EXPECT_THAT(Cmd.CommandLine,
+  ElementsAre(EndsWith("clang"), testPath("foo/bar.cc")));
   EXPECT_EQ(Cmd.Output, "");
 
   // .h files have unknown language, so they are parsed liberally as obj-c++.
@@ -66,15 +66,17 @@
 TEST_F(OverlayCDBTest, GetCompileCommand) {
   OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
-Base->getCompileCommand(testPath("foo.cc")));
+CDB.adjustArguments(*Base->getCompileCommand(testPath("foo.cc";
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
 
   auto Override = cmd(testPath("foo.cc"), "-DA=3");
   CDB.setCompileCommand(testPath("foo.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
+CDB.adjustArguments(Override));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
   CDB.setCompileCommand(testPath("missing.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")),
+CDB.adjustArguments(Override));
 }
 
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
@@ -88,6 +90,7 @@
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
+  Override = CDB.adjustArguments(Override);
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -11,6 +11,8 @@
 
 #include "Function.h"
 #include "Path.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
+#include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include 
@@ -110,6 +112,9 @@
   setCompileCommand(PathRef File,
 llvm::Optional CompilationCommand);
 
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -19,19 +19,6 @@
 namespace clangd {
 namespace {
 
-void adjustArguments(tooling::CompileCommand &Cmd,
- llvm::StringRef ResourceDir) {
-  // Strip plugin related command line arguments. Clangd does
-  // not support plugins currently. Therefore it breaks if
-  // compiler tries to load plugins.
-  Cmd.CommandLine =
-  tooling::getStripPluginsAdjuster()(Cmd.CommandLine, Cmd.Filename);
-  // Inject the resource dir.
-  // FIXME: Don't overwrite it if it's already there.
-  if (!ResourceDir.empty())
-Cmd.CommandLine.push_back(("-resource-dir=" + ResourceDir).str());
-}
-
 std::string getStandardResourceDir() {
   static int Dummy; // Just an address in this process.
   return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
@@ -156,8 +143,7 @@
 Cmd = Base->getCompileCommand(File, Project);
   if (!Cmd)
 return llvm::None;
-  adjustArguments(*Cmd, ResourceDir);
-  return Cmd;
+  return adjustArguments(*Cmd);
 }
 
 tooling::CompileCommand OverlayCDB::getFallbackCommand(PathRef File) const {
@@ -181,5 +167,25 @@
   OnCommandChanged.broadcast({File});
 }
 
+tooling::CompileCommand
+OverlayCDB::adjustArguments(tooling::CompileCommand Cmd) const {
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(
+  Cmd.CommandLine, Cmd.Filename);
+  // Strip plugin related command line arguments. Clangd does
+  // not support plugins currently. Therefore it breaks if
+  // compiler tries to load plugins.

[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-03-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, djasper, JonasToth, alexfh, krasimir.
MyDeveloperDay added a project: clang-tools-extra.
Herald added a subscriber: jdoerfert.

Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

  if(true) var++;
  else  {
  var--;
  }

is reformatted to be

  if (true)
var++;
  else {
var--;
  }

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support 
AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a 
compound else


https://reviews.llvm.org/D59087

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -487,6 +487,34 @@
   verifyFormat("if (a)\n  return;", AllowsMergedIf);
 }
 
+TEST_F(FormatTest, FormatIfWithoutCompoundStatementButElseWith) {
+  FormatStyle AllowsMergedIf = getLLVMStyle();
+  AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
+  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
+  verifyFormat("if (a)\n"
+   "  f();\n"
+   "else {\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+
+  AllowsMergedIf.AllowShortIfElseStatementsOnASingleLine = true;
+  verifyFormat("if (a) f();\n"
+   "else {\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+  verifyFormat("if (a) f();\n"
+   "else {\n"
+   "  if (a) f();\n"
+   "  else {\n"
+   "g();\n"
+   "  }\n"
+   "  g();\n"
+   "}",
+   AllowsMergedIf);
+}
+
 TEST_F(FormatTest, FormatLoopsWithoutCompoundStatement) {
   FormatStyle AllowsMergedLoops = getLLVMStyle();
   AllowsMergedLoops.AllowShortLoopsOnASingleLine = true;
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -413,10 +413,12 @@
 if (I[1]->First->isOneOf(tok::semi, tok::kw_if, tok::kw_for, tok::kw_while,
  TT_LineComment))
   return 0;
-// Only inline simple if's (no nested if or else).
-if (I + 2 != E && Line.startsWith(tok::kw_if) &&
-I[2]->First->is(tok::kw_else))
-  return 0;
+// Only inline simple if's (no nested if or else), unless specified
+if (!Style.AllowShortIfElseStatementsOnASingleLine) {
+  if (I + 2 != E && Line.startsWith(tok::kw_if) &&
+  I[2]->First->is(tok::kw_else))
+return 0;
+}
 return 1;
   }
 
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -331,6 +331,8 @@
Style.AllowShortFunctionsOnASingleLine);
 IO.mapOptional("AllowShortIfStatementsOnASingleLine",
Style.AllowShortIfStatementsOnASingleLine);
+IO.mapOptional("AllowShortIfElseStatementsOnASingleLine",
+   Style.AllowShortIfElseStatementsOnASingleLine);
 IO.mapOptional("AllowShortLoopsOnASingleLine",
Style.AllowShortLoopsOnASingleLine);
 IO.mapOptional("AlwaysBreakAfterDefinitionReturnType",
@@ -632,6 +634,7 @@
   LLVMStyle.AllowShortBlocksOnASingleLine = false;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
   LLVMStyle.AllowShortIfStatementsOnASingleLine = false;
+  LLVMStyle.AllowShortIfElseStatementsOnASingleLine = false;
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -365,11 +365,27 @@
   };
   void f() { bar(); }
 
-
-
 **AllowShortIfStatementsOnASingleLine** (``bool``)
   If ``true``, ``if (a) return;`` can be put on a single line.
 
+  .. code-block:: c++
+
+   if (a) return;
+   else 
+ return;
+
+**AllowShortIfElseStatementsOnASingleLine** (``bool``)
+  When used in conjuction with ``AllowShortIfIfStatementsOnASingleLine``
+  then when ``true``, ``if (a) return;`` can be put on a single even when
+  the else clause is a compound statement
+
+  .. code-block:: c++
+
+   if (a) return;
+   else {
+  return;
+   }
+
 **AllowShortLoopsOnASingleLine** (``bool``)
   If ``true``, ``while (

[PATCH] D59083: [clangd] Store explicit template specializations in index for code navigation purposes

2019-03-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

> We need that information for providing better code navigation support, like 
> find references, children/base classes etc.

It's not trivial how they make code navigation better. Can you explain and 
provide examples in the summary? Thanks!




Comment at: clangd/CodeComplete.cpp:1613
   };
+  // We index explicit template specializations merely for code navigation
+  // support.

nit: the context here is code completion. Maybe explain why they are not 
interesting for completion rather than why we index them?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59083/new/

https://reviews.llvm.org/D59083



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/GlobalCompilationDatabase.h:116
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+

This doesn't seem to be used in this patch (except for tests). Could you 
include intended uses in the patch so we can understand the problem better?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D59038: [8.0 Regression] Fix handling of `__builtin_constant_p` inside the enable_if attribute.

2019-03-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In D59038#1421310 , @hans wrote:

> I think I'll have to defer to Richard for reviewing this, since I'm not 
> familiar with the code. Since it's a regression we probably want to merge it 
> to clang 8. Can you give any guidance to how bad a regression this is, e.g. 
> does it break some important piece of code?


It breaks `absl::StrFormat` [1][2]. And it breaks libstdc++'s 
`std::string_view` inside unevaluated constant expressions [3].

This regression is a problem for Abseil.

[1] https://godbolt.org/z/Q_J2JP
[2] https://github.com/abseil/abseil-cpp/issues/271
[3 https://godbolt.org/z/Fg1sqM]


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59038/new/

https://reviews.llvm.org/D59038



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


[PATCH] D58818: [clang-tidy] added cppcoreguidelines-use-raii-locks check

2019-03-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-use-raii-locks.cpp:90
+  for (auto i = 0; i < 3; i++) {
+m.lock();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use RAII

JonasToth wrote:
> lewmpk wrote:
> > JonasToth wrote:
> > > I got another one that I think defeats the analysis:
> > > 
> > > ```
> > > while (true)
> > > {
> > > 
> > > my_label:
> > >   m.lock();
> > > 
> > >   if (some_condition)
> > > goto my_label;
> > >   
> > >   m.unlock();
> > > }
> > > ```
> > > Usage of `goto` can interfer and make the situation more complicated. I 
> > > am not asking you to implement that correctly (not sure if even possible 
> > > with pure clang-tidy) but I think a pathological example should be 
> > > documented for the user.
> > why would this defeat the analysis?
> Because `goto` allows you to reorder you code-locations, so the ordering of 
> what comes before what is not so ez.
let me restate: You are comparing the occurences of `lock` and `unlock` by 
linenumber, so physical appearance in the source code. `goto` allows you to 
jump wildly through your code, so that physical appearance does not match 
actual control flow.
I am not saying that you need to resolve that (not easily done within 
clang-tidy), but documenting it is worth it.
And if you mix `goto` and locking mechanisms, you get what you deserve, which 
is no help from tooling ;)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58818/new/

https://reviews.llvm.org/D58818



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


[PATCH] D58818: [clang-tidy] added cppcoreguidelines-use-raii-locks check

2019-03-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

IMHO the check is close to being finished. please address the notes and mark 
them as done if finished with it. So its clear to see whats outstanding.
In my opinion the user-facing documentation misses a "Limitations" sections 
that shows the artificial `goto` example, that would show that the used 
mechanism doesn't handle it.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58818/new/

https://reviews.llvm.org/D58818



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/GlobalCompilationDatabase.h:116
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+

ioeric wrote:
> This doesn't seem to be used in this patch (except for tests). Could you 
> include intended uses in the patch so we can understand the problem better?
Looks like this patch introduces two changes:

- move the internal adjustArguments to public, I have the same question, any 
reason doing it? because we can test it? 
- add additional Adjusters to adjustArguments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D59084: [clangd] Remove ./ and ../ in the file paths

2019-03-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

It would be nicer to have a unittest (if it doesn't take too much effort to 
create one).


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59084/new/

https://reviews.llvm.org/D59084



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


r355592 - [analyzer] Handle comparison between non-default AS symbol and constant

2019-03-07 Thread David Stenberg via cfe-commits
Author: dstenb
Date: Thu Mar  7 05:01:17 2019
New Revision: 355592

URL: http://llvm.org/viewvc/llvm-project?rev=355592&view=rev
Log:
[analyzer] Handle comparison between non-default AS symbol and constant

Summary:
When comparing a symbolic region and a constant, the constant would be
widened or truncated to the width of a void pointer, meaning that the
constant could be incorrectly truncated when handling symbols for
non-default address spaces. In the attached test case this resulted in a
false positive since the constant was truncated to zero. To fix this,
widen/truncate the constant to the width of the symbol expression's
type.

This commit does not consider non-symbolic regions as I'm not sure how
to generalize getting the type there.

This fixes PR40814.

Reviewers: NoQ, zaks.anna, george.karpenkov

Reviewed By: NoQ

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, jdoerfert, Charusso, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Analysis/ptr-cmp-const-trunc.cl
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=355592&r1=355591&r2=355592&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Thu Mar  7 05:01:17 
2019
@@ -571,7 +571,15 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
   // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // If the region has a symbolic base, pay attention to the type; it
+  // might be coming from a non-default address space. For non-symbolic
+  // regions it doesn't matter that much because such comparisons would
+  // most likely evaluate to concrete false anyway. FIXME: We might
+  // still need to handle the non-comparison case.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
+BasicVals.getAPSIntType(lSym->getType()).apply(i);
+  else
+BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
 }
 default:

Added: cfe/trunk/test/Analysis/ptr-cmp-const-trunc.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-cmp-const-trunc.cl?rev=355592&view=auto
==
--- cfe/trunk/test/Analysis/ptr-cmp-const-trunc.cl (added)
+++ cfe/trunk/test/Analysis/ptr-cmp-const-trunc.cl Thu Mar  7 05:01:17 2019
@@ -0,0 +1,11 @@
+//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze 
-analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+#include 
+
+void bar(__global int *p) __attribute__((nonnull(1)));
+
+void foo(__global int *p) {
+  if ((uint64_t)p <= 1UL << 32)
+bar(p); // no-warning
+}


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


r355593 - [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-03-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Thu Mar  7 05:01:51 2019
New Revision: 355593

URL: http://llvm.org/viewvc/llvm-project?rev=355593&view=rev
Log:
[ASTImporter] Handle redecl chain of FunctionTemplateDecls

Summary:
Redecl chains of function templates are not handled well currently. We
want to handle them similarly to functions, i.e. try to keep the
structure of the original AST as much as possible. The aim is to not
squash a prototype with a definition, rather we create both and put them
in a redecl chain.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=355593&r1=355592&r2=355593&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Mar  7 05:01:51 2019
@@ -4943,15 +4943,15 @@ ASTNodeImporter::VisitTemplateTemplatePa
   return ToD;
 }
 
-// Returns the definition for a (forward) declaration of a ClassTemplateDecl, 
if
+// Returns the definition for a (forward) declaration of a TemplateDecl, if
 // it has any definition in the redecl chain.
-static ClassTemplateDecl *getDefinition(ClassTemplateDecl *D) {
-  CXXRecordDecl *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
+template  static auto getTemplateDefinition(T *D) -> T * {
+  assert(D->getTemplatedDecl() && "Should be called on templates only");
+  auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
   if (!ToTemplatedDef)
 return nullptr;
-  ClassTemplateDecl *TemplateWithDef =
-  ToTemplatedDef->getDescribedClassTemplate();
-  return TemplateWithDef;
+  auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
+  return cast_or_null(TemplateWithDef);
 }
 
 ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
@@ -4983,7 +4983,8 @@ ExpectedDecl ASTNodeImporter::VisitClass
   if (FoundTemplate) {
 
 if (IsStructuralMatch(D, FoundTemplate)) {
-  ClassTemplateDecl *TemplateWithDef = getDefinition(FoundTemplate);
+  ClassTemplateDecl *TemplateWithDef =
+  getTemplateDefinition(FoundTemplate);
   if (D->isThisDeclarationADefinition() && TemplateWithDef) {
 return Importer.MapImported(D, TemplateWithDef);
   }
@@ -5046,6 +5047,8 @@ ExpectedDecl ASTNodeImporter::VisitClass
 // and this time the lookup finds the previous fwd friend class template.
 // In this case we must set up the previous decl for the templated decl.
 if (!ToTemplated->getPreviousDecl()) {
+  assert(FoundByLookup->getTemplatedDecl() &&
+ "Found decl must have its templated decl set");
   CXXRecordDecl *PrevTemplated =
   FoundByLookup->getTemplatedDecl()->getMostRecentDecl();
   if (ToTemplated != PrevTemplated)
@@ -5508,8 +5511,11 @@ ASTNodeImporter::VisitFunctionTemplateDe
   if (ToD)
 return ToD;
 
+  const FunctionTemplateDecl *FoundByLookup = nullptr;
+
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
+  // FIXME Split this into a separate function.
   if (!LexicalDC->isFunctionOrMethod()) {
 unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
@@ -5517,18 +5523,21 @@ ASTNodeImporter::VisitFunctionTemplateDe
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
 continue;
 
-  if (auto *FoundFunction =
-  dyn_cast(FoundDecl)) {
-if (FoundFunction->hasExternalFormalLinkage() &&
+  if (auto *FoundTemplate = dyn_cast(FoundDecl)) {
+if (FoundTemplate->hasExternalFormalLinkage() &&
 D->hasExternalFormalLinkage()) {
-  if (IsStructuralMatch(D, FoundFunction)) {
-Importer.MapImported(D, FoundFunction);
-// FIXME: Actually try to merge the body and other attributes.
-return FoundFunction;
+  if (IsStructuralMatch(D, FoundTemplate)) {
+FunctionTemplateDecl *TemplateWithDef =
+getTemplateDefinition(FoundTemplate);
+if (D->isThisDeclarationADefinition() && TemplateWithDef) {
+  return Importer.MapImported(D, TemplateWithDef);
+}
+FoundByLookup = FoundTemplate;
+break;
   }
+  // TODO: handle conflicting names
 }
   }
-  // TODO: handle conflicting names
 }
   }
 
@@ -5547,10 +5556,25 @@ ASTNodeImporter::VisitFunctionTemplateDe
 return ToFunc;
 
   TemplatedFD->setDescribedFunctionTemplate(ToFunc);
+
   ToFunc->setAccess(D->getAccess());
   ToFunc->setLexicalDeclContext

[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC355593: [ASTImporter] Handle redecl chain of 
FunctionTemplateDecls (authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58494?vs=189665&id=189694#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58494/new/

https://reviews.llvm.org/D58494

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -4943,15 +4943,15 @@
   return ToD;
 }
 
-// Returns the definition for a (forward) declaration of a ClassTemplateDecl, if
+// Returns the definition for a (forward) declaration of a TemplateDecl, if
 // it has any definition in the redecl chain.
-static ClassTemplateDecl *getDefinition(ClassTemplateDecl *D) {
-  CXXRecordDecl *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
+template  static auto getTemplateDefinition(T *D) -> T * {
+  assert(D->getTemplatedDecl() && "Should be called on templates only");
+  auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
   if (!ToTemplatedDef)
 return nullptr;
-  ClassTemplateDecl *TemplateWithDef =
-  ToTemplatedDef->getDescribedClassTemplate();
-  return TemplateWithDef;
+  auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
+  return cast_or_null(TemplateWithDef);
 }
 
 ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
@@ -4983,7 +4983,8 @@
   if (FoundTemplate) {
 
 if (IsStructuralMatch(D, FoundTemplate)) {
-  ClassTemplateDecl *TemplateWithDef = getDefinition(FoundTemplate);
+  ClassTemplateDecl *TemplateWithDef =
+  getTemplateDefinition(FoundTemplate);
   if (D->isThisDeclarationADefinition() && TemplateWithDef) {
 return Importer.MapImported(D, TemplateWithDef);
   }
@@ -5046,6 +5047,8 @@
 // and this time the lookup finds the previous fwd friend class template.
 // In this case we must set up the previous decl for the templated decl.
 if (!ToTemplated->getPreviousDecl()) {
+  assert(FoundByLookup->getTemplatedDecl() &&
+ "Found decl must have its templated decl set");
   CXXRecordDecl *PrevTemplated =
   FoundByLookup->getTemplatedDecl()->getMostRecentDecl();
   if (ToTemplated != PrevTemplated)
@@ -5508,8 +5511,11 @@
   if (ToD)
 return ToD;
 
+  const FunctionTemplateDecl *FoundByLookup = nullptr;
+
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
+  // FIXME Split this into a separate function.
   if (!LexicalDC->isFunctionOrMethod()) {
 unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
@@ -5517,18 +5523,21 @@
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
 continue;
 
-  if (auto *FoundFunction =
-  dyn_cast(FoundDecl)) {
-if (FoundFunction->hasExternalFormalLinkage() &&
+  if (auto *FoundTemplate = dyn_cast(FoundDecl)) {
+if (FoundTemplate->hasExternalFormalLinkage() &&
 D->hasExternalFormalLinkage()) {
-  if (IsStructuralMatch(D, FoundFunction)) {
-Importer.MapImported(D, FoundFunction);
-// FIXME: Actually try to merge the body and other attributes.
-return FoundFunction;
+  if (IsStructuralMatch(D, FoundTemplate)) {
+FunctionTemplateDecl *TemplateWithDef =
+getTemplateDefinition(FoundTemplate);
+if (D->isThisDeclarationADefinition() && TemplateWithDef) {
+  return Importer.MapImported(D, TemplateWithDef);
+}
+FoundByLookup = FoundTemplate;
+break;
   }
+  // TODO: handle conflicting names
 }
   }
-  // TODO: handle conflicting names
 }
   }
 
@@ -5547,10 +5556,25 @@
 return ToFunc;
 
   TemplatedFD->setDescribedFunctionTemplate(ToFunc);
+
   ToFunc->setAccess(D->getAccess());
   ToFunc->setLexicalDeclContext(LexicalDC);
-
   LexicalDC->addDeclInternal(ToFunc);
+
+  if (FoundByLookup) {
+auto *Recent =
+const_cast(FoundByLookup->getMostRecentDecl());
+if (!TemplatedFD->getPreviousDecl()) {
+  assert(FoundByLookup->getTemplatedDecl() &&
+ "Found decl must have its templated decl set");
+  auto *PrevTemplated =
+  FoundByLookup->getTemplatedDecl()->getMostRecentDecl();
+  if (TemplatedFD != PrevTemplated)
+TemplatedFD->setPreviousDecl(PrevTemplated);
+}
+ToFunc->setPreviousDecl(Recent);
+  }
+
   return ToFunc;
 }
 
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AS

[PATCH] D58665: [analyzer] Handle comparison between non-default AS symbol and constant

2019-03-07 Thread David Stenberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC355592: [analyzer] Handle comparison between non-default AS 
symbol and constant (authored by dstenb, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58665/new/

https://reviews.llvm.org/D58665

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-cmp-const-trunc.cl


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -571,7 +571,15 @@
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
   // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // If the region has a symbolic base, pay attention to the type; it
+  // might be coming from a non-default address space. For non-symbolic
+  // regions it doesn't matter that much because such comparisons would
+  // most likely evaluate to concrete false anyway. FIXME: We might
+  // still need to handle the non-comparison case.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
+BasicVals.getAPSIntType(lSym->getType()).apply(i);
+  else
+BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
 }
 default:
Index: test/Analysis/ptr-cmp-const-trunc.cl
===
--- test/Analysis/ptr-cmp-const-trunc.cl
+++ test/Analysis/ptr-cmp-const-trunc.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze 
-analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+#include 
+
+void bar(__global int *p) __attribute__((nonnull(1)));
+
+void foo(__global int *p) {
+  if ((uint64_t)p <= 1UL << 32)
+bar(p); // no-warning
+}


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -571,7 +571,15 @@
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
   // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // If the region has a symbolic base, pay attention to the type; it
+  // might be coming from a non-default address space. For non-symbolic
+  // regions it doesn't matter that much because such comparisons would
+  // most likely evaluate to concrete false anyway. FIXME: We might
+  // still need to handle the non-comparison case.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
+BasicVals.getAPSIntType(lSym->getType()).apply(i);
+  else
+BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
 }
 default:
Index: test/Analysis/ptr-cmp-const-trunc.cl
===
--- test/Analysis/ptr-cmp-const-trunc.cl
+++ test/Analysis/ptr-cmp-const-trunc.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+#include 
+
+void bar(__global int *p) __attribute__((nonnull(1)));
+
+void foo(__global int *p) {
+  if ((uint64_t)p <= 1UL << 32)
+bar(p); // no-warning
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58814: [clang][Index] Constructors and Destructors do not reference class

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 189695.
kadircet added a comment.

- Add NameReference role kind, and tag references from constructors/destructors 
to the class with that kind.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58814/new/

https://reviews.llvm.org/D58814

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  lib/Index/IndexingContext.cpp
  test/Index/Core/index-source.cpp
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -58,11 +58,13 @@
   Position WrittenPos;
   Position DeclPos;
   SymbolInfo SymInfo;
+  SymbolRoleSet Roles;
   // FIXME: add more information.
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TestSymbol &S) {
-  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos;
+  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos << '('
+<< static_cast(S.SymInfo.Kind) << ')';
 }
 
 class Indexer : public IndexDataConsumer {
@@ -84,6 +86,7 @@
 S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
 S.DeclPos =
 Position::fromSourceLocation(D->getLocation(), AST->getSourceManager());
+S.Roles = Roles;
 Symbols.push_back(std::move(S));
 return true;
   }
@@ -143,6 +146,7 @@
 MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
 MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
 MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; }
+MATCHER_P(HasRole, Role, "") { return arg.Roles & static_cast(Role); }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -257,6 +261,32 @@
   Contains(AllOf(QName("std::foo"), Kind(SymbolKind::Using;
 }
 
+TEST(IndexTest, Constructors) {
+  std::string Code = R"cpp(
+struct Foo {
+  Foo(int);
+  ~Foo();
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(
+  Index->Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+WrittenAt(Position(2, 12))),
+  AllOf(QName("Foo::Foo"), Kind(SymbolKind::Constructor),
+WrittenAt(Position(3, 7))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+HasRole(SymbolRole::NameReference), WrittenAt(Position(3, 7))),
+  AllOf(QName("Foo::~Foo"), Kind(SymbolKind::Destructor),
+WrittenAt(Position(4, 7))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+HasRole(SymbolRole::NameReference),
+WrittenAt(Position(4, 8);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -5,17 +5,17 @@
 class Cls { public:
   // CHECK: [[@LINE+3]]:3 | constructor/C++ | Cls | c:@S@Cls@F@Cls#I# | __ZN3ClsC1Ei | Decl,RelChild | rel: 1
   // CHECK-NEXT: RelChild | Cls | c:@S@Cls
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(int x);
   // CHECK: [[@LINE+2]]:3 | constructor/cxx-copy-ctor/C++ | Cls | c:@S@Cls@F@Cls#&1$@S@Cls# | __ZN3ClsC1ERKS_ | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(const Cls &);
   // CHECK: [[@LINE+2]]:3 | constructor/cxx-move-ctor/C++ | Cls | c:@S@Cls@F@Cls#&&$@S@Cls# | __ZN3ClsC1EOS_ | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(Cls &&);
 
   // CHECK: [[@LINE+2]]:3 | destructor/C++ | ~Cls | c:@S@Cls@F@~Cls# | __ZN3ClsD1Ev | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:4 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:4 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   ~Cls();
 };
 
@@ -35,12 +35,12 @@
 Cls::Cls(int x) {}
 // CHECK: [[@LINE-1]]:6 | constructor/C++ | Cls | c:@S@Cls@F@Cls#I# | __ZN3ClsC1Ei | Def,RelChild | rel: 1
 // CHECK: [[@LINE-2]]:1 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
-// CHECK: [[@LINE-3]]:6 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:6 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
 
 Cls::~/*a comment*/Cls() {}
 // CHECK: [[@LINE-1]]:6 | destructor/C++ | ~Cls | c:@S@Cls@F@~Cls# | __ZN3ClsD1Ev | Def,RelChild | rel: 1
 // CH

[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clangd/GlobalCompilationDatabase.h:116
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+

hokein wrote:
> ioeric wrote:
> > This doesn't seem to be used in this patch (except for tests). Could you 
> > include intended uses in the patch so we can understand the problem better?
> Looks like this patch introduces two changes:
> 
> - move the internal adjustArguments to public, I have the same question, any 
> reason doing it? because we can test it? 
> - add additional Adjusters to adjustArguments
It was only for testing


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D58814: [clang][Index] Constructors and Destructors do not reference class

2019-03-07 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.

Do we also need to change anything for constructor calls?  If not, please add a 
test for that.




Comment at: lib/Index/IndexDecl.cpp:251
+   Ctor->getParent(), Ctor->getDeclContext(),
+   (unsigned)(SymbolRole::NameReference));
 

No need for parens around `SymbolRole::NameReference`.



Comment at: lib/Index/IndexDecl.cpp:268
+ Dtor->getParent(), Dtor->getDeclContext(),
+ (unsigned)(SymbolRole::NameReference));
   }

No need for parens around `SymbolRole::NameReference`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58814/new/

https://reviews.llvm.org/D58814



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


[PATCH] D53818: [ASTImporter] Changed use of Import to Import_New in ASTImporter.

2019-03-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 189696.
balazske added a comment.
Herald added a reviewer: martong.
Herald added a subscriber: jdoerfert.

- Small style corrections.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53818/new/

https://reviews.llvm.org/D53818

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -134,25 +134,6 @@
   To->setIsUsed();
   }
 
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(SourceLocation &To, const SourceLocation &From) {
-To = Import(From);
-if (From.isValid() && To.isInvalid())
-return llvm::make_error();
-return Error::success();
-  }
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(QualType &To, const QualType &From) {
-To = Import(From);
-if (!From.isNull() && To.isNull())
-return llvm::make_error();
-return Error::success();
-  }
-
   class ASTNodeImporter : public TypeVisitor,
   public DeclVisitor,
   public StmtVisitor {
@@ -7674,13 +7655,6 @@
 
 ASTImporter::~ASTImporter() = default;
 
-Expected ASTImporter::Import_New(QualType FromT) {
-  QualType ToT = Import(FromT);
-  if (ToT.isNull() && !FromT.isNull())
-return make_error();
-  return ToT;
-}
-
 Optional ASTImporter::getFieldIndex(Decl *F) {
   assert(F && (isa(*F) || isa(*F)) &&
   "Try to get field index for non-field.");
@@ -7732,9 +7706,9 @@
   LookupTable->add(ToND);
 }
 
-QualType ASTImporter::Import(QualType FromT) {
+Expected ASTImporter::Import_New(QualType FromT) {
   if (FromT.isNull())
-return {};
+return QualType{};
 
   const Type *FromTy = FromT.getTypePtr();
 
@@ -7747,46 +7721,64 @@
   // Import the type
   ASTNodeImporter Importer(*this);
   ExpectedType ToTOrErr = Importer.Visit(FromTy);
-  if (!ToTOrErr) {
-llvm::consumeError(ToTOrErr.takeError());
-return {};
-  }
+  if (!ToTOrErr)
+return ToTOrErr.takeError();
 
   // Record the imported type.
   ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
 
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
+QualType ASTImporter::Import(QualType From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return {};
+}
 
 Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
-  TypeSourceInfo *ToTSI = Import(FromTSI);
-  if (!ToTSI && FromTSI)
-return llvm::make_error();
-  return ToTSI;
-}
-TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
 
   // FIXME: For now we just create a "trivial" type source info based
   // on the type and a single location. Implement a real version of this.
-  QualType T = Import(FromTSI->getType());
-  if (T.isNull())
-return nullptr;
+  ExpectedType TOrErr = Import_New(FromTSI->getType());
+  if (!TOrErr)
+return TOrErr.takeError();
+  ExpectedSLoc BeginLocOrErr = Import_New(FromTSI->getTypeLoc().getBeginLoc());
+  if (!BeginLocOrErr)
+return BeginLocOrErr.takeError();
 
-  return ToContext.getTrivialTypeSourceInfo(
-  T, Import(FromTSI->getTypeLoc().getBeginLoc()));
+  return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
+}
+TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
 }
 
 Expected ASTImporter::Import_New(const Attr *FromAttr) {
-  return Import(FromAttr);
-}
-Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
-  // NOTE: Import of SourceRange may fail.
-  ToAttr->setRange(Import(FromAttr->getRange()));
+  if (auto ToRangeOrErr = Import_New(FromAttr->getRange()))
+ToAttr->setRange(*ToRangeOrErr);
+  else
+return ToRangeOrErr.takeError();
+
   return ToAttr;
 }
+Attr *ASTImporter::Import(const Attr *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
+}
 
 Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
   auto Pos = ImportedDecls.find(FromD);
@@ -7804,12 +7796,6 @@
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {
-  Decl *ToD = Import(FromD);
-  if (!ToD && FromD)
-return llvm::make_error();
-  return ToD;
-}
-Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
 
@@ -7823,12 +7809,10 @@
 return ToD;
   }
 
-  // Import the type.
+  // Import the declaration.
   ExpectedDecl ToDOrErr = Importer.Visit(FromD);
-  if (!ToDOrErr) {
-llvm::consumeError(ToDOrErr.takeError());
-return nullptr;
-  }

[PATCH] D58673: [ASTImporter] Fix redecl failures of ClassTemplateSpec

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:5147
   }
+} else { // ODR violation.
+  // FIXME HandleNameConflict

shafik wrote:
> ODR violations are ill-formed no diagnostic required. So currently will this 
> fail for cases that clang proper would not?
> ODR violations are ill-formed no diagnostic required.

ASTStructuralEquivalenceContext already provides diagnostic in the ODR cases. 
E.g.:
```
  // Check for equivalent field names.
  IdentifierInfo *Name1 = Field1->getIdentifier();
  IdentifierInfo *Name2 = Field2->getIdentifier();
  if (!::IsStructurallyEquivalent(Name1, Name2)) {
if (Context.Complain) {
  Context.Diag2(Owner2->getLocation(),
Context.ErrorOnTagTypeMismatch
? diag::err_odr_tag_type_inconsistent
: diag::warn_odr_tag_type_inconsistent)
  << Context.ToCtx.getTypeDeclType(Owner2);
  Context.Diag2(Field2->getLocation(), diag::note_odr_field_name)
  << Field2->getDeclName();
  Context.Diag1(Field1->getLocation(), diag::note_odr_field_name)
  << Field1->getDeclName();
}
return false;
  }
```
We change this to be always a Warning instead of an Error in this patch: 
https://reviews.llvm.org/D58897

> So currently will this fail for cases that clang proper would not?

Well, I think the situation is more subtle than that.
There are cases when we can link two translation units and the linker provides 
a valid executable even if there is an ODR violation of a type. There is no 
type information used during linkage, except for functions' mangled names and 
visibility. That ODR violation is recognized though when we do the merge in the 
AST level (and I think it is useful to diagnose them).
So if "clang proper" includes the linker then the answer is yes. If not then we 
are talking about only one translation unit and the answer is no.



Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58673/new/

https://reviews.llvm.org/D58673



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


r355596 - [ASTImporter] Import member expr with explicit template args

2019-03-07 Thread Gabor Marton via cfe-commits
Author: martong
Date: Thu Mar  7 05:38:20 2019
New Revision: 355596

URL: http://llvm.org/viewvc/llvm-project?rev=355596&view=rev
Log:
[ASTImporter] Import member expr with explicit template args

Summary:
Member expressions with explicit template arguments were not imported
correctly: the DeclRefExpr was missing. This patch fixes.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=355596&r1=355595&r2=355596&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Mar  7 05:38:20 2019
@@ -7129,15 +7129,19 @@ ExpectedStmt ASTNodeImporter::VisitMembe
 
   DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
 
+  TemplateArgumentListInfo ToTAInfo, *ResInfo = nullptr;
   if (E->hasExplicitTemplateArgs()) {
-// FIXME: handle template arguments
-return make_error(ImportError::UnsupportedConstruct);
+if (Error Err =
+ImportTemplateArgumentListInfo(E->getLAngleLoc(), 
E->getRAngleLoc(),
+   E->template_arguments(), ToTAInfo))
+  return std::move(Err);
+ResInfo = &ToTAInfo;
   }
 
   return MemberExpr::Create(
   Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
   ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
-  ToMemberNameInfo, nullptr, ToType, E->getValueKind(), 
E->getObjectKind());
+  ToMemberNameInfo, ResInfo, ToType, E->getValueKind(), 
E->getObjectKind());
 }
 
 ExpectedStmt

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=355596&r1=355595&r2=355596&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu Mar  7 05:38:20 2019
@@ -2604,6 +2604,56 @@ TEST_P(ImportFunctions, ImportImplicitFu
   EXPECT_TRUE(LambdaRec->getDestructor());
 }
 
+TEST_P(ImportFunctions,
+   CallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X {
+template 
+void foo(){}
+  };
+  void f() {
+X x;
+x.foo();
+  }
+  )",
+  Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  EXPECT_TRUE(MatchVerifier().match(
+  ToD, functionDecl(hasName("f"), hasDescendant(declRefExpr();
+}
+
+TEST_P(ImportFunctions,
+   DependentCallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X {
+template 
+void foo(){}
+  };
+  template 
+  void f() {
+X x;
+x.foo();
+  }
+  void g() {
+f();
+  }
+  )",
+  Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("g")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  EXPECT_TRUE(MatchVerifier().match(
+  ToTU, translationUnitDecl(hasDescendant(
+functionDecl(hasName("f"), hasDescendant(declRefExpr()));
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {


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


[PATCH] D59054: [analyzer] C++17: PR40022: Support aggregate initialization with compound values in presence of base classes.

2019-03-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

LG in general.  A couple of comments.




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2348
+// Virtual bases still aren't allowed. Multiple bases are fine though.
+for (auto B : CRD->bases()) {
+  assert(B.isVirtual() == false);

Should this be `const auto&`?



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2349
+for (auto B : CRD->bases()) {
+  assert(B.isVirtual() == false);
+

`!B.isVirtual()`

Consider also adding `&& "more details about this assertion"`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59054/new/

https://reviews.llvm.org/D59054



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


[PATCH] D58830: [ASTImporter] Import member expr with explicit template args

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355596: [ASTImporter] Import member expr with explicit 
template args (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58830/new/

https://reviews.llvm.org/D58830

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7129,15 +7129,19 @@
 
   DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
 
+  TemplateArgumentListInfo ToTAInfo, *ResInfo = nullptr;
   if (E->hasExplicitTemplateArgs()) {
-// FIXME: handle template arguments
-return make_error(ImportError::UnsupportedConstruct);
+if (Error Err =
+ImportTemplateArgumentListInfo(E->getLAngleLoc(), 
E->getRAngleLoc(),
+   E->template_arguments(), ToTAInfo))
+  return std::move(Err);
+ResInfo = &ToTAInfo;
   }
 
   return MemberExpr::Create(
   Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
   ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
-  ToMemberNameInfo, nullptr, ToType, E->getValueKind(), 
E->getObjectKind());
+  ToMemberNameInfo, ResInfo, ToType, E->getValueKind(), 
E->getObjectKind());
 }
 
 ExpectedStmt
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2604,6 +2604,56 @@
   EXPECT_TRUE(LambdaRec->getDestructor());
 }
 
+TEST_P(ImportFunctions,
+   CallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X {
+template 
+void foo(){}
+  };
+  void f() {
+X x;
+x.foo();
+  }
+  )",
+  Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  EXPECT_TRUE(MatchVerifier().match(
+  ToD, functionDecl(hasName("f"), hasDescendant(declRefExpr();
+}
+
+TEST_P(ImportFunctions,
+   DependentCallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X {
+template 
+void foo(){}
+  };
+  template 
+  void f() {
+X x;
+x.foo();
+  }
+  void g() {
+f();
+  }
+  )",
+  Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("g")));
+  auto *ToD = Import(FromD, Lang_CXX);
+  EXPECT_TRUE(ToD);
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  EXPECT_TRUE(MatchVerifier().match(
+  ToTU, translationUnitDecl(hasDescendant(
+functionDecl(hasName("f"), hasDescendant(declRefExpr()));
+}
+
 struct ImportFriendFunctions : ImportFunctions {};
 
 TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -7129,15 +7129,19 @@
 
   DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
 
+  TemplateArgumentListInfo ToTAInfo, *ResInfo = nullptr;
   if (E->hasExplicitTemplateArgs()) {
-// FIXME: handle template arguments
-return make_error(ImportError::UnsupportedConstruct);
+if (Error Err =
+ImportTemplateArgumentListInfo(E->getLAngleLoc(), E->getRAngleLoc(),
+   E->template_arguments(), ToTAInfo))
+  return std::move(Err);
+ResInfo = &ToTAInfo;
   }
 
   return MemberExpr::Create(
   Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
   ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
-  ToMemberNameInfo, nullptr, ToType, E->getValueKind(), E->getObjectKind());
+  ToMemberNameInfo, ResInfo, ToType, E->getValueKind(), E->getObjectKind());
 }
 
 ExpectedStmt
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2604,6 +2604,56 @@
   EXPECT_TRUE(LambdaRec->getDestructor());
 }
 
+TEST_P(ImportFunctions,
+   CallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  struct X {
+template 
+void foo(){}
+  };
+  void f() {
+X x;
+x.foo();
+  }
+  )",
+  Lang_CXX);
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  auto

[PATCH] D58216: Support attribute used in member funcs of class templates II

2019-03-07 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a subscriber: bob.wilson.
davezarzycki added a comment.

I can't get Swift top-of-tree to build with gcc (8.3.1 20190223 (Red Hat 
8.3.1-2)), and I doubt that it is supported, but I could be wrong.

In any case, the requested change to the Swift compiler source sounds 
reasonable to me.

CC: @bob.wilson – Just FYI, top-of-tree clang will probably force a subtle 
change to the "master" and "upstream-with-swift" branches of Swift.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58216/new/

https://reviews.llvm.org/D58216



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


[PATCH] D58814: [clang][Index] Constructors and Destructors do not reference class

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

As discussed offline constructor calls are a different issue, coming from even 
a different layer than Indexing API.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58814/new/

https://reviews.llvm.org/D58814



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


[PATCH] D58814: [clang][Index] Constructors and Destructors do not reference class

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 189703.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Delete extra parens


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58814/new/

https://reviews.llvm.org/D58814

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  lib/Index/IndexingContext.cpp
  test/Index/Core/index-source.cpp
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -58,11 +58,13 @@
   Position WrittenPos;
   Position DeclPos;
   SymbolInfo SymInfo;
+  SymbolRoleSet Roles;
   // FIXME: add more information.
 };
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TestSymbol &S) {
-  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos;
+  return OS << S.QName << '[' << S.WrittenPos << ']' << '@' << S.DeclPos << '('
+<< static_cast(S.SymInfo.Kind) << ')';
 }
 
 class Indexer : public IndexDataConsumer {
@@ -84,6 +86,7 @@
 S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
 S.DeclPos =
 Position::fromSourceLocation(D->getLocation(), AST->getSourceManager());
+S.Roles = Roles;
 Symbols.push_back(std::move(S));
 return true;
   }
@@ -143,6 +146,7 @@
 MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
 MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
 MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; }
+MATCHER_P(HasRole, Role, "") { return arg.Roles & static_cast(Role); }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -257,6 +261,32 @@
   Contains(AllOf(QName("std::foo"), Kind(SymbolKind::Using;
 }
 
+TEST(IndexTest, Constructors) {
+  std::string Code = R"cpp(
+struct Foo {
+  Foo(int);
+  ~Foo();
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(
+  Index->Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+WrittenAt(Position(2, 12))),
+  AllOf(QName("Foo::Foo"), Kind(SymbolKind::Constructor),
+WrittenAt(Position(3, 7))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+HasRole(SymbolRole::NameReference), WrittenAt(Position(3, 7))),
+  AllOf(QName("Foo::~Foo"), Kind(SymbolKind::Destructor),
+WrittenAt(Position(4, 7))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Struct),
+HasRole(SymbolRole::NameReference),
+WrittenAt(Position(4, 8);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -5,17 +5,17 @@
 class Cls { public:
   // CHECK: [[@LINE+3]]:3 | constructor/C++ | Cls | c:@S@Cls@F@Cls#I# | __ZN3ClsC1Ei | Decl,RelChild | rel: 1
   // CHECK-NEXT: RelChild | Cls | c:@S@Cls
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(int x);
   // CHECK: [[@LINE+2]]:3 | constructor/cxx-copy-ctor/C++ | Cls | c:@S@Cls@F@Cls#&1$@S@Cls# | __ZN3ClsC1ERKS_ | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(const Cls &);
   // CHECK: [[@LINE+2]]:3 | constructor/cxx-move-ctor/C++ | Cls | c:@S@Cls@F@Cls#&&$@S@Cls# | __ZN3ClsC1EOS_ | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:3 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   Cls(Cls &&);
 
   // CHECK: [[@LINE+2]]:3 | destructor/C++ | ~Cls | c:@S@Cls@F@~Cls# | __ZN3ClsD1Ev | Decl,RelChild | rel: 1
-  // CHECK: [[@LINE+1]]:4 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+  // CHECK: [[@LINE+1]]:4 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
   ~Cls();
 };
 
@@ -35,12 +35,12 @@
 Cls::Cls(int x) {}
 // CHECK: [[@LINE-1]]:6 | constructor/C++ | Cls | c:@S@Cls@F@Cls#I# | __ZN3ClsC1Ei | Def,RelChild | rel: 1
 // CHECK: [[@LINE-2]]:1 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
-// CHECK: [[@LINE-3]]:6 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:6 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont,NameReference | rel: 1
 
 Cls::~/*a comment*/Cls() {}
 // CHECK: [[@LINE-1]]:6 | destructor/C++ | ~Cls | c:@S@Cls@F@~Cls# | __ZN3ClsD1Ev | Def,RelChild | rel: 1
 // CHECK: [[@LINE-2]]:1 | class/C++ | Cls | c:@S@C

r355598 - [ASTImporter] Changed use of Import to Import_New in ASTImporter.

2019-03-07 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Thu Mar  7 06:09:18 2019
New Revision: 355598

URL: http://llvm.org/viewvc/llvm-project?rev=355598&view=rev
Log:
[ASTImporter] Changed use of Import to Import_New in ASTImporter.

Reviewers: a.sidorin, shafik, a_sidorin, martong

Reviewed By: a_sidorin

Subscribers: rnkovacs, jdoerfert, davide, aprantl, llvm-commits, gamesh411, 
a_sidorin, dkrupp, martong, Szelethus, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=355598&r1=355597&r2=355598&view=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Thu Mar  7 06:09:18 2019
@@ -177,15 +177,10 @@ class TypeSourceInfo;
 /// \return Error information (success or error).
 template 
 LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) {
-  To = Import(From);
-  if (From && !To)
-  return llvm::make_error();
-  return llvm::Error::success();
-  // FIXME: this should be the final code
-  //auto ToOrErr = Import(From);
-  //if (ToOrErr)
-  //  To = *ToOrErr;
-  //return ToOrErr.takeError();
+  auto ToOrErr = Import_New(From);
+  if (ToOrErr)
+To = *ToOrErr;
+  return ToOrErr.takeError();
 }
 
 /// Import the given type from the "from" context into the "to"

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=355598&r1=355597&r2=355598&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Mar  7 06:09:18 2019
@@ -134,25 +134,6 @@ namespace clang {
   To->setIsUsed();
   }
 
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(SourceLocation &To, const SourceLocation &From) {
-To = Import(From);
-if (From.isValid() && To.isInvalid())
-return llvm::make_error();
-return Error::success();
-  }
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(QualType &To, const QualType &From) {
-To = Import(From);
-if (!From.isNull() && To.isNull())
-return llvm::make_error();
-return Error::success();
-  }
-
   class ASTNodeImporter : public TypeVisitor,
   public DeclVisitor,
   public StmtVisitor {
@@ -7702,13 +7683,6 @@ ASTImporter::ASTImporter(ASTContext &ToC
 
 ASTImporter::~ASTImporter() = default;
 
-Expected ASTImporter::Import_New(QualType FromT) {
-  QualType ToT = Import(FromT);
-  if (ToT.isNull() && !FromT.isNull())
-return make_error();
-  return ToT;
-}
-
 Optional ASTImporter::getFieldIndex(Decl *F) {
   assert(F && (isa(*F) || isa(*F)) &&
   "Try to get field index for non-field.");
@@ -7760,9 +7734,9 @@ void ASTImporter::AddToLookupTable(Decl
   LookupTable->add(ToND);
 }
 
-QualType ASTImporter::Import(QualType FromT) {
+Expected ASTImporter::Import_New(QualType FromT) {
   if (FromT.isNull())
-return {};
+return QualType{};
 
   const Type *FromTy = FromT.getTypePtr();
 
@@ -7775,46 +7749,64 @@ QualType ASTImporter::Import(QualType Fr
   // Import the type
   ASTNodeImporter Importer(*this);
   ExpectedType ToTOrErr = Importer.Visit(FromTy);
-  if (!ToTOrErr) {
-llvm::consumeError(ToTOrErr.takeError());
-return {};
-  }
+  if (!ToTOrErr)
+return ToTOrErr.takeError();
 
   // Record the imported type.
   ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
 
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
+QualType ASTImporter::Import(QualType From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return {};
+}
 
 Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
-  TypeSourceInfo *ToTSI = Import(FromTSI);
-  if (!ToTSI && FromTSI)
-return llvm::make_error();
-  return ToTSI;
-}
-TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
 
   // FIXME: For now we just create a "trivial" type source info based
   // on the type and a single location. Implement a real version of this.
-  QualType T = Import(FromTSI->getType());
-  if (T.isNull())
-return nullptr;
+  ExpectedType TOrErr = Import_New(FromTSI->getType());
+  if (!TOrErr)
+return TOrErr.takeError();
+  ExpectedSLoc BeginLocOrErr = Import_New(FromTSI->getTypeLoc().getBeginLoc());
+  if (!BeginLocOrErr)
+return BeginLocOrErr.takeError();
 
-  return ToContext.

[PATCH] D53818: [ASTImporter] Changed use of Import to Import_New in ASTImporter.

2019-03-07 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC355598: [ASTImporter] Changed use of Import to Import_New in 
ASTImporter. (authored by balazske, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53818?vs=189696&id=189704#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53818/new/

https://reviews.llvm.org/D53818

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -134,25 +134,6 @@
   To->setIsUsed();
   }
 
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(SourceLocation &To, const SourceLocation &From) {
-To = Import(From);
-if (From.isValid() && To.isInvalid())
-return llvm::make_error();
-return Error::success();
-  }
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(QualType &To, const QualType &From) {
-To = Import(From);
-if (!From.isNull() && To.isNull())
-return llvm::make_error();
-return Error::success();
-  }
-
   class ASTNodeImporter : public TypeVisitor,
   public DeclVisitor,
   public StmtVisitor {
@@ -7702,13 +7683,6 @@
 
 ASTImporter::~ASTImporter() = default;
 
-Expected ASTImporter::Import_New(QualType FromT) {
-  QualType ToT = Import(FromT);
-  if (ToT.isNull() && !FromT.isNull())
-return make_error();
-  return ToT;
-}
-
 Optional ASTImporter::getFieldIndex(Decl *F) {
   assert(F && (isa(*F) || isa(*F)) &&
   "Try to get field index for non-field.");
@@ -7760,9 +7734,9 @@
   LookupTable->add(ToND);
 }
 
-QualType ASTImporter::Import(QualType FromT) {
+Expected ASTImporter::Import_New(QualType FromT) {
   if (FromT.isNull())
-return {};
+return QualType{};
 
   const Type *FromTy = FromT.getTypePtr();
 
@@ -7775,46 +7749,64 @@
   // Import the type
   ASTNodeImporter Importer(*this);
   ExpectedType ToTOrErr = Importer.Visit(FromTy);
-  if (!ToTOrErr) {
-llvm::consumeError(ToTOrErr.takeError());
-return {};
-  }
+  if (!ToTOrErr)
+return ToTOrErr.takeError();
 
   // Record the imported type.
   ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
 
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
+QualType ASTImporter::Import(QualType From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return {};
+}
 
 Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
-  TypeSourceInfo *ToTSI = Import(FromTSI);
-  if (!ToTSI && FromTSI)
-return llvm::make_error();
-  return ToTSI;
-}
-TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
 
   // FIXME: For now we just create a "trivial" type source info based
   // on the type and a single location. Implement a real version of this.
-  QualType T = Import(FromTSI->getType());
-  if (T.isNull())
-return nullptr;
+  ExpectedType TOrErr = Import_New(FromTSI->getType());
+  if (!TOrErr)
+return TOrErr.takeError();
+  ExpectedSLoc BeginLocOrErr = Import_New(FromTSI->getTypeLoc().getBeginLoc());
+  if (!BeginLocOrErr)
+return BeginLocOrErr.takeError();
 
-  return ToContext.getTrivialTypeSourceInfo(
-  T, Import(FromTSI->getTypeLoc().getBeginLoc()));
+  return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
+}
+TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
 }
 
 Expected ASTImporter::Import_New(const Attr *FromAttr) {
-  return Import(FromAttr);
-}
-Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
-  // NOTE: Import of SourceRange may fail.
-  ToAttr->setRange(Import(FromAttr->getRange()));
+  if (auto ToRangeOrErr = Import_New(FromAttr->getRange()))
+ToAttr->setRange(*ToRangeOrErr);
+  else
+return ToRangeOrErr.takeError();
+
   return ToAttr;
 }
+Attr *ASTImporter::Import(const Attr *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
+}
 
 Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
   auto Pos = ImportedDecls.find(FromD);
@@ -7832,12 +7824,6 @@
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {
-  Decl *ToD = Import(FromD);
-  if (!ToD && FromD)
-return llvm::make_error();
-  return ToD;
-}
-Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
 
@@ -7851,12 +7837,10 @@
 return ToD;
   }
 
-  // Import the type.
+  // Import the declaration.
   ExpectedDecl ToDOrErr =

[PATCH] D57464: Generalize method overloading on addr spaces to C++

2019-03-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Any more input on this?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57464/new/

https://reviews.llvm.org/D57464



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 189706.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Change testing strategy


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086

Files:
  clangd/GlobalCompilationDatabase.cpp
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -16,15 +16,18 @@
 namespace clang {
 namespace clangd {
 namespace {
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
+using ::testing::Not;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
   auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
   EXPECT_EQ(Cmd.Directory, testPath("foo"));
-  EXPECT_THAT(Cmd.CommandLine, ElementsAre(
-EndsWith("clang"), testPath("foo/bar.cc")));
+  EXPECT_THAT(Cmd.CommandLine,
+  ElementsAre(EndsWith("clang"), testPath("foo/bar.cc")));
   EXPECT_EQ(Cmd.Output, "");
 
   // .h files have unknown language, so they are parsed liberally as obj-c++.
@@ -65,16 +68,18 @@
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
   OverlayCDB CDB(Base.get(), {}, std::string(""));
-  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
-Base->getCompileCommand(testPath("foo.cc")));
+  EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
+  AllOf(Contains(testPath("foo.cc")), Contains("-DA=1")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
 
   auto Override = cmd(testPath("foo.cc"), "-DA=3");
   CDB.setCompileCommand(testPath("foo.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
+  Contains("-DA=3"));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
   CDB.setCompileCommand(testPath("missing.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+  EXPECT_THAT(CDB.getCompileCommand(testPath("missing.cc"))->CommandLine,
+  Contains("-DA=3"));
 }
 
 TEST_F(OverlayCDBTest, GetFallbackCommand) {
@@ -88,7 +93,8 @@
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
-  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
+  EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine,
+  Contains("-DA=5"));
 
   EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
   ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6"));
@@ -111,6 +117,35 @@
ElementsAre("A.cpp"), ElementsAre("C.cpp")));
 }
 
+TEST_F(OverlayCDBTest, Adjustments) {
+  OverlayCDB CDB(Base.get(), {}, std::string(""));
+  auto Cmd = CDB.getCompileCommand(testPath("foo.cc")).getValue();
+  // Delete the file name.
+  Cmd.CommandLine.pop_back();
+
+  // Check dependency file commands are dropped.
+  Cmd.CommandLine.push_back("-MF");
+  Cmd.CommandLine.push_back("random-dependency");
+
+  // Check plugin-related commands are dropped.
+  Cmd.CommandLine.push_back("-Xclang");
+  Cmd.CommandLine.push_back("-load");
+  Cmd.CommandLine.push_back("-Xclang");
+  Cmd.CommandLine.push_back("random-plugin");
+
+  Cmd.CommandLine.push_back("-DA=5");
+  Cmd.CommandLine.push_back(Cmd.Filename);
+
+  CDB.setCompileCommand(testPath("foo.cc"), Cmd);
+
+  EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
+  AllOf(Contains("-fsyntax-only"), Contains("-DA=5"),
+Contains(testPath("foo.cc")), Not(Contains("-MF")),
+Not(Contains("random-dependency")),
+Not(Contains("-Xclang")), Not(Contains("-load")),
+Not(Contains("random-plugin";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -21,11 +21,17 @@
 
 void adjustArguments(tooling::CompileCommand &Cmd,
  llvm::StringRef ResourceDir) {
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(
+  Cmd.CommandLine, Cmd.Filename);
   // Strip plugin related command line arguments. Clangd does
   // not support plugins currently. Therefore it breaks if
   // compiler tries to load plugins.
   Cmd.CommandLine =
   tooling::getStripPluginsAdjuster()(Cmd.CommandLine, Cmd.Filename);
+
+  Cmd.Com

[clang-tools-extra] r355599 - [clangd] Strip plugin arguments in clangd-indexer.

2019-03-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Mar  7 06:47:17 2019
New Revision: 355599

URL: http://llvm.org/viewvc/llvm-project?rev=355599&view=rev
Log:
[clangd] Strip plugin arguments in clangd-indexer.

Summary: This would allow clangd-indexer runs on chromium repo.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp

Modified: clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp?rev=355599&r1=355598&r2=355599&view=diff
==
--- clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp Thu Mar  7 06:47:17 
2019
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
@@ -110,7 +111,8 @@ int main(int argc, const char **argv) {
   // Collect symbols found in each translation unit, merging as we go.
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
-  llvm::make_unique(Data));
+  llvm::make_unique(Data),
+  clang::tooling::getStripPluginsAdjuster());
   if (Err) {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }


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


[PATCH] D59022: [clangd] Strip plugin arguments in clangd-indexer.

2019-03-07 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355599: [clangd] Strip plugin arguments in clangd-indexer. 
(authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59022/new/

https://reviews.llvm.org/D59022

Files:
  clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp


Index: clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
@@ -110,7 +111,8 @@
   // Collect symbols found in each translation unit, merging as we go.
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
-  llvm::make_unique(Data));
+  llvm::make_unique(Data),
+  clang::tooling::getStripPluginsAdjuster());
   if (Err) {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }


Index: clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolCollector.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Tooling.h"
@@ -110,7 +111,8 @@
   // Collect symbols found in each translation unit, merging as we go.
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
-  llvm::make_unique(Data));
+  llvm::make_unique(Data),
+  clang::tooling::getStripPluginsAdjuster());
   if (Err) {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59092: [clangd] Deduplicate Refs on the fly.

2019-03-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: arphaman, mgrang, jkorous, MaskRay, ioeric, 
ilya-biryukov.
Herald added a project: clang.

Currently, we only do deduplication when we flush final results. We may
have huge duplications (refs from headers) during the indexing period (running
clangd-indexer on Chromium).

With this change, clangd-indexer can index the whole chromium projects
(48 threads, 40 GB peak memory usage).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59092

Files:
  clangd/index/Ref.cpp
  clangd/index/Ref.h
  clangd/indexer/IndexerMain.cpp


Index: clangd/indexer/IndexerMain.cpp
===
--- clangd/indexer/IndexerMain.cpp
+++ clangd/indexer/IndexerMain.cpp
@@ -56,7 +56,6 @@
[&](RefSlab S) {
  std::lock_guard Lock(SymbolsMu);
  for (const auto &Sym : S) {
-   // No need to merge as currently all Refs are from main 
file.
for (const auto &Ref : Sym.second)
  Refs.insert(Sym.first, Ref);
  }
Index: clangd/index/Ref.h
===
--- clangd/index/Ref.h
+++ clangd/index/Ref.h
@@ -16,6 +16,7 @@
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -99,7 +100,7 @@
   private:
 llvm::BumpPtrAllocator Arena;
 llvm::UniqueStringSaver UniqueStrings; // Contents on the arena.
-llvm::DenseMap> Refs;
+llvm::DenseMap> Refs;
   };
 
 private:
Index: clangd/index/Ref.cpp
===
--- clangd/index/Ref.cpp
+++ clangd/index/Ref.cpp
@@ -33,9 +33,12 @@
 
 void RefSlab::Builder::insert(const SymbolID &ID, const Ref &S) {
   auto &M = Refs[ID];
-  M.push_back(S);
-  M.back().Location.FileURI =
-  UniqueStrings.save(M.back().Location.FileURI).data();
+  if (M.count(S))
+return;
+  Ref R = S;
+  R.Location.FileURI =
+  UniqueStrings.save(R.Location.FileURI).data();
+  M.insert(std::move(R));
 }
 
 RefSlab RefSlab::Builder::build() && {
@@ -45,11 +48,7 @@
   Result.reserve(Refs.size());
   size_t NumRefs = 0;
   for (auto &Sym : Refs) {
-auto &SymRefs = Sym.second;
-llvm::sort(SymRefs);
-// FIXME: do we really need to dedup?
-SymRefs.erase(std::unique(SymRefs.begin(), SymRefs.end()), SymRefs.end());
-
+std::vector SymRefs(Sym.second.begin(), Sym.second.end());
 NumRefs += SymRefs.size();
 Result.emplace_back(Sym.first, llvm::ArrayRef(SymRefs).copy(Arena));
   }


Index: clangd/indexer/IndexerMain.cpp
===
--- clangd/indexer/IndexerMain.cpp
+++ clangd/indexer/IndexerMain.cpp
@@ -56,7 +56,6 @@
[&](RefSlab S) {
  std::lock_guard Lock(SymbolsMu);
  for (const auto &Sym : S) {
-   // No need to merge as currently all Refs are from main file.
for (const auto &Ref : Sym.second)
  Refs.insert(Sym.first, Ref);
  }
Index: clangd/index/Ref.h
===
--- clangd/index/Ref.h
+++ clangd/index/Ref.h
@@ -16,6 +16,7 @@
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -99,7 +100,7 @@
   private:
 llvm::BumpPtrAllocator Arena;
 llvm::UniqueStringSaver UniqueStrings; // Contents on the arena.
-llvm::DenseMap> Refs;
+llvm::DenseMap> Refs;
   };
 
 private:
Index: clangd/index/Ref.cpp
===
--- clangd/index/Ref.cpp
+++ clangd/index/Ref.cpp
@@ -33,9 +33,12 @@
 
 void RefSlab::Builder::insert(const SymbolID &ID, const Ref &S) {
   auto &M = Refs[ID];
-  M.push_back(S);
-  M.back().Location.FileURI =
-  UniqueStrings.save(M.back().Location.FileURI).data();
+  if (M.count(S))
+return;
+  Ref R = S;
+  R.Location.FileURI =
+  UniqueStrings.save(R.Location.FileURI).data();
+  M.insert(std::move(R));
 }
 
 RefSlab RefSlab::Builder::build() && {
@@ -45,11 +48,7 @@
   Result.reserve(Refs.size());
   size_t NumRefs = 0;
   for (auto &Sym : Refs) {
-auto &SymRefs = Sym.second;
-llvm::sort(SymRefs);
-// FIXME: do we really need to dedup?
-SymRefs.erase(std::unique(SymRefs.begin(), SymRefs.end()), SymRefs.end());
-
+std::vector SymRefs(Sym.second.begin(), Sym.second.end());
 NumRefs += SymRefs.size();
 Result.emplace_back(Sym.first, llvm::ArrayRef(SymRefs).copy(Arena));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45978: dllexport const variables must have external linkage.

2019-03-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:5970
 auto *VD = dyn_cast(&ND);
-if (!ND.isExternallyVisible() || (VD && VD->isStaticLocal())) {
+const NamespaceDecl *NS = nullptr;
+bool isAnonymousNS = false;

This can be lowered into the below `if` statement.



Comment at: lib/Sema/SemaDecl.cpp:5971-5972
+const NamespaceDecl *NS = nullptr;
+bool isAnonymousNS = false;
+bool isMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+if (VD) {

is -> Is per our naming convention rules.



Comment at: lib/Sema/SemaDecl.cpp:5977
+  while (DC && NS) {
+isAnonymousNS = isAnonymousNS || (NS && NS->getDeclName().isEmpty());
+DC = DC->getParent();

No need to test that `NS` is nonnull here; already done as part of the while 
loop predicate. Also, you can call `NamespaceDecl::isAnonymousNamespace()` 
rather than manually try to test the declared identifier.

I think a more clear way to write this is:
```
if (VD) {
  const NamespaceDecl *NS = dyn_cast(VD->getDeclContext());
  while (NS && !IsAnonymousNS) {
IsAnonymousNS = NS->isAnonymousNamespace();
NS = dyn_cast(NS->getParent());
  }
  ...
}
```



Comment at: lib/Sema/SemaDecl.cpp:5982-5984
+if ((ND.isExternallyVisible() && isAnonymousNS && isMicrosoft) ||
+(!(isAnonymousNS && isMicrosoft) &&
+ (!ND.isExternallyVisible() || (VD && VD->isStaticLocal() {

This is a pretty complicated predicate; I'd simplify it a bit and then add some 
comments to explain it further. The comments from line 5967 could move down 
here (with modification), in fact. Untested:
```
bool AnonNSInMicrosoftMode = IsAnonymous && IsMicrosoft;
if ((ND.isExternallyVisible() && AnonNSInMicrosoftMode) ||
(!AnonNSInMicrosoftMode &&
 (!ND.isExternallyVisible() || VD->isStaticLocal( {
  ...
}
```



Comment at: test/Sema/dllexport-1.cpp:7
+#if MSVC
+// expected-no-diagnostics@+4
+#else

I am almost certain that `expected-no-diagnostics` applies to the entire file, 
so the @ doesn't make sense. I think you just need one of these for the entire 
file:
```
#ifdef MSVC
// expected-no-diagnostics
#endif
```
(Note, I switched it to use `#ifdef` as well.)



Comment at: test/Sema/dllexport-2.cpp:6
+
+#if MSVC
+// expected-error@+6 {{default initialization of an object of const type 
'const int'}}

Please switch to `#ifdef` rather than `#if`.



Comment at: test/Sema/dllexport-2.cpp:28
+#if MSVC
+// expected-nodiagnostics
+#else

This isn't correct -- had the typo not been there, then the test would have 
failed because the file has diagnostics in MSVC mode. This should read:
```
#ifndef MSVC
// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
#endif
```



Comment at: test/SemaCXX/dllexport.cpp:73
+#ifdef MS
+// expected-nodiagnostics
+#else

Typo, but this is the wrong construct. Should be:
```
#ifndef MS
namespace {
  __declspec(dllexport) int InternalGlobal; // expected-error{{anonymous 
namespace)::InternalGlobal' must have external linkage when declared 
'dllexport'}}
}
#endif
```



Comment at: test/SemaCXX/dllexport.cpp:133
+#ifdef MS
+// expected-nodiagnostics
+#else

Similar here as above.



Comment at: test/SemaCXX/dllimport.cpp:125
+#ifdef MS
+// expected-nodiagnostics
+#else

Here too.



Comment at: test/SemaCXX/dllimport.cpp:222
+#ifdef MS
+// expected-nodiagnostics
+#else

And here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45978/new/

https://reviews.llvm.org/D45978



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


r355601 - expected-no-diagnostics@ does not make sense, switching to a more idiomatic form; NFC.

2019-03-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Mar  7 07:03:06 2019
New Revision: 355601

URL: http://llvm.org/viewvc/llvm-project?rev=355601&view=rev
Log:
expected-no-diagnostics@ does not make sense, switching to a more idiomatic 
form; NFC.

Modified:
cfe/trunk/test/SemaObjCXX/vararg-non-pod.mm

Modified: cfe/trunk/test/SemaObjCXX/vararg-non-pod.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/vararg-non-pod.mm?rev=355601&r1=355600&r2=355601&view=diff
==
--- cfe/trunk/test/SemaObjCXX/vararg-non-pod.mm (original)
+++ cfe/trunk/test/SemaObjCXX/vararg-non-pod.mm Thu Mar  7 07:03:06 2019
@@ -2,6 +2,10 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs 
-std=c++98
 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs 
-std=c++11
 
+#if __cplusplus > 199711L
+// expected-no-diagnostics
+#endif
+
 extern char version[];
 
 @protocol P;
@@ -22,8 +26,6 @@ void t1(D *d)
   [d g:10, c]; 
 #if __cplusplus <= 199711L // C++03 or earlier modes
   // expected-warning@-2{{cannot pass object of non-POD type 'C' through 
variadic method; call will abort at runtime}}
-#else
-  // expected-no-diagnostics@-4
 #endif
   [d g:10, version];
 }


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


[PATCH] D58878: [Diagnostics] Warn for assignments in bool contexts

2019-03-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 189711.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58878/new/

https://reviews.llvm.org/D58878

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
  test/CodeCompletion/skip-auto-funcs.cpp
  test/Modules/diag-pragma.c
  test/Modules/diag-pragma.cpp
  test/Sema/assigment-in-bool-context.c
  test/Sema/parentheses.c
  test/SemaCXX/assigment-in-bool-context.cpp
  test/SemaCXX/warn-assignment-condition.cpp
  test/SemaObjC/idiomatic-parentheses.m
  test/SemaObjC/self-assign.m

Index: test/SemaObjC/self-assign.m
===
--- test/SemaObjC/self-assign.m
+++ test/SemaObjC/self-assign.m
@@ -6,7 +6,7 @@
 - (id):(int)x :(int)y {
 int z;
 // 
-if (self = [self :x :y]) {} // expected-warning{{using the result of an assignment as a condition without parentheses}} \
+if (self = [self :x :y]) {} // expected-warning{{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
 // expected-note{{place parentheses around the assignment to silence this warning}}
 return self;
Index: test/SemaObjC/idiomatic-parentheses.m
===
--- test/SemaObjC/idiomatic-parentheses.m
+++ test/SemaObjC/idiomatic-parentheses.m
@@ -27,7 +27,7 @@
   if (self = [self initWithInt: i]) {
   }
   // rdar://11066598
-  if (self.uid = 100) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  if (self.uid = 100) { // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note {{place parentheses around the assignment to silence this warning}} \
 // expected-note {{use '==' to turn this assignment into an equality comparison}}
 // ...
Index: test/SemaCXX/warn-assignment-condition.cpp
===
--- test/SemaCXX/warn-assignment-condition.cpp
+++ test/SemaCXX/warn-assignment-condition.cpp
@@ -12,41 +12,41 @@
   A a, b;
 
   // With scalars.
-  if (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  if (x = 7) {} // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
   if ((x = 7)) {}
   do {
-  } while (x = 7); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  } while (x = 7); // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
   do {
   } while ((x = 7));
-  while (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  while (x = 7) {} // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
 
   while ((x = 7)) {}
-  for (; x = 7; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  for (; x = 7; ) {} // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
   for (; (x = 7); ) {}
 
-  if (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  if (p = p) {} // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
   if ((p = p)) {}
   do {
-  } while (p = p); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  } while (p = p); // expected-warning {{converting the result of an assignment to bool}} \
 // expected-note{{use '==' to turn this assignment into an equality comparison}} \
   // expected-note{{place parentheses around the assignment to silence this warning}}
   do {
   } while ((p = p));
-  while (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+  while (p = p) {} // expected-warning {{con

[PATCH] D58878: [Diagnostics] Warn for assignments in bool contexts

2019-03-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Addressed notes.

Not sure why we miss
_Bool warn3(int x, _Bool a) {

  return x = 0 || a;

}

in C mode :/


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58878/new/

https://reviews.llvm.org/D58878



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


[PATCH] D58930: Add XCOFF triple object format type for AIX

2019-03-07 Thread Jason Liu via Phabricator via cfe-commits
jasonliu updated this revision to Diff 189713.
jasonliu added a comment.

Share the same "unsupported error" message with WASM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58930/new/

https://reviews.llvm.org/D58930

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1258,6 +1258,11 @@
   EXPECT_EQ(Triple::Wasm,
 Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
 
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
+
   Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
   EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
 
@@ -1276,6 +1281,9 @@
 
   T.setObjectFormat(Triple::MachO);
   EXPECT_EQ(Triple::MachO, T.getObjectFormat());
+  
+  T.setObjectFormat(Triple::XCOFF);
+  EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
 }
 
 TEST(TripleTest, NormalizeWindows) {
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -5594,6 +5594,9 @@
   case MCObjectFileInfo::IsWasm:
 CurrentFormat = WASM;
 break;
+  case MCObjectFileInfo::IsXCOFF:
+llvm_unreachable("unexpected object format");
+break;
   }
 
   if (~Prefix->SupportedFormats & CurrentFormat) {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -534,6 +534,9 @@
 
 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
   return StringSwitch(EnvironmentName)
+// "xcoff" must come before "coff" because of the order-dependendent
+// pattern matching.
+.EndsWith("xcoff", Triple::XCOFF)
 .EndsWith("coff", Triple::COFF)
 .EndsWith("elf", Triple::ELF)
 .EndsWith("macho", Triple::MachO)
@@ -622,6 +625,7 @@
   case Triple::ELF: return "elf";
   case Triple::MachO: return "macho";
   case Triple::Wasm: return "wasm";
+  case Triple::XCOFF: return "xcoff";
   }
   llvm_unreachable("unknown object format type");
 }
@@ -686,6 +690,8 @@
   case Triple::ppc64:
 if (T.isOSDarwin())
   return Triple::MachO;
+else if (T.isOSAIX())
+  return Triple::XCOFF;
 return Triple::ELF;
 
   case Triple::wasm32:
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -710,6 +710,9 @@
   case MCObjectFileInfo::IsWasm:
 PlatformParser.reset(createWasmAsmParser());
 break;
+  case MCObjectFileInfo::IsXCOFF:
+// TODO: Need to implement createXCOFFAsmParser for XCOFF format.
+break;
   }
 
   PlatformParser->Initialize(*this);
Index: llvm/lib/MC/MCObjectFileInfo.cpp
===
--- llvm/lib/MC/MCObjectFileInfo.cpp
+++ llvm/lib/MC/MCObjectFileInfo.cpp
@@ -801,6 +801,10 @@
 Env = IsWasm;
 initWasmMCObjectFileInfo(TT);
 break;
+  case Triple::XCOFF:
+Env = IsXCOFF;
+// TODO: Initialize MCObjectFileInfo for XCOFF format when MCSectionXCOFF is ready.
+break;
   case Triple::UnknownObjectFormat:
 report_fatal_error("Cannot initialize MC for unknown object file format.");
 break;
@@ -816,6 +820,7 @@
   case Triple::MachO:
   case Triple::COFF:
   case Triple::Wasm:
+  case Triple::XCOFF:
   case Triple::UnknownObjectFormat:
 report_fatal_error("Cannot get DWARF comdat section for this object file "
"format: not implemented.");
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -161,6 +161,9 @@
   return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
 case MCObjectFileInfo::IsWasm:
   return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
+case MCObjectFileInfo::IsXCOFF:
+  // TODO: Need to implement class MCSymbolXCOFF.
+  break;
 }
   }
   return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
Inde

[PATCH] D53757: [ASTImporter] Changed use of Import to Import_New in ASTNodeImporter.

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a reviewer: martong.
Herald added a project: clang.

Ping. This patch is the next in the series of patches to finish the proper 
error handling (i.e. using Error and Expected). Please see the "Stack" 
column above.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53757/new/

https://reviews.llvm.org/D53757



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


[PATCH] D59094: [ARM] Fix bug 39982 - pcs("aapcs-vfp") is not consistent

2019-03-07 Thread Carey Williams via Phabricator via cfe-commits
carwil created this revision.
Herald added subscribers: cfe-commits, jdoerfert, kristof.beyls, javed.absar.
Herald added a project: clang.

See: https://bugs.llvm.org/show_bug.cgi?id=39982

When considering how to classify homogeneous aggregates as return/argument 
types, the ABI of the function (specified by attribute pcs) wasn't being taken 
into account. This resulted in some weird and unexpected hybrid assembly when 
compiling with softfp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59094

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCXX/arm-pcs.cpp

Index: clang/test/CodeGenCXX/arm-pcs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/arm-pcs.cpp
@@ -0,0 +1,46 @@
+// Covers a bug fix for ABI selection with homogenous aggregates:
+//  See: https://bugs.llvm.org/show_bug.cgi?id=39982
+
+// RUN: %clang -mfloat-abi=hard --target=armv7-unknown-linux-gnueabi -O3 -S -o - %s | FileCheck %s -check-prefixes=HARD_INSTRs,CHECK
+// RUN: %clang -mfloat-abi=softfp --target=armv7-unknown-linux-gnueabi -O3 -S -o - %s | FileCheck %s -check-prefixes=HARD_INSTRs,CHECK
+// RUN: %clang -mfloat-abi=soft --target=armv7-unknown-linux-gnueabi -O3 -S -o - %s | FileCheck %s -check-prefixes=SOFT_INSTRs,CHECK
+
+struct S {
+  float f;
+  float d;
+};
+
+// Variadic functions should always marshal for the base standard.
+// See section 5.5 (Parameter Passing) of the AAPCS.
+float __attribute__((pcs("aapcs-vfp"))) variadic(S s, ...) {
+  // CHECK-NOT: vmov s{{[0-9]+}}, s{{[0-9]+}}
+  // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
+  return s.d;
+}
+
+float __attribute__((pcs("aapcs-vfp"))) not_variadic(S s) {
+  // SOFT_INSTRs: mov r{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs-NOT: vmov s{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs: vmov.f32 s{{[0-9]+}}, s{{[0-9]+}}
+  return s.d;
+}
+
+float __attribute__((pcs("aapcs-vfp"))) baz(float x, float y) {
+  // SOFT_INSTRs: mov r{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs-NOT: mov s{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs: vmov.f32 s{{[0-9]+}}, s{{[0-9]+}}
+  return y;
+}
+
+float __attribute__((pcs("aapcs-vfp"))) foo(S s) {
+  // SOFT_INSTRs: mov r{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs-NOT: mov r{{[0-9]+}}, r{{[0-9]+}}
+  // HARD_INSTRs: vmov.f32 s{{[0-9]+}}, s{{[0-9]+}}
+  return s.d;
+}
+
+float __attribute__((pcs("aapcs"))) bar(S s) {
+  // CHECK-NOT: vmov s{{[0-9]+}}, s{{[0-9]+}}
+  // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
+  return s.d;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5591,8 +5591,10 @@
   ABIKind getABIKind() const { return Kind; }
 
 private:
-  ABIArgInfo classifyReturnType(QualType RetTy, bool isVariadic) const;
-  ABIArgInfo classifyArgumentType(QualType RetTy, bool isVariadic) const;
+  ABIArgInfo classifyReturnType(QualType RetTy, bool isVariadic,
+unsigned functionCallConv) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, bool isVariadic,
+  unsigned functionCallConv) const;
   ABIArgInfo classifyHomogeneousAggregate(QualType Ty, const Type *Base,
   uint64_t Members) const;
   ABIArgInfo coerceIllegalVector(QualType Ty) const;
@@ -5722,11 +5724,12 @@
 
 void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const {
   if (!::classifyReturnType(getCXXABI(), FI, *this))
-FI.getReturnInfo() =
-classifyReturnType(FI.getReturnType(), FI.isVariadic());
+FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), FI.isVariadic(),
+FI.getCallingConvention());
 
   for (auto &I : FI.arguments())
-I.info = classifyArgumentType(I.type, FI.isVariadic());
+I.info = classifyArgumentType(I.type, FI.isVariadic(),
+  FI.getCallingConvention());
 
   // Always honor user-specified calling convention.
   if (FI.getCallingConvention() != llvm::CallingConv::C)
@@ -5805,8 +5808,8 @@
   return ABIArgInfo::getDirect(nullptr, 0, nullptr, false);
 }
 
-ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty,
-bool isVariadic) const {
+ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
+unsigned functionCallConv) const {
   // 6.1.2.1 The following argument types are VFP CPRCs:
   //   A single-precision floating-point type (including promoted
   //   half-precision types); A double-precision floating-point type;
@@ -5814,8 +5817,11 @@
   //   with a Base Type of a single- or double-precision floating-point type,
   //   64-bit containerized vectors or 128-bit containerized vectors with one
   //   to four Elements.
-  bool IsEffectivelyAAPCS_VFP = getABIKind() == AAPCS_VFP && !isVariadic;
 
+  bool IsEffectivelyAAPCS_VFP =
+  (getABIKind() == 

[PATCH] D53757: [ASTImporter] Changed use of Import to Import_New in ASTNodeImporter.

2019-03-07 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a subscriber: rnkovacs.

> This patch is the next in the series of patches to finish the proper error 
> handling (i.e. using Error and Expected). Please see the "Stack" column 
> above.

@balazske Or is it superseded by this one? https://reviews.llvm.org/D53818


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53757/new/

https://reviews.llvm.org/D53757



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


[PATCH] D59054: [analyzer] C++17: PR40022: Support aggregate initialization with compound values in presence of base classes.

2019-03-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

At first glance this looks OK, but I'll take the time to understand the 
infrastructure behind it and give a proper review.




Comment at: clang/test/Analysis/array-struct-region.cpp:3
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c++ 
-analyzer-config c++-inlining=constructors %s
+// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c++ 
-std=c++17 -analyzer-config c++-inlining=constructors %s
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.core,debug.ExprInspection -DINLINE -verify -x c %s

I didn't see `-analyzer-config c++-inlining=constructors` in the bugreport -- 
why is it needed?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59054/new/

https://reviews.llvm.org/D59054



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
  llvm::StringRef ResourceDir) {
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(

Please don't duplicate code in comments. Explain why it shouldn't generate the 
dependency files, or drop the comment.





Comment at: clangd/GlobalCompilationDatabase.h:116
+  /// Adjusts given compile command for clangd.
+  tooling::CompileCommand adjustArguments(tooling::CompileCommand Cmd) const;
+

kadircet wrote:
> hokein wrote:
> > ioeric wrote:
> > > This doesn't seem to be used in this patch (except for tests). Could you 
> > > include intended uses in the patch so we can understand the problem 
> > > better?
> > Looks like this patch introduces two changes:
> > 
> > - move the internal adjustArguments to public, I have the same question, 
> > any reason doing it? because we can test it? 
> > - add additional Adjusters to adjustArguments
> It was only for testing
This patch also changes `getCompileCommand` to call `adjustArguments`.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:25
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(
+  Cmd.CommandLine, Cmd.Filename);

Please use `clang::tooling::combineAdjusters`.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355605: [analyzer] handle modification of vars inside an 
expr with comma operator (authored by petarj, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58894?vs=189661&id=189719#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
  cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
+++ cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -24,6 +24,18 @@
   return InnerMatcher.matches(*Range, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, maybeEvalCommaExpr,
+ ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr* Result = &Node;
+  while (const auto *BOComma =
+   dyn_cast_or_null(Result->IgnoreParens())) {
+if (!BOComma->isCommaOp())
+  break;
+Result = BOComma->getRHS();
+  }
+  return InnerMatcher.matches(*Result, Finder, Builder);
+}
+
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 cxxTypeidExpr;
 
@@ -193,24 +205,28 @@
 const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) {
   // LHS of any assignment operators.
   const auto AsAssignmentLhs =
-  binaryOperator(isAssignmentOperator(), hasLHS(equalsNode(Exp)));
+  binaryOperator(isAssignmentOperator(),
+ hasLHS(maybeEvalCommaExpr(equalsNode(Exp;
 
   // Operand of increment/decrement operators.
   const auto AsIncDecOperand =
   unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),
-hasUnaryOperand(equalsNode(Exp)));
+hasUnaryOperand(maybeEvalCommaExpr(equalsNode(Exp;
 
   // Invoking non-const member function.
   // A member function is assumed to be non-const when it is unresolved.
   const auto NonConstMethod = cxxMethodDecl(unless(isConst()));
   const auto AsNonConstThis =
-  expr(anyOf(cxxMemberCallExpr(callee(NonConstMethod), on(equalsNode(Exp))),
+  expr(anyOf(cxxMemberCallExpr(callee(NonConstMethod),
+   on(maybeEvalCommaExpr(equalsNode(Exp,
  cxxOperatorCallExpr(callee(NonConstMethod),
- hasArgument(0, equalsNode(Exp))),
+ hasArgument(0,
+ maybeEvalCommaExpr(equalsNode(Exp,
  callExpr(callee(expr(anyOf(
- unresolvedMemberExpr(hasObjectExpression(equalsNode(Exp))),
+ unresolvedMemberExpr(
+   hasObjectExpression(maybeEvalCommaExpr(equalsNode(Exp,
  cxxDependentScopeMemberExpr(
- hasObjectExpression(equalsNode(Exp);
+ hasObjectExpression(maybeEvalCommaExpr(equalsNode(Exp));
 
   // Taking address of 'Exp'.
   // We're assuming 'Exp' is mutated as soon as its address is taken, though in
@@ -220,10 +236,11 @@
   unaryOperator(hasOperatorName("&"),
 // A NoOp implicit cast is adding const.
 unless(hasParent(implicitCastExpr(hasCastKind(CK_NoOp,
-hasUnaryOperand(equalsNode(Exp)));
+hasUnaryOperand(maybeEvalCommaExpr(equalsNode(Exp;
   const auto AsPointerFromArrayDecay =
   castExpr(hasCastKind(CK_ArrayToPointerDecay),
-   unless(hasParent(arraySubscriptExpr())), has(equalsNode(Exp)));
+   unless(hasParent(arraySubscriptExpr())),
+   has(maybeEvalCommaExpr(equalsNode(Exp;
   // Treat calling `operator->()` of move-only classes as taking address.
   // These are typically smart pointers with unique ownership so we treat
   // mutation of pointee as mutation of the smart pointer itself.
@@ -231,7 +248,8 @@
   cxxOperatorCallExpr(hasOverloadedOperatorName("->"),
   callee(cxxMethodDecl(ofClass(isMoveOnly()),
returns(nonConstPointerType(,
-  argumentCountIs(1), hasArgument(0, equalsNode(Exp)));
+  argumentCountIs(1),
+  hasArgument(0, maybeEvalCommaExpr(equalsNode(Exp;
 
   // Used as non-const-ref argument when calling a function.
   // An argument is assumed to be non-const-ref when the function is unresolved.
@@ -239,7 +257,8 @@
   // findFunctionArgMutation which has additional smarts for handling forwarding
   // references.
   const auto NonConstRefParam = forEachArgumentWithParam(
-  equalsNode(Exp), parmVarDecl(hasType(no

[PATCH] D59092: [clangd] Deduplicate Refs on the fly.

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/index/Ref.cpp:44
 
 RefSlab RefSlab::Builder::build() && {
   // We can reuse the arena, as it only has unique strings and we need them 
all.

Can you add a comment saying that references will be ordered?



Comment at: clangd/indexer/IndexerMain.cpp:59
  for (const auto &Sym : S) {
-   // No need to merge as currently all Refs are from main 
file.
for (const auto &Ref : Sym.second)

instead of just deleting let's mention that it de-duplicates during insertion.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59092/new/

https://reviews.llvm.org/D59092



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


r355606 - [PR40778] Preserve addr space in Derived to Base cast.

2019-03-07 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Mar  7 08:23:15 2019
New Revision: 355606

URL: http://llvm.org/viewvc/llvm-project?rev=355606&view=rev
Log:
[PR40778] Preserve addr space in Derived to Base cast.

The address space for the Base class pointer when up-casting
from Derived should be taken from the Derived class pointer.

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


Added:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=355606&r1=355605&r2=355606&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Mar  7 08:23:15 2019
@@ -302,7 +302,8 @@ Address CodeGenFunction::GetAddressOfBas
 
   // Get the base pointer type.
   llvm::Type *BasePtrTy =
-ConvertType((PathEnd[-1])->getType())->getPointerTo();
+  ConvertType((PathEnd[-1])->getType())
+  ->getPointerTo(Value.getType()->getPointerAddressSpace());
 
   QualType DerivedTy = getContext().getRecordType(Derived);
   CharUnits DerivedAlign = CGM.getClassPointerAlignment(Derived);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=355606&r1=355605&r2=355606&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar  7 08:23:15 2019
@@ -2660,10 +2660,15 @@ Sema::PerformObjectMemberConversion(Expr
   bool PointerConversions = false;
   if (isa(Member)) {
 DestRecordType = Context.getCanonicalType(Context.getTypeDeclType(RD));
+auto FromPtrType = FromType->getAs();
+DestRecordType = Context.getAddrSpaceQualType(
+DestRecordType, FromPtrType
+? FromType->getPointeeType().getAddressSpace()
+: FromType.getAddressSpace());
 
-if (FromType->getAs()) {
+if (FromPtrType) {
   DestType = Context.getPointerType(DestRecordType);
-  FromRecordType = FromType->getPointeeType();
+  FromRecordType = FromPtrType->getPointeeType();
   PointerConversions = true;
 } else {
   DestType = DestRecordType;

Added: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl?rev=355606&view=auto
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl (added)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl Thu Mar  7 
08:23:15 2019
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck 
%s
+
+struct B {
+  int mb;
+};
+
+class D : public B {
+public:
+  int getmb() { return mb; }
+};
+
+void foo() {
+  D d;
+  //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
+  //CHECK: call i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
+  d.getmb();
+}
+
+//Derived and Base are in the same address space.
+
+//CHECK: define linkonce_odr i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)* 
%this)
+//CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*


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


r355608 - [PR40778][Sema] Adjust addr space of operands in builtin operators.

2019-03-07 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Mar  7 08:43:41 2019
New Revision: 355608

URL: http://llvm.org/viewvc/llvm-project?rev=355608&view=rev
Log:
[PR40778][Sema] Adjust addr space of operands in builtin operators.

Adjust address space for references and pointer operands of builtin operators.

Currently this change only fixes addr space in assignment (= and |=) operator,
that is needed for the test case reported in the bug. Wider support for all
other operations will follow.

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


Added:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=355608&r1=355607&r2=355608&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Mar  7 08:43:41 2019
@@ -7659,6 +7659,12 @@ BuiltinCandidateTypeSet::AddTypesConvert
 }
   }
 }
+/// Helper function for adjusting address spaces for the pointer or reference
+/// operands of builtin operators depending on the argument.
+static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T,
+Expr *Arg) {
+  return S.Context.getAddrSpaceQualType(T, Arg->getType().getAddressSpace());
+}
 
 /// Helper function for AddBuiltinOperatorCandidates() that adds
 /// the volatile- and non-volatile-qualified assignment operators for the
@@ -7670,15 +7676,17 @@ static void AddBuiltinAssignmentOperator
   QualType ParamTypes[2];
 
   // T& operator=(T&, T)
-  ParamTypes[0] = S.Context.getLValueReferenceType(T);
+  ParamTypes[0] = S.Context.getLValueReferenceType(
+  AdjustAddressSpaceForBuiltinOperandType(S, T, Args[0]));
   ParamTypes[1] = T;
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/true);
 
   if (!S.Context.getCanonicalType(T).isVolatileQualified()) {
 // volatile T& operator=(volatile T&, T)
-ParamTypes[0]
-  = S.Context.getLValueReferenceType(S.Context.getVolatileType(T));
+ParamTypes[0] = S.Context.getLValueReferenceType(
+AdjustAddressSpaceForBuiltinOperandType(S, 
S.Context.getVolatileType(T),
+Args[0]));
 ParamTypes[1] = T;
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/true);
@@ -8573,8 +8581,9 @@ public:
 ParamTypes[1] = ArithmeticTypes[Right];
 
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] =
-  S.Context.getLValueReferenceType(ArithmeticTypes[Left]);
+ParamTypes[0] = S.Context.getLValueReferenceType(
+AdjustAddressSpaceForBuiltinOperandType(S, ArithmeticTypes[Left],
+Args[0]));
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 if (VisibleTypeConversionsQuals.hasVolatile()) {
   // Add this built-in operator as a candidate (VQ is 'volatile').

Added: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl?rev=355608&view=auto
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl (added)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl Thu Mar  7 08:43:41 
2019
@@ -0,0 +1,46 @@
+//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck 
%s
+
+enum E {
+  a,
+  b,
+};
+
+class C {
+public:
+  void Assign(E e) { me = e; }
+  void OrAssign(E e) { mi |= e; }
+  E me;
+  int mi;
+};
+
+__global E globE;
+//CHECK-LABEL: define spir_func void @_Z3barv()
+void bar() {
+  C c;
+  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, 
i32 0)
+  c.Assign(a);
+  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* 
%{{[0-9]+}}, i32 0)
+  c.OrAssign(a);
+
+  E e;
+  // CHECK: store i32 1, i32* %e
+  e = b;
+  // CHECK: store i32 0, i32 addrspace(1)* @globE
+  globE = a;
+  // FIXME: Sema fails here because it thinks the types are incompatible.
+  //e = b;
+  //globE = a;
+}
+
+//CHECK: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* 
%this, i32 %e)
+//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
+//CHECK: %me = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, 
i32 0, i32 0
+//CHECK: store i32 [[E]], i32 addrspace(4)* %me
+
+//CHECK define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C 
addrspace(4)* %this, i32 %e)
+//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
+//CHECK: %mi = getelementptr inbound

[PATCH] D58719: [PR40778][Sema] Adjust address space of operands in builtin operators

2019-03-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC355608: [PR40778][Sema] Adjust addr space of operands in 
builtin operators. (authored by stulova, committed by ).
Herald added a subscriber: kristina.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D58719?vs=189527&id=189725#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58719/new/

https://reviews.llvm.org/D58719

Files:
  lib/Sema/SemaOverload.cpp
  test/CodeGenOpenCLCXX/addrspace-operators.cl

Index: test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -0,0 +1,46 @@
+//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+enum E {
+  a,
+  b,
+};
+
+class C {
+public:
+  void Assign(E e) { me = e; }
+  void OrAssign(E e) { mi |= e; }
+  E me;
+  int mi;
+};
+
+__global E globE;
+//CHECK-LABEL: define spir_func void @_Z3barv()
+void bar() {
+  C c;
+  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  c.Assign(a);
+  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  c.OrAssign(a);
+
+  E e;
+  // CHECK: store i32 1, i32* %e
+  e = b;
+  // CHECK: store i32 0, i32 addrspace(1)* @globE
+  globE = a;
+  // FIXME: Sema fails here because it thinks the types are incompatible.
+  //e = b;
+  //globE = a;
+}
+
+//CHECK: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %this, i32 %e)
+//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
+//CHECK: %me = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 0
+//CHECK: store i32 [[E]], i32 addrspace(4)* %me
+
+//CHECK define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %this, i32 %e)
+//CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
+//CHECK: %mi = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 1
+//CHECK: [[MI:%[0-9]+]] = load i32, i32 addrspace(4)* %mi
+//CHECK: %or = or i32 [[MI]], [[E]]
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -7659,6 +7659,12 @@
 }
   }
 }
+/// Helper function for adjusting address spaces for the pointer or reference
+/// operands of builtin operators depending on the argument.
+static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T,
+Expr *Arg) {
+  return S.Context.getAddrSpaceQualType(T, Arg->getType().getAddressSpace());
+}
 
 /// Helper function for AddBuiltinOperatorCandidates() that adds
 /// the volatile- and non-volatile-qualified assignment operators for the
@@ -7670,15 +7676,17 @@
   QualType ParamTypes[2];
 
   // T& operator=(T&, T)
-  ParamTypes[0] = S.Context.getLValueReferenceType(T);
+  ParamTypes[0] = S.Context.getLValueReferenceType(
+  AdjustAddressSpaceForBuiltinOperandType(S, T, Args[0]));
   ParamTypes[1] = T;
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/true);
 
   if (!S.Context.getCanonicalType(T).isVolatileQualified()) {
 // volatile T& operator=(volatile T&, T)
-ParamTypes[0]
-  = S.Context.getLValueReferenceType(S.Context.getVolatileType(T));
+ParamTypes[0] = S.Context.getLValueReferenceType(
+AdjustAddressSpaceForBuiltinOperandType(S, S.Context.getVolatileType(T),
+Args[0]));
 ParamTypes[1] = T;
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/true);
@@ -8573,8 +8581,9 @@
 ParamTypes[1] = ArithmeticTypes[Right];
 
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] =
-  S.Context.getLValueReferenceType(ArithmeticTypes[Left]);
+ParamTypes[0] = S.Context.getLValueReferenceType(
+AdjustAddressSpaceForBuiltinOperandType(S, ArithmeticTypes[Left],
+Args[0]));
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 if (VisibleTypeConversionsQuals.hasVolatile()) {
   // Add this built-in operator as a candidate (VQ is 'volatile').
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r355609 - [Sema] Change addr space diagnostics in casts to follow C++ style.

2019-03-07 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Mar  7 09:06:30 2019
New Revision: 355609

URL: http://llvm.org/viewvc/llvm-project?rev=355609&view=rev
Log:
[Sema] Change addr space diagnostics in casts to follow C++ style.

This change adds a new diagnostic for mismatching address spaces
to be used for C++ casts (only enabled in C style cast for now,
the rest will follow!).

The change extends C-style cast rules to account for address spaces.
It also adds a separate function for address space cast checking that
can be used to map from a separate address space cast operator
addrspace_cast (to be added as a follow up patch).

Note, that after this change clang will no longer allows arbitrary
address space conversions in reinterpret_casts because they can lead
to accidental errors. The implicit safe conversions would still be
allowed.

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


Added:
cfe/trunk/test/CodeGenOpenCLCXX/address-space-castoperators.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/SemaCXX/address-space-conversion.cpp
cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
cfe/trunk/test/SemaOpenCL/address-spaces.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=355609&r1=355608&r2=355609&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar  7 09:06:30 
2019
@@ -6271,6 +6271,10 @@ def err_bad_cxx_cast_bitfield : Error<
 def err_bad_cxx_cast_qualifiers_away : Error<
   "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
   "functional-style cast}0 from %1 to %2 casts away qualifiers">;
+def err_bad_cxx_cast_addr_space_mismatch : Error<
+  "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
+  "functional-style cast}0 from %1 to %2 converts between mismatching address"
+  " spaces">;
 def ext_bad_cxx_cast_qualifiers_away_incoherent : ExtWarn<
   "ISO C++ does not allow "
   "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=355609&r1=355608&r2=355609&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Mar  7 09:06:30 2019
@@ -2212,7 +2212,15 @@ static TryCastResult TryReinterpretCast(
  /*CheckObjCLifetime=*/CStyle))
 SuccessResult = getCastAwayConstnessCastKind(CACK, msg);
 
-  if (IsLValueCast) {
+  if (IsAddressSpaceConversion(SrcType, DestType)) {
+Kind = CK_AddressSpaceConversion;
+assert(SrcType->isPointerType() && DestType->isPointerType());
+if (!CStyle &&
+!DestType->getPointeeType().getQualifiers().isAddressSpaceSupersetOf(
+SrcType->getPointeeType().getQualifiers())) {
+  SuccessResult = TC_Failed;
+}
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {
 Kind = Self.PrepareCastToObjCObjectPointer(SrcExpr);
@@ -,8 +2230,6 @@ static TryCastResult TryReinterpretCast(
 } else {
   Kind = CK_BitCast;
 }
-  } else if (IsAddressSpaceConversion(SrcType, DestType)) {
-Kind = CK_AddressSpaceConversion;
   } else {
 Kind = CK_BitCast;
   }
@@ -2278,6 +2284,41 @@ static TryCastResult TryReinterpretCast(
   return SuccessResult;
 }
 
+static TryCastResult TryAddressSpaceCast(Sema &Self, ExprResult &SrcExpr,
+ QualType DestType, bool CStyle,
+ unsigned &msg) {
+  if (!Self.getLangOpts().OpenCL)
+// FIXME: As compiler doesn't have any information about overlapping addr
+// spaces at the moment we have to be permissive here.
+return TC_NotApplicable;
+  // Even though the logic below is general enough and can be applied to
+  // non-OpenCL mode too, we fast-path above because no other languages
+  // define overlapping address spaces currently.
+  auto SrcType = SrcExpr.get()->getType();
+  auto SrcPtrType = SrcType->getAs();
+  if (!SrcPtrType)
+return TC_NotApplicable;
+  auto DestPtrType = DestType->getAs();
+  if (!DestPtrType)
+return TC_NotApplicable;
+  auto SrcPointeeType = SrcPtrType->getPointeeType();
+  auto DestPointeeType = DestPtrType->getPointeeType();
+  if (SrcPointeeType.getAddressSpace() == DestPointeeType.getAddressSpace())
+return TC_NotApplicable;
+  if (!DestPtrType->isAddressSpaceOverlapping(*SrcPtrType)) {
+msg = diag::err_bad_cxx_cast_addr_space_mismatch;
+return TC_Failed;
+  }
+  auto SrcPointeeTypeWithoutAS =
+  Self.Context.r

[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-03-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355609: [Sema] Change addr space diagnostics in casts to 
follow C++ style. (authored by stulova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58346?vs=189474&id=189731#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58346/new/

https://reviews.llvm.org/D58346

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  cfe/trunk/test/SemaCXX/address-space-conversion.cpp
  cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  cfe/trunk/test/SemaOpenCL/address-spaces.cl

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6271,6 +6271,10 @@
 def err_bad_cxx_cast_qualifiers_away : Error<
   "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
   "functional-style cast}0 from %1 to %2 casts away qualifiers">;
+def err_bad_cxx_cast_addr_space_mismatch : Error<
+  "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
+  "functional-style cast}0 from %1 to %2 converts between mismatching address"
+  " spaces">;
 def ext_bad_cxx_cast_qualifiers_away_incoherent : ExtWarn<
   "ISO C++ does not allow "
   "%select{const_cast|static_cast|reinterpret_cast|dynamic_cast|C-style cast|"
Index: cfe/trunk/test/SemaCXX/address-space-conversion.cpp
===
--- cfe/trunk/test/SemaCXX/address-space-conversion.cpp
+++ cfe/trunk/test/SemaCXX/address-space-conversion.cpp
@@ -131,24 +131,24 @@
 void test_reinterpret_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
-   const void __attribute__((address_space(1))) *cvp1) {
-  // reinterpret_cast can be used to cast to a different address space.
-  (void)reinterpret_cast(ap1);
-  (void)reinterpret_cast(ap2);
+   const void __attribute__((address_space(1))) * cvp1) {
+  // reinterpret_cast can't be used to cast to a different address space unless they are matching (i.e. overlapping).
+  (void)reinterpret_cast(ap1); // expected-error{{reinterpret_cast from 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') to 'A_ptr' (aka 'A *') is not allowed}}
+  (void)reinterpret_cast(ap2); // expected-error{{reinterpret_cast from 'A_ptr_2' (aka '__attribute__((address_space(2))) A *') to 'A_ptr' (aka 'A *') is not allowed}}
   (void)reinterpret_cast(bp);
-  (void)reinterpret_cast(bp1);
-  (void)reinterpret_cast(bp2);
+  (void)reinterpret_cast(bp1); // expected-error{{reinterpret_cast from 'B_ptr_1' (aka '__attribute__((address_space(1))) B *') to 'A_ptr' (aka 'A *') is not allowed}}
+  (void)reinterpret_cast(bp2); // expected-error{{reinterpret_cast from 'B_ptr_2' (aka '__attribute__((address_space(2))) B *') to 'A_ptr' (aka 'A *') is not allowed}}
   (void)reinterpret_cast(vp);
-  (void)reinterpret_cast(vp1);
-  (void)reinterpret_cast(vp2);
-  (void)reinterpret_cast(ap);
-  (void)reinterpret_cast(ap2);
-  (void)reinterpret_cast(bp);
+  (void)reinterpret_cast(vp1);   // expected-error{{reinterpret_cast from 'void_ptr_1' (aka '__attribute__((address_space(1))) void *') to 'A_ptr' (aka 'A *') is not allowed}}
+  (void)reinterpret_cast(vp2);   // expected-error{{reinterpret_cast from 'void_ptr_2' (aka '__attribute__((address_space(2))) void *') to 'A_ptr' (aka 'A *') is not allowed}}
+  (void)reinterpret_cast(ap);  // expected-error{{reinterpret_cast from 'A_ptr' (aka 'A *') to 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') is not allowed}}
+  (void)reinterpret_cast(ap2); // expected-error{{reinterpret_cast from 'A_ptr_2' (aka '__attribute__((address_space(2))) A *') to 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') is not allowed}}
+  (void)reinterpret_cast(bp);  // expected-error{{reinterpret_cast from 'B_ptr' (aka 'B *') to 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') is not allowed}}
   (void)reinterpret_cast(bp1);
-  (void)reinterpret_cast(bp2);
-  (void)reinterpret_cast(vp);
+  (void)reinterpret_cast(bp2); // expected-error{{reinterpret_cast from 'B_ptr_2' (aka '__attribute__((address_space(2))) B *') to 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') is not allowed}}
+  (void)reinterpret_cast(vp);  // expected-error{{reinterpret_cast from 'void_ptr' (aka 'void *') to 'A_ptr_1' (aka '__attribute__((address_space(1))) A *') is not allowed}}
   (void)reinterpret_cast(vp1);
-  (void)reinterpret_cast(vp2);
+  (void)reinterpret_cast(vp2); // expected-error{{rei

[PATCH] D58708: [PR40778] Preserve addr space in Derived to Base cast

2019-03-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in r355606.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58708/new/

https://reviews.llvm.org/D58708



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


[PATCH] D58216: Support attribute used in member funcs of class templates II

2019-03-07 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added a comment.

OK, that doesn't sound like it will be a problem


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58216/new/

https://reviews.llvm.org/D58216



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
  llvm::StringRef ResourceDir) {
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(

gribozavr wrote:
> Please don't duplicate code in comments. Explain why it shouldn't generate 
> the dependency files, or drop the comment.
> 
> 
I am saying we are stripping "dependecy file related" commands, because clangd 
is not producing them. 
I feel like this provides the cause of the following statement, not replicates 
it. Becuase the following statement just says strip "dependency file related" 
commands.

But happy to drop the comment if you insist.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


[PATCH] D59086: [clangd] Adjust compile commands to be applicable for tooling

2019-03-07 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
  llvm::StringRef ResourceDir) {
+  // Clangd does not generate dependency file.
+  Cmd.CommandLine = tooling::getClangStripDependencyFileAdjuster()(

kadircet wrote:
> gribozavr wrote:
> > Please don't duplicate code in comments. Explain why it shouldn't generate 
> > the dependency files, or drop the comment.
> > 
> > 
> I am saying we are stripping "dependecy file related" commands, because 
> clangd is not producing them. 
> I feel like this provides the cause of the following statement, not 
> replicates it. Becuase the following statement just says strip "dependency 
> file related" commands.
> 
> But happy to drop the comment if you insist.
What about "clangd should not write files to disk, including dependency files 
requested on the command line."


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59086/new/

https://reviews.llvm.org/D59086



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


r355614 - [OPENMP 5.0]Add initial support for 'allocate' directive.

2019-03-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Mar  7 09:54:44 2019
New Revision: 355614

URL: http://llvm.org/viewvc/llvm-project?rev=355614&view=rev
Log:
[OPENMP 5.0]Add initial support for 'allocate' directive.

Added parsing/sema analysis/serialization/deserialization support for
'allocate' directive.

Added:
cfe/trunk/test/OpenMP/allocate_ast_print.cpp
cfe/trunk/test/OpenMP/allocate_messages.cpp
cfe/trunk/test/PCH/chain-openmp-allocate.cpp
Modified:
cfe/trunk/include/clang/AST/ASTMutationListener.h
cfe/trunk/include/clang/AST/ASTNodeTraverser.h
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclOpenMP.cpp
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTCommon.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTMutationListener.h?rev=355614&r1=355613&r2=355614&view=diff
==
--- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
+++ cfe/trunk/include/clang/AST/ASTMutationListener.h Thu Mar  7 09:54:44 2019
@@ -127,6 +127,11 @@ public:
   virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
 const Attr *Attr) {}
 
+  /// A declaration is marked as a variable with OpenMP allocator.
+  ///
+  /// \param D the declaration marked as a variable with OpenMP allocator.
+  virtual void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {}
+
   /// A definition has been made visible by being redefined locally.
   ///
   /// \param D The definition that was previously not visible.

Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=355614&r1=355613&r2=355614&view=diff
==
--- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
+++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Thu Mar  7 09:54:44 2019
@@ -393,6 +393,11 @@ public:
 Visit(D->getInit());
   }
 
+  void VisitOMPAllocateDecl(const OMPAllocateDecl *D) {
+for (const auto *E : D->varlists())
+  Visit(E);
+  }
+
   template 
   void dumpTemplateDeclSpecialization(const SpecializationDecl *D) {
 for (const auto *RedeclWithBadType : D->redecls()) {

Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=355614&r1=355613&r2=355614&view=diff
==
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Thu Mar  7 09:54:44 2019
@@ -405,6 +405,73 @@ public:
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == OMPRequires; }
 };
+
+/// This represents '#pragma omp allocate ...' directive.
+/// For example, in the following, the default allocator is used for both 'a'
+/// and 'A::b':
+///
+/// \code
+/// int a;
+/// #pragma omp allocate(a)
+/// struct A {
+///   static int b;
+/// #pragma omp allocate(b)
+/// };
+/// \endcode
+///
+class OMPAllocateDecl final
+: public Decl,
+  private llvm::TrailingObjects {
+  friend class ASTDeclReader;
+  friend TrailingObjects;
+
+  /// Number of variable within the allocate directive.
+  unsigned NumVars = 0;
+
+  virtual void anchor();
+
+  OMPAllocateDecl(Kind DK, DeclContext *DC, SourceLocation L)
+  : Decl(DK, DC, L) {}
+
+  ArrayRef getVars() const {
+return llvm::makeArrayRef(getTrailingObjects(), NumVars);
+  }
+
+  MutableArrayRef ge

r355616 - Rollback of rL355585.

2019-03-07 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Thu Mar  7 10:13:39 2019
New Revision: 355616

URL: http://llvm.org/viewvc/llvm-project?rev=355616&view=rev
Log:
Rollback of rL355585.

Introduces memory leak in FunctionTest.GetPointerAlignment that breaks 
sanitizer buildbots:

```
=
==2453==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x610428 in operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105
#1 0x16936bc in llvm::User::operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/User.cpp:151:19
#2 0x7c3fe9 in Create 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:12
#3 0x7c3fe9 in (anonymous 
namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136
#4 0x1a836a0 in HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#5 0x1a836a0 in testing::Test::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474
#6 0x1a85c55 in testing::TestInfo::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#7 0x1a870d0 in testing::TestCase::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#8 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
#9 0x1aa4d30 in 
HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#10 0x1aa4d30 in testing::UnitTest::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257
#11 0x1a6b656 in RUN_ALL_TESTS 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#12 0x1a6b656 in main 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50
#13 0x7f5af37a22e0 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

Indirect leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x610428 in operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105
#1 0x151be6b in make_unique 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1349:29
#2 0x151be6b in llvm::Function::Function(llvm::FunctionType*, 
llvm::GlobalValue::LinkageTypes, unsigned int, llvm::Twine const&, 
llvm::Module*) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/Function.cpp:241
#3 0x7c4006 in Create 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:16
#4 0x7c4006 in (anonymous 
namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136
#5 0x1a836a0 in HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#6 0x1a836a0 in testing::Test::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474
#7 0x1a85c55 in testing::TestInfo::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#8 0x1a870d0 in testing::TestCase::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#9 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
#10 0x1aa4d30 in 
HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#11 0x1aa4d30 in testing::UnitTest::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257
#12 0x1a6b656 in RUN_ALL_TESTS 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#13 0x1a6b656 in main 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50
#14 0x7f5af37a22e0 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

SUMMARY: AddressSanitizer: 168 byte(s) leaked in 2 allocation(s).
```

See 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11358/steps/check-llvm%20asan/logs/stdio
 for more information.

Also introduces use-of-uninitialized-value in 
ConstantsTest.FoldGlobalVariablePtr:
```
==7070==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x14e703c in User 
/b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/User.h:79:5
#1 0x14e703c in Consta

r355605 - [analyzer] handle modification of vars inside an expr with comma operator

2019-03-07 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Thu Mar  7 07:50:52 2019
New Revision: 355605

URL: http://llvm.org/viewvc/llvm-project?rev=355605&view=rev
Log:
[analyzer] handle modification of vars inside an expr with comma operator

We should track mutation of a variable within a comma operator expression.
Current code in ExprMutationAnalyzer does not handle it.

This will handle cases like:

(a, b) ++ < == b is modified
(a, b) = c < == b is modifed


Patch by Djordje Todorovic.

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

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=355605&r1=355604&r2=355605&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Mar  7 07:50:52 2019
@@ -3403,6 +3403,9 @@ public:
   static bool isComparisonOp(Opcode Opc) { return Opc >= BO_Cmp && Opc<=BO_NE; 
}
   bool isComparisonOp() const { return isComparisonOp(getOpcode()); }
 
+  static bool isCommaOp(Opcode Opc) { return Opc == BO_Comma; }
+  bool isCommaOp() const { return isCommaOp(getOpcode()); }
+
   static Opcode negateComparisonOp(Opcode Opc) {
 switch (Opc) {
 default:

Modified: cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp?rev=355605&r1=355604&r2=355605&view=diff
==
--- cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp (original)
+++ cfe/trunk/lib/Analysis/ExprMutationAnalyzer.cpp Thu Mar  7 07:50:52 2019
@@ -24,6 +24,18 @@ AST_MATCHER_P(CXXForRangeStmt, hasRangeS
   return InnerMatcher.matches(*Range, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, maybeEvalCommaExpr,
+ ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr* Result = &Node;
+  while (const auto *BOComma =
+   dyn_cast_or_null(Result->IgnoreParens())) {
+if (!BOComma->isCommaOp())
+  break;
+Result = BOComma->getRHS();
+  }
+  return InnerMatcher.matches(*Result, Finder, Builder);
+}
+
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 cxxTypeidExpr;
 
@@ -193,24 +205,28 @@ const Stmt *ExprMutationAnalyzer::findDe
 const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) {
   // LHS of any assignment operators.
   const auto AsAssignmentLhs =
-  binaryOperator(isAssignmentOperator(), hasLHS(equalsNode(Exp)));
+  binaryOperator(isAssignmentOperator(),
+ hasLHS(maybeEvalCommaExpr(equalsNode(Exp;
 
   // Operand of increment/decrement operators.
   const auto AsIncDecOperand =
   unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),
-hasUnaryOperand(equalsNode(Exp)));
+hasUnaryOperand(maybeEvalCommaExpr(equalsNode(Exp;
 
   // Invoking non-const member function.
   // A member function is assumed to be non-const when it is unresolved.
   const auto NonConstMethod = cxxMethodDecl(unless(isConst()));
   const auto AsNonConstThis =
-  expr(anyOf(cxxMemberCallExpr(callee(NonConstMethod), 
on(equalsNode(Exp))),
+  expr(anyOf(cxxMemberCallExpr(callee(NonConstMethod),
+   on(maybeEvalCommaExpr(equalsNode(Exp,
  cxxOperatorCallExpr(callee(NonConstMethod),
- hasArgument(0, equalsNode(Exp))),
+ hasArgument(0,
+ 
maybeEvalCommaExpr(equalsNode(Exp,
  callExpr(callee(expr(anyOf(
- 
unresolvedMemberExpr(hasObjectExpression(equalsNode(Exp))),
+ unresolvedMemberExpr(
+   
hasObjectExpression(maybeEvalCommaExpr(equalsNode(Exp,
  cxxDependentScopeMemberExpr(
- hasObjectExpression(equalsNode(Exp);
+ 
hasObjectExpression(maybeEvalCommaExpr(equalsNode(Exp));
 
   // Taking address of 'Exp'.
   // We're assuming 'Exp' is mutated as soon as its address is taken, though in
@@ -220,10 +236,11 @@ const Stmt *ExprMutationAnalyzer::findDi
   unaryOperator(hasOperatorName("&"),
 // A NoOp implicit cast is adding const.
 unless(hasParent(implicitCastExpr(hasCastKind(CK_NoOp,
-hasUnaryOperand(equalsNode(Exp)));
+hasUnaryOperand(maybeEvalCommaExpr(equalsNode(Exp;
   const auto AsPointerFromArrayDecay =
   castExpr(hasCastKind(CK_ArrayToPointerDecay),
-   unless(hasParent(arraySubscriptExpr())), has(equalsNode(Exp)));
+   unless(hasParent(arraySubscript

[PATCH] D58814: [clang][Index] Constructors and Destructors do not reference class

2019-03-07 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes accepted this revision.
nathawes added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58814/new/

https://reviews.llvm.org/D58814



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


[PATCH] D59034: Delete x86_64 ShadowCallStack support

2019-03-07 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 189750.
vlad.tsyrklevich added a comment.

- Keep x86_64 doc link


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59034/new/

https://reviews.llvm.org/D59034

Files:
  clang/docs/ShadowCallStack.rst
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/test/shadowcallstack/libc_support.h
  compiler-rt/test/shadowcallstack/lit.cfg
  compiler-rt/test/shadowcallstack/minimal_runtime.h
  compiler-rt/test/shadowcallstack/overflow-aarch64.c
  compiler-rt/test/shadowcallstack/overflow-x86_64.c
  compiler-rt/test/shadowcallstack/overflow.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ShadowCallStack.cpp
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/shadow-call-stack.mir
  llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
@@ -76,7 +76,6 @@
 deps += [ ":X86GenFoldTables" ]
   }
   sources = [
-"ShadowCallStack.cpp",
 "X86AsmPrinter.cpp",
 "X86AvoidStoreForwardingBlocks.cpp",
 "X86CallFrameOptimization.cpp",
Index: llvm/test/CodeGen/X86/shadow-call-stack.mir
===
--- llvm/test/CodeGen/X86/shadow-call-stack.mir
+++ /dev/null
@@ -1,212 +0,0 @@
-# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass shadow-call-stack -verify-machineinstrs -o - %s | FileCheck %s
 |
-
-  define void @no_return() #0 { ret void }
-  define void @normal_return() #0 { ret void }
-  define void @normal_return_leaf_func() #0 { ret void }
-  define void @short_leaf_func() #0 { ret void }
-  define void @normal_tail_call() #0 { ret void }
-  define void @r11_tail_call() #0 { ret void }
-  define void @conditional_tail_call() #0 { ret void }
-  define void @r10_live_in() #0 { ret void }
-
-  attributes #0 = { shadowcallstack }
-
-...

-# CHECK-LABEL: name: no_return
-name: no_return
-tracksRegLiveness: true
-frameInfo:
-  adjustsStack: true # not a leaf function
-body: |
-  ; CHECK: bb.0:
-  bb.0:
-; CHECK-NEXT: $eax = MOV32ri 13
-$eax = MOV32ri 13
-...

-# CHECK-LABEL: name: normal_return
-name: normal_return
-tracksRegLiveness: true
-frameInfo:
-  adjustsStack: true # not a leaf function
-body: |
-  ; CHECK: bb.0:
-  bb.0:
-; CHECK: $r10 = MOV64rm $rsp, 1, $noreg, 0, $noreg
-; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
-; CHECK-NEXT: ADD64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
-; CHECK-NEXT: $r11 = MOV64rm $r11, 1, $noreg, 0, $gs
-; CHECK-NEXT: MOV64mr $r11, 1, $noreg, 0, $gs, $r10
-; CHECK-NEXT: $eax = MOV32ri 13
-$eax = MOV32ri 13
-
-; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
-; CHECK-NEXT: $r10 = MOV64rm $r11, 1, $noreg, 0, $gs
-; CHECK-NEXT: $r10 = MOV64rm $r10, 1, $noreg, 0, $gs
-; CHECK-NEXT: SUB64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
-; CHECK-NEXT: CMP64mr $rsp, 1, $noreg, 0, $noreg, $r10, implicit-def $eflags
-; CHECK-NEXT: JNE_1 %bb.1, implicit $eflags
-; CHECK-NEXT: RETQ $eax
-RETQ $eax
-
-; CHECK: bb.1:
-; CHECK-NEXT; TRAP
-...

-# CHECK-LABEL: name: normal_return_leaf_func
-name: normal_return_leaf_func
-tracksRegLiveness: true
-frameInfo:
-  adjustsStack: false # leaf function
-body: |
-  ; CHECK: bb.0:
-  ; CHECK: liveins: $rcx
-  bb.0:
-liveins: $rcx
-
-; CHECK: $rdx = MOV64rm $rsp, 1, $noreg, 0, $noreg
-; CHECK-NEXT: $eax = MOV32ri 0
-$eax = MOV32ri 0
-; CHECK-NEXT: CMP64ri8 $rcx, 5, implicit-def $eflags
-CMP64ri8 $rcx, 5, implicit-def $eflags
-; CHECK-NEXT: JA_1 %bb.1, implicit $eflags
-JA_1 %bb.1, implicit $eflags
-; CHECK-NEXT: JMP_1 %bb.2
-JMP_1 %bb.2
-
-  ; CHECK: bb.1
-  ; CHECK: liveins: $eax, $rdx
-  bb.1:
-liveins: $eax
-
-; CHECKT: $eax = MOV32ri 1
-$eax = MOV32ri 1
-
-  ; CHECK: bb.2
-  ; CHECK: liveins: $eax, $rdx
-  bb.2:
-liveins: $eax
-
-; CHECK: CMP64mr $rsp, 1, $noreg, 0, $noreg, $rdx, implicit-def $eflags
-; CHECK-NEXT: JNE_1 %bb.3, implicit $eflags
-; CHECK-NEXT: RETQ $eax
-RETQ $eax
-
-; CHECK: bb.3:
-; CHECK-NEXT; TRAP
-...

-# CHECK-LABEL: name: short_leaf_func
-name: short_leaf_func
-tracksRegLiveness: true
-frameInfo:
-  adjustsStack: false # leaf function
-body: |
-  ; CHECK: bb.0:
-  bb.0:
-; Ensure these are not counted as machine instructions
-CFI_INSTRUCTION 0
-CFI_INSTRUCTION 0
-CFI_INSTRUCTION 0
-DBG_VALUE 0
-DBG_VALUE 0
-DBG_VALUE 0
-
-; CHECK: $eax = MOV32ri 13
-$eax = MOV32ri 13
-
-; CHECK-NEXT: RETQ $eax
-RETQ $eax
-...

-# CHECK-LABEL: na

[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

2019-03-07 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:197-200
-  if (S.isUnevaluatedContext()) {
-S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
-return false;
-  }

Does removing this check now mean that we're not checking that `co_return` 
statements don't appear in unevaluated contexts?

Or is that already handled elsewhere by the fact that `co_return` statements 
are not expressions and are therefore detected earlier as a grammar violation 
when parsing `sizeof()` expression?



Comment at: lib/Sema/SemaCoroutine.cpp:675
+  // Second emphasis of [expr.await]p2: must be outside of an exception 
handler.
+  if (S.getCurScope()->getFlags() & Scope::CatchScope) {
+S.Diag(Loc, diag::err_coroutine_within_handler) << Keyword;

modocache wrote:
> EricWF wrote:
> > We can still build a valid AST after encountering this error, no?
> > 
> > 
> I believe so. Just to be clear: you'd like me to continue building the AST 
> even after emitting this error diagnostic? My understanding is that most of 
> this file bails soon after any error is encountered (correct me if that's 
> wrong). I'm happy to change that, but I wonder if it'd be better to do that 
> in a separate diff...?
Do the scope flags reset when a lambda occurs within a catch-block?

eg. The following should still be valid.
```
try { ... }
catch (...) {
  []() -> task { co_await foo(); }();
}
```



Comment at: test/SemaCXX/coroutines.cpp:299-311
   // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
 co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
   }
   void operator=(CtorDtor const &) {
 co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
   }

Not related to this diff, but...

I don't think that these should be ill-formed.

According to N4775 there are only exclusions added for [class.ctor] and 
[class.dtor].
I can't see anything in the spec that says that assignment special member 
functions cannot be coroutines.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Kalle Huttunen via Phabricator via cfe-commits
kallehuttunen created this revision.
kallehuttunen added reviewers: alexfh, hokein, JonasToth, aaron.ballman.
kallehuttunen added a project: clang-tools-extra.
Herald added subscribers: jdoerfert, xazax.hun, mgorny.
Herald added a project: clang.

The checker detects comparison operators that don't access all fields of the 
compared types.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59103

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/IncompleteComparisonOperatorCheck.cpp
  clang-tidy/bugprone/IncompleteComparisonOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-incomplete-comparison-operator.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-incomplete-comparison-operator-custom.cpp
  test/clang-tidy/bugprone-incomplete-comparison-operator.cpp

Index: test/clang-tidy/bugprone-incomplete-comparison-operator.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-incomplete-comparison-operator.cpp
@@ -0,0 +1,280 @@
+// RUN: %check_clang_tidy %s bugprone-incomplete-comparison-operator %t
+
+struct Good {
+  int Member1;
+  int Member2;
+};
+
+bool operator==(const Good &Lhs, const Good &Rhs) {
+  return Lhs.Member1 == Rhs.Member1 && Lhs.Member2 == Rhs.Member2;
+}
+
+bool operator!=(const Good &Lhs, const Good &Rhs) {
+  return !(Lhs == Rhs);
+}
+
+bool operator<(const Good &Lhs, const Good &Rhs) {
+  if (Lhs.Member1 != Rhs.Member1)
+return Lhs.Member1 < Rhs.Member1;
+  return Lhs.Member2 < Rhs.Member2;
+}
+
+bool operator>(const Good &Lhs, const Good &Rhs) {
+  return Rhs < Lhs;
+}
+
+bool operator<=(const Good &Lhs, const Good &Rhs) {
+  return !(Rhs < Lhs);
+}
+
+bool operator>=(const Good &Lhs, const Good &Rhs) {
+  return !(Lhs < Rhs);
+}
+
+struct Bad {
+  int Member1;
+  int Member2;
+};
+
+bool operator==(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member2 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member2 not accessed
+  return Lhs.Member1 == Rhs.Member1;
+}
+
+bool operator!=(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member2 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member2 not accessed
+  return !(Lhs == Rhs);
+}
+
+bool operator<(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member1 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member1 not accessed
+  return Lhs.Member2 < Rhs.Member2;
+}
+
+bool operator>(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member1 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member1 not accessed
+  return Rhs < Lhs;
+}
+
+bool operator<=(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member1 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member1 not accessed
+  return !(Rhs < Lhs);
+}
+
+bool operator>=(const Bad &Lhs, const Bad &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.Member1 not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.Member1 not accessed
+  return !(Lhs < Rhs);
+}
+
+struct Ugly {
+  Good GoodParts;
+  Bad BadParts;
+};
+
+// Missing field access for only one of the params -> warning
+bool operator==(const Ugly &Lhs, const Ugly &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Rhs.BadParts not accessed
+  return Lhs.GoodParts == Rhs.GoodParts && Lhs.BadParts == Lhs.BadParts;
+}
+
+// Args are passed to a function in another TU -> no warning
+bool testForInequality(const Ugly &, const Ugly &);
+bool operator!=(const Ugly &Lhs, const Ugly &Rhs) {
+  return testForInequality(Lhs, Rhs);
+}
+
+// Fields are passed to a function in another TU, but some fields are not accessed -> warning
+bool compareGoodness(const Good &, const Good &);
+bool operator<(const Ugly &Lhs, const Ugly &Rhs) {
+  // CHECK-NOTES: [[@LINE-1]]:1: warning: incomplete comparison operator
+  // CHECK-NOTES: [[@LINE-2]]:1: note: Lhs.BadParts not accessed
+  // CHECK-NOTES: [[@LINE-3]]:1: note: Rhs.BadParts not accessed
+  return compareGoodness(Lhs.GoodParts, Rhs.GoodParts);
+}
+
+// Args are passed to recursive function -> no warning
+bool strangeLoop(const Ugly &U) { return strangeLoop(U); }
+bool operator>(const Ugly &Lhs, const Ugly &Rhs) {
+  return strangeLoop(Lhs);
+}
+
+class Encapsulated {
+public:
+  int get1() const { return Member1; }
+  int get2() const

[PATCH] D58530: Add PragmaHandler for MSVC pragma execution_character_set

2019-03-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks! Would you like someone to land this for you?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58530/new/

https://reviews.llvm.org/D58530



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for working on this!

This looks questionable to me.
Is this based on some coding standard?
Are there any numbers on the false-positive rate of theck?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


[PATCH] D58530: Add PragmaHandler for MSVC pragma execution_character_set

2019-03-07 Thread Matt Gardner via Phabricator via cfe-commits
sigatrev added a comment.

Yeah, that would be great. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58530/new/

https://reviews.llvm.org/D58530



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


r355624 - Delete x86_64 ShadowCallStack support

2019-03-07 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Thu Mar  7 10:56:36 2019
New Revision: 355624

URL: http://llvm.org/viewvc/llvm-project?rev=355624&view=rev
Log:
Delete x86_64 ShadowCallStack support

Summary:
ShadowCallStack on x86_64 suffered from the same racy security issues as
Return Flow Guard and had performance overhead as high as 13% depending
on the benchmark. x86_64 ShadowCallStack was always an experimental
feature and never shipped a runtime required to support it, as such
there are no expected downstream users.

Reviewers: pcc

Reviewed By: pcc

Subscribers: mgorny, javed.absar, hiraditya, jdoerfert, cfe-commits, 
#sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

Modified:
cfe/trunk/docs/ShadowCallStack.rst

Modified: cfe/trunk/docs/ShadowCallStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ShadowCallStack.rst?rev=355624&r1=355623&r2=355624&view=diff
==
--- cfe/trunk/docs/ShadowCallStack.rst (original)
+++ cfe/trunk/docs/ShadowCallStack.rst Thu Mar  7 10:56:36 2019
@@ -9,7 +9,7 @@ Introduction
 
 
 ShadowCallStack is an instrumentation pass, currently only implemented for
-aarch64 and x86_64, that protects programs against return address overwrites
+aarch64, that protects programs against return address overwrites
 (e.g. stack buffer overflows.) It works by saving a function's return address
 to a separately allocated 'shadow call stack' in the function prolog in
 non-leaf functions and loading the return address from the shadow call stack
@@ -18,11 +18,10 @@ for compatibility with unwinders, but is
 
 The aarch64 implementation is considered production ready, and
 an `implementation of the runtime`_ has been added to Android's libc
-(bionic). The x86_64 implementation was evaluated using Chromium and was
-found to have critical performance and security deficiencies, and may be
-removed in a future release of the compiler. This document only describes
-the aarch64 implementation; details on the x86_64 implementation are found
-in the `Clang 7.0.1 documentation`_.
+(bionic). An x86_64 implementation was evaluated using Chromium and was found
+to have critical performance and security deficiencies--it was removed in
+LLVM 9.0. Details on the x86_64 implementation can be found in the
+`Clang 7.0.1 documentation`_.
 
 .. _`implementation of the runtime`: 
https://android.googlesource.com/platform/bionic/+/808d176e7e0dd727c7f929622ec017f6e065c582/libc/bionic/pthread_create.cpp#128
 .. _`Clang 7.0.1 documentation`: 
https://releases.llvm.org/7.0.1/tools/clang/docs/ShadowCallStack.html
@@ -37,10 +36,9 @@ consuming more memory for shorter functi
 memory accesses.
 
 `Return Flow Guard`_ is a pure software implementation of shadow call stacks
-on x86_64. It is similar to the ShadowCallStack x86_64 implementation but
-trades off higher memory usage for a shorter prologue and epilogue. Like
-x86_64 ShadowCallStack, it is inherently racy due to the architecture's use
-of the stack for calls and returns.
+on x86_64. Like the previous implementation of ShadowCallStack on x86_64, it is
+inherently racy due to the architecture's use of the stack for calls and
+returns.
 
 Intel `Control-flow Enforcement Technology`_ (CET) is a proposed hardware
 extension that would add native support to use a shadow stack to store/check


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


[PATCH] D59034: Delete x86_64 ShadowCallStack support

2019-03-07 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT355624: Delete x86_64 ShadowCallStack support (authored by 
vlad.tsyrklevich, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59034?vs=189750&id=189756#toc

Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59034/new/

https://reviews.llvm.org/D59034

Files:
  cmake/config-ix.cmake
  test/shadowcallstack/libc_support.h
  test/shadowcallstack/lit.cfg
  test/shadowcallstack/minimal_runtime.h
  test/shadowcallstack/overflow-aarch64.c
  test/shadowcallstack/overflow-x86_64.c
  test/shadowcallstack/overflow.c

Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -254,7 +254,7 @@
 else()
 set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} powerpc64le)
 endif()
-set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${X86_64} ${ARM64})
+set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64})
 
 if(APPLE)
   include(CompilerRTDarwinUtils)
Index: test/shadowcallstack/minimal_runtime.h
===
--- test/shadowcallstack/minimal_runtime.h
+++ test/shadowcallstack/minimal_runtime.h
@@ -4,10 +4,6 @@
 
 #pragma once
 
-#ifdef __x86_64__
-#include 
-int arch_prctl(int code, void *addr);
-#endif
 #include 
 #include 
 #include 
@@ -21,10 +17,7 @@
   if (stack == MAP_FAILED)
 abort();
 
-#if defined(__x86_64__)
-  if (arch_prctl(ARCH_SET_GS, stack))
-abort();
-#elif defined(__aarch64__)
+#if defined(__aarch64__)
   __asm__ __volatile__("mov x18, %0" ::"r"(stack));
 #else
 #error Unsupported platform
Index: test/shadowcallstack/libc_support.h
===
--- test/shadowcallstack/libc_support.h
+++ test/shadowcallstack/libc_support.h
@@ -33,9 +33,5 @@
 }
 
 #else
-
-__attribute__((noinline)) void scs_fputs_stdout(const char *p) {
-  fputs(p, stdout);
-}
-
+#error Unsupported platform
 #endif
Index: test/shadowcallstack/lit.cfg
===
--- test/shadowcallstack/lit.cfg
+++ test/shadowcallstack/lit.cfg
@@ -19,5 +19,5 @@
   scs_arch_cflags += ' -ffixed-x18 '
 config.substitutions.append( ("%clang_scs ", config.clang + ' -O0 -fsanitize=shadow-call-stack ' + scs_arch_cflags + ' ') )
 
-if config.host_os not in ['Linux'] or config.target_arch not in ['x86_64', 'aarch64']:
+if config.host_os not in ['Linux'] or config.target_arch not in ['aarch64']:
config.unsupported = True
Index: test/shadowcallstack/overflow.c
===
--- test/shadowcallstack/overflow.c
+++ test/shadowcallstack/overflow.c
@@ -8,12 +8,10 @@
 // RUN: %clang_scs %s -o %t -DITERATIONS=3
 // RUN: %run %t | FileCheck %s
 
-// The behavioral check for SCS + overflow lives in the tests overflow-x86_64.c
-// and overflow-aarch64.c. This is because the expected behavior is different
-// between the two platforms. On x86_64 we crash because the comparison between
-// the shadow call stack and the regular stack fails. On aarch64 there is no
-// comparison, we just load the return address from the shadow call stack. So we
-// just expect not to see the output from print_and_exit.
+// On aarch64 we just load the return address from the shadow call stack so we
+// do not expect to see the output from print_and_exit.
+// RUN: %clang_scs %s -o %t -DITERATIONS=12
+// RUN: %run %t | FileCheck %S/overflow.c
 
 #include 
 #include 
Index: test/shadowcallstack/overflow-aarch64.c
===
--- test/shadowcallstack/overflow-aarch64.c
+++ test/shadowcallstack/overflow-aarch64.c
@@ -1,5 +0,0 @@
-// See overflow.c for a description.
-
-// REQUIRES: aarch64-target-arch
-// RUN: %clang_scs %S/overflow.c -o %t -DITERATIONS=12
-// RUN: %run %t | FileCheck %S/overflow.c
Index: test/shadowcallstack/overflow-x86_64.c
===
--- test/shadowcallstack/overflow-x86_64.c
+++ test/shadowcallstack/overflow-x86_64.c
@@ -1,5 +0,0 @@
-// See overflow.c for a description.
-
-// REQUIRES: x86_64-target-arch
-// RUN: %clang_scs %S/overflow.c -o %t -DITERATIONS=12
-// RUN: not --crash %run %t
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r355625 - Fix some clang analysis tests passing arguments incorrectly

2019-03-07 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Mar  7 10:57:04 2019
New Revision: 355625

URL: http://llvm.org/viewvc/llvm-project?rev=355625&view=rev
Log:
Fix some clang analysis tests passing arguments incorrectly

Modified:
cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Modified: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp?rev=355625&r1=355624&r2=355625&view=diff
==
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp (original)
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp Thu Mar  7 
10:57:04 2019
@@ -933,14 +933,14 @@ TEST(ExprMutationAnalyzerTest, CommaExpr
   auto AST = buildASTFromCodeWithArgs(
   "template  struct S;"
   "template  void f() { S s; int x, y; s.mf((y, x)); }",
-  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  {"-fno-delayed-template-parsing", "-Wno-unused-value"});
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_TRUE(isMutated(Results, AST.get()));
 
   AST = buildASTFromCodeWithArgs(
   "template  void f(T t) { int x, y; g(t, (y, x)); }",
-  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  {"-fno-delayed-template-parsing", "-Wno-unused-value"});
   Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_TRUE(isMutated(Results, AST.get()));
 }
@@ -1006,7 +1006,7 @@ TEST(ExprMutationAnalyzerTest, CommaExpr
   UniquePtrDef + "template  void f() "
  "{ UniquePtr x; UniquePtr y;"
  " (y, x)->mf(); }",
-  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  {"-fno-delayed-template-parsing", "-Wno-unused-value"});
   const auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_TRUE(isMutated(Results, AST.get()));


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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Kalle Huttunen via Phabricator via cfe-commits
kallehuttunen added a comment.

The checker gives quite many warnings on LLVM code base. For example, running 
it for lib/Transforms/Scalar:

  /home/kalle/llvm/lib/Transforms/Scalar/GVN.cpp:119:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
bool operator==(const Expression &other) const {
^
  /home/kalle/llvm/lib/Transforms/Scalar/GVN.cpp:119:3: note: commutative not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVN.cpp:119:3: note: other.commutative 
not accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:151:3: warning: 
incomplete comparison operator [bugprone-incomplete-comparison-operator]
bool operator==(const CHIArg &A) { return VN == A.VN; }
^
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:151:3: note: Dest not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:151:3: note: I not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:151:3: note: A.Dest not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:151:3: note: A.I not 
accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:152:3: warning: 
incomplete comparison operator [bugprone-incomplete-comparison-operator]
bool operator!=(const CHIArg &A) { return !(*this == A); }
^
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:152:3: note: Dest not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:152:3: note: I not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:152:3: note: A.Dest not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNHoist.cpp:152:3: note: A.I not 
accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
bool operator>(const SinkingInstructionCandidate &Other) const {
^
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: NumBlocks not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: 
NumInstructions not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: NumPHIs not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: 
NumMemoryInsts not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: Blocks not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: 
Other.NumBlocks not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: 
Other.NumInstructions not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: Other.NumPHIs 
not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: 
Other.NumMemoryInsts not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/GVNSink.cpp:211:3: note: Other.Blocks 
not accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/MergeICmps.cpp:90:3: warning: 
incomplete comparison operator [bugprone-incomplete-comparison-operator]
bool operator<(const BCEAtom &O) const {
^
  /home/kalle/llvm/lib/Transforms/Scalar/MergeICmps.cpp:90:3: note: GEP not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/MergeICmps.cpp:90:3: note: LoadI not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/MergeICmps.cpp:90:3: note: O.GEP not 
accessed
  /home/kalle/llvm/lib/Transforms/Scalar/MergeICmps.cpp:90:3: note: O.LoadI not 
accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/NewGVN.cpp:436:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
bool operator==(const Expression &Other) const {
^
  /home/kalle/llvm/lib/Transforms/Scalar/NewGVN.cpp:436:3: note: Other.Opcode 
not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/NewGVN.cpp:436:3: note: Other.HashVal 
not accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:206:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
friend LLVM_ATTRIBUTE_UNUSED bool operator<(const Slice &LHS,
^
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:206:3: note: LHS.EndOffset 
not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:206:3: note: 
LHS.UseAndIsSplittable not accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:210:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
friend LLVM_ATTRIBUTE_UNUSED bool operator<(uint64_t LHSOffset,
^
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:210:3: note: RHS.EndOffset 
not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:210:3: note: 
RHS.UseAndIsSplittable not accessed
  
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:582:3: warning: incomplete 
comparison operator [bugprone-incomplete-comparison-operator]
bool operator==(const partition_iterator &RHS) const {
^
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:582:3: note: 
MaxSplitSliceEndOffset not accessed
  /home/kalle/llvm/lib/Transforms/Scalar/SROA.cpp:582:3: note: 
RHS.MaxSplitSliceEndOffset not accessed

Running the checker on 100k SLOC p

[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Kalle Huttunen via Phabricator via cfe-commits
kallehuttunen added a comment.

In D59103#1421875 , @lebedev.ri wrote:

> Thank you for working on this!
>
> This looks questionable to me.
>  Is this based on some coding standard?
>  Are there any numbers on the false-positive rate of theck?


It's not based on any coding standard, but is rather an attempt to eliminate 
one class of bugs (forgetting to update comparison operator when adding struct 
members) that I've encountered several times.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/bugprone/IncompleteComparisonOperatorCheck.cpp:242-243
+diag(Operator->getBeginLoc(), "incomplete comparison operator");
+Lhs->diagFields(*this, Operator->getBeginLoc());
+Rhs->diagFields(*this, Operator->getBeginLoc());
+  }

These should point to the actual field decl location in the class


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


r355627 - Recommit "Support attribute used in member funcs of class templates"

2019-03-07 Thread Rafael Auler via cfe-commits
Author: rafauler
Date: Thu Mar  7 11:14:30 2019
New Revision: 355627

URL: http://llvm.org/viewvc/llvm-project?rev=355627&view=rev
Log:
Recommit "Support attribute used in member funcs of class templates"

The patch originally broke code that was incompatible with GCC, but
we want to follow GCC behavior here according to the discussion in
https://reviews.llvm.org/D58216

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

Added:

cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=355627&r1=355626&r2=355627&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Mar  7 11:14:30 2019
@@ -2232,6 +2232,20 @@ TemplateDeclInstantiator::VisitCXXMethod
 Owner->addDecl(Method);
   }
 
+  // PR17480: Honor the used attribute to instantiate member function
+  // definitions
+  if (Method->hasAttr()) {
+if (const auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;
+  if (const MemberSpecializationInfo *MSInfo =
+  A->getMemberSpecializationInfo())
+Loc = MSInfo->getPointOfInstantiation();
+  else if (const auto *Spec = dyn_cast(A))
+Loc = Spec->getPointOfInstantiation();
+  SemaRef.MarkFunctionReferenced(Loc, Method);
+}
+  }
+
   return Method;
 }
 

Added: 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp?rev=355627&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
(added)
+++ 
cfe/trunk/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp 
Thu Mar  7 11:14:30 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
+// classes
+namespace InstantiateUsedMemberDefinition {
+template 
+struct S {
+  int __attribute__((used)) f() {
+return 0;
+  }
+};
+
+void test() {
+  // Check that InstantiateUsedMemberDefinition::S::f() is defined
+  // as a result of the S class template implicit instantiation
+  // CHECK: define linkonce_odr i32 
@_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
+  S inst;
+}
+} // namespace InstantiateUsedMemberDefinition


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


[PATCH] D59094: [ARM] Fix bug 39982 - pcs("aapcs-vfp") is not consistent

2019-03-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It looks like every call to getABIKind() is doing the wrong thing; I'm worried 
that's going to lead to some sort of subtle miscompile without some sort of 
centralized fix to compute the correct calling convention for every place that 
checks it.  Not sure how to write a testcase off the top of my head... have you 
tried homogeneous aggregates with more than two elements?




Comment at: clang/test/CodeGenCXX/arm-pcs.cpp:4
+
+// RUN: %clang -mfloat-abi=hard --target=armv7-unknown-linux-gnueabi -O3 -S -o 
- %s | FileCheck %s -check-prefixes=HARD_INSTRs,CHECK
+// RUN: %clang -mfloat-abi=softfp --target=armv7-unknown-linux-gnueabi -O3 -S 
-o - %s | FileCheck %s -check-prefixes=HARD_INSTRs,CHECK

This test needs "// REQUIRES: arm-registered-target" so it's automatically 
disabled if the ARM target isn't available.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59094/new/

https://reviews.llvm.org/D59094



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I definately been burnt by not handling all the cases, but imagine a string 
class

class mystring
{

  const char *ptr;
  int size;
  int numallocated;

}

to compare the strings I wouldn't want to compare all the fields?

I think this could lead to a lot of false positives


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

2019-03-07 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:197-200
-  if (S.isUnevaluatedContext()) {
-S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
-return false;
-  }

lewissbaker wrote:
> Does removing this check now mean that we're not checking that `co_return` 
> statements don't appear in unevaluated contexts?
> 
> Or is that already handled elsewhere by the fact that `co_return` statements 
> are not expressions and are therefore detected earlier as a grammar violation 
> when parsing `sizeof()` expression?
That's right! If one were to attempt to use a `co_return` within a 
subexpression of `sizeof`, they'd see `error: expected expression` before 
they'd ever have seen this error message. So I believe there's no need to 
perform this check for `co_return`, and I believe that's why the revisions to 
the standard included in the Coroutines TS don't make any special mention of 
disallowing `co_return` in those contexts.



Comment at: lib/Sema/SemaCoroutine.cpp:675
+  // Second emphasis of [expr.await]p2: must be outside of an exception 
handler.
+  if (S.getCurScope()->getFlags() & Scope::CatchScope) {
+S.Diag(Loc, diag::err_coroutine_within_handler) << Keyword;

lewissbaker wrote:
> modocache wrote:
> > EricWF wrote:
> > > We can still build a valid AST after encountering this error, no?
> > > 
> > > 
> > I believe so. Just to be clear: you'd like me to continue building the AST 
> > even after emitting this error diagnostic? My understanding is that most of 
> > this file bails soon after any error is encountered (correct me if that's 
> > wrong). I'm happy to change that, but I wonder if it'd be better to do that 
> > in a separate diff...?
> Do the scope flags reset when a lambda occurs within a catch-block?
> 
> eg. The following should still be valid.
> ```
> try { ... }
> catch (...) {
>   []() -> task { co_await foo(); }();
> }
> ```
I believe they're reset, the example you posted compiles fine with this patch. 
I'll add a test case specifically for this and confirm exactly where the scope 
flags are reset or ignored in the lambda case.



Comment at: test/SemaCXX/coroutines.cpp:299-311
   // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
 co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
   }
   void operator=(CtorDtor const &) {
 co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
   }

lewissbaker wrote:
> Not related to this diff, but...
> 
> I don't think that these should be ill-formed.
> 
> According to N4775 there are only exclusions added for [class.ctor] and 
> [class.dtor].
> I can't see anything in the spec that says that assignment special member 
> functions cannot be coroutines.
That's a great point. Could you create a Bugzilla for this work? And maybe we 
can get @GorNishanov's opinion?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@lebedev.ri @kallehuttunen what do you think of putting this into context of 
the proposal (i believe its being standardized with c++20) of `operator==() = 
default` and the spaceship-operator.
This check could serve as a basis to modernize the `operator==` to the default 
if appropriate and warn/diagnose in the other cases.
WDYT?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

2019-03-07 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 189763.
modocache added a comment.

Add test case for executing a lambda using co_yield within a catch block.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Scope.h
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -328,6 +328,34 @@
 // not allowed. A user may not understand that this is "outside a function."
 void default_argument(int arg = co_await 0) {} // expected-error {{'co_await' cannot be used outside a function}}
 
+void await_in_catch_coroutine() {
+  try {
+  } catch (...) {
+co_await a; // expected-error {{'co_await' cannot be used in the handler of a try block}}
+  }
+}
+
+void await_in_lambda_in_catch_coroutine() {
+  try {
+  } catch (...) {
+[]() -> void { co_await a; }(); // OK
+  }
+}
+
+void yield_in_catch_coroutine() {
+  try {
+  } catch (...) {
+co_yield a; // expected-error {{'co_yield' cannot be used in the handler of a try block}}
+  }
+}
+
+void return_in_catch_coroutine() {
+  try {
+  } catch (...) {
+co_return 123; // OK
+  }
+}
+
 constexpr auto constexpr_deduced_return_coroutine() {
   co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
   // expected-error@-1 {{'co_yield' cannot be used in a function with a deduced return type}}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -185,21 +185,8 @@
 
 static bool isValidCoroutineContext(Sema &S, SourceLocation Loc,
 StringRef Keyword) {
-  // 'co_await' and 'co_yield' are not permitted in unevaluated operands,
-  // such as subexpressions of \c sizeof.
-  //
-  // [expr.await]p2, emphasis added: "An await-expression shall appear only in
-  // a *potentially evaluated* expression within the compound-statement of a
-  // function-body outside of a handler [...] A context within a function where
-  // an await-expression can appear is called a suspension context of the
-  // function." And per [expr.yield]p1: "A yield-expression shall appear only
-  // within a suspension context of a function."
-  if (S.isUnevaluatedContext()) {
-S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
-return false;
-  }
-
-  // Per [expr.await]p2, any other usage must be within a function.
+  // [expr.await]p2 dictates that 'co_await' and 'co_yield' must be used within
+  // a function body.
   // FIXME: This also covers [expr.await]p2: "An await-expression shall not
   // appear in a default argument." But the diagnostic QoI here could be
   // improved to inform the user that default arguments specifically are not
@@ -668,8 +655,34 @@
   return true;
 }
 
+// [expr.await]p2, emphasis added: "An await-expression shall appear only in
+// a *potentially evaluated* expression within the compound-statement of a
+// function-body *outside of a handler* [...] A context within a function
+// where an await-expression can appear is called a suspension context of the
+// function."
+static bool isValidSuspensionContext(Sema &S, SourceLocation Loc,
+ StringRef Keyword,
+ bool IsImplicit = false) {
+  // First emphasis of [expr.await]p2: must be a potentially evaluated context.
+  // That is, 'co_await' and 'co_yield' cannot appear in subexpressions of
+  // \c sizeof.
+  if (S.isUnevaluatedContext()) {
+S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
+return false;
+  }
+
+  // Second emphasis of [expr.await]p2: must be outside of an exception handler.
+  if (S.getCurScope()->getFlags() & Scope::CatchScope) {
+S.Diag(Loc, diag::err_coroutine_within_handler) << Keyword;
+return false;
+  }
+
+  return true;
+}
+
 ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) {
-  if (!ActOnCoroutineBodyStart(S, Loc, "co_await")) {
+  if (!ActOnCoroutineBodyStart(S, Loc, "co_await") ||
+  !isValidSuspensionContext(*this, Loc, "co_await")) {
 CorrectDelayedTyposInExpr(E);
 return ExprError();
   }
@@ -689,7 +702,7 @@
 ExprResult Sema::BuildUnresolvedCoawaitExpr(SourceLocation Loc, Expr *E,
 UnresolvedLookupExpr *Lookup) {
   auto *FSI = checkCoroutineContext(*this, Loc, "co_await");
-  if (!FSI)
+  if (!FSI || !isValidSuspensionContext(*this, Loc, "co_await"))
 return ExprError();
 
   if (E->getType()->isPlaceholderType()) {
@@ -766,7 +779,8 @@
 }
 
 ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) {
-  if (!ActOnCoroutineBodyStart(S, Loc, "co_yield")) {
+  

[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

2019-03-07 Thread Brian Gesiak via Phabricator via cfe-commits
modocache marked an inline comment as done.
modocache added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:675
+  // Second emphasis of [expr.await]p2: must be outside of an exception 
handler.
+  if (S.getCurScope()->getFlags() & Scope::CatchScope) {
+S.Diag(Loc, diag::err_coroutine_within_handler) << Keyword;

modocache wrote:
> lewissbaker wrote:
> > modocache wrote:
> > > EricWF wrote:
> > > > We can still build a valid AST after encountering this error, no?
> > > > 
> > > > 
> > > I believe so. Just to be clear: you'd like me to continue building the 
> > > AST even after emitting this error diagnostic? My understanding is that 
> > > most of this file bails soon after any error is encountered (correct me 
> > > if that's wrong). I'm happy to change that, but I wonder if it'd be 
> > > better to do that in a separate diff...?
> > Do the scope flags reset when a lambda occurs within a catch-block?
> > 
> > eg. The following should still be valid.
> > ```
> > try { ... }
> > catch (...) {
> >   []() -> task { co_await foo(); }();
> > }
> > ```
> I believe they're reset, the example you posted compiles fine with this 
> patch. I'll add a test case specifically for this and confirm exactly where 
> the scope flags are reset or ignored in the lambda case.
When the parser encounters a lambda, it takes the path 
`Parser::ParseLambdaExpression -> Parser::ParseLambdaExpressionAfterIntroducer 
-> Parser::ParseCompoundStatementBody`, which creates an inner scope for the 
body of the lambda. This inner scope does not have the `Scope::CatchScope` 
flag, so it doesn't result in the error.

Although, your question did make me realize that this compiles just fine, even 
with this patch:

```
void example() {
  try {
throw;
  } catch (...) {
try {
  co_await a;
}
  }
}
```

But I believe this above case should also be treated as an error, right?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076



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


[PATCH] D59103: [clang-tidy] New checker bugprone-incomplete-comparison-operator

2019-03-07 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/bugprone/IncompleteComparisonOperatorCheck.cpp:197
+
+  const auto Ops = utils::options::parseStringList(CheckedFunctions);
+  Finder->addMatcher(

Please don't use auto where return type is not obvious.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59103/new/

https://reviews.llvm.org/D59103



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


[PATCH] D58530: Add PragmaHandler for MSVC pragma execution_character_set

2019-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Does our serialization machinery serialize these correctly automatically? What 
happens if you compiler a header saying `execution_character_set_push, 
"utf-8")` in a header, compile that to a pch, then include that through the pch 
in a .c file that does pop?

My guess is that this either needs (de)serialization code or a warning when the 
stack is not empty when a pch is written.

(Examples: https://reviews.llvm.org/rL262493 https://reviews.llvm.org/rL262539 
-- the latter one is probably a better example)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58530/new/

https://reviews.llvm.org/D58530



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


  1   2   >