[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

2019-08-22 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

This test case has never passed for me with `check-clang`, is there something 
environment related that is needed with this or are others experiencing this 
too?

  [147/148] Running the Clang regression tests
  llvm-lit: 
/home/nathan/cbl/git/tc-build/llvm-project/llvm/utils/lit/lit/llvm/config.py:340:
 note: using clang: /home/nathan/cbl/git/tc-build/build/llvm/stage1/bin/clang
  FAIL: Clang :: Driver/check-time-trace-sections.cpp (4955 of 15278)
   TEST 'Clang :: Driver/check-time-trace-sections.cpp' 
FAILED 
  Script:
  --
  : 'RUN: at line 2';   
/home/nathan/cbl/git/tc-build/build/llvm/stage1/bin/clang --driver-mode=g++ -S 
-ftime-trace -ftime-trace-granularity=0 -o 
/home/nathan/cbl/git/tc-build/build/llvm/stage1/tools/clang/test/Driver/Output/check-time-trace-sections
 
/home/nathan/cbl/git/tc-build/llvm-project/clang/test/Driver/check-time-trace-sections.cpp
  : 'RUN: at line 3';   cat 
/home/nathan/cbl/git/tc-build/build/llvm/stage1/tools/clang/test/Driver/Output/check-time-trace-sections.json
 | "/usr/bin/python" 
/home/nathan/cbl/git/tc-build/llvm-project/clang/test/Driver/check-time-trace-sections.py
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  Time trace json-file dumped to 
/home/nathan/cbl/git/tc-build/build/llvm/stage1/tools/clang/test/Driver/Output/check-time-trace-sections.json
  Use chrome://tracing or Speedscope App (https://www.speedscope.app) for 
flamegraph visualization
  Not all CodeGen sections are inside any Frontend section!
  
  --
  
  
  Testing Time: 38.46s
  
  Failing Tests (1):
  Clang :: Driver/check-time-trace-sections.cpp
  
Expected Passes: 14008
Expected Failures  : 15
Unsupported Tests  : 1254
Unexpected Failures: 1
  FAILED: tools/clang/test/CMakeFiles/check-clang 

This is on bdceb9fb14595d10f7d94e1dd950cf2d94d2f2d3 
 using 
this script 's command: 
`./build-llvm.py --build-stage1-only --check-targets clang --projects clang 
--targets X86`


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63325



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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Jian Cai via Phabricator via cfe-commits
jcai19 marked 7 inline comments as done.
jcai19 added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp:2
+//===--- PthreadReturnCheck.cpp - 
clang-tidy---===//
+//clang-tidy-===//
+//

Eugene.Zelenko wrote:
> Please remove this line.
Good catch! Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627



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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 216768.
jcai19 added a comment.

Fix typos.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pthread-return.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
@@ -0,0 +1,187 @@
+// RUN: %check_clang_tidy %s bugprone-pthread-return %t
+
+#define NULL nullptr
+#define ZERO 0
+#define NEGATIVE_ONE -1
+
+typedef decltype(sizeof(int)) size_t;
+# define __CPU_SETSIZE 1024
+# define __NCPUBITS (8 * sizeof (__cpu_mask))
+typedef unsigned long int __cpu_mask;
+typedef struct
+{
+  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+typedef int clockid_t;
+# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
+typedef struct
+{
+  unsigned long int __val[_SIGSET_NWORDS];
+} sigset_t;
+typedef struct _opaque_pthread_t *__darwin_pthread_t;
+typedef __darwin_pthread_t pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
+typedef struct pthread_mutex_t_ * pthread_mutex_t;
+typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
+typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
+typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
+
+
+extern "C" void pthread_cleanup_push(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop(int execute);
+extern "C" void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop_restore_np(int execute);
+extern "C" void pthread_exit(void *retval);
+extern "C" void pthread_kill_other_threads_np(void);
+extern "C" void pthread_testcancel(void);
+
+extern "C" pthread_t pthread_self(void);
+
+extern "C" int pthread_attr_init(pthread_attr_t *attr);
+extern "C" int pthread_attr_destroy(pthread_attr_t *attr);
+extern "C" int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
+extern "C" int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
+extern "C" int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
+extern "C" int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize);
+extern "C" int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
+extern "C" int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched);
+extern "C" int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
+extern "C" int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
+extern "C" int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
+extern "C" int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
+extern "C" int pthread_attr_setscope(pthread_attr_t *attr, int scope);
+extern "C" int pthread_attr_getscope(const pthread_attr_t *attr, int *scope);
+extern "C" int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
+extern "C" int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize);
+extern "C" int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
+extern "C" int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr);
+extern "C" int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
+extern "C" int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
+extern "C" int pthread_cancel(pthread_t thread);
+extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+extern "C" int pthread_detach(pthread_t thread);
+extern "C" int pthread_equal(pthread_t t1, pthread_t t2);
+extern "C" int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_getattr_default_np(pthread_attr_t *attr);
+extern "C" int pthread_setattr_default_np(pthread_attr_t *attr);
+extern "C" int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr);
+extern "C" int pthread_setconcurrency(int new_level);
+extern "C" int 

[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp:1
+//===--- PthreadReturnCheck.cpp - 
clang-tidy---===//
+//clang-tidy-===//

Please put space after clang-tidy. Same in header.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp:2
+//===--- PthreadReturnCheck.cpp - 
clang-tidy---===//
+//clang-tidy-===//
+//

Please remove this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369732: [clang-format] Recognize ECMAScript module .mjs as 
JavaScript (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66584?vs=216588=216766#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66584

Files:
  cfe/trunk/lib/Format/Format.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -2411,8 +2411,9 @@
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
 return FormatStyle::LK_Java;
-  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts"))
-return FormatStyle::LK_JavaScript; // JavaScript or TypeScript.
+  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".mjs") ||
+  FileName.endswith_lower(".ts"))
+return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
   if (FileName.endswith(".m") || FileName.endswith(".mm"))
 return FormatStyle::LK_ObjC;
   if (FileName.endswith_lower(".proto") ||


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -2411,8 +2411,9 @@
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
 return FormatStyle::LK_Java;
-  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts"))
-return FormatStyle::LK_JavaScript; // JavaScript or TypeScript.
+  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".mjs") ||
+  FileName.endswith_lower(".ts"))
+return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
   if (FileName.endswith(".m") || FileName.endswith(".mm"))
 return FormatStyle::LK_ObjC;
   if (FileName.endswith_lower(".proto") ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369732 - [clang-format] Recognize ECMAScript module .mjs as JavaScript

2019-08-22 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Aug 22 21:46:01 2019
New Revision: 369732

URL: http://llvm.org/viewvc/llvm-project?rev=369732=rev
Log:
[clang-format] Recognize ECMAScript module .mjs as JavaScript

PR43085.

Recognize .mjs files as JavaScript. .mjs is the extension for ECMAScript 
modules.
A specific extension (and associated content type javascript/esm) is
introduced to differentiate it from CommonJS modules and solve some
interoperability problems.

Differential Revision: https://reviews.llvm.org/D66584
Patch by Fergal Daly

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=369732=369731=369732=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Aug 22 21:46:01 2019
@@ -2411,8 +2411,9 @@ const char *StyleOptionHelpDescription =
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
 return FormatStyle::LK_Java;
-  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts"))
-return FormatStyle::LK_JavaScript; // JavaScript or TypeScript.
+  if (FileName.endswith_lower(".js") || FileName.endswith_lower(".mjs") ||
+  FileName.endswith_lower(".ts"))
+return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
   if (FileName.endswith(".m") || FileName.endswith(".mm"))
 return FormatStyle::LK_ObjC;
   if (FileName.endswith_lower(".proto") ||


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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fergal Daly via Phabricator via cfe-commits
fergald added a comment.

Thanks, I'm happy with that description


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 216765.
jcai19 added a comment.

Fix format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pthread-return.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
@@ -0,0 +1,187 @@
+// RUN: %check_clang_tidy %s bugprone-pthread-return %t
+
+#define NULL nullptr
+#define ZERO 0
+#define NEGATIVE_ONE -1
+
+typedef decltype(sizeof(int)) size_t;
+# define __CPU_SETSIZE 1024
+# define __NCPUBITS (8 * sizeof (__cpu_mask))
+typedef unsigned long int __cpu_mask;
+typedef struct
+{
+  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+typedef int clockid_t;
+# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
+typedef struct
+{
+  unsigned long int __val[_SIGSET_NWORDS];
+} sigset_t;
+typedef struct _opaque_pthread_t *__darwin_pthread_t;
+typedef __darwin_pthread_t pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
+typedef struct pthread_mutex_t_ * pthread_mutex_t;
+typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
+typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
+typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
+
+
+extern "C" void pthread_cleanup_push(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop(int execute);
+extern "C" void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop_restore_np(int execute);
+extern "C" void pthread_exit(void *retval);
+extern "C" void pthread_kill_other_threads_np(void);
+extern "C" void pthread_testcancel(void);
+
+extern "C" pthread_t pthread_self(void);
+
+extern "C" int pthread_attr_init(pthread_attr_t *attr);
+extern "C" int pthread_attr_destroy(pthread_attr_t *attr);
+extern "C" int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
+extern "C" int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
+extern "C" int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
+extern "C" int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize);
+extern "C" int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
+extern "C" int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched);
+extern "C" int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
+extern "C" int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
+extern "C" int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
+extern "C" int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
+extern "C" int pthread_attr_setscope(pthread_attr_t *attr, int scope);
+extern "C" int pthread_attr_getscope(const pthread_attr_t *attr, int *scope);
+extern "C" int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
+extern "C" int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize);
+extern "C" int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
+extern "C" int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr);
+extern "C" int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
+extern "C" int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
+extern "C" int pthread_cancel(pthread_t thread);
+extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+extern "C" int pthread_detach(pthread_t thread);
+extern "C" int pthread_equal(pthread_t t1, pthread_t t2);
+extern "C" int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_getattr_default_np(pthread_attr_t *attr);
+extern "C" int pthread_setattr_default_np(pthread_attr_t *attr);
+extern "C" int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr);
+extern "C" int pthread_setconcurrency(int new_level);
+extern "C" int 

[PATCH] D66593: [analyzer] CastValueChecker: Fix some assertions

2019-08-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso abandoned this revision.
Charusso marked 4 inline comments as done.
Charusso added a comment.

Wow, it is great you could address every of the edge cases. Thanks you so much! 
I believe only one problem left: we need to `return false` instead of plain 
`return` in order to let the Analyzer model the function call. I could fix it 
easily, thanks!


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

https://reviews.llvm.org/D66593



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


[PATCH] D66593: [analyzer] CastValueChecker: Fix some assertions

2019-08-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Pushed my own emergency hotfixes as rC369726 
, rC369727 
, rC369728 
, rC369729 
; reduced tests included.


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

https://reviews.llvm.org/D66593



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


r369729 - [analyzer] CastValueChecker: Correctly model results of based-to-derived casts.

2019-08-22 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Aug 22 20:24:04 2019
New Revision: 369729

URL: http://llvm.org/viewvc/llvm-project?rev=369729=rev
Log:
[analyzer] CastValueChecker: Correctly model results of based-to-derived casts.

Our SVal hierarchy doesn't allow modeling pointer casts as no-op. The
pointer type is instead encoded into the pointer object. Defer to our
usual pointer casting facility, SValBuilder::evalBinOp().

Fixes a crash.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
cfe/trunk/test/Analysis/cast-value-logic.cpp
cfe/trunk/test/Analysis/cast-value-notes.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp?rev=369729=369728=369729=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp Thu Aug 22 
20:24:04 2019
@@ -138,6 +138,20 @@ static const NoteTag *getNoteTag(Checker
 // Main logic to evaluate a cast.
 
//===--===//
 
+static QualType alignReferenceTypes(QualType toAlign, QualType alignTowards,
+ASTContext ) {
+  if (alignTowards->isLValueReferenceType() &&
+  alignTowards.isConstQualified()) {
+toAlign.addConst();
+return ACtx.getLValueReferenceType(toAlign);
+  } else if (alignTowards->isLValueReferenceType())
+return ACtx.getLValueReferenceType(toAlign);
+  else if (alignTowards->isRValueReferenceType())
+return ACtx.getRValueReferenceType(toAlign);
+
+  llvm_unreachable("Must align towards a reference type!");
+}
+
 static void addCastTransition(const CallEvent , DefinedOrUnknownSVal DV,
   CheckerContext , bool IsNonNullParam,
   bool IsNonNullReturn,
@@ -156,6 +170,15 @@ static void addCastTransition(const Call
   } else {
 Object = cast()->getCXXThisExpr();
 CastFromTy = Object->getType();
+if (CastToTy->isPointerType()) {
+  if (!CastFromTy->isPointerType())
+return;
+} else {
+  if (!CastFromTy->isReferenceType())
+return;
+
+  CastFromTy = alignReferenceTypes(CastFromTy, CastToTy, 
C.getASTContext());
+}
   }
 
   const MemRegion *MR = DV.getAsRegion();
@@ -183,7 +206,8 @@ static void addCastTransition(const Call
 State = setDynamicTypeAndCastInfo(State, MR, CastFromTy, CastToTy,
   CastSucceeds);
 
-  SVal V = CastSucceeds ? DV : C.getSValBuilder().makeNull();
+  SVal V = CastSucceeds ? C.getSValBuilder().evalCast(DV, CastToTy, CastFromTy)
+: C.getSValBuilder().makeNull();
   C.addTransition(
   State->BindExpr(Call.getOriginExpr(), C.getLocationContext(), V, false),
   getNoteTag(C, CastInfo, CastToTy, Object, CastSucceeds, IsKnownCast));
@@ -198,14 +222,8 @@ static void addInstanceOfTransition(cons
   QualType CastToTy = FD->getTemplateSpecializationArgs()->get(0).getAsType();
   if (CastFromTy->isPointerType())
 CastToTy = C.getASTContext().getPointerType(CastToTy);
-  else if (CastFromTy->isLValueReferenceType() &&
-   CastFromTy.isConstQualified()) {
-CastToTy.addConst();
-CastToTy = C.getASTContext().getLValueReferenceType(CastToTy);
-  } else if (CastFromTy->isLValueReferenceType())
-CastToTy = C.getASTContext().getLValueReferenceType(CastToTy);
-  else if (CastFromTy->isRValueReferenceType())
-CastToTy = C.getASTContext().getRValueReferenceType(CastToTy);
+  else if (CastFromTy->isReferenceType())
+CastToTy = alignReferenceTypes(CastToTy, CastFromTy, C.getASTContext());
   else
 return;
 

Modified: cfe/trunk/test/Analysis/cast-value-logic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-logic.cpp?rev=369729=369728=369729=diff
==
--- cfe/trunk/test/Analysis/cast-value-logic.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-logic.cpp Thu Aug 22 20:24:04 2019
@@ -19,7 +19,11 @@ struct Shape {
   virtual double area();
 };
 class Triangle : public Shape {};
-class Circle : public Shape {};
+class Circle : public Shape {
+public:
+  ~Circle();
+};
+class SuspiciouslySpecificCircle : public Circle {};
 } // namespace clang
 
 using namespace llvm;
@@ -149,4 +153,10 @@ double test_virtual_method_after_call(Sh
 return S->area();
   return S->area() / 2;
 }
+
+void test_delete_crash() {
+  extern Circle *makeCircle();
+  Shape *S = makeCircle();
+  delete cast(S);
+}
 } // namespace crashes

Modified: cfe/trunk/test/Analysis/cast-value-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-notes.cpp?rev=369729=369728=369729=diff

r369726 - [analyzer] DynamicTypeInfo: Avoid putting null regions into dynamic typemap.

2019-08-22 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Aug 22 20:23:55 2019
New Revision: 369726

URL: http://llvm.org/viewvc/llvm-project?rev=369726=rev
Log:
[analyzer] DynamicTypeInfo: Avoid putting null regions into dynamic typemap.

Fixes a crash.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp
cfe/trunk/test/Analysis/cast-value-logic.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp?rev=369726=369725=369726=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp Thu Aug 22 20:23:55 2019
@@ -93,6 +93,9 @@ ProgramStateRef setDynamicTypeAndCastInf
   QualType CastFromTy,
   QualType CastToTy, QualType ResultTy,
   bool CastSucceeds) {
+  if (!MR)
+return State;
+
   if (CastSucceeds)
 State = State->set(MR, ResultTy);
 

Modified: cfe/trunk/test/Analysis/cast-value-logic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-logic.cpp?rev=369726=369725=369726=diff
==
--- cfe/trunk/test/Analysis/cast-value-logic.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-logic.cpp Thu Aug 22 20:23:55 2019
@@ -131,3 +131,8 @@ void evalLogic(const Shape *S) {
 }
 } // namespace test_get_as
 
+namespace crashes {
+void test_non_reference_null_region_crash(Shape s) {
+  cast(s); // no-crash
+}
+} // namespace crashes


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


r369727 - [analyzer] CastValueChecker: Avoid modeling casts between objects.

2019-08-22 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Aug 22 20:23:58 2019
New Revision: 369727

URL: http://llvm.org/viewvc/llvm-project?rev=369727=rev
Log:
[analyzer] CastValueChecker: Avoid modeling casts between objects.

Our method only works correctly when casting a pointer to a pointer
or a reference to a reference.

Fixes a crash.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
cfe/trunk/test/Analysis/Inputs/llvm.h
cfe/trunk/test/Analysis/cast-value-logic.cpp
cfe/trunk/test/Analysis/cast-value-notes.cpp
cfe/trunk/test/Analysis/cast-value-state-dump.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp?rev=369727=369726=369727=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp Thu Aug 22 
20:23:58 2019
@@ -382,8 +382,13 @@ bool CastValueChecker::evalCall(const Ca
 
   switch (Kind) {
   case CallKind::Function: {
-// We need to obtain the record type of the call's parameter to model it.
-if (!getRecordType(Call.parameters()[0]->getType())->isRecordType())
+// We only model casts from pointers to pointers or from references
+// to references. Other casts are most likely specialized and we
+// cannot model them.
+QualType ParamT = Call.parameters()[0]->getType();
+QualType ResultT = Call.getResultType();
+if (!(ParamT->isPointerType() && ResultT->isPointerType()) &&
+!(ParamT->isReferenceType() && ResultT->isReferenceType()))
   return false;
 
 DV = Call.getArgSVal(0).getAs();

Modified: cfe/trunk/test/Analysis/Inputs/llvm.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/llvm.h?rev=369727=369726=369727=diff
==
--- cfe/trunk/test/Analysis/Inputs/llvm.h (original)
+++ cfe/trunk/test/Analysis/Inputs/llvm.h Thu Aug 22 20:23:58 2019
@@ -1,5 +1,7 @@
 #pragma clang system_header
 
+#include "system-header-simulator-cxx.h"
+
 namespace llvm {
 template 
 const X *cast(Y Value);
@@ -22,4 +24,7 @@ bool isa(Y Value);
 
 template 
 bool isa_and_nonnull(Y Value);
+
+template 
+std::unique_ptr cast(std::unique_ptr &);
 } // namespace llvm

Modified: cfe/trunk/test/Analysis/cast-value-logic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-logic.cpp?rev=369727=369726=369727=diff
==
--- cfe/trunk/test/Analysis/cast-value-logic.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-logic.cpp Thu Aug 22 20:23:58 2019
@@ -135,4 +135,10 @@ namespace crashes {
 void test_non_reference_null_region_crash(Shape s) {
   cast(s); // no-crash
 }
+
+void test_non_reference_temporary_crash() {
+  extern std::unique_ptr foo();
+  auto P = foo();
+  auto Q = cast(std::move(P)); // no-crash
+}
 } // namespace crashes

Modified: cfe/trunk/test/Analysis/cast-value-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-notes.cpp?rev=369727=369726=369727=diff
==
--- cfe/trunk/test/Analysis/cast-value-notes.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-notes.cpp Thu Aug 22 20:23:58 2019
@@ -27,9 +27,9 @@ void evalReferences(const Shape ) {
 }
 
 void evalNonNullParamNonNullReturnReference(const Shape ) {
+  // Unmodeled cast from reference to pointer.
   const auto *C = dyn_cast_or_null(S);
-  // expected-note@-1 {{Assuming 'S' is a 'Circle'}}
-  // expected-note@-2 {{'C' initialized here}}
+  // expected-note@-1 {{'C' initialized here}}
 
   if (!dyn_cast_or_null(C)) {
 // expected-note@-1 {{'C' is a 'Circle'}}
@@ -132,10 +132,11 @@ void evalZeroParamNonNullReturn(const Sh
   // expected-warning@-3 {{Division by zero}}
 }
 
-void evalZeroParamNullReturn(const Shape ) {
-  const auto *C = S.getAs();
+void evalZeroParamNullReturn(const Shape *S) {
+  const auto  = S->getAs();
   // expected-note@-1 {{Assuming 'S' is not a 'Circle'}}
-  // expected-note@-2 {{'C' initialized to a null pointer value}}
+  // expected-note@-2 {{Storing null pointer value}}
+  // expected-note@-3 {{'C' initialized here}}
 
   if (!dyn_cast_or_null(S)) {
 // expected-note@-1 {{Assuming 'S' is a 'Triangle'}}

Modified: cfe/trunk/test/Analysis/cast-value-state-dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-state-dump.cpp?rev=369727=369726=369727=diff
==
--- cfe/trunk/test/Analysis/cast-value-state-dump.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-state-dump.cpp Thu Aug 22 20:23:58 2019
@@ -16,7 +16,7 @@ class Square : public Shape {};
 using namespace llvm;
 using 

r369728 - [analyzer] CastValueChecker: Provide DynamicTypeMap with pointer types only.

2019-08-22 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Aug 22 20:24:01 2019
New Revision: 369728

URL: http://llvm.org/viewvc/llvm-project?rev=369728=rev
Log:
[analyzer] CastValueChecker: Provide DynamicTypeMap with pointer types only.

The idea to drop this requirement is good, but for now every other user
of DynamicTypeInfo expects pointer types.

Fixes a crash.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/DynamicType.cpp
cfe/trunk/test/Analysis/cast-value-logic.cpp
cfe/trunk/test/Analysis/cast-value-state-dump.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h?rev=369728=369727=369728=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h Thu 
Aug 22 20:24:01 2019
@@ -54,7 +54,7 @@ ProgramStateRef setDynamicTypeInfo(Progr
 ProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State,
   const MemRegion *MR,
   QualType CastFromTy,
-  QualType CastToTy, QualType ResultTy,
+  QualType CastToTy,
   bool IsCastSucceeds);
 
 /// Removes the dead type informations from \p State.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp?rev=369728=369727=369728=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp Thu Aug 22 
20:24:01 2019
@@ -92,18 +92,6 @@ private:
 };
 } // namespace
 
-static QualType getRecordType(QualType Ty) {
-  Ty = Ty.getCanonicalType();
-
-  if (Ty->isPointerType())
-Ty = Ty->getPointeeType();
-
-  if (Ty->isReferenceType())
-Ty = Ty.getNonReferenceType();
-
-  return Ty.getUnqualifiedType();
-}
-
 static bool isInfeasibleCast(const DynamicCastInfo *CastInfo,
  bool CastSucceeds) {
   if (!CastInfo)
@@ -117,8 +105,8 @@ static const NoteTag *getNoteTag(Checker
  QualType CastToTy, const Expr *Object,
  bool CastSucceeds, bool IsKnownCast) {
   std::string CastToName =
-  CastInfo ? CastInfo->to()->getAsCXXRecordDecl()->getNameAsString()
-   : CastToTy->getAsCXXRecordDecl()->getNameAsString();
+  CastInfo ? CastInfo->to()->getPointeeCXXRecordDecl()->getNameAsString()
+   : CastToTy->getPointeeCXXRecordDecl()->getNameAsString();
   Object = Object->IgnoreParenImpCasts();
 
   return C.getNoteTag(
@@ -160,14 +148,14 @@ static void addCastTransition(const Call
 
   const Expr *Object;
   QualType CastFromTy;
-  QualType CastToTy = getRecordType(Call.getResultType());
+  QualType CastToTy = Call.getResultType();
 
   if (Call.getNumArgs() > 0) {
 Object = Call.getArgExpr(0);
-CastFromTy = getRecordType(Call.parameters()[0]->getType());
+CastFromTy = Call.parameters()[0]->getType();
   } else {
 Object = cast()->getCXXThisExpr();
-CastFromTy = getRecordType(Object->getType());
+CastFromTy = Object->getType();
   }
 
   const MemRegion *MR = DV.getAsRegion();
@@ -193,7 +181,7 @@ static void addCastTransition(const Call
   bool IsKnownCast = CastInfo || IsCheckedCast || CastFromTy == CastToTy;
   if (!IsKnownCast || IsCheckedCast)
 State = setDynamicTypeAndCastInfo(State, MR, CastFromTy, CastToTy,
-  Call.getResultType(), CastSucceeds);
+  CastSucceeds);
 
   SVal V = CastSucceeds ? DV : C.getSValBuilder().makeNull();
   C.addTransition(
@@ -206,8 +194,20 @@ static void addInstanceOfTransition(cons
 ProgramStateRef State, CheckerContext ,
 bool IsInstanceOf) {
   const FunctionDecl *FD = Call.getDecl()->getAsFunction();
+  QualType CastFromTy = Call.parameters()[0]->getType();
   QualType CastToTy = FD->getTemplateSpecializationArgs()->get(0).getAsType();
-  QualType CastFromTy = getRecordType(Call.parameters()[0]->getType());
+  if (CastFromTy->isPointerType())
+CastToTy = C.getASTContext().getPointerType(CastToTy);
+  else if (CastFromTy->isLValueReferenceType() &&
+   CastFromTy.isConstQualified()) {
+CastToTy.addConst();
+CastToTy = C.getASTContext().getLValueReferenceType(CastToTy);
+  } else if (CastFromTy->isLValueReferenceType())
+  

[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Reading some materials online... I think this should be named ECMAScript module 
(ECM), not JavaScript modules.. I can fix the description and commit for you.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fergal Daly via Phabricator via cfe-commits
fergald added a comment.

"why .mjs is so common that it justifies a clang-format change?"

I don't have data but Module JS is the future, it's supported by all major 
browsers for some time and also Node.js, it solves the problem of everything 
being lumped into one namespace.

Why does it need a different suffix? It adds the "export" and "import" keywords 
and so it incompatible with common JS. Forcing everyone to keep using js for 
both is not helpful (clang-format is not forcing of course but applying 
clang-format with --assume-filename is pretty awkward).

Node specifies .mjs as the suffix

https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff
https://nodejs.org/api/esm.html

So the use of the .mjs suffix is going to grow in volume as people modernize 
their project. It would be great for clang-format to be enabling that migration.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


r369725 - Revert "PR42587: diagnose unexpanded uses of a pack parameter of a generic" due to buildbot breakage.

2019-08-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 22 19:33:46 2019
New Revision: 369725

URL: http://llvm.org/viewvc/llvm-project?rev=369725=rev
Log:
Revert "PR42587: diagnose unexpanded uses of a pack parameter of a generic" due 
to buildbot breakage.

This reverts commit r369722.

Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=369725=369724=369725=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Aug 22 19:33:46 2019
@@ -928,12 +928,12 @@ void Sema::ActOnStartOfLambdaDefinition(
 
 // Check for unexpanded parameter packs in the method type.
 if (MethodTyInfo->getType()->containsUnexpandedParameterPack())
-  DiagnoseUnexpandedParameterPack(Intro.Range.getBegin(), MethodTyInfo,
-  UPPC_DeclarationType);
+  ContainsUnexpandedParameterPack = true;
   }
 
   CXXRecordDecl *Class = createLambdaClosureType(Intro.Range, MethodTyInfo,
  KnownDependent, 
Intro.Default);
+
   CXXMethodDecl *Method =
   startLambdaDefinition(Class, Intro.Range, MethodTyInfo, EndLoc, Params,
 ParamInfo.getDeclSpec().getConstexprSpecifier());

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=369725=369724=369725=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Thu Aug 22 19:33:46 2019
@@ -313,17 +313,10 @@ Sema::DiagnoseUnexpandedParameterPacks(S
 
 if (auto *LSI = dyn_cast(Func)) {
   if (N == FunctionScopes.size()) {
-const DeclContext *LambdaDC = LSI->CallOperator;
-// While we're parsing the lambda-declarator, we don't have a call
-// operator yet and the parameters instead get temporarily attached
-// to the translation unit.
-if (!LambdaDC)
-  LambdaDC = Context.getTranslationUnitDecl();
-
 for (auto  : Unexpanded) {
   auto *VD = dyn_cast_or_null(
   Pack.first.dyn_cast());
-  if (VD && VD->getDeclContext() == LambdaDC)
+  if (VD && VD->getDeclContext() == LSI->CallOperator)
 LambdaParamPackReferences.push_back(Pack);
 }
   }

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp?rev=369725=369724=369725=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp Thu Aug 22 
19:33:46 2019
@@ -122,11 +122,3 @@ namespace PR33082 {
 b(Pack(), 1, 2, 3); // expected-note {{instantiation of}}
   }
 }
-
-void pr42587() {
-  (void)[](auto... args) -> decltype(args) {}; // expected-error {{type 
contains unexpanded parameter pack}}
-  (void)[](auto... args, int = args) {}; // expected-error {{default argument 
contains unexpanded parameter pack}}
-  (void)[](auto... args, decltype(args)) {}; // expected-error {{type contains 
unexpanded parameter pack}}
-  (void)[](auto... args, decltype(args)...) {}; // (ok)
-  (void)[](auto... args, int = [=] { return args; }()) {}; // expected-error 
{{default argument contains unexpanded parameter pack}}
-}


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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This causes .mjs files to be treated as javascript.

I think you meant .mjs was not recognized before but will be recognized as 
JavaScript with this change.

Can you elaborate a bit why .mjs is so common that it justifies a clang-format 
change?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> module-javascript. Module javascript is not compatible with non-module java 
> script as it uses the "export" and "import" keywords which are only legal in 
> module-javascript.

java script -> JavaScript
module-javascript -> Module JavaScript?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fergal Daly via Phabricator via cfe-commits
fergald added a comment.

I cannot commit this, please do so, if you're happy with it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Fergal Daly via Phabricator via cfe-commits
fergald added a comment.

It seems to do the right thing. E.g.

https://crrev.com/c/1767284/5/third_party/blink/renderer/core/script/resources/layered_api/elements/virtual-scroller/visibility-manager.mjs


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

2019-08-22 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Does clang-format format import and export lines in mjs files correctly?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66584



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-22 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked an inline comment as done.
logan-5 added a comment.

@rsmith I agree having a final destructor in a non-final class smells weird. 
I'd be interested in working on adding a warning like that, if it sounds like a 
useful thing.

For now, I need help committing this, if anyone would be so kind!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-22 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 216757.
logan-5 added a comment.

Tweaked comment wording for accuracy.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp


Index: clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -24,6 +24,20 @@
   }
 }
 
+namespace Test2a {
+  struct A {
+virtual ~A() final {}
+virtual int f();
+  };
+
+  // CHECK-LABEL: define i32 @_ZN6Test2a1fEPNS_1AE
+  int f(A *a) {
+// CHECK: call i32 @_ZN6Test2a1A1fEv
+return a->f();
+  }
+}
+
+
 namespace Test3 {
   struct A {
 virtual int f();
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2067,9 +2067,11 @@
   if (DevirtualizedMethod->hasAttr())
 return DevirtualizedMethod;
 
-  // Similarly, if the class itself is marked 'final' it can't be overridden
-  // and we can therefore devirtualize the member function call.
-  if (BestDynamicDecl->hasAttr())
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be derived from and we can therefore devirtualize the 
+  // member function call.
+  if (BestDynamicDecl->hasAttr() ||
+  BestDynamicDecl->getDestructor()->hasAttr())
 return DevirtualizedMethod;
 
   if (const auto *DRE = dyn_cast(Base)) {


Index: clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -24,6 +24,20 @@
   }
 }
 
+namespace Test2a {
+  struct A {
+virtual ~A() final {}
+virtual int f();
+  };
+
+  // CHECK-LABEL: define i32 @_ZN6Test2a1fEPNS_1AE
+  int f(A *a) {
+// CHECK: call i32 @_ZN6Test2a1A1fEv
+return a->f();
+  }
+}
+
+
 namespace Test3 {
   struct A {
 virtual int f();
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2067,9 +2067,11 @@
   if (DevirtualizedMethod->hasAttr())
 return DevirtualizedMethod;
 
-  // Similarly, if the class itself is marked 'final' it can't be overridden
-  // and we can therefore devirtualize the member function call.
-  if (BestDynamicDecl->hasAttr())
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be derived from and we can therefore devirtualize the 
+  // member function call.
+  if (BestDynamicDecl->hasAttr() ||
+  BestDynamicDecl->getDestructor()->hasAttr())
 return DevirtualizedMethod;
 
   if (const auto *DRE = dyn_cast(Base)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66555: [driver] add a new option `-gen-cdb-fragment-path` to emit a fragment of a compilation database for each compilation

2019-08-22 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.h:99
+  void DumpCompilationDatabaseFragmentToDir(
+  StringRef Dir, Compilation , StringRef Target, const InputInfo ,
+  const InputInfo , const llvm::opt::ArgList ) const;

BTW this looks kind of funny `const InputInfo , const InputInfo `.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66555



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


[PATCH] D66555: [driver] add a new option `-gen-cdb-fragment-path` to emit a fragment of a compilation database for each compilation

2019-08-22 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2067
+  const auto  = C.getDriver();
+  auto CWD = Driver.getVFS().getCurrentWorkingDirectory();
+  if (!CWD) {

Do we still need this now?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2089
+  if (Err) {
+Driver.Diag(diag::err_drv_compilationdatabase) << Err.message();
+return;

Just to make sure - the error different on purpose here?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2092
+  }
+  CompilationDatabase =
+  std::make_unique(FD, /*shouldClose=*/true);

I'm not familiar with intended lifecycle of `CompilationDatabase ` member. Just 
to make sure - we need neither to preserve the original value nor reset the 
stream after we're done here (as in - nobody is going to write anything after 
we're done here), right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66555



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


r369722 - PR42587: diagnose unexpanded uses of a pack parameter of a generic

2019-08-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 22 18:41:48 2019
New Revision: 369722

URL: http://llvm.org/viewvc/llvm-project?rev=369722=rev
Log:
PR42587: diagnose unexpanded uses of a pack parameter of a generic
lambda from within the lambda-declarator.

Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=369722=369721=369722=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Thu Aug 22 18:41:48 2019
@@ -928,12 +928,12 @@ void Sema::ActOnStartOfLambdaDefinition(
 
 // Check for unexpanded parameter packs in the method type.
 if (MethodTyInfo->getType()->containsUnexpandedParameterPack())
-  ContainsUnexpandedParameterPack = true;
+  DiagnoseUnexpandedParameterPack(Intro.Range.getBegin(), MethodTyInfo,
+  UPPC_DeclarationType);
   }
 
   CXXRecordDecl *Class = createLambdaClosureType(Intro.Range, MethodTyInfo,
  KnownDependent, 
Intro.Default);
-
   CXXMethodDecl *Method =
   startLambdaDefinition(Class, Intro.Range, MethodTyInfo, EndLoc, Params,
 ParamInfo.getDeclSpec().getConstexprSpecifier());

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=369722=369721=369722=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Thu Aug 22 18:41:48 2019
@@ -313,10 +313,17 @@ Sema::DiagnoseUnexpandedParameterPacks(S
 
 if (auto *LSI = dyn_cast(Func)) {
   if (N == FunctionScopes.size()) {
+const DeclContext *LambdaDC = LSI->CallOperator;
+// While we're parsing the lambda-declarator, we don't have a call
+// operator yet and the parameters instead get temporarily attached
+// to the translation unit.
+if (!LambdaDC)
+  LambdaDC = Context.getTranslationUnitDecl();
+
 for (auto  : Unexpanded) {
   auto *VD = dyn_cast_or_null(
   Pack.first.dyn_cast());
-  if (VD && VD->getDeclContext() == LSI->CallOperator)
+  if (VD && VD->getDeclContext() == LambdaDC)
 LambdaParamPackReferences.push_back(Pack);
 }
   }

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp?rev=369722=369721=369722=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp Thu Aug 22 
18:41:48 2019
@@ -122,3 +122,11 @@ namespace PR33082 {
 b(Pack(), 1, 2, 3); // expected-note {{instantiation of}}
   }
 }
+
+void pr42587() {
+  (void)[](auto... args) -> decltype(args) {}; // expected-error {{type 
contains unexpanded parameter pack}}
+  (void)[](auto... args, int = args) {}; // expected-error {{default argument 
contains unexpanded parameter pack}}
+  (void)[](auto... args, decltype(args)) {}; // expected-error {{type contains 
unexpanded parameter pack}}
+  (void)[](auto... args, decltype(args)...) {}; // (ok)
+  (void)[](auto... args, int = [=] { return args; }()) {}; // expected-error 
{{default argument contains unexpanded parameter pack}}
+}


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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp:1
+//===--- PthreadReturnCheck.cpp -
+//clang-tidy-===//

Please make it single line, 80 characters long.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp:23
+ const char *BindingStr) {
+  const CallExpr *MatchedCall = cast(
+  (Result.Nodes.getNodeAs(BindingStr))->getLHS());

You could use const auto * here, because type is spelled in same statement.



Comment at: clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.h:1
+//===--- PthreadReturnCheck.h - clang-tidy-*- C++ 
-*-===//
+//

Please make line 80 characters long.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:82
 
+- New :doc:`bugprone-pthread-return
+  ` check.

Please keep new checks list sorted alphabetically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66627



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This seems subtle, but I believe it is correct.

I wonder whether we should provide a warning for a non-final class has a final 
destructor, since moving the `final` from the destructor to the class seems 
like a more obvious way to present the code (and will likely lead to better 
code generation in compilers that haven't realized they can do this).




Comment at: clang/lib/AST/DeclCXX.cpp:2071
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be overridden and we can therefore devirtualize the 
+  // member function call.

This comment doesn't make much sense (pre-existing, but since you're changing 
it anyway): classes can't be "overridden", they can only be derived from.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D66627: [clang-tidy] new check: bugprone-pthread-return

2019-08-22 Thread Jian Cai via Phabricator via cfe-commits
jcai19 created this revision.
Herald added subscribers: cfe-commits, jfb, xazax.hun, mgorny.
Herald added a project: clang.

Checks if any calls to POSIX pthread functions expect negative return values.
These functions return either 0 on success or an errno on failure, which is
positive only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66627

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PthreadReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pthread-return.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-pthread-return.cpp
@@ -0,0 +1,187 @@
+// RUN: %check_clang_tidy %s bugprone-pthread-return %t
+
+#define NULL nullptr
+#define ZERO 0
+#define NEGATIVE_ONE -1
+
+typedef decltype(sizeof(int)) size_t;
+# define __CPU_SETSIZE 1024
+# define __NCPUBITS (8 * sizeof (__cpu_mask))
+typedef unsigned long int __cpu_mask;
+typedef struct
+{
+  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+typedef int clockid_t;
+# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
+typedef struct
+{
+  unsigned long int __val[_SIGSET_NWORDS];
+} sigset_t;
+typedef struct _opaque_pthread_t *__darwin_pthread_t;
+typedef __darwin_pthread_t pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
+typedef struct pthread_mutex_t_ * pthread_mutex_t;
+typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
+typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
+typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
+
+
+extern "C" void pthread_cleanup_push(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop(int execute);
+extern "C" void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg);
+extern "C" void pthread_cleanup_pop_restore_np(int execute);
+extern "C" void pthread_exit(void *retval);
+extern "C" void pthread_kill_other_threads_np(void);
+extern "C" void pthread_testcancel(void);
+
+extern "C" pthread_t pthread_self(void);
+
+extern "C" int pthread_attr_init(pthread_attr_t *attr);
+extern "C" int pthread_attr_destroy(pthread_attr_t *attr);
+extern "C" int pthread_attr_setaffinity_np(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
+extern "C" int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
+extern "C" int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
+extern "C" int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize);
+extern "C" int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
+extern "C" int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched);
+extern "C" int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
+extern "C" int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
+extern "C" int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
+extern "C" int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
+extern "C" int pthread_attr_setscope(pthread_attr_t *attr, int scope);
+extern "C" int pthread_attr_getscope(const pthread_attr_t *attr, int *scope);
+extern "C" int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);
+extern "C" int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize);
+extern "C" int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
+extern "C" int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr);
+extern "C" int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
+extern "C" int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
+extern "C" int pthread_cancel(pthread_t thread);
+extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
+extern "C" int pthread_detach(pthread_t thread);
+extern "C" int pthread_equal(pthread_t t1, pthread_t t2);
+extern "C" int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset);
+extern "C" int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset);
+extern "C" int pthread_getattr_default_np(pthread_attr_t *attr);
+extern "C" int pthread_setattr_default_np(pthread_attr_t *attr);
+extern "C" 

[PATCH] D66564: [clang-tidy] new FPGA struct pack align check

2019-08-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/fpga/FPGATidyModule.cpp:15
+
+
+using namespace clang::ast_matchers;

Unnecessary empty line.



Comment at: clang-tidy/fpga/FPGATidyModule.cpp:32
+
+} // namespace flocl
+

Wrong namespace in comment. Try to run Clang-tidy llvm-namespace-comment.



Comment at: clang-tidy/fpga/StructPackAlignCheck.cpp:10
+
+#ifndef MAX_ALIGN_POWER_OF_TWO
+#define MAX_ALIGN_POWER_OF_TWO 7

Should be  be constexpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66564



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


[PATCH] D62571: Implement codegen for MSVC unions with reference members

2019-08-22 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom added a comment.

Thanks @aaron.ballman!

I will need someone to commit this for me :)

Cheers,
Dom


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

https://reviews.llvm.org/D62571



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

Thanks for being responsive to all this code review! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66573: [clang][ifs] Dropping older experimental interface stub formats.

2019-08-22 Thread Puyan Lotfi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369719: [clang][ifs] Dropping older experimental interface 
stub formats. (authored by zer0, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66573?vs=216722=216742#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66573

Files:
  cfe/trunk/include/clang/Frontend/FrontendActions.h
  cfe/trunk/include/clang/Frontend/FrontendOptions.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/test/InterfaceStubs/bad-format.cpp
  cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp
  cfe/trunk/test/InterfaceStubs/externstatic.c
  cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp
  cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp
  cfe/trunk/test/InterfaceStubs/inline.c
  cfe/trunk/test/InterfaceStubs/object.cpp
  cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp
  cfe/trunk/test/InterfaceStubs/virtual.cpp
  cfe/trunk/test/InterfaceStubs/visibility.cpp
  cfe/trunk/test/InterfaceStubs/weak.cpp

Index: cfe/trunk/test/InterfaceStubs/inline.c
===
--- cfe/trunk/test/InterfaceStubs/inline.c
+++ cfe/trunk/test/InterfaceStubs/inline.c
@@ -1,14 +1,14 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \
 // RUN: -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=gnu89 -xc %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 -std=gnu89 -xc %s | \
 // RUN: FileCheck -check-prefix=CHECK-GNU %s
 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c \
 // RUN: -std=gnu89 -xc %s | llvm-nm - | FileCheck -check-prefix=CHECK-GNU %s
 
 // RUN: %clang -DINLINE="__attribute__((always_inline))" \
 // RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -xc %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 -xc %s | \
 // RUN: FileCheck -check-prefix=CHECK-GNU %s
 // RUN: %clang -DINLINE="__attribute__((always_inline))" \
 // RUN: -target x86_64-linux-gnu -O0 -o - -c -xc %s | \
@@ -16,14 +16,14 @@
 
 // RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \
 // RUN: -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
 // RUN: FileCheck -check-prefix=CHECK-STD %s
 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -O0 -o - -c -std=c99 \
 // RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-STD %s
 
 // RUN: %clang -DINLINE="__attribute__((noinline))" \
 // RUN: -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
 // RUN: FileCheck -check-prefix=CHECK-NOINLINE %s
 // RUN: %clang -DINLINE="__attribute__((noinline))" -target x86_64-linux-gnu \
 // RUN: -O0 -o - -c -std=c99 -xc %s | llvm-nm - 2>&1 | \
@@ -31,7 +31,7 @@
 
 // RUN: %clang -DINLINE="static" -target x86_64-unknown-linux-gnu -o - \
 // RUN: -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 -std=c99 -xc %s | \
 // RUN: FileCheck -check-prefix=CHECK-STATIC %s
 // RUN: %clang -DINLINE="static" -target x86_64-linux-gnu -O0 -o - -c \
 // RUN: -std=c99 -xc %s | llvm-nm - 2>&1 | \
@@ -51,11 +51,11 @@
 }
 
 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
-// RUN: -emit-interface-stubs -interface-stub-version=experimental-tapi-elf-v1 \
+// RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \
 // RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-TAPI %s
 
 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
-// RUN: -emit-interface-stubs -interface-stub-version=experimental-tapi-elf-v1 \
+// RUN: -emit-interface-stubs -interface-stub-version=experimental-ifs-v1 \
 // RUN: -std=gnu89 -xc %s | FileCheck -check-prefix=CHECK-SYMBOLS %s
 // RUN: %clang -DINLINE=inline -target x86_64-linux-gnu -o - \
 // RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \
Index: cfe/trunk/test/InterfaceStubs/externstatic.c
===
--- cfe/trunk/test/InterfaceStubs/externstatic.c
+++ cfe/trunk/test/InterfaceStubs/externstatic.c
@@ -1,21 +1,21 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \
 // RUN: 

r369719 - [clang][ifs] Dropping older experimental interface stub formats.

2019-08-22 Thread Puyan Lotfi via cfe-commits
Author: zer0
Date: Thu Aug 22 16:44:34 2019
New Revision: 369719

URL: http://llvm.org/viewvc/llvm-project?rev=369719=rev
Log:
[clang][ifs] Dropping older experimental interface stub formats.

I've been working on a new tool, llvm-ifs, for merging interface stub files
generated by clang and I've iterated on my derivative format of TBE to a newer
format. llvm-ifs will only support the new format, so I am going to drop the
older experimental interface stubs formats in this commit to make things
simpler.

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

Modified:
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/test/InterfaceStubs/bad-format.cpp
cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/externstatic.c
cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp
cfe/trunk/test/InterfaceStubs/inline.c
cfe/trunk/test/InterfaceStubs/object.cpp
cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp
cfe/trunk/test/InterfaceStubs/virtual.cpp
cfe/trunk/test/InterfaceStubs/visibility.cpp
cfe/trunk/test/InterfaceStubs/weak.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=369719=369718=369719=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Aug 22 16:44:34 2019
@@ -126,19 +126,6 @@ protected:
   bool hasASTFileSupport() const override { return false; }
 };
 
-// Support different interface stub formats this way:
-class GenerateInterfaceYAMLExpV1Action : public GenerateInterfaceStubAction {
-protected:
-  std::unique_ptr CreateASTConsumer(CompilerInstance ,
- StringRef InFile) override;
-};
-
-class GenerateInterfaceTBEExpV1Action : public GenerateInterfaceStubAction {
-protected:
-  std::unique_ptr CreateASTConsumer(CompilerInstance ,
- StringRef InFile) override;
-};
-
 class GenerateInterfaceIfsExpV1Action : public GenerateInterfaceStubAction {
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance ,

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=369719=369718=369719=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Aug 22 16:44:34 2019
@@ -90,8 +90,6 @@ enum ActionKind {
   GeneratePCH,
 
   /// Generate Interface Stub Files.
-  GenerateInterfaceYAMLExpV1,
-  GenerateInterfaceTBEExpV1,
   GenerateInterfaceIfsExpV1,
 
   /// Only execute frontend initialization.

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369719=369718=369719=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug 22 16:44:34 2019
@@ -3631,22 +3631,27 @@ void Clang::ConstructJob(Compilation ,
JA.getType() == types::TY_LTO_BC) {
   CmdArgs.push_back("-emit-llvm-bc");
 } else if (JA.getType() == types::TY_IFS) {
+  StringRef ArgStr =
+  Args.hasArg(options::OPT_iterface_stub_version_EQ)
+  ? Args.getLastArgValue(options::OPT_iterface_stub_version_EQ)
+  : "";
   StringRef StubFormat =
-  llvm::StringSwitch(
-  Args.hasArg(options::OPT_iterface_stub_version_EQ)
-  ? Args.getLastArgValue(options::OPT_iterface_stub_version_EQ)
-  : "")
-  .Case("experimental-yaml-elf-v1", "experimental-yaml-elf-v1")
-  .Case("experimental-tapi-elf-v1", "experimental-tapi-elf-v1")
+  llvm::StringSwitch(ArgStr)
   .Case("experimental-ifs-v1", "experimental-ifs-v1")
   .Default("");
 
-  if (StubFormat.empty())
+  if (StubFormat.empty()) {
+std::string ErrorMessage =
+"Invalid interface stub format: " + ArgStr.str() +
+((ArgStr == "experimental-yaml-elf-v1" ||
+  ArgStr == "experimental-tapi-elf-v1")
+ ? " is deprecated."
+ : ".");
 D.Diag(diag::err_drv_invalid_value)
-<< "Must 

[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216739.
Nathan-Huckleberry added a comment.

- Simplify logic for readability


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c


Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 
'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // warning with -Wformat-pedantic only
+  printf("%hu\n", (uint8_t)1);   // warning with -Wformat-pedantic only
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+
+int printf(const char *restrict, ...);
+
+typedef unsigned char uint8_t;
+
+void print_char_as_short() {
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned 
char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -79,10 +79,10 @@
   printf("%hhd", input); // no-warning
   printf("%hhd", CharConstant); // no-warning
 
-  // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but 
the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 
'short'}}
-  
+  // This is not correct, but it is safe. Only warned in pedantic mode because 
'%hd' shows intent.
+  printf("%hd", input);
+  printf("%hd", CharConstant);
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8098,9 +8098,13 @@
   // function.
   if (ICE->getType() == S.Context.IntTy ||
   ICE->getType() == S.Context.UnsignedIntTy) {
-// All further checking is done on the subexpression.
-if (AT.matchesType(S.Context, ExprTy))
+// All further checking is done on the subexpression
+const analyze_printf::ArgType::MatchKind ImplicitMatch =
+AT.matchesType(S.Context, ExprTy);
+if (ImplicitMatch == analyze_printf::ArgType::Match)
   return true;
+else if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
+  Pedantic = true;
   }
 }
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -386,6 +386,8 @@
   case BuiltinType::SChar:
   case BuiltinType::Char_U:

[PATCH] D66593: [analyzer] CastValueChecker: Fix some assertions

2019-08-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:743-750
+  QualType RegionType = DynType.getType();
+  if (RegionType->isPointerType())
+RegionType = RegionType->getPointeeType();
+  else
+RegionType = RegionType.getNonReferenceType();
+
+  assert(!RegionType.isNull() &&

NoQ wrote:
> I don't think this does anything:
> ```lang=c++
>505 QualType Type::getPointeeType() const {
>506   if (const auto *PT = getAs())
>507 return PT->getPointeeType();
>508   if (const auto *OPT = getAs())
>509 return OPT->getPointeeType();
>510   if (const auto *BPT = getAs())
>511 return BPT->getPointeeType();
>512   if (const auto *RT = getAs())
>513 return RT->getPointeeType();
>514   if (const auto *MPT = getAs())
>515 return MPT->getPointeeType();
>516   if (const auto *DT = getAs())
>517 return DT->getPointeeType();
>518   return {};
>519 }
> ```
> This getter usually works very reliably for both pointers and references.
I have measured each assertion failure one-by-one, so all of the hotfixes are 
necessary in order to reduce the crash-counter to zero. I have not got time to 
go in-depth, and have a great talk about them, sorry.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:118-122
+  for (const auto  : Map) {
+const MemRegion *MR = Elem.first;
+if (MR && !SR.isLiveRegion(MR))
+  State = State->remove(MR);
+  }

NoQ wrote:
> We shouldn't put null regions into our maps.
Yes, but that is problematic. I have updated the diff.


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

https://reviews.llvm.org/D66593



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


[PATCH] D66593: [analyzer] CastValueChecker: Fix some assertions

2019-08-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216737.
Charusso marked 2 inline comments as done.
Charusso added a comment.

- The null `MemRegion` is a `0 (Loc)`, try to avoid to store it.


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

https://reviews.llvm.org/D66593

Files:
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Analysis/cast-value-notes.cpp

Index: clang/test/Analysis/cast-value-notes.cpp
===
--- clang/test/Analysis/cast-value-notes.cpp
+++ clang/test/Analysis/cast-value-notes.cpp
@@ -85,13 +85,12 @@
 
 void evalNonNullParamNullReturn(const Shape *S) {
   const auto *C = dyn_cast_or_null(S);
-  // expected-note@-1 {{Assuming 'S' is not a 'Circle'}}
+  // expected-note@-1 {{Assuming null pointer is passed into cast}}
 
   if (const auto *T = dyn_cast_or_null(S)) {
-// expected-note@-1 {{Assuming 'S' is a 'Triangle'}}
-// expected-note@-2 {{'T' initialized here}}
-// expected-note@-3 {{'T' is non-null}}
-// expected-note@-4 {{Taking true branch}}
+// expected-note@-1 {{'T' initialized here}}
+// expected-note@-2 {{'T' is non-null}}
+// expected-note@-3 {{Taking true branch}}
 
 (void)(1 / !T);
 // expected-note@-1 {{'T' is non-null}}
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1048,7 +1048,7 @@
   return getSubRegion(E, getStackLocalsRegion(SFC));
 }
 
-/// Checks whether \p BaseClass is a valid virtual or direct non-virtual base
+/*/// Checks whether \p BaseClass is a valid virtual or direct non-virtual base
 /// class of the type of \p Super.
 static bool isValidBaseClass(const CXXRecordDecl *BaseClass,
  const TypedValueRegion *Super,
@@ -1068,15 +1068,16 @@
   }
 
   return false;
-}
+}*/
 
 const CXXBaseObjectRegion *
 MemRegionManager::getCXXBaseObjectRegion(const CXXRecordDecl *RD,
  const SubRegion *Super,
  bool IsVirtual) {
   if (isa(Super)) {
-assert(isValidBaseClass(RD, dyn_cast(Super), IsVirtual));
-(void)
+// FIXME: Make this assertion great again.
+/*assert(isValidBaseClass(RD, dyn_cast(Super), IsVirtual));
+(void)*/
 
 if (IsVirtual) {
   // Virtual base regions should not be layered, since the layout rules
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -325,13 +325,15 @@
   return State;
 }
 Result = InitWithAdjustments;
-  } else {
+  }
+  // FIXME: Make this assertion great again.
+  /* else {
 // We need to create a region no matter what. For sanity, make sure we don't
 // try to stuff a Loc into a non-pointer temporary region.
 assert(!InitValWithAdjustments.getAs() ||
Loc::isLocType(Result->getType()) ||
Result->getType()->isMemberPointerType());
-  }
+  }*/
 
   ProgramStateManager  = State->getStateManager();
   MemRegionManager  = StateMgr.getRegionManager();
Index: clang/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -740,8 +740,14 @@
 return {};
 
   // Is the type a C++ class? (This is mostly a defensive check.)
-  QualType RegionType = DynType.getType()->getPointeeType();
-  assert(!RegionType.isNull() && "DynamicTypeInfo should always be a pointer.");
+  QualType RegionType = DynType.getType();
+  if (RegionType->isPointerType())
+RegionType = RegionType->getPointeeType();
+  else
+RegionType = RegionType.getNonReferenceType();
+
+  assert(!RegionType.isNull() &&
+ "DynamicTypeInfo should always be a pointer or a reference.");
 
   const CXXRecordDecl *RD = RegionType->getAsCXXRecordDecl();
   if (!RD || !RD->hasDefinition())
Index: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
@@ -98,8 +98,7 @@
 
   if (Ty->isPointerType())
 Ty = Ty->getPointeeType();
-
-  if (Ty->isReferenceType())
+  else if (Ty->isReferenceType())
 Ty = Ty.getNonReferenceType();
 
   return Ty.getUnqualifiedType();
@@ -411,6 +410,9 @@
   if (!DV)
 return false;
 
+  if (!DV->getAsRegion())
+return false;
+
   Check(this, Call, *DV, C);
   return true;
 }
___
cfe-commits mailing 

[PATCH] D66446: [clang][IFS] Adding new Interface Stubs format.

2019-08-22 Thread Puyan Lotfi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369715: [clang][ifs] New interface stubs format (llvm triple 
based). (authored by zer0, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66446?vs=216004=216734#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66446

Files:
  cfe/trunk/include/clang/Frontend/FrontendActions.h
  cfe/trunk/include/clang/Frontend/FrontendOptions.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -68,6 +68,8 @@
 return std::make_unique();
   case GenerateInterfaceTBEExpV1:
 return std::make_unique();
+  case GenerateInterfaceIfsExpV1:
+return std::make_unique();
   case InitOnly:   return std::make_unique();
   case ParseSyntaxOnly:return std::make_unique();
   case ModuleFileInfo: return std::make_unique();
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3638,12 +3638,14 @@
   : "")
   .Case("experimental-yaml-elf-v1", "experimental-yaml-elf-v1")
   .Case("experimental-tapi-elf-v1", "experimental-tapi-elf-v1")
+  .Case("experimental-ifs-v1", "experimental-ifs-v1")
   .Default("");
 
   if (StubFormat.empty())
 D.Diag(diag::err_drv_invalid_value)
 << "Must specify a valid interface stub format type using "
 << "-interface-stub-version=";
 
   CmdArgs.push_back("-emit-interface-stubs");
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1737,11 +1737,14 @@
 frontend::GenerateInterfaceYAMLExpV1)
   .Case("experimental-tapi-elf-v1",
 frontend::GenerateInterfaceTBEExpV1)
+  .Case("experimental-ifs-v1",
+frontend::GenerateInterfaceIfsExpV1)
   .Default(llvm::None);
   if (!ProgramAction)
 Diags.Report(diag::err_drv_invalid_value)
 << "Must specify a valid interface stub format type using "
 << "-interface-stub-version=";
   Opts.ProgramAction = *ProgramAction;
   break;
@@ -3185,6 +3188,7 @@
   case frontend::GeneratePCH:
   case frontend::GenerateInterfaceYAMLExpV1:
   case frontend::GenerateInterfaceTBEExpV1:
+  case frontend::GenerateInterfaceIfsExpV1:
   case frontend::ParseSyntaxOnly:
   case frontend::ModuleFileInfo:
   case frontend::VerifyPCH:
Index: cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -354,9 +354,55 @@
   OS.flush();
 };
 
+auto writeIfsV1 =
+[this](const llvm::Triple , const MangledSymbols ,
+   const ASTContext , StringRef Format,
+   raw_ostream ) -> void {
+  OS << "--- !" << Format << "\n";
+  OS << "IfsVersion: 1.0\n";
+  OS << "Triple: " << T.str() << "\n";
+  OS << "ObjectFileFormat: " << "ELF" << "\n"; // TODO: For now, just ELF.
+  OS << "Symbols:\n";
+  for (const auto  : Symbols) {
+const MangledSymbol  = E.second;
+for (auto Name : Symbol.Names) {
+  OS << "  "
+ << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
+ ? ""
+ : (Symbol.ParentName + "."))
+ << Name << ": { Type: ";
+  switch (Symbol.Type) {
+  default:
+llvm_unreachable(
+"clang -emit-iterface-stubs: Unexpected symbol type.");
+  case llvm::ELF::STT_NOTYPE:
+OS << "NoType";
+break;
+  case llvm::ELF::STT_OBJECT: {
+auto VD = cast(E.first)->getType();
+OS << "Object, Size: "
+   << context.getTypeSizeInChars(VD).getQuantity();
+break;
+  }
+  case llvm::ELF::STT_FUNC:
+OS << "Func";
+break;
+  }
+  if (Symbol.Binding == llvm::ELF::STB_WEAK)
+OS << ", Weak: true";
+  OS << " }\n";
+}

[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8107
+return true;
+  Pedantic |= ImplicitMatch == 
analyze_printf::ArgType::NoMatchPedantic;
+}

At this point `ImplicitMatch` can only have the value 
`analyze_printf::ArgType::NoMatchPedantic` as `ArgType::MatchKind` is an enum 
with only 3 values (see `clang/include/clang/AST/FormatString.h`).

Rather than have conditional/ternaries for each case, I think 2 conditionals 
are maybe simpler:

```
if (ImplicitMatch == analyze_printf::ArgType::Match)
  return true;
else if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
  Pedantic = true;
```

The `|=` is kind of more complicated than simple assignment.

Then you don't need a block for `if (ImplicitMatch)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


r369715 - [clang][ifs] New interface stubs format (llvm triple based).

2019-08-22 Thread Puyan Lotfi via cfe-commits
Author: zer0
Date: Thu Aug 22 16:29:22 2019
New Revision: 369715

URL: http://llvm.org/viewvc/llvm-project?rev=369715=rev
Log:
[clang][ifs] New interface stubs format (llvm triple based).

After posting llvm-ifs on phabricator, I made some progress in hardening up how
I think the format for Interface Stubs should look. There are a number of
things I think the TBE format was missing (no endianness, no info about the
Object Format because it assumes ELF), so I have added those and broken off
from being as similar to the TBE schema. In a subsequent commit I can drop the
other formats.

An example of how The format will look is as follows:

--- !experimental-ifs-v1
IfsVersion: 1.0
Triple: x86_64-unknown-linux-gnu
ObjectFileFormat: ELF
Symbols:
  _Z9nothiddenv: { Type: Func }
  _Z10cmdVisiblev: { Type: Func }
...

The format is still marked experimental.

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

Modified:
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=369715=369714=369715=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Aug 22 16:29:22 2019
@@ -139,6 +139,12 @@ protected:
  StringRef InFile) override;
 };
 
+class GenerateInterfaceIfsExpV1Action : public GenerateInterfaceStubAction {
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef InFile) override;
+};
+
 class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
 private:
   bool BeginSourceFileAction(CompilerInstance ) override;

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=369715=369714=369715=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Aug 22 16:29:22 2019
@@ -92,6 +92,7 @@ enum ActionKind {
   /// Generate Interface Stub Files.
   GenerateInterfaceYAMLExpV1,
   GenerateInterfaceTBEExpV1,
+  GenerateInterfaceIfsExpV1,
 
   /// Only execute frontend initialization.
   InitOnly,

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369715=369714=369715=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug 22 16:29:22 2019
@@ -3638,12 +3638,14 @@ void Clang::ConstructJob(Compilation ,
   : "")
   .Case("experimental-yaml-elf-v1", "experimental-yaml-elf-v1")
   .Case("experimental-tapi-elf-v1", "experimental-tapi-elf-v1")
+  .Case("experimental-ifs-v1", "experimental-ifs-v1")
   .Default("");
 
   if (StubFormat.empty())
 D.Diag(diag::err_drv_invalid_value)
 << "Must specify a valid interface stub format type using "
 << "-interface-stub-version=";
 
   CmdArgs.push_back("-emit-interface-stubs");

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=369715=369714=369715=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Aug 22 16:29:22 2019
@@ -1737,11 +1737,14 @@ static InputKind ParseFrontendArgs(Front
 frontend::GenerateInterfaceYAMLExpV1)
   .Case("experimental-tapi-elf-v1",
 frontend::GenerateInterfaceTBEExpV1)
+  .Case("experimental-ifs-v1",
+frontend::GenerateInterfaceIfsExpV1)
   .Default(llvm::None);
   if (!ProgramAction)
 Diags.Report(diag::err_drv_invalid_value)
 << "Must specify a valid interface stub format type using "
 << "-interface-stub-version=";
   Opts.ProgramAction = *ProgramAction;
   break;
@@ -3185,6 +3188,7 @@ static bool isStrictlyPreprocessorAction
   case frontend::GeneratePCH:
   case frontend::GenerateInterfaceYAMLExpV1:
   case frontend::GenerateInterfaceTBEExpV1:
+  case frontend::GenerateInterfaceIfsExpV1:
   

r369714 - [libclang][NFC] Remove debug comment

2019-08-22 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Aug 22 16:29:10 2019
New Revision: 369714

URL: http://llvm.org/viewvc/llvm-project?rev=369714=rev
Log:
[libclang][NFC] Remove debug comment

Modified:
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=369714=369713=369714=diff
==
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Thu Aug 22 16:29:10 2019
@@ -125,9 +125,7 @@ class SessionSkipBodyData {
   PPRegionSetTy ParsedRegions;
 
 public:
-  ~SessionSkipBodyData() {
-//llvm::errs() << "RegionData: " << Skipped.size() << " - " << 
Skipped.getMemorySize() << "\n";
-  }
+  ~SessionSkipBodyData() = default;
 
   void copyTo(PPRegionSetTy ) {
 std::lock_guard MG(Mux);


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


[PATCH] D66622: [Bugfix] fix r369705 unit test

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369713: [Bugfix] fix r369705 unit test (authored by 
nickdesaulniers, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66622?vs=216727=216732#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66622

Files:
  cfe/trunk/test/CodeGen/alias.c


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

2019-08-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D66486#1640203 , @mgehre wrote:

> In the false-positive example, after the `DerivedToBase`, we see a 
> constructor call which I think is the copy constructor.


Yeah, but we do not have problems with the copy constructors.

> 1. We should consider `MutableArrayRef` to be a gsl::Pointer according to the 
> paper, because it publicly derives from one.

So as soon as the user annotate a type as gsl::Pointer, this annotation should 
be applied to all derived classes? It would solve this particular issue. Also 
it feels a bit weird to change the ownership semantics in a derived class, I 
bet that would violate the Liskov substitution principle.

> 2. Also in the paper, the copy constructor does should copies the pset of the 
> argument instead of making the pointer point at the argument.

This is exactly what the warnings are doing now. If the first gsl::Pointer is 
constructed from a second gsl::Pointer, we will just check if the second 
gsl::Pointer will dangle at the and of the expression and so on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486



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


r369713 - [Bugfix] fix r369705 unit test

2019-08-22 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Thu Aug 22 16:18:46 2019
New Revision: 369713

URL: http://llvm.org/viewvc/llvm-project?rev=369713=rev
Log:
[Bugfix] fix r369705 unit test

Summary:
Aliases aren't supported on OSX.  Add a GNU target triple.

Reported-by: leonardchan
Reported-by: erik.pilkington

Reviewers: leonardchan, erik.pilkington

Reviewed By: leonardchan, erik.pilkington

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/CodeGen/alias.c

Modified: cfe/trunk/test/CodeGen/alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=369713=369712=369713=diff
==
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Thu Aug 22 16:18:46 2019
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0


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


[PATCH] D65239: [analyzer] RangeConstraintManager: Apply constraint ranges of bitwise operations

2019-08-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In overall I wanted to keep the [A, B] shape of the tests, but now they are 
more precise, thanks!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:503
+
+  if (!BinaryOperator::isBitwiseOrShiftOp(SIE->getOpcode()))
+return State;

NoQ wrote:
> I suspect we have problems with bitwise OR here, which (unlike other 
> bitwise/shift ops) may be true when the LHS is 0.
Whoops, thanks!



Comment at: clang/test/Analysis/bitwise-ranges.cpp:28
+  unsigned int D = X << 1;
+  clang_analyzer_eval((D >= 1 && D <= 4294967295) || D == 0);
+  // expected-warning@-1 {{TRUE}}

NoQ wrote:
> This check is trivially true regardless of the value of D or constraints on 
> it.
Hm, yes. I felt like `D` equals to `E`, but that test fails, so I have just 
removed them.


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

https://reviews.llvm.org/D65239



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216730.
Nathan-Huckleberry added a comment.

- Fix broken logic from previous revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c


Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 
'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // warning with -Wformat-pedantic only
+  printf("%hu\n", (uint8_t)1);   // warning with -Wformat-pedantic only
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+
+int printf(const char *restrict, ...);
+
+typedef unsigned char uint8_t;
+
+void print_char_as_short() {
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned 
char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -79,10 +79,10 @@
   printf("%hhd", input); // no-warning
   printf("%hhd", CharConstant); // no-warning
 
-  // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but 
the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 
'short'}}
-  
+  // This is not correct, but it is safe. Only warned in pedantic mode because 
'%hd' shows intent.
+  printf("%hd", input);
+  printf("%hd", CharConstant);
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8098,9 +8098,14 @@
   // function.
   if (ICE->getType() == S.Context.IntTy ||
   ICE->getType() == S.Context.UnsignedIntTy) {
-// All further checking is done on the subexpression.
-if (AT.matchesType(S.Context, ExprTy))
-  return true;
+// All further checking is done on the subexpression
+const analyze_printf::ArgType::MatchKind ImplicitMatch =
+AT.matchesType(S.Context, ExprTy);
+if (ImplicitMatch) {
+  if (ImplicitMatch == analyze_printf::ArgType::Match)
+return true;
+  Pedantic |= ImplicitMatch == 
analyze_printf::ArgType::NoMatchPedantic;
+}
   }
 }
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -386,6 +386,8 @@
   case 

[PATCH] D65239: [analyzer] RangeConstraintManager: Apply constraint ranges of bitwise operations

2019-08-22 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216731.
Charusso marked 7 inline comments as done.
Charusso edited the summary of this revision.
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D65239

Files:
  clang/include/clang/AST/Expr.h
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/bitwise-nullability.cpp
  clang/test/Analysis/bitwise-ranges.cpp

Index: clang/test/Analysis/bitwise-ranges.cpp
===
--- /dev/null
+++ clang/test/Analysis/bitwise-ranges.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -verify %s
+
+void clang_analyzer_eval(int);
+
+void test_range(unsigned int X) {
+  if (X < 2 || X > 3)
+return;
+
+  clang_analyzer_eval(X >= 2 && X <= 3);
+  // expected-warning@-1 {{TRUE}}
+
+  // We have no non-null constraint range information available for 'A'.
+  unsigned int A = X | 8;
+  clang_analyzer_eval(A == 0);
+  // expected-warning@-1 {{FALSE}}
+
+  unsigned int B = X & 8;
+  clang_analyzer_eval((B >= 1 && B <= 8) || B == 0);
+  // expected-warning@-1 {{TRUE}}
+
+  unsigned int C = X & 1;
+  clang_analyzer_eval(C == 1 || C == 0);
+  // expected-warning@-1 {{TRUE}}
+
+  void(X / 0);
+  // expected-warning@-1 {{division by zero is undefined}}
+  // expected-warning@-2 {{Division by zero}}
+}
Index: clang/test/Analysis/bitwise-nullability.cpp
===
--- /dev/null
+++ clang/test/Analysis/bitwise-nullability.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core \
+// RUN:  -analyzer-output=text -verify %s
+
+typedef unsigned long long uint64_t;
+
+void test_null_lhs_range_to_non_null_result_infeasible(uint64_t Magic) {
+  uint64_t MaskedMagic = Magic & (0xULL >> 13);
+
+  if (Magic) {
+// no-note: 'Assuming 'Magic' is 0' was here.
+return;
+  }
+
+  if (MaskedMagic) {
+// no-note: 'Assuming 'MaskedMagic' is not equal to 0' was here.
+(void)(1 / Magic); // no-warning
+  }
+}
+
+void test_non_null_lhs_range_to_null_result_feasible(uint64_t Magic) {
+  uint64_t MaskedMagic = Magic & (0xULL >> 13);
+
+  if (!Magic) {
+// expected-note@-1 {{Assuming 'Magic' is not equal to 0}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  }
+
+  if (!MaskedMagic) {
+// expected-note@-1 {{Assuming 'MaskedMagic' is 0}}
+// expected-note@-2 {{Taking true branch}}
+(void)(1 / !Magic);
+// expected-note@-1 {{'Magic' is not equal to 0}}
+// expected-note@-2 {{Division by zero}}
+// expected-warning@-3 {{Division by zero}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -476,6 +476,53 @@
   return Input;
 }
 
+// We do not support evaluating bitwise operations, so that when we check for
+// their results being null we create a new assumption whether the current new
+// symbol is null or non-null. If we are on the non-null assumption's branch
+// we need to check the left-hand side operand's constraint range informations:
+// - It if contradicts with the forming new range 'RS' then it returns a null
+//   state as it is an impossible condition.
+// - Otherwise it removes the nullability from its ranges as we know that it
+//   cannot be null on that branch (except bitwise OR).
+static ProgramStateRef applyBitwiseRanges(ProgramStateRef State,
+  BasicValueFactory ,
+  RangeSet::Factory , RangeSet RS,
+  SymbolRef Sym) {
+  if (RS.isEmpty())
+return State;
+
+  // If we cannot be sure whether the value is non-null, do nothing.
+  const llvm::APSInt  = BV.getAPSIntType(Sym->getType()).getZeroValue();
+  if (!RS.Intersect(BV, F, Zero, Zero).isEmpty())
+return State;
+
+  const SymIntExpr *SIE = dyn_cast(Sym);
+  if (!SIE)
+return State;
+
+  // Bitwise OR could be null.
+  BinaryOperator::Opcode Op = SIE->getOpcode();
+  if (!BinaryOperator::isBitwiseOrShiftOp(Op) || Op == BO_Or)
+return State;
+
+  ConstraintRangeTy Constraints = State->get();
+  const SymExpr *CurrentSym = SIE->getLHS();
+  if (const RangeSet *CurrentRS = Constraints.lookup(CurrentSym)) {
+const RangeSet NewRS = assumeNonZero(BV, F, CurrentSym, *CurrentRS);
+
+// If the 'NewRS' is not empty it means the 'CurrentSym' is not assumed
+// to be concrete zero, so it does not contradicts with the non-null
+// assumption and we could apply the new constraint ranges.
+if (!NewRS.isEmpty()) {
+  State 

[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-08-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

@thakis wrote:

> What was the motivation for firing on more than bare literals?

Well, fundamentally, there is no difference in code quality between any of 
these snippets:

  #define BIG 300
  double bigpower1() { return 10 ^ BIG; }
  
  static constexpr int BIG = 300; double bigpower2() { return 10 ^ BIG; }
  
  double bigpower3(int BIG) { return 10 ^ BIG; }
  
  double bigpower4(int BIG) { return 10 ^ (BIG+1); }
  
  minval -= 10 ^ -precision;  // 
https://codesearch.isocpp.org/actcd19/main/q/qgis/qgis_2.18.28+dfsg-2/src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
  intermediate = (str[offset] - '0') / (10 ^ lpc);  // 
https://codesearch.isocpp.org/actcd19/main/p/pacemaker/pacemaker_1.1.18-2/lib/common/iso8601.c
  real_loop += (((unsigned int) *argv[4]+k) - 48) * 10^(strlen(argv[4]) - 
(k+1));  // 
https://codesearch.isocpp.org/actcd19/main/liba/libaria/libaria_2.8.0+repack-1.2/tests/testCOM.cpp

If you seriously mean "xor", then you shouldn't be writing code that looks like 
you meant "exponentiate." I don't think it matters whether the LHS or RHS come 
from literals, macros, constexpr variables, const variables, function calls, 
additions, subtractions, or what-have-you. It seems reasonable, when you write 
`10 ^ x` or `2 ^ x` in C++, for the compiler to tell you about it so you can go 
fix it. (Admittedly it looks like a slippery slope to `int square(int n) { 
return n ^ 2; }` — but we can be data-driven here. There are no true-positive 
instances of `^ 2` in our corpus, whereas there are many true positives of `10 
^` and `2 ^`.)

To the target audience of this warning, the news about `^`'s semantics would be 
coming as a surprise. Not every user of C++ is a power user; and only power 
users would be like "I know `10 ^ alpha` means `alpha xor 0xA` and in fact 
that's exactly what I meant — please don't warn me about my code!"

However, if this is the version that gets committed, it's far better than 
nothing, and it can always be further tightened up later. (For example, this 
version doesn't yet warn about `bigpower3` et seq., right? It basically 
//only// hits the literal cases.)


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

https://reviews.llvm.org/D66397



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


[PATCH] D66572: [analyzer] BugReporter Separation Ep.I.

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

You got me convinced.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:223
+  using visitor_iterator = VisitorList::iterator;
+  using visitor_range = llvm::iterator_range;
+

I think I added a visitor range not long ago?


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

https://reviews.llvm.org/D66572



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

Please can you explain why the snippet i posted in-line does not work for you?




Comment at: clang/lib/Sema/SemaChecking.cpp:8105-8107
+  if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
   return true;

I do not understand this.
Even if you set `Pedantic = true`, you will immediately `return true` without 
ever using that `Pedantic`.
This seems broken?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66593: [analyzer] CastValueChecker: Fix some assertions

2019-08-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

These assertions are fundamental, so we can't remove them; i believe we messed 
up modeling at some point. I'll pick this up to address some nasty regressions 
quickly; i managed to reproduce the crashes and i already have 4 creduces 
running.




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:743-750
+  QualType RegionType = DynType.getType();
+  if (RegionType->isPointerType())
+RegionType = RegionType->getPointeeType();
+  else
+RegionType = RegionType.getNonReferenceType();
+
+  assert(!RegionType.isNull() &&

I don't think this does anything:
```lang=c++
   505 QualType Type::getPointeeType() const {
   506   if (const auto *PT = getAs())
   507 return PT->getPointeeType();
   508   if (const auto *OPT = getAs())
   509 return OPT->getPointeeType();
   510   if (const auto *BPT = getAs())
   511 return BPT->getPointeeType();
   512   if (const auto *RT = getAs())
   513 return RT->getPointeeType();
   514   if (const auto *MPT = getAs())
   515 return MPT->getPointeeType();
   516   if (const auto *DT = getAs())
   517 return DT->getPointeeType();
   518   return {};
   519 }
```
This getter usually works very reliably for both pointers and references.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:118-122
+  for (const auto  : Map) {
+const MemRegion *MR = Elem.first;
+if (MR && !SR.isLiveRegion(MR))
+  State = State->remove(MR);
+  }

We shouldn't put null regions into our maps.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:329-336
+  // FIXME: Make this assertion great again.
+  /* else {
 // We need to create a region no matter what. For sanity, make sure we 
don't
 // try to stuff a Loc into a non-pointer temporary region.
 assert(!InitValWithAdjustments.getAs() ||
Loc::isLocType(Result->getType()) ||
Result->getType()->isMemberPointerType());

This usually fails when we mess up lvalue/rvalue vs. loc/nonloc invariants in 
our modeling.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1079-1080
+// FIXME: Make this assertion great again.
+/*assert(isValidBaseClass(RD, dyn_cast(Super), 
IsVirtual));
+(void)*/
 

Ugh, i suspect that we can't pass through the original pointer in our cast 
modeling; we need to actually model pointer casts, which is annoying but 
necessary, given that the cast doesn't necessarily yield the same pointer value 
even in run-time (see multiple inheritance).


Repository:
  rC Clang

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

https://reviews.llvm.org/D66593



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216729.
Nathan-Huckleberry added a comment.

- Remove else and |=


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c


Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 
'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // warning with -Wformat-pedantic only
+  printf("%hu\n", (uint8_t)1);   // warning with -Wformat-pedantic only
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+
+int printf(const char *restrict, ...);
+
+typedef unsigned char uint8_t;
+
+void print_char_as_short() {
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned 
char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -79,10 +79,10 @@
   printf("%hhd", input); // no-warning
   printf("%hhd", CharConstant); // no-warning
 
-  // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but 
the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 
'short'}}
-  
+  // This is not correct, but it is safe. Only warned in pedantic mode because 
'%hd' shows intent.
+  printf("%hd", input);
+  printf("%hd", CharConstant);
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8098,9 +8098,14 @@
   // function.
   if (ICE->getType() == S.Context.IntTy ||
   ICE->getType() == S.Context.UnsignedIntTy) {
-// All further checking is done on the subexpression.
-if (AT.matchesType(S.Context, ExprTy))
+// All further checking is done on the subexpression
+const analyze_printf::ArgType::MatchKind ImplicitMatch =
+AT.matchesType(S.Context, ExprTy);
+if (ImplicitMatch) {
+  if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
   return true;
+}
   }
 }
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -386,6 +386,8 @@
   case BuiltinType::SChar:
   case BuiltinType::Char_U:
   case BuiltinType::UChar:
+ 

[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry marked an inline comment as done.
Nathan-Huckleberry added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8100-8107
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;

lebedev.ri wrote:
> lebedev.ri wrote:
> > Just add a new variable
> > ```
> > // All further checking is done on the subexpression
> > analyze_printf::ArgType::MatchKind Match2 = AT.matchesType(S.Context, 
> > ExprTy);
> > if (Match2 == analyze_printf::ArgType::Match)
> >   return true;
> > Pedantic |= Match2 == analyze_printf::ArgType::NoMatchPedantic;
> > ```
> Early return would simplify this still
Could be ArgType::NoMatch and wouldn't display a warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry marked an inline comment as done.
Nathan-Huckleberry added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8100-8107
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;

Nathan-Huckleberry wrote:
> lebedev.ri wrote:
> > lebedev.ri wrote:
> > > Just add a new variable
> > > ```
> > > // All further checking is done on the subexpression
> > > analyze_printf::ArgType::MatchKind Match2 = AT.matchesType(S.Context, 
> > > ExprTy);
> > > if (Match2 == analyze_printf::ArgType::Match)
> > >   return true;
> > > Pedantic |= Match2 == analyze_printf::ArgType::NoMatchPedantic;
> > > ```
> > Early return would simplify this still
> Could be ArgType::NoMatch and wouldn't display a warning
Wait this should definitely be an else-if


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry marked an inline comment as done.
Nathan-Huckleberry added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8100-8107
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;

Nathan-Huckleberry wrote:
> Nathan-Huckleberry wrote:
> > lebedev.ri wrote:
> > > lebedev.ri wrote:
> > > > Just add a new variable
> > > > ```
> > > > // All further checking is done on the subexpression
> > > > analyze_printf::ArgType::MatchKind Match2 = AT.matchesType(S.Context, 
> > > > ExprTy);
> > > > if (Match2 == analyze_printf::ArgType::Match)
> > > >   return true;
> > > > Pedantic |= Match2 == analyze_printf::ArgType::NoMatchPedantic;
> > > > ```
> > > Early return would simplify this still
> > Could be ArgType::NoMatch and wouldn't display a warning
> Wait this should definitely be an else-if
Nevermind you are correct. Will remove else case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66622: [Bugfix] fix r369705 unit test

2019-08-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for fixing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66622



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


[PATCH] D66556: [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings

2019-08-22 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Lex/DependencyDirectivesSourceMinimizer.cpp:213
+  unsigned Len = isEOL(First, End);
+  assert(Len);
+  First += Len;

Nit: Please add `&& "expected newline")` to the assert.



Comment at: lib/Lex/DependencyDirectivesSourceMinimizer.cpp:240
+if (!wasLineContinuation(First, Len))
   return;
 

This return now changes behavior of `skipToNewlineRaw` for the clients, as 
`First` is now right after the newline if this return is taken, as opposed to 
right before the newline, like it used to be before this patch. I think you 
need to move `First += Len` after this `return`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66556



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


[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

@leonardchan thanks for the report, would you mind reviewing: 
https://reviews.llvm.org/D66622?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492



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


Re: r369705 - [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Nick Desaulniers via cfe-commits
Thanks for the report, would you mind reviewing:
https://reviews.llvm.org/D66622?

On Thu, Aug 22, 2019 at 2:44 PM Erik Pilkington
 wrote:
>
> This commit is causing test failures on darwin:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/1464/consoleFull#-18314650158254eaf0-7326-4999-85b0-388101f2d404
>
> Looks like you need to add a triple to the RUN line you added. Can you fix 
> this?
>
> Thanks!
> Erik
>
> On Aug 22, 2019, at 1:47 PM, Nick Desaulniers via cfe-commits 
>  wrote:
>
> Author: nickdesaulniers
> Date: Thu Aug 22 13:47:12 2019
> New Revision: 369705
>
> URL: http://llvm.org/viewvc/llvm-project?rev=369705=rev
> Log:
> [Clang][CodeGen] set alias linkage on QualType
>
> Summary:
> It seems that CodeGen was always using ExternalLinkage when emitting a
> GlobalDecl with __attribute__((alias)). This leads to symbol
> redefinitions (ODR) that cause failures at link time for static aliases.
> This is readily attempting to link an ARM (32b) allyesconfig Linux
> kernel built with Clang.
>
> Reported-by: nathanchance
> Suggested-by: ihalip
> Link: https://bugs.llvm.org/show_bug.cgi?id=42377
> Link: https://github.com/ClangBuiltLinux/linux/issues/631
>
> Reviewers: rsmith, aaron.ballman, erichkeane
>
> Reviewed By: aaron.ballman
>
> Subscribers: javed.absar, kristof.beyls, cfe-commits, srhines, ihalip, 
> nathanchance
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D66492
>
> Modified:
>cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>cfe/trunk/test/CodeGen/alias.c
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=369705=369704=369705=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Aug 22 13:47:12 2019
> @@ -4363,17 +4363,22 @@ void CodeGenModule::EmitAliasDefinition(
>   // Create a reference to the named value.  This ensures that it is emitted
>   // if a deferred decl.
>   llvm::Constant *Aliasee;
> -  if (isa(DeclTy))
> +  llvm::GlobalValue::LinkageTypes LT;
> +  if (isa(DeclTy)) {
> Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
>   /*ForVTable=*/false);
> -  else
> +LT = getFunctionLinkage(GD);
> +  } else {
> Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
> llvm::PointerType::getUnqual(DeclTy),
> /*D=*/nullptr);
> +LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
> + D->getType().isConstQualified());
> +  }
>
>   // Create the new alias itself, but don't set a name yet.
> -  auto *GA = llvm::GlobalAlias::create(
> -  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
> +  auto *GA =
> +  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
>
>   if (Entry) {
> if (GA->getAliasee() == Entry) {
>
> Modified: cfe/trunk/test/CodeGen/alias.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=369705=369704=369705=diff
> ==
> --- cfe/trunk/test/CodeGen/alias.c (original)
> +++ cfe/trunk/test/CodeGen/alias.c Thu Aug 22 13:47:12 2019
> @@ -2,6 +2,7 @@
> // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
> -check-prefix=CHECKBASIC %s
> // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
> FileCheck -check-prefix=CHECKCC %s
> // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | 
> FileCheck -check-prefix=CHECKASM %s
> +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS 
> %s
>
> int g0;
> // CHECKBASIC-DAG: @g0 = common global i32 0
> @@ -88,3 +89,13 @@ void test8_zed() __attribute__((alias("t
> void test9_bar(void) { }
> void test9_zed(void) __attribute__((section("test")));
> void test9_zed(void) __attribute__((alias("test9_bar")));
> +
> +// Test that the alias gets its linkage from its declared qual type.
> +// CHECKGLOBALS: @test10_foo = internal
> +// CHECKGLOBALS-NOT: @test10_foo = dso_local
> +int test10;
> +static int test10_foo __attribute__((alias("test10")));
> +// CHECKGLOBALS: @test11_foo = internal
> +// CHECKGLOBALS-NOT: @test11_foo = dso_local
> +void test11(void) {}
> +static void test11_foo(void) __attribute__((alias("test11")));
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


-- 
Thanks,
~Nick Desaulniers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66622: [Bugfix] fix r369705 unit test

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: leonardchan, erik.pilkington.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Aliases aren't supported on OSX.  Add a GNU target triple.

Reported-by: leonardchan
Reported-by: erik.pilkington


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66622

Files:
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66404: [CFG] Make destructor calls more accurate

2019-08-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

This looks fantastic, thanks!

> Note: I don't have commit access.

I can commit this for you but i believe you should totally ask for it 
.




Comment at: test/Analysis/more-dtors-cfg-output.cpp:50
+// CXX14: (CXXConstructExpr{{.*}}, struct Foo)
+// CXX14: ~Foo() (Temporary object destructor)
+// CHECK: ~Foo() (Implicit destructor)

comex wrote:
> NoQ wrote:
> > Maybe also add `CXX20-NOT` so that to make sure that the destructor *isn't* 
> > there? (i think this applies to a lot of other tests)
> The `-implicit-check-not=destructor` handles that: it complains if any line 
> containing "destructor" isn't covered by a CHECK.
Ahaa, i see what you did here!



Comment at: test/Analysis/more-dtors-cfg-output.cpp:251-252
+void default_ctor_with_default_arg() {
+  // FIXME: The CFG records a construction of the array type but a destruction
+  // of the base type, which is inconsistent.  It really should should be
+  // emitting a loop, which should also contain the construction/destruction of

comex wrote:
> NoQ wrote:
> > Is it just mismatching dump styles or is it an actual error?
> Oops – it's actually just the printing code for implicit destructors that 
> does:
> 
> ```
> if (const ArrayType *AT = ACtx.getAsArrayType(T))
>   T = ACtx.getBaseElementType(AT);
> ```
> 
> I'm not sure why that's there: perhaps because `~Foo[]()` is not valid C++ 
> syntax, but there's plenty of other places in the printing code that can 
> print invalid syntax, and printing just `~Foo()` is misleading.
> For now, until this code is overhauled to emit loops for constructors and 
> destructors, I think it makes the most sense to remove those two lines.  I'll 
> do that in the updated patch.
I don't care if it's valid C++ syntax as long as it's readable/testable.

Another possible variant is `~Foo() (Array destructor)`, we seem to do this a 
lot.



Comment at: test/Analysis/more-dtors-cfg-output.cpp:273
+#if CXX2A
+// Boilerplate needed to test co_return:
+

comex wrote:
> NoQ wrote:
> > Feel free to move this into 
> > `test/Analysis/inputs/system-header-simulator-cxx.h`, we could always use 
> > more mocks in there.
> Well, `TestPromise` is a bit specific to this test.  In particular, the 
> `return_value` method would normally return `void`, but I have it return a 
> `Foo`, which just gets discarded, in order to check that the corresponding 
> destructor call is recorded properly.
> 
> The non-test-specific boilerplate is <10 lines of code.  I could add it to 
> `system-header-simulator-cxx.h`, but then I'd have to figure out how to make 
> sure that this test file doesn't get confused by CFG output from any inline 
> functions defined there, especially given the `-implicit-check-not` flag.  
> Right now almost all function implementations in the header are within a 
> template and thus won't produce CFG (or IR or other analysis) output by 
> themselves, so the solution would probably consist of merely adding a comment 
> to `system-header-simulator-cxx.h`, requesting that any future additions be 
> either similarly templated or hidden behind an #ifdef.  That's definitely 
> feasible, but it doesn't seem worth dealing with for such a small amount of 
> code. :)
> 
> However, I need to fix the indentation and improve the wording of the comment 
> in `coreturn`.
Ok np then!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66404



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

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

Aha okay :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

I think this patch might be causing some test failures on our mac bots:

  FAIL: Clang :: CodeGen/alias.c (2014 of 15397)
   TEST 'Clang :: CodeGen/alias.c' FAILED 

  Script:
  --
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -triple i386-pc-linux-gnu -emit-llvm -o - 
/b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c | 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/FileCheck 
-check-prefix=CHECKBASIC /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c
  : 'RUN: at line 3';   
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - 
/b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c | 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/FileCheck 
-check-prefix=CHECKCC /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c
  : 'RUN: at line 4';   
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -triple armv7a-eabi -mfloat-abi hard -S -o - 
/b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c | 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/FileCheck 
-check-prefix=CHECKASM /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c
  : 'RUN: at line 5';   
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/lib/clang/10.0.0/include 
-nostdsysteminc -emit-llvm -o - 
/b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c | 
/b/s/w/ir/k/recipe_cleanup/clangVieak_/llvm_build_dir/bin/FileCheck 
-check-prefix=CHECKGLOBALS /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:87:33: warning: alias 
will always resolve to test8_bar even if weak definition of test8_foo is 
overridden
  void test8_zed() __attribute__((alias("test8_foo")));
  ^
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:90:37: warning: alias 
will not be in section 'test' but in the same section as the aliasee
  void test9_zed(void) __attribute__((section("test")));
  ^
  2 warnings generated.
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:87:33: warning: alias 
will always resolve to test8_bar even if weak definition of test8_foo is 
overridden
  void test8_zed() __attribute__((alias("test8_foo")));
  ^
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:90:37: warning: alias 
will not be in section 'test' but in the same section as the aliasee
  void test9_zed(void) __attribute__((section("test")));
  ^
  2 warnings generated.
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:87:33: warning: alias 
will always resolve to test8_bar even if weak definition of test8_foo is 
overridden
  void test8_zed() __attribute__((alias("test8_foo")));
  ^
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:90:37: warning: alias 
will not be in section 'test' but in the same section as the aliasee
  void test9_zed(void) __attribute__((section("test")));
  ^
  2 warnings generated.
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:24:57: error: aliases are 
not supported on darwin
  extern const int __mod_usb_device_table __attribute__ 
((alias("wacom_usb_ids")));
  ^
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:31:28: error: aliases are 
not supported on darwin
  extern int g1 __attribute((alias("g0")));
 ^
  /b/s/w/ir/k/llvm-project/clang/test/CodeGen/alias.c:37:50: error: aliases are 
not supported on darwin
  extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
   ^
  ... A bunch more like this
  
  --
  
  
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 126.01s
  
  Failing Tests (1):
  Clang :: CodeGen/alias.c

Could you take a look? Thanks.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492



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


[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2019-08-22 Thread Wei Mi via Phabricator via cfe-commits
wmi added a comment.

In D36562#1639441 , @chill wrote:

> Shouldn't we disable `OPT_ffine_grained_bitfield_accesses` only if TSAN is 
> active?


I don't remember why it is disabled for all sanitizer modes. Seems you are 
right that the disabling the option is only necessary for TSAN. Do you have 
actual needs for the option to be functioning on other sanitizer modes?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D36562



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-22 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

That appears sort of tangential to me. To clarify, this PR is not (necessarily) 
about devirtualizing destructors themselves, but rather devirtualizing OTHER 
member function calls for classes whose destructor is marked `final`, since 
that is sort of morally equivalent to marking the entire class `final`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-08-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 216724.

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

https://reviews.llvm.org/D66397

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -10,8 +10,10 @@
 #define XOR(x, y) (x ^ y)
 #define TWO 2
 #define TEN 10
+#define IOP 64
 #define TWO_ULL 2ULL
 #define EPSILON 10 ^ -300
+#define ALPHA_OFFSET 3
 
 #define flexor 7
 
@@ -21,7 +23,7 @@
 constexpr long long operator"" _0b(unsigned long long v) { return v; }
 constexpr long long operator"" _0X(unsigned long long v) { return v; }
 #else
-#define xor^ // iso646.h
+#define xor ^ // iso646.h
 #endif
 
 void test(unsigned a, unsigned b) {
@@ -32,25 +34,25 @@
   res = 2 ^ -1;
   res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
-  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
-  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ +8; // expected-warning {{result of '2 ^ +8' is 10; did you mean '1 << +8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << +8"
+  // expected-note@-2 {{replace expression with '0x2 ^ +8' or use 'xor' instead of '^' to silence this warning}}
+  res = TWO ^ 8;
   res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
-  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
-  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
-  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ TEN;
+  res = res + (2 ^ ALPHA_OFFSET);
   res = 0x2 ^ 16;
   res = 2 xor 16;
 
@@ -69,31 +71,50 @@
   res = TWO_ULL ^ 16;
   res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
-  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
-  res = 2 ^ 64;
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean '-1LL'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"-1LL"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+#define ULLONG_MAX 18446744073709551615ULL
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"ULLONG_MAX"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 2;
+  res = (2 ^ IOP) - 1;
+  res = (2 ^ 64) - 1u; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:22}:"ULLONG_MAX"
+  // expected-note@-2 

[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-08-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 216723.

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

https://reviews.llvm.org/D66397

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -10,8 +10,10 @@
 #define XOR(x, y) (x ^ y)
 #define TWO 2
 #define TEN 10
+#define IOP 64
 #define TWO_ULL 2ULL
 #define EPSILON 10 ^ -300
+#define ALPHA_OFFSET 3
 
 #define flexor 7
 
@@ -21,7 +23,7 @@
 constexpr long long operator"" _0b(unsigned long long v) { return v; }
 constexpr long long operator"" _0X(unsigned long long v) { return v; }
 #else
-#define xor^ // iso646.h
+#define xor ^ // iso646.h
 #endif
 
 void test(unsigned a, unsigned b) {
@@ -32,25 +34,25 @@
   res = 2 ^ -1;
   res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
-  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
-  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ +8; // expected-warning {{result of '2 ^ +8' is 10; did you mean '1 << +8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << +8"
+  // expected-note@-2 {{replace expression with '0x2 ^ +8' or use 'xor' instead of '^' to silence this warning}}
+  res = TWO ^ 8;
   res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
-  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
-  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
-  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ TEN;
+  res = res + (2 ^ ALPHA_OFFSET);
   res = 0x2 ^ 16;
   res = 2 xor 16;
 
@@ -69,31 +71,50 @@
   res = TWO_ULL ^ 16;
   res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
-  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
-  res = 2 ^ 64;
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean '-1LL'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"-1LL"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+#define ULLONG_MAX 18446744073709551615ULL
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"ULLONG_MAX"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 2;
+  res = (2 ^ IOP) - 1;
+  res = (2 ^ 64) - 1u; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:22}:"ULLONG_MAX"
+  // expected-note@-2 

Re: r369705 - [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Erik Pilkington via cfe-commits
This commit is causing test failures on darwin:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/1464/consoleFull#-18314650158254eaf0-7326-4999-85b0-388101f2d404
 


Looks like you need to add a triple to the RUN line you added. Can you fix this?

Thanks!
Erik

> On Aug 22, 2019, at 1:47 PM, Nick Desaulniers via cfe-commits 
>  wrote:
> 
> Author: nickdesaulniers
> Date: Thu Aug 22 13:47:12 2019
> New Revision: 369705
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=369705=rev
> Log:
> [Clang][CodeGen] set alias linkage on QualType
> 
> Summary:
> It seems that CodeGen was always using ExternalLinkage when emitting a
> GlobalDecl with __attribute__((alias)). This leads to symbol
> redefinitions (ODR) that cause failures at link time for static aliases.
> This is readily attempting to link an ARM (32b) allyesconfig Linux
> kernel built with Clang.
> 
> Reported-by: nathanchance
> Suggested-by: ihalip
> Link: https://bugs.llvm.org/show_bug.cgi?id=42377
> Link: https://github.com/ClangBuiltLinux/linux/issues/631
> 
> Reviewers: rsmith, aaron.ballman, erichkeane
> 
> Reviewed By: aaron.ballman
> 
> Subscribers: javed.absar, kristof.beyls, cfe-commits, srhines, ihalip, 
> nathanchance
> 
> Tags: #clang
> 
> Differential Revision: https://reviews.llvm.org/D66492
> 
> Modified:
>cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>cfe/trunk/test/CodeGen/alias.c
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=369705=369704=369705=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Aug 22 13:47:12 2019
> @@ -4363,17 +4363,22 @@ void CodeGenModule::EmitAliasDefinition(
>   // Create a reference to the named value.  This ensures that it is emitted
>   // if a deferred decl.
>   llvm::Constant *Aliasee;
> -  if (isa(DeclTy))
> +  llvm::GlobalValue::LinkageTypes LT;
> +  if (isa(DeclTy)) {
> Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
>   /*ForVTable=*/false);
> -  else
> +LT = getFunctionLinkage(GD);
> +  } else {
> Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
> llvm::PointerType::getUnqual(DeclTy),
> /*D=*/nullptr);
> +LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
> + D->getType().isConstQualified());
> +  }
> 
>   // Create the new alias itself, but don't set a name yet.
> -  auto *GA = llvm::GlobalAlias::create(
> -  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
> +  auto *GA =
> +  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
> 
>   if (Entry) {
> if (GA->getAliasee() == Entry) {
> 
> Modified: cfe/trunk/test/CodeGen/alias.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=369705=369704=369705=diff
> ==
> --- cfe/trunk/test/CodeGen/alias.c (original)
> +++ cfe/trunk/test/CodeGen/alias.c Thu Aug 22 13:47:12 2019
> @@ -2,6 +2,7 @@
> // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
> -check-prefix=CHECKBASIC %s
> // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
> FileCheck -check-prefix=CHECKCC %s
> // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | 
> FileCheck -check-prefix=CHECKASM %s
> +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS 
> %s
> 
> int g0;
> // CHECKBASIC-DAG: @g0 = common global i32 0
> @@ -88,3 +89,13 @@ void test8_zed() __attribute__((alias("t
> void test9_bar(void) { }
> void test9_zed(void) __attribute__((section("test")));
> void test9_zed(void) __attribute__((alias("test9_bar")));
> +
> +// Test that the alias gets its linkage from its declared qual type.
> +// CHECKGLOBALS: @test10_foo = internal
> +// CHECKGLOBALS-NOT: @test10_foo = dso_local
> +int test10;
> +static int test10_foo __attribute__((alias("test10")));
> +// CHECKGLOBALS: @test11_foo = internal
> +// CHECKGLOBALS-NOT: @test11_foo = dso_local
> +void test11(void) {}
> +static void test11_foo(void) __attribute__((alias("test11")));
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

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

Removed macro support (again...).

I agree with Nico, this warning is on by default so should be as exact as 
possible without many false positives. While we all know that the Chromium's 
false positive case could be rewritten for better code readability, on the 
other side Clang's default warnings shouldn't be annoying.

Nico, PTAL and possibly approve.


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

https://reviews.llvm.org/D66397



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

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

https://reviews.llvm.org/rGcb30590da10ba80a133222588efedab7e5fc9bdd does not 
help here?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621



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


[PATCH] D66573: [clang][ifs] Dropping older experimental interface stub formats.

2019-08-22 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 216722.
plotfi added a comment.

Better diag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66573

Files:
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/externstatic.c
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/hidden-class-inheritance.cpp
  clang/test/InterfaceStubs/inline.c
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/virtual.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- clang/test/InterfaceStubs/weak.cpp
+++ clang/test/InterfaceStubs/weak.cpp
@@ -1,12 +1,8 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck %s
 
-// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
-// RUN: FileCheck --check-prefix=CHECK-YAML %s
-
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | \
 // RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
 
@@ -14,14 +10,6 @@
 // CHECK-DAG:  _Z8weakFuncv: { Type: Func, Weak: true }
 // CHECK-DAG:  _Z10strongFuncv: { Type: Func }
 
-// CHECK-YAML: Symbols:
-// CHECK-YAML-DAG:   - Name:_Z8weakFuncv
-// CHECK-YAML-DAG: Type:STT_FUNC
-// CHECK-YAML-DAG: Binding: STB_WEAK
-// CHECK-YAML-DAG:   - Name:_Z10strongFuncv
-// CHECK-YAML-DAG: Type:STT_FUNC
-// CHECK-YAML-DAG: Binding: STB_GLOBAL
-
 // CHECK-SYMBOLS-DAG: _Z10strongFuncv
 // CHECK-SYMBOLS-DAG: _Z8weakFuncv
 __attribute__((weak)) void weakFunc() {}
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- clang/test/InterfaceStubs/visibility.cpp
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -1,26 +1,26 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden \
+// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
 // RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden \
+// RUN: -interface-stub-version=experimental-ifs-v1 -fvisibility=hidden \
 // RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck --check-prefix=CHECK-CMD2 %s
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
Index: clang/test/InterfaceStubs/virtual.cpp
===
--- clang/test/InterfaceStubs/virtual.cpp
+++ clang/test/InterfaceStubs/virtual.cpp
@@ -1,9 +1,9 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: -interface-stub-version=experimental-ifs-v1 %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
-// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \

[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-08-22 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 216720.
xbolva00 added a comment.

Addressed Bruno Ricci's tips.
Removed macro support.


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

https://reviews.llvm.org/D66397

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -10,8 +10,10 @@
 #define XOR(x, y) (x ^ y)
 #define TWO 2
 #define TEN 10
+#define IOP 64
 #define TWO_ULL 2ULL
 #define EPSILON 10 ^ -300
+#define ALPHA_OFFSET 3
 
 #define flexor 7
 
@@ -21,7 +23,7 @@
 constexpr long long operator"" _0b(unsigned long long v) { return v; }
 constexpr long long operator"" _0X(unsigned long long v) { return v; }
 #else
-#define xor^ // iso646.h
+#define xor ^ // iso646.h
 #endif
 
 void test(unsigned a, unsigned b) {
@@ -32,25 +34,25 @@
   res = 2 ^ -1;
   res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
-  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
-  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ +8; // expected-warning {{result of '2 ^ +8' is 10; did you mean '1 << +8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << +8"
+  // expected-note@-2 {{replace expression with '0x2 ^ +8' or use 'xor' instead of '^' to silence this warning}}
+  res = TWO ^ 8;
   res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
-  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
-  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
-  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ TEN;
+  res = res + (2 ^ ALPHA_OFFSET);
   res = 0x2 ^ 16;
   res = 2 xor 16;
 
@@ -69,31 +71,50 @@
   res = TWO_ULL ^ 16;
   res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
-  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
-  res = 2 ^ 64;
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean '-1LL'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"-1LL"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+#define ULLONG_MAX 18446744073709551615ULL
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"ULLONG_MAX"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 2;
+  res = (2 ^ IOP) - 1;
+  res = (2 ^ 64) - 1u; // expected-warning {{result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?}}
+  // CHECK: 

[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8106
+  if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic |= true;
+  else

I don't think this needs to use `|= true`. If `Pedantic` was true, this is a 
noop. If it was false, this sets it to true. Either way the value is true, so I 
think it should just be `Pedantic = true;` The logic gets easier if you write 
this as:
```
if (ImplicitMatch && ImplicitMatch != analyze_printf::ArgType::NoMatchPedantic)
  return true;
Pedantic |= ImplicitMatch;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66559: [OPENMP] Update the diagnosis message for canonical loop form

2019-08-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D66559#1641827 , @cchen wrote:

> Is there any way that I can find the OpenMP version in Clang? I couldn't find 
> any example in source code. Thanks.


LangOpts.OpenMP has the version of OpenMP. For OpenMP 5.0 this value is set to 
50.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66559



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


[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

2019-08-22 Thread Logan Smith via Phabricator via cfe-commits
logan-5 created this revision.
logan-5 added a reviewer: rsmith.
logan-5 added a project: clang.
Herald added subscribers: cfe-commits, Prazek.

A class with a destructor marked `final` cannot be derived from, so it should 
afford the same devirtualization opportunities as marking the entire class 
`final`.


Repository:
  rC Clang

https://reviews.llvm.org/D66621

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp


Index: clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -24,6 +24,20 @@
   }
 }
 
+namespace Test2a {
+  struct A {
+virtual ~A() final {}
+virtual int f();
+  };
+
+  // CHECK-LABEL: define i32 @_ZN6Test2a1fEPNS_1AE
+  int f(A *a) {
+// CHECK: call i32 @_ZN6Test2a1A1fEv
+return a->f();
+  }
+}
+
+
 namespace Test3 {
   struct A {
 virtual int f();
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2067,9 +2067,11 @@
   if (DevirtualizedMethod->hasAttr())
 return DevirtualizedMethod;
 
-  // Similarly, if the class itself is marked 'final' it can't be overridden
-  // and we can therefore devirtualize the member function call.
-  if (BestDynamicDecl->hasAttr())
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be overridden and we can therefore devirtualize the 
+  // member function call.
+  if (BestDynamicDecl->hasAttr() ||
+  BestDynamicDecl->getDestructor()->hasAttr())
 return DevirtualizedMethod;
 
   if (const auto *DRE = dyn_cast(Base)) {


Index: clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
===
--- clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -24,6 +24,20 @@
   }
 }
 
+namespace Test2a {
+  struct A {
+virtual ~A() final {}
+virtual int f();
+  };
+
+  // CHECK-LABEL: define i32 @_ZN6Test2a1fEPNS_1AE
+  int f(A *a) {
+// CHECK: call i32 @_ZN6Test2a1A1fEv
+return a->f();
+  }
+}
+
+
 namespace Test3 {
   struct A {
 virtual int f();
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2067,9 +2067,11 @@
   if (DevirtualizedMethod->hasAttr())
 return DevirtualizedMethod;
 
-  // Similarly, if the class itself is marked 'final' it can't be overridden
-  // and we can therefore devirtualize the member function call.
-  if (BestDynamicDecl->hasAttr())
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be overridden and we can therefore devirtualize the 
+  // member function call.
+  if (BestDynamicDecl->hasAttr() ||
+  BestDynamicDecl->getDestructor()->hasAttr())
 return DevirtualizedMethod;
 
   if (const auto *DRE = dyn_cast(Base)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66555: [driver] add a new option `-gen-cdb-fragment-path` to emit a fragment of a compilation database for each compilation

2019-08-22 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 216717.
arphaman added a comment.
Herald added a subscriber: ributzka.

Reimplement the new option on top of `-MJ`. `-MJ` is still the preferred option 
if both are specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66555

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/gen-cdb-fragment.c

Index: clang/test/Driver/gen-cdb-fragment.c
===
--- /dev/null
+++ clang/test/Driver/gen-cdb-fragment.c
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t.cdb
+// RUN: %clang -target x86_64-apple-macos10.15 -c %s -o -  -gen-cdb-fragment-path %t.cdb
+// RUN: ls %t.cdb | FileCheck --check-prefix=CHECK-LS %s
+// CHECK-LS: gen-cdb-fragment.c.{{.*}}.json
+
+// RUN: cat %t.cdb/*.json | FileCheck --check-prefix=CHECK %s
+// CHECK: { "directory": "{{.*}}", "file": "{{.*}}gen-cdb-fragment.c", "output": "-", "arguments": [{{.*}}, "--target=x86_64-apple-macos10.15"{{.*}}]},
+// RUN: cat %t.cdb/*.json | FileCheck --check-prefix=CHECK-FLAG %s
+// CHECK-FLAG-NOT: -gen-cdb-fragment-path
+
+// RUN: rm -rf %t.cdb
+// RUN: mkdir %t.cdb
+// RUN: ls %t.cdb | not FileCheck --check-prefix=CHECK-LS %s
+// RUN: %clang -target x86_64-apple-macos10.15 -S %s -o -  -gen-cdb-fragment-path %t.cdb
+// RUN: ls %t.cdb | FileCheck --check-prefix=CHECK-LS %s
+
+// Empty path is equivalent to '.'
+// RUN: rm -rf %t.cdb
+// RUN: mkdir %t.cdb
+// RUN: %clang -target x86_64-apple-macos10.15 -working-directory %t.cdb -c %s -o -  -gen-cdb-fragment-path ""
+// RUN: ls %t.cdb | FileCheck --check-prefix=CHECK-LS %s
+
+// -### does not emit the CDB fragment
+// RUN: rm -rf %t.cdb
+// RUN: mkdir %t.cdb
+// RUN: %clang -target x86_64-apple-macos10.15 -S %s -o -  -gen-cdb-fragment-path %t.cdb -###
+// RUN: ls %t.cdb | not FileCheck --check-prefix=CHECK-LS %s
+
+// -MJ is preferred over -gen-cdb-fragment-path
+// RUN: rm -rf %t.cdb
+// RUN: mkdir %t.cdb
+// RUN: %clang -target x86_64-apple-macos10.15 -S %s -o -  -gen-cdb-fragment-path %t.cdb -MJ %t.out
+// RUN: ls %t.cdb | not FileCheck --check-prefix=CHECK-LS %s
+// RUN: FileCheck %s < %t.out
Index: clang/lib/Driver/ToolChains/Clang.h
===
--- clang/lib/Driver/ToolChains/Clang.h
+++ clang/lib/Driver/ToolChains/Clang.h
@@ -95,6 +95,10 @@
const InputInfo , const InputInfo ,
const llvm::opt::ArgList ) const;
 
+  void DumpCompilationDatabaseFragmentToDir(
+  StringRef Dir, Compilation , StringRef Target, const InputInfo ,
+  const InputInfo , const llvm::opt::ArgList ) const;
+
 public:
   Clang(const ToolChain );
   ~Clang() override;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2037,6 +2037,8 @@
 // Skip writing dependency output and the compilation database itself.
 if (O.getGroup().isValid() && O.getGroup().getID() == options::OPT_M_Group)
   continue;
+if (O.getID() == options::OPT_gen_cdb_fragment_path)
+  continue;
 // Skip inputs.
 if (O.getKind() == Option::InputClass)
   continue;
@@ -2051,6 +2053,47 @@
   CDB << ", \"" << escape(Buf) << "\"]},\n";
 }
 
+void Clang::DumpCompilationDatabaseFragmentToDir(
+StringRef Dir, Compilation , StringRef Target, const InputInfo ,
+const InputInfo , const llvm::opt::ArgList ) const {
+  // If this is a dry run, do not create the compilation database file.
+  if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
+return;
+
+  if (CompilationDatabase)
+DumpCompilationDatabase(C, "", Target, Output, Input, Args);
+
+  const auto  = C.getDriver();
+  auto CWD = Driver.getVFS().getCurrentWorkingDirectory();
+  if (!CWD) {
+Driver.Diag(diag::err_drv_emit_cdb_fragment_dir_failure)
+<< CWD.getError().message();
+return;
+  }
+
+  SmallString<256> Path = Dir;
+  Driver.getVFS().makeAbsolute(Path);
+  auto Err = llvm::sys::fs::create_directory(Path, /*IgnoreExisting=*/true);
+  if (Err) {
+Driver.Diag(diag::err_drv_emit_cdb_fragment_dir_failure) << Err.message();
+return;
+  }
+
+  llvm::sys::path::append(
+  Path,
+  Twine(llvm::sys::path::filename(Input.getFilename())) + "..json");
+  int FD;
+  SmallString<256> TempPath;
+  Err = llvm::sys::fs::createUniqueFile(Path, FD, TempPath);
+  if (Err) {
+Driver.Diag(diag::err_drv_compilationdatabase) << Err.message();
+return;
+  }
+  CompilationDatabase =
+  std::make_unique(FD, /*shouldClose=*/true);
+  DumpCompilationDatabase(C, "", Target, Output, Input, Args);
+}
+
 static void 

[PATCH] D66555: [driver] add a new option `-gen-cdb-fragment-path` to emit a fragment of a compilation database for each compilation

2019-08-22 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@jkorous I addressed your comments as well ("" directory is now allowed, error 
is reported, existing escape used).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66555



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


[PATCH] D66559: [OPENMP] Update the diagnosis message for canonical loop form

2019-08-22 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

Is there any way that I can find the OpenMP version in Clang? I couldn't find 
any example in source code. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66559



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


[PATCH] D54441: [OPENMP] Support relational-op !- (not-equal) as one of the canonical forms of random access iterator

2019-08-22 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54441



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8100-8107
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;

lebedev.ri wrote:
> Just add a new variable
> ```
> // All further checking is done on the subexpression
> analyze_printf::ArgType::MatchKind Match2 = AT.matchesType(S.Context, ExprTy);
> if (Match2 == analyze_printf::ArgType::Match)
>   return true;
> Pedantic |= Match2 == analyze_printf::ArgType::NoMatchPedantic;
> ```
Early return would simplify this still


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216713.
Nathan-Huckleberry added a comment.

- Add variable for implicit match and fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c


Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 
'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // warning with -Wformat-pedantic only
+  printf("%hu\n", (uint8_t)1);   // warning with -Wformat-pedantic only
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+
+int printf(const char *restrict, ...);
+
+typedef unsigned char uint8_t;
+
+void print_char_as_short() {
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned 
char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -79,10 +79,10 @@
   printf("%hhd", input); // no-warning
   printf("%hhd", CharConstant); // no-warning
 
-  // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but 
the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 
'short'}}
-  
+  // This is not correct, but it is safe. Only warned in pedantic mode because 
'%hd' shows intent.
+  printf("%hd", input);
+  printf("%hd", CharConstant);
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8098,9 +8098,15 @@
   // function.
   if (ICE->getType() == S.Context.IntTy ||
   ICE->getType() == S.Context.UnsignedIntTy) {
-// All further checking is done on the subexpression.
-if (AT.matchesType(S.Context, ExprTy))
-  return true;
+// All further checking is done on the subexpression
+const analyze_printf::ArgType::MatchKind ImplicitMatch =
+AT.matchesType(S.Context, ExprTy);
+if (ImplicitMatch) {
+  if (ImplicitMatch == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic |= true;
+  else
+return true;
+}
   }
 }
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
Index: clang/lib/AST/FormatString.cpp
===
--- clang/lib/AST/FormatString.cpp
+++ clang/lib/AST/FormatString.cpp
@@ -386,6 +386,8 @@
   case BuiltinType::SChar:
  

[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8101
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {

Maybe leave the top level Match const and just create a new one?  It may be 
surprising if someone goes to reuse `Match` below not noticing that it may be 
modified here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/format-strings-enum-fixed-type.cpp:82
 
   // This is not correct but it is safe. We warn because '%hd' shows intent.
+  printf("%hd", input);// no-warning

aaron.ballman wrote:
> This comment is now incorrect.
Not quite what I had in mind. I would remove the `// no-warning` comments that 
were added and instead change the comment on line 82 to say `This is not 
correct, but it is safe. Only warned in pedantic mode because '%hd' shows 
intent.` or something along those lines.



Comment at: clang/test/Sema/format-strings.c:280-281
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 
'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies 
type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // no-warning
+  printf("%hu\n", (uint8_t)1);   // no-warning
 }

I'd drop the `no-warning` comments here, or say `warning with -Wformat-pedantic 
only` if you think it adds value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:8080-8083
+  analyze_printf::ArgType::MatchKind Match = AT.matchesType(S.Context, ExprTy);
   bool Pedantic = Match == analyze_printf::ArgType::NoMatchPedantic;
   if (Match == analyze_printf::ArgType::Match)
 return true;

`Match` isn't used outside of this block later on, so i don't think you need 
*this* change.



Comment at: clang/lib/Sema/SemaChecking.cpp:8100-8107
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;

Just add a new variable
```
// All further checking is done on the subexpression
analyze_printf::ArgType::MatchKind Match2 = AT.matchesType(S.Context, ExprTy);
if (Match2 == analyze_printf::ArgType::Match)
  return true;
Pedantic |= Match2 == analyze_printf::ArgType::NoMatchPedantic;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186



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


[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369705: [Clang][CodeGen] set alias linkage on QualType 
(authored by nickdesaulniers, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66492?vs=216697=216703#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66492

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGen/alias.c


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias itself, but don't set a name yet.
-  auto *GA = llvm::GlobalAlias::create(
-  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
+  auto *GA =
+  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
 
   if (Entry) {
 if (GA->getAliasee() == Entry) {


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
   

[PATCH] D66505: Make add_new_check.py's insertion of registerCheck<> more closely match the sort order

2019-08-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: alexfh, djasper, JonasToth.
aaron.ballman added a comment.

Given that the alphabetization we want really is based on the string literal, 
would it make sense to look for that rather than the check name? Adding a few 
more reviewers for a better mix of opinions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66505



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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

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

>> What was the motivation for firing on more than bare literals?

First patch supported diagnosing macros. There is no exact motivation why, 
simply “I just did it” to present working prototype. Based on review, things 
were adjusted.

Some reviewers wanted to keep full macro support, some didnt like diagnose ^ in 
macros. That case was removed.

I think nobody complained about macro as LHS/RHS.


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

https://reviews.llvm.org/D66397



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


r369705 - [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Thu Aug 22 13:47:12 2019
New Revision: 369705

URL: http://llvm.org/viewvc/llvm-project?rev=369705=rev
Log:
[Clang][CodeGen] set alias linkage on QualType

Summary:
It seems that CodeGen was always using ExternalLinkage when emitting a
GlobalDecl with __attribute__((alias)). This leads to symbol
redefinitions (ODR) that cause failures at link time for static aliases.
This is readily attempting to link an ARM (32b) allyesconfig Linux
kernel built with Clang.

Reported-by: nathanchance
Suggested-by: ihalip
Link: https://bugs.llvm.org/show_bug.cgi?id=42377
Link: https://github.com/ClangBuiltLinux/linux/issues/631

Reviewers: rsmith, aaron.ballman, erichkeane

Reviewed By: aaron.ballman

Subscribers: javed.absar, kristof.beyls, cfe-commits, srhines, ihalip, 
nathanchance

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/alias.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=369705=369704=369705=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Aug 22 13:47:12 2019
@@ -4363,17 +4363,22 @@ void CodeGenModule::EmitAliasDefinition(
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias itself, but don't set a name yet.
-  auto *GA = llvm::GlobalAlias::create(
-  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
+  auto *GA =
+  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
 
   if (Entry) {
 if (GA->getAliasee() == Entry) {

Modified: cfe/trunk/test/CodeGen/alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=369705=369704=369705=diff
==
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Thu Aug 22 13:47:12 2019
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@ void test8_zed() __attribute__((alias("t
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));


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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216702.
Nathan-Huckleberry added a comment.

- Cleanup test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c

Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // no-warning
+  printf("%hu\n", (uint8_t)1);   // no-warning
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem %S/Inputs %s
+
+int printf(const char *restrict, ...);
+
+typedef unsigned char uint8_t;
+
+void print_char_as_short() {
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -80,9 +80,9 @@
   printf("%hhd", CharConstant); // no-warning
 
   // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 'short'}}
-  
+  printf("%hd", input);// no-warning
+  printf("%hd", CharConstant); // no-warning
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8077,8 +8077,7 @@
 ExprTy = TET->getUnderlyingExpr()->getType();
   }
 
-  const analyze_printf::ArgType::MatchKind Match =
-  AT.matchesType(S.Context, ExprTy);
+  analyze_printf::ArgType::MatchKind Match = AT.matchesType(S.Context, ExprTy);
   bool Pedantic = Match == analyze_printf::ArgType::NoMatchPedantic;
   if (Match == analyze_printf::ArgType::Match)
 return true;
@@ -8098,9 +8097,14 @@
   // function.
   if (ICE->getType() == S.Context.IntTy ||
   ICE->getType() == S.Context.UnsignedIntTy) {
-// All further checking is done on the subexpression.
-if (AT.matchesType(S.Context, ExprTy))
-  return true;
+// All further checking is done on the subexpression
+Match = AT.matchesType(S.Context, ExprTy);
+if (Match) {
+  if (Match == analyze_printf::ArgType::NoMatchPedantic)
+Pedantic = true;
+  else
+return true;
+}
   }
 }
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
Index: clang/lib/AST/FormatString.cpp
===
--- 

[PATCH] D66302: [SVE][Inline-Asm] Support for SVE asm operands

2019-08-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Thanks for making these changes @kmclaughlin, LGTM!


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

https://reviews.llvm.org/D66302



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


[PATCH] D66186: [Sema] Don't warn on printf('%hd', [char]) (PR41467)

2019-08-22 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 216699.
Nathan-Huckleberry added a comment.

- Warn when -Wformat-pedantic is set


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66186

Files:
  clang/lib/AST/FormatString.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m
  clang/test/Sema/format-strings-enum-fixed-type.cpp
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings.c

Index: clang/test/Sema/format-strings.c
===
--- clang/test/Sema/format-strings.c
+++ clang/test/Sema/format-strings.c
@@ -277,8 +277,8 @@
 
 void should_understand_small_integers() {
   printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
-  printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
-  printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
+  printf("%hu\n", (unsigned char)1); // no-warning
+  printf("%hu\n", (uint8_t)1);   // no-warning
 }
 
 void test11(void *p, char *s) {
Index: clang/test/Sema/format-strings-pedantic.c
===
--- /dev/null
+++ clang/test/Sema/format-strings-pedantic.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem %S/Inputs %s
+
+#include 
+#include 
+#define __need_wint_t
+#include  // For wint_t and wchar_t
+
+typedef struct _FILE FILE;
+int fprintf(FILE *, const char *restrict, ...);
+int printf(const char *restrict, ...);
+int snprintf(char *restrict, size_t, const char *restrict, ...);
+int sprintf(char *restrict, const char *restrict, ...);
+int vasprintf(char **, const char *, va_list);
+int asprintf(char **, const char *, ...);
+int vfprintf(FILE *, const char *restrict, va_list);
+int vprintf(const char *restrict, va_list);
+int vsnprintf(char *, size_t, const char *, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list);
+
+int vscanf(const char *restrict format, va_list arg);
+
+typedef unsigned char uint8_t;
+
+void should_understand_small_integers() {
+  printf("%hhu", (short)10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
+  printf("%hu\n", (unsigned char)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
+  printf("%hu\n", (uint8_t)1);   // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t' (aka 'unsigned char')}}
+}
Index: clang/test/Sema/format-strings-enum-fixed-type.cpp
===
--- clang/test/Sema/format-strings-enum-fixed-type.cpp
+++ clang/test/Sema/format-strings-enum-fixed-type.cpp
@@ -80,9 +80,9 @@
   printf("%hhd", CharConstant); // no-warning
 
   // This is not correct but it is safe. We warn because '%hd' shows intent.
-  printf("%hd", input); // expected-warning{{format specifies type 'short' but the argument has underlying type 'char'}}
-  printf("%hd", CharConstant); // expected-warning{{format specifies type 'short'}}
-  
+  printf("%hd", input);// no-warning
+  printf("%hd", CharConstant); // no-warning
+
   // This is not correct but it matches the promotion rules (and is safe).
   printf("%d", input); // no-warning
   printf("%d", CharConstant); // no-warning
Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -205,9 +205,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
 
-  NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)"
+  NSLog(@"%C", (char)0x260300);
 
   NSLog(@"%C", 'a'); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c"
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8077,8 +8077,7 @@
 ExprTy = TET->getUnderlyingExpr()->getType();
   }
 
-  const analyze_printf::ArgType::MatchKind Match =
-  AT.matchesType(S.Context, ExprTy);
+  analyze_printf::ArgType::MatchKind Match = AT.matchesType(S.Context, ExprTy);
   bool Pedantic = Match == analyze_printf::ArgType::NoMatchPedantic;
   if (Match == 

[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2019-08-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 216697.
nickdesaulniers added a comment.

- add unit test for function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66492

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias itself, but don't set a name yet.
-  auto *GA = llvm::GlobalAlias::create(
-  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
+  auto *GA =
+  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
 
   if (Entry) {
 if (GA->getAliasee() == Entry) {


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias itself, but don't set a name yet.
-  auto *GA = 

[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-22 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked an inline comment as done.
mgehre added a comment.

Yes, for  libc++ we could add the annotations to its source code, and 
eventually this would be the cleaner solution.
Currently, that is neither sufficient (because one could use libstdc++, MSVC or 
an older libc++ version) nor necessary (the inference we need for libstdc++ / 
MSVC also works for libc++),
so it's currently low on our priority list.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66179



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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-08-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D66397#1639818 , @rsmith wrote:

> The `ALPHA_OFFSET` code seems to be unnecessarily "clever" to me. I think the 
> warning can be suppressed by reversing the operands:
>
> `ALPHA_OFFSET ^ 2`
>
> But if I were maintaining that code I would get rid of the xor hack entirely 
> and use
>
>   #define CHANNEL_OFFSET(i) (i)
>
>
> or
>
>   #define CHANNEL_OFFSET(i) (3-(i))
>


+1

In D66397#1641121 , @thakis wrote:

> In D66397#1640685 , @xbolva00 wrote:
>
> > >> I think adding parens and casts are fairly well-understood to suppress 
> > >> warnings.
> >
> > It should work here as well. #define ALPHA_OFFSET (3). Did anobody from 
> > Chromium try it?
> >
> > >> They have varying levels of C++ proficiency
> >
> > I consider things like hex decimals or parens to silence as a quite basic 
> > knowledge.
>
>
> parens for sure, but I'm not aware of any other warning that behaves 
> differently for ordinary and hex literals. What else is there?


I thought we did in Clang proper, but now I am second-guessing because I cannot 
find any with a quick search. Regardless, I think the "how do we silence this 
diagnostic" is getting a bit out of hand. We seem to now silence it when 
there's a hex, oct, or binary literal, a digit separator, or the `xor` token. I 
think we do not want to list all of those options in a diagnostic message.

> I looked through D63423  and didn't find an 
> evaluation of false / true positive rates when lhs and rhs are just literals 
> vs when they're identifiers / macros. Glancing through 
> https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=10+%5E=Search , I 
> couldn't find a single true positive where lhs or rhs weren't a bare literal 
> (but I didn't look super carefully). Did I just miss that in D63423 
> ? What was the motivation for firing on more 
> than bare literals?

This is an interesting question to me that may help inform how we want to 
proceed.


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

https://reviews.llvm.org/D66397



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


[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-22 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 2 inline comments as done.
mgehre added inline comments.



Comment at: cfe/trunk/unittests/Sema/GslOwnerPointerInference.cpp:9
+
+#include "../ASTMatchers/ASTMatchersTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"

thakis wrote:
> mgehre wrote:
> > thakis wrote:
> > > This weird relative include path is a hint that this isn't the intended 
> > > use :)
> > True. But ...
> > I thought about copying the `matches` function from STMatchersTest.h, but 
> > together with all callees, that's many lines of code.
> > Alternatively, I could implement my own AST walking and property checking, 
> > but then the test would be much less readable.
> > As yet another alternative, I though about moving the 
> > `GslOwnerPointerInference.cpp` test itself to `unittests/ASTMatchers`,
> > but that would also be strange because it actually tests Sema functionality.
> > 
> > What would be your suggestion? (It's good that we discuss this now because 
> > I'm planning to extend this unit test further).
> Do you need the full matches() function? With the current test, it's not even 
> clear to me what exactly it tests since it looks very integration-testy and 
> not very unit-testy. Maybe if you make the test narrower, you don't that much 
> scaffolding? (Integration-type tests are supposed to be lit tests, and unit 
> tests are supposed to test small details that are difficult to test via lit.)
The purpose of the test is to verify that the ClassTemplateSpecialization gets 
the Owner attribute, independent of which of the redeclarations of the template 
had the attribute attached.
The second thing that I want to test here in the future is that the inference 
for std:: types leads to correct Owner/Pointer attributes on the 
`ClassTemplateSpecialization`.,
i.e. a type named `std::vector` should have OwnerAttr on each of its 
`ClassTemplateSpecialization`.

We currently do this in a lit test here 
https://reviews.llvm.org/differential/changeset/?ref=1574879 via checking the 
AST dump, but that is really hard to debug in cases of failures,
and not entirely clear that it checks exactly what we want. (E.g. we can check 
that a `ClassTemplateSpecializationDecl` line is followed by a `PointerAttr` 
line, but we don't actually know if that attribute hierarchically belongs to 
that decl or a another one).

So @gribozavr suggested to me to instead break this integration tests into 
smaller chunks using the ASTMatchers, which at least solves that problem.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66179



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-08-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from an accidental newline change.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:15
 let CategoryName = "Semantic Issue" in {
-
 def note_previous_decl : Note<"%0 declared here">;

Spurious removal?



Comment at: lib/Sema/SemaExpr.cpp:15070-15079
+  // Trivial default constructors and destructors are never actually used.
+  // FIXME: What about other special members?
+  if (Func->isTrivial() && !Func->hasAttr() &&
+  OdrUse == OdrUseContext::Used) {
+if (auto *Constructor = dyn_cast(Func))
+  if (Constructor->isDefaultConstructor())
+OdrUse = OdrUseContext::FormallyOdrUsed;

rsmith wrote:
> aaron.ballman wrote:
> > This seems unrelated to the patch?
> I agree it seems that way, but it is related:
> 
> The block of code below that got turned into a lambda contains early exits 
> via `return` for the cases that get downgraded to `FormallyOdrUsed` here. We 
> used to bail out of the whole function and not mark these trivial special 
> member functions as "used" (in the code after the `NeedDefinition && 
> !Func->getBody()` condition), which seems somewhat reasonable since we don't 
> actually need definitions of them; other parts of Clang (specifically the 
> static analyzer) have developed a reliance on that behavior.
> 
> So this is preserving the existing behavior and (hopefully) making it more 
> obvious what that behavior is, rather than getting that behavior by an early 
> exit from the "need a definition?" portion of this function leaking into the 
> semantics of the "mark used" portion.
> 
> I can split this out and make this change first if you like.
> I can split this out and make this change first if you like.

No need, I appreciate the explanation!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66361



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


Re: r369591 - [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-22 Thread Matthias Gehre via cfe-commits
Hi Diana,
hi Richard,

thank you for the feedback!

Diana,
I remember that some gcc version had issues with raw string literals inside
macros. I'll fix that to use normal
string literals instead.

Richard,
We are definitely want the gsl::Pointer-based warnings that are enabled by
default to be free of any false-positives.
As you expected, this is showing a problem we have in another part of our
analysis, and we will fix it before landing
this PR again.

Both, sorry for the breakage!

Am Do., 22. Aug. 2019 um 19:47 Uhr schrieb Richard Smith <
rich...@metafoo.co.uk>:

> Reverted in r369677.
>
> On Thu, 22 Aug 2019 at 10:34, Richard Smith  wrote:
>
>> Hi Matthias,
>>
>> This introduces false positives into -Wreturn-stack-address for an
>> example such as:
>>
>> #include 
>>
>> std::vector::iterator downcast_to(std::vector::iterator value) {
>>   return *
>> }
>>
>> This breaks an internal build bot for us, so I'm going to revert this for
>> now (though I expect this isn't the cause of the problem, but is rather
>> exposing a problem elsewhere).
>>
>> If we can make the gsl::Pointer diagnostics false-positive-free, that's
>> great, but otherwise we should use a different warning flag for the
>> warnings that involve these annotations and use -Wreturn-stack-address for
>> only the zero-false-positive cases that it historically diagnosed.
>>
>> Thanks, and sorry for the trouble.
>>
>> On Wed, 21 Aug 2019 at 15:07, Matthias Gehre via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: mgehre
>>> Date: Wed Aug 21 15:08:59 2019
>>> New Revision: 369591
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=369591=rev
>>> Log:
>>> [LifetimeAnalysis] Support more STL idioms (template forward declaration
>>> and DependentNameType)
>>>
>>> Summary:
>>> This fixes inference of gsl::Pointer on std::set::iterator with
>>> libstdc++ (the typedef for iterator
>>> on the template is a DependentNameType - we can only put the
>>> gsl::Pointer attribute
>>> on the underlaying record after instantiation)
>>>
>>> inference of gsl::Pointer on std::vector::iterator with libc++ (the
>>> class was forward-declared,
>>> we added the gsl::Pointer on the canonical decl (the forward decl), and
>>> later when the
>>> template was instantiated, there was no attribute on the definition so
>>> it was not instantiated).
>>>
>>> and a duplicate gsl::Pointer on some class with libstdc++ (we first
>>> added an attribute to
>>> a incomplete instantiation, and then another was copied from the
>>> template definition
>>> when the instantiation was completed).
>>>
>>> We now add the attributes to all redeclarations to fix thos issues and
>>> make their usage easier.
>>>
>>> Reviewers: gribozavr
>>>
>>> Subscribers: Szelethus, xazax.hun, cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D66179
>>>
>>> Added:
>>> cfe/trunk/unittests/Sema/GslOwnerPointerInference.cpp
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaAttr.cpp
>>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> cfe/trunk/lib/Sema/SemaInit.cpp
>>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>>> cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
>>> cfe/trunk/test/SemaCXX/attr-gsl-owner-pointer.cpp
>>> cfe/trunk/unittests/Sema/CMakeLists.txt
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=369591=369590=369591=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaAttr.cpp Wed Aug 21 15:08:59 2019
>>> @@ -88,13 +88,11 @@ void Sema::AddMsStructLayoutForRecord(Re
>>>  template 
>>>  static void addGslOwnerPointerAttributeIfNotExisting(ASTContext
>>> ,
>>>   CXXRecordDecl
>>> *Record) {
>>> -  CXXRecordDecl *Canonical = Record->getCanonicalDecl();
>>> -  if (Canonical->hasAttr() ||
>>> Canonical->hasAttr())
>>> +  if (Record->hasAttr() || Record->hasAttr())
>>>  return;
>>>
>>> -  Canonical->addAttr(::new (Context) Attribute(SourceRange{}, Context,
>>> -   /*DerefType*/ nullptr,
>>> -   /*Spelling=*/0));
>>> +  for (Decl *Redecl : Record->redecls())
>>> +Redecl->addAttr(Attribute::CreateImplicit(Context,
>>> /*DerefType=*/nullptr));
>>>  }
>>>
>>>  void Sema::inferGslPointerAttribute(NamedDecl *ND,
>>> @@ -189,8 +187,7 @@ void Sema::inferGslOwnerPointerAttribute
>>>
>>>// Handle classes that directly appear in std namespace.
>>>if (Record->isInStdNamespace()) {
>>> -CXXRecordDecl *Canonical = Record->getCanonicalDecl();
>>> -if (Canonical->hasAttr() ||
>>> Canonical->hasAttr())
>>> +if (Record->hasAttr() || Record->hasAttr())
>>>return;
>>>
>>>  if (StdOwners.count(Record->getName()))
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp

[PATCH] D66606: IR. Change strip* family of functions to not look through aliases.

2019-08-22 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369697: IR. Change strip* family of functions to not look 
through aliases. (authored by pcc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66606?vs=216671=216694#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66606

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  llvm/trunk/include/llvm/IR/Value.h
  llvm/trunk/lib/Analysis/ConstantFolding.cpp
  llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/trunk/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/trunk/lib/CodeGen/Analysis.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/trunk/lib/IR/Constants.cpp
  llvm/trunk/lib/IR/Module.cpp
  llvm/trunk/lib/IR/Value.cpp
  llvm/trunk/lib/IR/Verifier.cpp
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerGlobalDtors.cpp
  llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
  llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/trunk/test/Transforms/InstCombine/bitcast-alias-function.ll
  llvm/trunk/test/Transforms/InstCombine/bitcast-function.ll
  llvm/trunk/test/Transforms/InstCombine/gep-alias.ll
  llvm/trunk/test/Transforms/InstCombine/pr39177.ll

Index: llvm/trunk/include/llvm/IR/Value.h
===
--- llvm/trunk/include/llvm/IR/Value.h
+++ llvm/trunk/include/llvm/IR/Value.h
@@ -513,17 +513,17 @@
   /// swifterror attribute.
   bool isSwiftError() const;
 
-  /// Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
+  /// Strip off pointer casts, all-zero GEPs and address space casts.
   ///
   /// Returns the original uncasted value.  If this is called on a non-pointer
   /// value, it returns 'this'.
   const Value *stripPointerCasts() const;
   Value *stripPointerCasts() {
 return const_cast(
- static_cast(this)->stripPointerCasts());
+static_cast(this)->stripPointerCasts());
   }
 
-  /// Strip off pointer casts, all-zero GEPs, address space casts, and aliases
+  /// Strip off pointer casts, all-zero GEPs and address space casts
   /// but ensures the representation of the result stays the same.
   ///
   /// Returns the original uncasted value with the same representation. If this
@@ -534,26 +534,15 @@
->stripPointerCastsSameRepresentation());
   }
 
-  /// Strip off pointer casts, all-zero GEPs, aliases and invariant group
-  /// info.
+  /// Strip off pointer casts, all-zero GEPs and invariant group info.
   ///
   /// Returns the original uncasted value.  If this is called on a non-pointer
   /// value, it returns 'this'. This function should be used only in
   /// Alias analysis.
   const Value *stripPointerCastsAndInvariantGroups() const;
   Value *stripPointerCastsAndInvariantGroups() {
-return const_cast(
-static_cast(this)->stripPointerCastsAndInvariantGroups());
-  }
-
-  /// Strip off pointer casts and all-zero GEPs.
-  ///
-  /// Returns the original uncasted value.  If this is called on a non-pointer
-  /// value, it returns 'this'.
-  const Value *stripPointerCastsNoFollowAliases() const;
-  Value *stripPointerCastsNoFollowAliases() {
-return const_cast(
-  static_cast(this)->stripPointerCastsNoFollowAliases());
+return const_cast(static_cast(this)
+   ->stripPointerCastsAndInvariantGroups());
   }
 
   /// Strip off pointer casts and all-constant inbounds GEPs.
Index: llvm/trunk/test/Transforms/InstCombine/gep-alias.ll
===
--- llvm/trunk/test/Transforms/InstCombine/gep-alias.ll
+++ llvm/trunk/test/Transforms/InstCombine/gep-alias.ll
@@ -0,0 +1,15 @@
+; RUN: opt -S -instcombine -o - %s | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-android1"
+
+@x.hwasan = private global { [3 x i32], [4 x i8] } { [3 x i32] [i32 42, i32 57, i32 10], [4 x i8] c"\00\00\00\87" }, align 16
+@x = alias [3 x i32], inttoptr (i64 add (i64 ptrtoint ({ [3 x i32], [4 x i8] }* @x.hwasan to i64), i64 -8718968878589280256) to [3 x i32]*)
+
+define i32 @f(i64 %i) {
+entry:
+  ; CHECK: getelementptr inbounds [3 x i32], [3 x i32]* @x
+  %arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* @x, i64 0, i64 %i
+  %0 = load i32, i32* %arrayidx
+  ret i32 %0
+}
Index: llvm/trunk/test/Transforms/InstCombine/pr39177.ll
===
--- llvm/trunk/test/Transforms/InstCombine/pr39177.ll
+++ llvm/trunk/test/Transforms/InstCombine/pr39177.ll
@@ -30,7 +30,7 @@
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP0:%.*]] = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
-; CHECK-NEXT:[[TMP1:%.*]] = call i64 @__fwrite_alias(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7, i64 1, 

[PATCH] D62731: [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior

2019-08-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

ping, looking for a code review, especially from front end folks.  thank you!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


  1   2   >