[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2016-12-16 Thread Tony Jiang via Phabricator via cfe-commits
jtony added inline comments.



Comment at: llvm/include/llvm/ADT/APFloat.h:800
 
-  void makeLargest(bool Neg) { getIEEE().makeLargest(Neg); }
+  void makeLargest(bool Neg) {
+if (usesLayout(getSemantics())) {

I know it is allowed to return a void function call inside a void function, but 
I think this reduces the code readability in general and causes some confusing 
to some people. Maybe it is better to avoid using this kind of coding style. I 
think we can simply call each function in each branch without the 'return' 
keyword, by default, the program will reach the end of function and return.  

One possible equivalent code:

void makeNaN(bool SNaN, bool Neg, const APInt *fill) {
if (usesLayout(getSemantics())) {
  U.IEEE.makeNaN(SNaN, Neg, fill);
} else if (usesLayout(getSemantics())) {
  U.Double.makeNaN(SNaN, Neg, fill);
} else {
  llvm_unreachable("Unexpected semantics");
}
  }



Comment at: llvm/include/llvm/ADT/APFloat.h:811
+  void makeSmallest(bool Neg) {
+if (usesLayout(getSemantics())) {
+  return U.IEEE.makeSmallest(Neg);

Same here.



Comment at: llvm/include/llvm/ADT/APFloat.h:821
   void makeSmallestNormalized(bool Neg) {
-getIEEE().makeSmallestNormalized(Neg);
+if (usesLayout(getSemantics())) {
+  return U.IEEE.makeSmallestNormalized(Neg);

Same here.



Comment at: llvm/include/llvm/ADT/APFloat.h:1100
 
-  void changeSign() { getIEEE().changeSign(); }
-  void clearSign() { getIEEE().clearSign(); }
-  void copySign(const APFloat ) { getIEEE().copySign(RHS.getIEEE()); }
+  void changeSign() {
+if (usesLayout(getSemantics())) {

Same here.


https://reviews.llvm.org/D27872



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


Re: [libcxx] r289963 - [CMake] Put headers relative to clang

2016-12-16 Thread Evgenii Stepanov via cfe-commits
FTR,

buildbot logs:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/2585/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio

External project cmake error log:

CMake Error at include/CMakeLists.txt:15 (file):
  file COPY cannot make directory "/include/c++/v1/.": No such file or
  directory


On Fri, Dec 16, 2016 at 5:56 PM, Evgenii Stepanov
 wrote:
> Hi,
>
> this is using LLVM_BINARY_DIR when NOT LIBCXX_USING_INSTALLED_LLVM.
>
> HandleOutOfTreeLLVM.cmake defines LLVM_BINARY_DIR only when
> LIBCXX_USING_INSTALLED_LLVM. Is it supposed to come from the user
> cmake arguments?
>
> This broke sanitizer tests on Linux (check-tsan, check-msan). See
> add_custom_libcxx() in compiler-rt cmake scripts.
>
> On Fri, Dec 16, 2016 at 9:30 AM, Chris Bieneman via cfe-commits
>  wrote:
>> Author: cbieneman
>> Date: Fri Dec 16 11:30:51 2016
>> New Revision: 289963
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=289963=rev
>> Log:
>> [CMake] Put headers relative to clang
>>
>> When libcxx isn't building with an installed LLVM we copy the libcxx headers 
>> into the LLVM build directory so that a clang in that build tree can find 
>> the headers relative to itself.
>>
>> This is only important in situations where you don't have headers installed 
>> under /, which is common these days on Darwin.
>>
>> Modified:
>> libcxx/trunk/include/CMakeLists.txt
>>
>> Modified: libcxx/trunk/include/CMakeLists.txt
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=289963=289962=289963=diff
>> ==
>> --- libcxx/trunk/include/CMakeLists.txt (original)
>> +++ libcxx/trunk/include/CMakeLists.txt Fri Dec 16 11:30:51 2016
>> @@ -10,18 +10,14 @@ set(LIBCXX_HEADER_PATTERN
>>${LIBCXX_SUPPORT_HEADER_PATTERN}
>>)
>>
>> -if (LIBCXX_STANDALONE_BUILD)
>> -  set(LIBCXX_BUILD_ROOT "${LIBCXX_BINARY_DIR}")
>> -else()
>> -  set(LIBCXX_BUILD_ROOT "${LLVM_BINARY_DIR}")
>> +if(NOT LIBCXX_USING_INSTALLED_LLVM)
>> +  file(COPY .
>> +DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
>> +FILES_MATCHING
>> +${LIBCXX_HEADER_PATTERN}
>> +)
>>  endif()
>>
>> -file(COPY .
>> -  DESTINATION "${LIBCXX_BUILD_ROOT}/include/c++/v1"
>> -  FILES_MATCHING
>> -  ${LIBCXX_HEADER_PATTERN}
>> -)
>> -
>>  if (LIBCXX_INSTALL_HEADERS)
>>install(DIRECTORY .
>>  DESTINATION include/c++/v1
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r289963 - [CMake] Put headers relative to clang

2016-12-16 Thread Evgenii Stepanov via cfe-commits
Hi,

this is using LLVM_BINARY_DIR when NOT LIBCXX_USING_INSTALLED_LLVM.

HandleOutOfTreeLLVM.cmake defines LLVM_BINARY_DIR only when
LIBCXX_USING_INSTALLED_LLVM. Is it supposed to come from the user
cmake arguments?

This broke sanitizer tests on Linux (check-tsan, check-msan). See
add_custom_libcxx() in compiler-rt cmake scripts.

On Fri, Dec 16, 2016 at 9:30 AM, Chris Bieneman via cfe-commits
 wrote:
> Author: cbieneman
> Date: Fri Dec 16 11:30:51 2016
> New Revision: 289963
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289963=rev
> Log:
> [CMake] Put headers relative to clang
>
> When libcxx isn't building with an installed LLVM we copy the libcxx headers 
> into the LLVM build directory so that a clang in that build tree can find the 
> headers relative to itself.
>
> This is only important in situations where you don't have headers installed 
> under /, which is common these days on Darwin.
>
> Modified:
> libcxx/trunk/include/CMakeLists.txt
>
> Modified: libcxx/trunk/include/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=289963=289962=289963=diff
> ==
> --- libcxx/trunk/include/CMakeLists.txt (original)
> +++ libcxx/trunk/include/CMakeLists.txt Fri Dec 16 11:30:51 2016
> @@ -10,18 +10,14 @@ set(LIBCXX_HEADER_PATTERN
>${LIBCXX_SUPPORT_HEADER_PATTERN}
>)
>
> -if (LIBCXX_STANDALONE_BUILD)
> -  set(LIBCXX_BUILD_ROOT "${LIBCXX_BINARY_DIR}")
> -else()
> -  set(LIBCXX_BUILD_ROOT "${LLVM_BINARY_DIR}")
> +if(NOT LIBCXX_USING_INSTALLED_LLVM)
> +  file(COPY .
> +DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
> +FILES_MATCHING
> +${LIBCXX_HEADER_PATTERN}
> +)
>  endif()
>
> -file(COPY .
> -  DESTINATION "${LIBCXX_BUILD_ROOT}/include/c++/v1"
> -  FILES_MATCHING
> -  ${LIBCXX_HEADER_PATTERN}
> -)
> -
>  if (LIBCXX_INSTALL_HEADERS)
>install(DIRECTORY .
>  DESTINATION include/c++/v1
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290025 - [libclang] Remove the 'extern "C"' blocks from the implementation files.

2016-12-16 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Dec 16 19:09:40 2016
New Revision: 290025

URL: http://llvm.org/viewvc/llvm-project?rev=290025=rev
Log:
[libclang] Remove the 'extern "C"' blocks from the implementation files.

These are unnecessary, the declarations already carry the 'extern C' property, 
and if there is mismatch
between declaration and definition then we will get linker errors via 
libclang.exports.

Modified:
cfe/trunk/tools/libclang/ARCMigrate.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCXX.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
cfe/trunk/tools/libclang/CIndexHigh.cpp
cfe/trunk/tools/libclang/CIndexInclusionStack.cpp
cfe/trunk/tools/libclang/CIndexUSRs.cpp
cfe/trunk/tools/libclang/CXComment.cpp
cfe/trunk/tools/libclang/CXCompilationDatabase.cpp
cfe/trunk/tools/libclang/CXCursor.cpp
cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
cfe/trunk/tools/libclang/CXSourceLocation.cpp
cfe/trunk/tools/libclang/CXString.cpp
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/tools/libclang/ARCMigrate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/ARCMigrate.cpp?rev=290025=290024=290025=diff
==
--- cfe/trunk/tools/libclang/ARCMigrate.cpp (original)
+++ cfe/trunk/tools/libclang/ARCMigrate.cpp Fri Dec 16 19:09:40 2016
@@ -32,8 +32,6 @@ struct Remap {
 // libClang public APIs.
 
//===--===//
 
-extern "C" {
-
 CXRemapping clang_getRemappings(const char *migrate_dir_path) {
 #ifndef CLANG_ENABLE_ARCMT
   llvm::errs() << "error: feature not enabled in this build\n";
@@ -138,5 +136,3 @@ void clang_remap_getFilenames(CXRemappin
 void clang_remap_dispose(CXRemapping map) {
   delete static_cast(map);
 }
-
-} // end: extern "C"

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=290025=290024=290025=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Dec 16 19:09:40 2016
@@ -3110,7 +3110,6 @@ struct RegisterFatalErrorHandler {
 
 static llvm::ManagedStatic 
RegisterFatalErrorHandlerOnce;
 
-extern "C" {
 CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
   int displayDiagnostics) {
   // We use crash recovery to make some of our APIs more reliable, implicitly
@@ -3968,13 +3967,10 @@ CXCursor clang_getTranslationUnitCursor(
   return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU);
 }
 
-} // end: extern "C"
-
 
//===--===//
 // CXFile Operations.
 
//===--===//
 
-extern "C" {
 CXString clang_getFileName(CXFile SFile) {
   if (!SFile)
 return cxstring::createNull();
@@ -4043,8 +4039,6 @@ int clang_File_isEqual(CXFile file1, CXF
   return FEnt1->getUniqueID() == FEnt2->getUniqueID();
 }
 
-} // end: extern "C"
-
 
//===--===//
 // CXCursor Operations.
 
//===--===//
@@ -4120,8 +4114,6 @@ static SourceLocation getLocationFromExp
   return E->getLocStart();
 }
 
-extern "C" {
-
 unsigned clang_visitChildren(CXCursor parent,
  CXCursorVisitor visitor,
  CXClientData client_data) {
@@ -5383,8 +5375,6 @@ CXSourceLocation clang_getCursorLocation
   return cxloc::translateSourceLocation(getCursorContext(C), Loc);
 }
 
-} // end extern "C"
-
 CXCursor cxcursor::getCursor(CXTranslationUnit TU, SourceLocation SLoc) {
   assert(TU);
 
@@ -5554,8 +5544,6 @@ static SourceRange getFullCursorExtent(C
   return getRawCursorExtent(C);
 }
 
-extern "C" {
-
 CXSourceRange clang_getCursorExtent(CXCursor C) {
   SourceRange R = getRawCursorExtent(C);
   if (R.isInvalid())
@@ -6048,8 +6036,6 @@ void clang_executeOnThread(void (*fn)(vo
   llvm::llvm_execute_on_thread(fn, user_data, stack_size);
 }
 
-} // end: extern "C"
-
 
//===--===//
 // Token-based Operations.
 
//===--===//
@@ -6062,8 +6048,6 @@ void clang_executeOnThread(void (*fn)(vo
  *   ptr_data: for identifiers and keywords, an IdentifierInfo*.
  *   otherwise unused.
  */
-extern "C" {
-
 CXTokenKind clang_getTokenKind(CXToken CXTok) {
   return static_cast(CXTok.int_data[0]);
 }
@@ -6252,8 +6236,6 @@ void clang_disposeTokens(CXTranslationUn
   free(Tokens);
 }
 
-} // end: extern "C"
-
 

r290023 - [analyzer] UnixAPIChecker: Don't diagnose for functions in C++ namespaces

2016-12-16 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Dec 16 19:08:17 2016
New Revision: 290023

URL: http://llvm.org/viewvc/llvm-project?rev=290023=rev
Log:
[analyzer] UnixAPIChecker: Don't diagnose for functions in C++ namespaces

Update the UnixAPIChecker to not diagnose for calls to functions that
are declared in C++ namespaces. This avoids false positives when a
namespaced function has the same name as a Unix API.

This address PR28331.

Added:
cfe/trunk/test/Analysis/unix-api.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp?rev=290023=290022=290023=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp Fri Dec 16 
19:08:17 2016
@@ -427,6 +427,12 @@ void UnixAPIChecker::checkPreStmt(const
   if (!FD || FD->getKind() != Decl::Function)
 return;
 
+  // Don't treat functions in namespaces with the same name a Unix function
+  // as a call to the Unix function.
+  const DeclContext *NamespaceCtx = FD->getEnclosingNamespaceContext();
+  if (NamespaceCtx && isa(NamespaceCtx))
+return;
+
   StringRef FName = C.getCalleeName(FD);
   if (FName.empty())
 return;

Added: cfe/trunk/test/Analysis/unix-api.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unix-api.cpp?rev=290023=auto
==
--- cfe/trunk/test/Analysis/unix-api.cpp (added)
+++ cfe/trunk/test/Analysis/unix-api.cpp Fri Dec 16 19:08:17 2016
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s
+extern "C" {
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+
+#ifndef NULL
+#define NULL ((void*) 0)
+#endif
+
+int open(const char *, int, ...);
+int close(int fildes);
+
+} // extern "C"
+
+namespace MyNameSpace {
+int open(const char *a, int b, int c, int d);
+}
+
+void unix_open(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY); // no-warning
+  if (fd > -1)
+close(fd);
+}
+
+void unix_open_misuse(const char *path) {
+  int fd;
+  int mode = 0x0;
+  fd = open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' 
with more than 3 arguments}}
+  if (fd > -1)
+close(fd);
+}
+
+// Don't treat open() in namespaces as the POSIX open()
+void namespaced_open(const char *path) {
+  MyNameSpace::open("Hi", 2, 3, 4); // no-warning
+
+  using namespace MyNameSpace;
+
+  open("Hi", 2, 3, 4); // no-warning
+
+  int fd;
+  int mode = 0x0;
+  fd = ::open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' 
with more than 3 arguments}}
+  if (fd > -1)
+close(fd);
+}
+
+class MyClass {
+public:
+  static int open(const char *a, int b, int c, int d);
+
+  int open(int a, int, int c, int d);
+};
+
+void class_qualified_open() {
+  MyClass::open("Hi", 2, 3, 4); // no-warning
+
+  MyClass mc;
+  mc.open(1, 2, 3, 4); // no-warning
+}


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


[PATCH] D27836: Store the "current position" index within the ASTRecordReader.

2016-12-16 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

I like moving `Idx` into the reader, but I have mixed feelings about the 
iterator-like interface. For consistency with the rest of the `ASTRecordReader` 
interface, and with how we model the writer side, I think perhaps 
`Record.ReadInt()` would fit better than using `*Record++`.


https://reviews.llvm.org/D27836



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


Re: r289995 - [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

2016-12-16 Thread Argyrios Kyrtzidis via cfe-commits
Yes, I see, thanks Reid!

I’d just remove the 'extern "C” {‘ from the cpp file, which is not really 
necessary, I’ll do it in a subsequent commit anyway.

> On Dec 16, 2016, at 4:48 PM, Yung, Douglas  wrote:
> 
> I think Reid already fixed the problem in r290009.
> 
> Douglas Yung
> 
>> -Original Message-
>> From: Argyrios Kyrtzidis [mailto:akyr...@gmail.com]
>> Sent: Friday, December 16, 2016 16:46
>> To: Yung, Douglas
>> Cc: cfe-commits@lists.llvm.org
>> Subject: Re: r289995 - [libclang] Restore the CXXRecordDecl path for
>> clang_Type_getNumTemplateArguments and
>> clang_Type_getTemplateArgumentAsType
>> 
>> Looking into..
>> 
>>> On Dec 16, 2016, at 3:13 PM, Yung, Douglas 
>> wrote:
>>> 
>>> Hi, this change seems to be causing the PS4 Windows build bot to be
>> red, can you take a look?
>>> 
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-
>> windo
>>> ws10pro-fast/builds/2784
>>> 
>>> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP -
>> DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -
>> DCLANG_ENABLE_STATIC_ANALYZER -DCLANG_TOOL_EXTRA_BUILD -
>> DGTEST_HAS_RTTI=0 -DUNICODE -D_CINDEX_LIB_ -D_CRT_NONSTDC_NO_DEPRECATE
>> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -
>> D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -
>> D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -
>> D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -
>> Itools\clang\tools\libclang -IC:\Buildbot\Slave\llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang -
>> IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\include -Itools\clang\include -Iinclude -
>> IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\include /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180
>> -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457
>> -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512
>> -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703
>> -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324
>> -w14062 -we4238 /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /MD /O2
>> /Ob2   -UNDEBUG  /EHs-c- /GR- /showIncludes
>> /Fotools\clang\tools\libclang\CMakeFiles\libclang.dir\CXType.cpp.obj
>> /Fdtools\clang\tools\libclang\CMakeFiles\libclang.dir\ /FS -c
>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): error C2526:
>> 'GetTemplateArguments': C linkage function cannot return C++ class
>> 'llvm::Optional'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(927): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(933): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(936): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(926): warning
>> C4390: ';': empty controlled statement found; is this the intent?
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(932): warning
>> C4390: ';': empty controlled statement found; is this the intent?
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(952): error C3313:
>> 'TA': variable cannot have the type 'void'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(953): error C3536: 'TA':
>>> cannot be used before it is initialized
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(956): error C2228: left
>> of
>>> '.getValue' must have class/struct/union
>>> 

Re: r289995 - [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

2016-12-16 Thread Argyrios Kyrtzidis via cfe-commits
Looking into..

> On Dec 16, 2016, at 3:13 PM, Yung, Douglas  wrote:
> 
> Hi, this change seems to be causing the PS4 Windows build bot to be red, can 
> you take a look?
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2784
> 
> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP -DCLANG_ENABLE_ARCMT 
> -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER 
> -DCLANG_TOOL_EXTRA_BUILD -DGTEST_HAS_RTTI=0 -DUNICODE -D_CINDEX_LIB_ 
> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
> -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
> -D__STDC_LIMIT_MACROS -Itools\clang\tools\libclang 
> -IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang
>  
> -IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\include
>  -Itools\clang\include -Iinclude 
> -IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include
>  /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 
> -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 
> -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 
> -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 
> -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline 
> /Zc:strictStrings /Oi /Zc:rvalueCast /MD /O2 /Ob2   -UNDEBUG  /EHs-c- /GR- 
> /showIncludes 
> /Fotools\clang\tools\libclang\CMakeFiles\libclang.dir\CXType.cpp.obj 
> /Fdtools\clang\tools\libclang\CMakeFiles\libclang.dir\ /FS -c 
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
>  error C2526: 'GetTemplateArguments': C linkage function cannot return C++ 
> class 'llvm::Optional'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(927):
>  error C2562: 'GetTemplateArguments': 'void' function returning a value
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
>  note: see declaration of 'GetTemplateArguments'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(933):
>  error C2562: 'GetTemplateArguments': 'void' function returning a value
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
>  note: see declaration of 'GetTemplateArguments'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(936):
>  error C2562: 'GetTemplateArguments': 'void' function returning a value
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
>  note: see declaration of 'GetTemplateArguments'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(926):
>  warning C4390: ';': empty controlled statement found; is this the intent?
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(932):
>  warning C4390: ';': empty controlled statement found; is this the intent?
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(952):
>  error C3313: 'TA': variable cannot have the type 'void'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(953):
>  error C3536: 'TA': cannot be used before it is initialized
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(956):
>  error C2228: left of '.getValue' must have class/struct/union
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(956):
>  note: type is 'int'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959):
>  error C2526: 'TemplateArgumentToQualType': C linkage function cannot return 
> C++ class 'llvm::Optional'
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(961):
>  error C2562: 'TemplateArgumentToQualType': 'void' function returning a value
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959):
>  note: see declaration of 'TemplateArgumentToQualType'
> 

[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2016-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: llvm/include/llvm/ADT/APFloat.h:773
+  return U.IEEE.makeZero(Neg);
+} else if (usesLayout(getSemantics())) {
+  return U.Double.makeZero(Neg);

You don't need else after return.


https://reviews.llvm.org/D27872



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


[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2016-12-16 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added reviewers: hfinkel, kbarton, iteratee, echristo.
timshen added subscribers: llvm-commits, cfe-commits.
Herald added subscribers: nemanjai, mehdi_amini.

This patch changes the layout of DoubleAPFloat, and adjust all
operations to do either:

1. (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl, 
then run the old algorithm.
2. Do the right thing directly.

1. includes multiply, divide, remainder, mod, fusedMultiplyAdd, 
roundToIntegral, convertFromString, next, convertToInteger, convertFromAPInt, 
convertFromSignExtendedInteger, convertFromZeroExtendedInteger, 
convertToHexString, toString, getExactInverse.
2. includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized, 
compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest, isLargest, 
isInteger, ilogb, scalbn, frexp, hash_value, Profile.

I could split this into two patches, e.g. use

1. for all operatoins first, then incrementally change some of them to

2). I didn't do that, because 1) involves code that converts data between
PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may
pessimize the compiler. Instead, I find easy functions and use
approach 2) for them directly.

Next step is to implement move multiply and divide from 1) to 2). I don't
have plans for other functions in 1).


https://reviews.llvm.org/D27872

Files:
  clang/test/CodeGen/ppc64-complex-parms.c
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll
  llvm/unittests/ADT/APFloatTest.cpp

Index: llvm/unittests/ADT/APFloatTest.cpp
===
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -9,6 +9,7 @@
 
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
@@ -3262,7 +3263,7 @@
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3296,7 +3297,7 @@
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3496,12 +3497,53 @@
 APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
 APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
 EXPECT_EQ(Expected, A1.compare(A2))
-<< formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
+<< formatv("compare(({0:x} + {1:x}), ({2:x} + {3:x}))", Op1[0], Op1[1],
+   Op2[0], Op2[1])
+   .str();
+  }
+}
+
+TEST(APFloatTest, PPCDoubleDoubleBitwiseIsEqual) {
+  using DataType = std::tuple;
+
+  DataType Data[] = {
+  // (1 + 0) = (1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff0ull, 0, true),
+  // (1 + 0) != (1.00...1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff1ull, 0,
+  false),
+  // NaN = NaN
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull, 0, true),
+  // NaN != NaN with a different bit pattern
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull,
+  0x3ff0ull, false),
+  // Inf = Inf
+  std::make_tuple(0x7ff0ull, 0, 0x7ff0ull, 0, true),
+  };
+
+  for (auto Tp : Data) {
+uint64_t Op1[2], Op2[2];
+bool Expected;
+std::tie(Op1[0], Op1[1], Op2[0], Op2[1], Expected) = Tp;
+
+APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
+APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
+EXPECT_EQ(Expected, A1.bitwiseIsEqual(A2))
+<< formatv("({0:x} + {1:x}) = ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
   }
 }
 
+TEST(APFloatTest, PPCDoubleDoubleHashValue) {
+  uint64_t Data1[] = {0x3ff1ull, 0x0001ull};
+  uint64_t Data2[] = {0x3ff1ull, 0};
+  // The hash values are *hopefully* different.
+  EXPECT_NE(
+  hash_value(APFloat(APFloat::PPCDoubleDouble(), APInt(128, 2, Data1))),
+  hash_value(APFloat(APFloat::PPCDoubleDouble(), APInt(128, 2, Data2;
+}
+
 TEST(APFloatTest, 

LLVM buildmaster will be restarted tonight

2016-12-16 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 5 PM Pacific time
today.

Thanks

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


[PATCH] D21626: Lit C++11 Compatibility Patch #10

2016-12-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 81817.
tigerleapgorge added a comment.

Previous update contain typos in the RUN lines of 
test/SemaCXX/virtual-base-used.cpp
This has been corrected in this latest revision.


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/a.h
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/OpenMP/declare_reduction_messages.cpp
  test/OpenMP/openmp_check.cpp
  test/SemaCXX/MicrosoftExtensions.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/format-strings.cpp
  test/SemaCXX/printf-cstr.cpp
  test/SemaCXX/virtual-base-used.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,10 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1465,21 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+// expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/virtual-base-used.cpp
===
--- test/SemaCXX/virtual-base-used.cpp
+++ test/SemaCXX/virtual-base-used.cpp
@@ -1,89 +1,215 @@
 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s
 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s
 // PR7800
 
 // The Microsoft ABI doesn't have the concept of key functions, so we have different
 // expectations about when functions are first required for that case.
 
+class NoDestroy { ~NoDestroy(); };
+#if __cplusplus <= 199711L
+// expected-note@-2 3 {{declared private here}}
 #ifdef MSABI
-// expected-note@+2 3 {{declared private here}}
+// expected-note@-4 3 {{declared private here}}
 #endif
-class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
+#endif
+
 struct A {
   virtual ~A();
+#if __cplusplus >= 201103L
+  // expected-note@-2 3 {{overridden virtual function is here}}
+#endif
 };
 
+struct B : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}}
+// expected-note@-3 {{overridden virtual function is here}}
+#endif
+
+  NoDestroy x;
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{field of type 'NoDestroy' has private destructor}}
 #ifdef MSABI
-// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
+  // expected-error@-4 {{field of type 'NoDestroy' has private destructor}}
 #endif
-struct B : public virtual A {
-  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
-};
+#else
+  // expected-note@-7 {{destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}}
 #ifdef MSABI
-// expected-note@+3 {{implicit default constructor for 'B' first required here}}
-// 

[PATCH] D21626: Lit C++11 Compatibility Patch #10

2016-12-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 81810.
tigerleapgorge added a comment.

Update patch to match latest Clang C++11 diagnostics.

2 tests are changed.

test/SemaCXX/PR9572.cpp

  Expect the following additional Note following existing Error.
destructor of 'Foo' is implicitly deleted because base class 'Base' has an 
inaccessible destructor

test/SemaCXX/virtual-base-used.cpp

  Expect the following additional Notes following existing Errors.
destructor of 'B' is implicitly deleted because field 'x' has an 
inaccessible destructor
destructor of 'E' is implicitly deleted because field 'x' has an 
inaccessible destructor
destructor of 'H' is implicitly deleted because field 'x' has an 
inaccessible destructor


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/a.h
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/OpenMP/declare_reduction_messages.cpp
  test/OpenMP/openmp_check.cpp
  test/SemaCXX/MicrosoftExtensions.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/format-strings.cpp
  test/SemaCXX/printf-cstr.cpp
  test/SemaCXX/virtual-base-used.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,10 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1465,21 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+// expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/virtual-base-used.cpp
===
--- test/SemaCXX/virtual-base-used.cpp
+++ test/SemaCXX/virtual-base-used.cpp
@@ -1,89 +1,215 @@
-// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
-// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
+// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
+// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s
+// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s
+// UN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
+// UN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s
 // PR7800
 
 // The Microsoft ABI doesn't have the concept of key functions, so we have different
 // expectations about when functions are first required for that case.
 
+class NoDestroy { ~NoDestroy(); };
+#if __cplusplus <= 199711L
+// expected-note@-2 3 {{declared private here}}
 #ifdef MSABI
-// expected-note@+2 3 {{declared private here}}
+// expected-note@-4 3 {{declared private here}}
 #endif
-class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
+#endif
+
 struct A {
   virtual ~A();
+#if __cplusplus >= 201103L
+  // expected-note@-2 3 {{overridden virtual function is here}}
+#endif
 };
 
+struct B : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}}
+// expected-note@-3 {{overridden virtual 

r290009 - Fix MSVC build of libclang after r288438

2016-12-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec 16 17:44:44 2016
New Revision: 290009

URL: http://llvm.org/viewvc/llvm-project?rev=290009=rev
Log:
Fix MSVC build of libclang after r288438

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

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=290009=290008=290009=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Fri Dec 16 17:44:44 2016
@@ -143,6 +143,45 @@ static inline CXTranslationUnit GetTU(CX
   return static_cast(CT.data[1]);
 }
 
+static Optional
+GetTemplateArguments(QualType Type) {
+  assert(!Type.isNull());
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
+  if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
+const auto *TemplateDecl =
+  dyn_cast(RecordDecl);
+if (TemplateDecl)
+  return TemplateDecl->getTemplateArgs().asArray();
+  }
+
+  return None;
+}
+
+static Optional TemplateArgumentToQualType(const TemplateArgument 
) {
+  if (A.getKind() == TemplateArgument::Type)
+return A.getAsType();
+  return None;
+}
+
+static Optional
+FindTemplateArgumentTypeAt(ArrayRef TA, unsigned index) {
+  unsigned current = 0;
+  for (const auto  : TA) {
+if (A.getKind() == TemplateArgument::Pack) {
+  if (index < current + A.pack_size())
+return TemplateArgumentToQualType(A.getPackAsArray()[index - current]);
+  current += A.pack_size();
+  continue;
+}
+if (current == index)
+  return TemplateArgumentToQualType(A);
+current++;
+  }
+  return None;
+}
+
 extern "C" {
 
 CXType clang_getCursorType(CXCursor C) {
@@ -920,22 +959,6 @@ CXString clang_getDeclObjCTypeEncoding(C
   return cxstring::createDup(encoding);
 }
 
-static Optional
-GetTemplateArguments(QualType Type) {
-  assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
-  if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
-const auto *TemplateDecl =
-  dyn_cast(RecordDecl);
-if (TemplateDecl)
-  return TemplateDecl->getTemplateArgs().asArray();
-  }
-
-  return None;
-}
-
 static unsigned GetTemplateArgumentArraySize(ArrayRef TA) {
   unsigned size = TA.size();
   for (const auto  : TA)
@@ -956,29 +979,6 @@ int clang_Type_getNumTemplateArguments(C
   return GetTemplateArgumentArraySize(TA.getValue());
 }
 
-static Optional TemplateArgumentToQualType(const TemplateArgument 
) {
-  if (A.getKind() == TemplateArgument::Type)
-return A.getAsType();
-  return None;
-}
-
-static Optional
-FindTemplateArgumentTypeAt(ArrayRef TA, unsigned index) {
-  unsigned current = 0;
-  for (const auto  : TA) {
-if (A.getKind() == TemplateArgument::Pack) {
-  if (index < current + A.pack_size())
-return TemplateArgumentToQualType(A.getPackAsArray()[index - current]);
-  current += A.pack_size();
-  continue;
-}
-if (current == index)
-  return TemplateArgumentToQualType(A);
-current++;
-  }
-  return None;
-}
-
 CXType clang_Type_getTemplateArgumentAsType(CXType CT, unsigned index) {
   QualType T = GetQualType(CT);
   if (T.isNull())


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


r290010 - Added clangLex to the dependencies for clang-import-test.

2016-12-16 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Fri Dec 16 17:45:03 2016
New Revision: 290010

URL: http://llvm.org/viewvc/llvm-project?rev=290010=rev
Log:
Added clangLex to the dependencies for clang-import-test.

This is part of the effort to get the i686-mingw32-RA-on-linux bot to like 
clang-import-test.

Modified:
cfe/trunk/tools/clang-import-test/CMakeLists.txt

Modified: cfe/trunk/tools/clang-import-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/CMakeLists.txt?rev=290010=290009=290010=diff
==
--- cfe/trunk/tools/clang-import-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-import-test/CMakeLists.txt Fri Dec 16 17:45:03 2016
@@ -18,6 +18,7 @@ set(CLANG_IMPORT_TEST_LIB_DEPS
   clangBasic
   clangCodeGen
   clangFrontend
+  clangLex
   clangParse
   )
 


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


r290008 - Add explicit triple to test to fix arm bots.

2016-12-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Dec 16 17:43:51 2016
New Revision: 290008

URL: http://llvm.org/viewvc/llvm-project?rev=290008=rev
Log:
Add explicit triple to test to fix arm bots.

Modified:
cfe/trunk/test/CodeGen/dbg-const-int128.c

Modified: cfe/trunk/test/CodeGen/dbg-const-int128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dbg-const-int128.c?rev=290008=290007=290008=diff
==
--- cfe/trunk/test/CodeGen/dbg-const-int128.c (original)
+++ cfe/trunk/test/CodeGen/dbg-const-int128.c Fri Dec 16 17:43:51 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited  %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -S -emit-llvm 
-debug-info-kind=limited  %s -o - | FileCheck %s
 // CHECK: !DIGlobalVariable({{.*}}
 // CHECK-NOT: expr:
 


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


r290006 - Fixed library dependencies on clang-import-test to clean up the bots.

2016-12-16 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Fri Dec 16 17:34:16 2016
New Revision: 290006

URL: http://llvm.org/viewvc/llvm-project?rev=290006=rev
Log:
Fixed library dependencies on clang-import-test to clean up the bots.

Modified:
cfe/trunk/tools/clang-import-test/CMakeLists.txt

Modified: cfe/trunk/tools/clang-import-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/CMakeLists.txt?rev=290006=290005=290006=diff
==
--- cfe/trunk/tools/clang-import-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-import-test/CMakeLists.txt Fri Dec 16 17:34:16 2016
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  core
   support
 )
 
@@ -17,6 +18,7 @@ set(CLANG_IMPORT_TEST_LIB_DEPS
   clangBasic
   clangCodeGen
   clangFrontend
+  clangParse
   )
 
 target_link_libraries(clang-import-test


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


[PATCH] D27180: Testbed and skeleton of a new expression parser

2016-12-16 Thread Sean Callanan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290004: Testbed and skeleton of a new expression parser 
(authored by spyffe).

Changed prior to commit:
  https://reviews.llvm.org/D27180?vs=81803=81807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27180

Files:
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/Import/clang-flags/Inputs/S.c
  cfe/trunk/test/Import/clang-flags/test.c
  cfe/trunk/test/Import/empty-struct/Inputs/S.c
  cfe/trunk/test/Import/empty-struct/test.c
  cfe/trunk/test/Import/error-in-expression/Inputs/S.c
  cfe/trunk/test/Import/error-in-expression/test.c
  cfe/trunk/test/Import/error-in-import/Inputs/S.c
  cfe/trunk/test/Import/error-in-import/test.c
  cfe/trunk/test/Import/missing-import/test.c
  cfe/trunk/tools/CMakeLists.txt
  cfe/trunk/tools/clang-import-test/CMakeLists.txt
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Index: cfe/trunk/tools/CMakeLists.txt
===
--- cfe/trunk/tools/CMakeLists.txt
+++ cfe/trunk/tools/CMakeLists.txt
@@ -5,6 +5,7 @@
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
+add_clang_subdirectory(clang-import-test)
 add_clang_subdirectory(clang-offload-bundler)
 
 add_clang_subdirectory(c-index-test)
Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -0,0 +1,319 @@
+//===-- import-test.cpp - ASTImporter/ExternalASTSource testbed ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+
+using namespace clang;
+
+static llvm::cl::opt Expression(
+"expression", llvm::cl::Required,
+llvm::cl::desc("Path to a file containing the expression to parse"));
+
+static llvm::cl::list
+Imports("import", llvm::cl::ZeroOrMore,
+llvm::cl::desc("Path to a file containing declarations to import"));
+
+static llvm::cl::list
+ClangArgs("Xcc", llvm::cl::ZeroOrMore,
+  llvm::cl::desc("Argument to pass to the CompilerInvocation"),
+  llvm::cl::CommaSeparated);
+
+namespace init_convenience {
+class TestDiagnosticConsumer : public DiagnosticConsumer {
+private:
+  std::unique_ptr Passthrough;
+  const LangOptions *LangOpts = nullptr;
+
+public:
+  TestDiagnosticConsumer()
+  : Passthrough(llvm::make_unique()) {}
+
+  virtual void BeginSourceFile(const LangOptions ,
+   const Preprocessor *PP = nullptr) override {
+this->LangOpts = 
+return Passthrough->BeginSourceFile(LangOpts, PP);
+  }
+
+  virtual void EndSourceFile() override {
+this->LangOpts = nullptr;
+Passthrough->EndSourceFile();
+  }
+
+  virtual bool IncludeInDiagnosticCounts() const override {
+return Passthrough->IncludeInDiagnosticCounts();
+  }
+
+private:
+  static void PrintSourceForLocation(const SourceLocation ,
+ SourceManager ) {
+const char *LocData = SM.getCharacterData(Loc, /*Invalid=*/nullptr);
+unsigned LocColumn =
+SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
+FileID FID = SM.getFileID(Loc);
+llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+
+assert(LocData >= Buffer->getBufferStart() &&
+   LocData < Buffer->getBufferEnd());
+
+const char *LineBegin = LocData - LocColumn;
+
+assert(LineBegin >= Buffer->getBufferStart());
+
+const char *LineEnd = nullptr;
+
+for (LineEnd = LineBegin; *LineEnd != '\n' && *LineEnd != '\r' &&
+  LineEnd < Buffer->getBufferEnd();
+ ++LineEnd)
+  ;
+
+llvm::StringRef LineString(LineBegin, LineEnd - LineBegin);
+
+llvm::errs() << LineString << '\n';
+std::string Space(LocColumn, ' ');
+llvm::errs() << Space.c_str() << '\n';
+  }
+
+  virtual void HandleDiagnostic(DiagnosticsEngine::Level 

r290004 - Testbed and skeleton of a new expression parser

2016-12-16 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Fri Dec 16 17:21:38 2016
New Revision: 290004

URL: http://llvm.org/viewvc/llvm-project?rev=290004=rev
Log:
Testbed and skeleton of a new expression parser

LLVM's JIT is now the foundation of dynamic-compilation features for many 
languages. Clang also has low-level support for dynamic compilation 
(ASTImporter and ExternalASTSource, notably). How the compiler is set up for 
dynamic parsing is generally left up to individual clients, for example LLDB's 
C/C++/Objective-C expression parser and the ROOT project.

Although this arrangement offers external clients the flexibility to implement 
dynamic features as they see fit, the lack of an in-tree client means that 
subtle bugs can be introduced that cause regressions in the external clients 
but aren't caught by tests (or users) until much later. LLDB for example 
regularly encounters complicated ODR violation scenarios where it is not 
immediately clear who is at fault.

Other external clients (notably, Cling) rely on similar functionality, and 
another goal is to break this functionality up into composable parts so that 
any client can be built easily on top of Clang without requiring extensive 
additional code.

I propose that the parts required to build a simple expression parser be added 
to Clang.  Initially, I aim to have the following features:

- A piece that looks up external declarations from a variety of sources (e.g., 
from previous dynamic compilations, from modules, or from DWARF) and uses clear 
conflict resolution rules to reconcile differences, with easily understood 
errors. This functionality will be supported by in-tree tests.

- A piece that works hand in hand with the LLVM JIT to resolve the locations of 
external declarations so that e.g. variables can be redeclared and (for 
high-performance applications like DTrace) external variables can be accessed 
directly from the registers where they reside.

This commit adds a tester that parses a sequence of source files and then uses 
them as source data for an expression. External references are resolved using 
an ExternalASTSource that responds to name queries using an ASTImporter. This 
is the setup that LLDB uses, and the motivating reason for MinimalImport in 
ASTImporter.  When complete, this tester will implement the first of the above 
goals.

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

Added:
cfe/trunk/test/Import/
cfe/trunk/test/Import/clang-flags/
cfe/trunk/test/Import/clang-flags/Inputs/
cfe/trunk/test/Import/clang-flags/Inputs/S.c
cfe/trunk/test/Import/clang-flags/test.c
cfe/trunk/test/Import/empty-struct/
cfe/trunk/test/Import/empty-struct/Inputs/
cfe/trunk/test/Import/empty-struct/Inputs/S.c
cfe/trunk/test/Import/empty-struct/test.c
cfe/trunk/test/Import/error-in-expression/
cfe/trunk/test/Import/error-in-expression/Inputs/
cfe/trunk/test/Import/error-in-expression/Inputs/S.c
cfe/trunk/test/Import/error-in-expression/test.c
cfe/trunk/test/Import/error-in-import/
cfe/trunk/test/Import/error-in-import/Inputs/
cfe/trunk/test/Import/error-in-import/Inputs/S.c
cfe/trunk/test/Import/error-in-import/test.c
cfe/trunk/test/Import/missing-import/
cfe/trunk/test/Import/missing-import/test.c
cfe/trunk/tools/clang-import-test/
cfe/trunk/tools/clang-import-test/CMakeLists.txt
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
Modified:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/tools/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=290004=290003=290004=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Fri Dec 16 17:21:38 2016
@@ -39,6 +39,7 @@ list(APPEND CLANG_TEST_DEPS
   c-index-test diagtool
   clang-tblgen
   clang-offload-bundler
+  clang-import-test
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Added: cfe/trunk/test/Import/clang-flags/Inputs/S.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/clang-flags/Inputs/S.c?rev=290004=auto
==
--- cfe/trunk/test/Import/clang-flags/Inputs/S.c (added)
+++ cfe/trunk/test/Import/clang-flags/Inputs/S.c Fri Dec 16 17:21:38 2016
@@ -0,0 +1,2 @@
+STRUCT S {
+};

Added: cfe/trunk/test/Import/clang-flags/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/clang-flags/test.c?rev=290004=auto
==
--- cfe/trunk/test/Import/clang-flags/test.c (added)
+++ cfe/trunk/test/Import/clang-flags/test.c Fri Dec 16 17:21:38 2016
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/S.c -expression %s -Xcc 
-DSTRUCT=struct
+void expr() {
+  STRUCT S MyS;
+  void *MyPtr = 
+}

Added: cfe/trunk/test/Import/empty-struct/Inputs/S.c
URL: 

[PATCH] D27180: Testbed and skeleton of a new expression parser

2016-12-16 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 81803.
spyffe added a comment.

Updated CMakeFiles to fix dependencies.

- Fixed dependencies on `gen_intrinsics`
- Added a testsuite dependency on clang-import-test


Repository:
  rL LLVM

https://reviews.llvm.org/D27180

Files:
  test/CMakeLists.txt
  test/Import/clang-flags/Inputs/S.c
  test/Import/clang-flags/test.c
  test/Import/empty-struct/Inputs/S.c
  test/Import/empty-struct/test.c
  test/Import/error-in-expression/Inputs/S.c
  test/Import/error-in-expression/test.c
  test/Import/error-in-import/Inputs/S.c
  test/Import/error-in-import/test.c
  test/Import/missing-import/test.c
  tools/CMakeLists.txt
  tools/clang-import-test/CMakeLists.txt
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -0,0 +1,319 @@
+//===-- import-test.cpp - ASTImporter/ExternalASTSource testbed ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+
+using namespace clang;
+
+static llvm::cl::opt Expression(
+"expression", llvm::cl::Required,
+llvm::cl::desc("Path to a file containing the expression to parse"));
+
+static llvm::cl::list
+Imports("import", llvm::cl::ZeroOrMore,
+llvm::cl::desc("Path to a file containing declarations to import"));
+
+static llvm::cl::list
+ClangArgs("Xcc", llvm::cl::ZeroOrMore,
+  llvm::cl::desc("Argument to pass to the CompilerInvocation"),
+  llvm::cl::CommaSeparated);
+
+namespace init_convenience {
+class TestDiagnosticConsumer : public DiagnosticConsumer {
+private:
+  std::unique_ptr Passthrough;
+  const LangOptions *LangOpts = nullptr;
+
+public:
+  TestDiagnosticConsumer()
+  : Passthrough(llvm::make_unique()) {}
+
+  virtual void BeginSourceFile(const LangOptions ,
+   const Preprocessor *PP = nullptr) override {
+this->LangOpts = 
+return Passthrough->BeginSourceFile(LangOpts, PP);
+  }
+
+  virtual void EndSourceFile() override {
+this->LangOpts = nullptr;
+Passthrough->EndSourceFile();
+  }
+
+  virtual bool IncludeInDiagnosticCounts() const override {
+return Passthrough->IncludeInDiagnosticCounts();
+  }
+
+private:
+  static void PrintSourceForLocation(const SourceLocation ,
+ SourceManager ) {
+const char *LocData = SM.getCharacterData(Loc, /*Invalid=*/nullptr);
+unsigned LocColumn =
+SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
+FileID FID = SM.getFileID(Loc);
+llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+
+assert(LocData >= Buffer->getBufferStart() &&
+   LocData < Buffer->getBufferEnd());
+
+const char *LineBegin = LocData - LocColumn;
+
+assert(LineBegin >= Buffer->getBufferStart());
+
+const char *LineEnd = nullptr;
+
+for (LineEnd = LineBegin; *LineEnd != '\n' && *LineEnd != '\r' &&
+  LineEnd < Buffer->getBufferEnd();
+ ++LineEnd)
+  ;
+
+llvm::StringRef LineString(LineBegin, LineEnd - LineBegin);
+
+llvm::errs() << LineString << '\n';
+std::string Space(LocColumn, ' ');
+llvm::errs() << Space.c_str() << '\n';
+  }
+
+  virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+if (Info.hasSourceManager() && LangOpts) {
+  SourceManager  = Info.getSourceManager();
+
+  if (Info.getLocation().isValid()) {
+Info.getLocation().print(llvm::errs(), SM);
+llvm::errs() << ": ";
+  }
+
+  SmallString<16> DiagText;
+  Info.FormatDiagnostic(DiagText);
+  llvm::errs() << DiagText << '\n';
+
+  if (Info.getLocation().isValid()) {
+PrintSourceForLocation(Info.getLocation(), SM);
+  }
+
+  for (const CharSourceRange  : Info.getRanges()) {
+bool Invalid = true;
+StringRef 

RE: r289995 - [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

2016-12-16 Thread Yung, Douglas via cfe-commits
Hi, this change seems to be causing the PS4 Windows build bot to be red, can 
you take a look?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2784

C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP -DCLANG_ENABLE_ARCMT 
-DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER 
-DCLANG_TOOL_EXTRA_BUILD -DGTEST_HAS_RTTI=0 -DUNICODE -D_CINDEX_LIB_ 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools\clang\tools\libclang 
-IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang
 
-IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\include
 -Itools\clang\include -Iinclude 
-IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\include
 /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 
-wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 
-wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 
-wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 
-wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Zc:strictStrings /Oi 
/Zc:rvalueCast /MD /O2 /Ob2   -UNDEBUG  /EHs-c- /GR- /showIncludes 
/Fotools\clang\tools\libclang\CMakeFiles\libclang.dir\CXType.cpp.obj 
/Fdtools\clang\tools\libclang\CMakeFiles\libclang.dir\ /FS -c 
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
 error C2526: 'GetTemplateArguments': C linkage function cannot return C++ 
class 'llvm::Optional'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(927):
 error C2562: 'GetTemplateArguments': 'void' function returning a value
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
 note: see declaration of 'GetTemplateArguments'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(933):
 error C2562: 'GetTemplateArguments': 'void' function returning a value
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
 note: see declaration of 'GetTemplateArguments'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(936):
 error C2562: 'GetTemplateArguments': 'void' function returning a value
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924):
 note: see declaration of 'GetTemplateArguments'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(926):
 warning C4390: ';': empty controlled statement found; is this the intent?
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(932):
 warning C4390: ';': empty controlled statement found; is this the intent?
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(952):
 error C3313: 'TA': variable cannot have the type 'void'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(953):
 error C3536: 'TA': cannot be used before it is initialized
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(956):
 error C2228: left of '.getValue' must have class/struct/union
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(956):
 note: type is 'int'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959):
 error C2526: 'TemplateArgumentToQualType': C linkage function cannot return 
C++ class 'llvm::Optional'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(961):
 error C2562: 'TemplateArgumentToQualType': 'void' function returning a value
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959):
 note: see declaration of 'TemplateArgumentToQualType'
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(962):
 error C2562: 'TemplateArgumentToQualType': 'void' function returning a value

[PATCH] D27858: Default to standalone debug info on Windows

2016-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D27858#625367, @thakis wrote:

> Did you measure what this does to link times?


I've measured now, and it's pretty bad. Times to link blink_core increase by 
39% with -fstandalone-debug (211s -> 294s). I still think it's what we should 
do by default.

There's other things we can do with PCH to have less duplicate debug info when 
not using /debug:fastlink.


https://reviews.llvm.org/D27858



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


Re: [PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2016-12-16 Thread Nico Weber via cfe-commits
https://developer.apple.com/library/content/releasenotes/General/CarbonCoreDeprecations/index.html#//apple_ref/doc/uid/TP40012224-CH1-SW16
explicitly suggests sysctl as replacement when targeting 10.8+, which
strongly suggests that it'll work.

On Fri, Dec 16, 2016 at 4:37 PM, Erik Pilkington via Phabricator <
revi...@reviews.llvm.org> wrote:

> erik.pilkington added a comment.
>
> I seem to remember that mapping from kernel versions to marketing versions
> was tossed around as a potential alternative to Gestalt. I think that the
> problem was Apple sometimes introduces (or reserves the right to introduce)
> new SDKs in a patch release (ie, Z in X.Y.Z), which wouldn't necessary
> imply a new kernel version, and would still need to be queried by
> @available. This makes it impossible to use kernel version in the general
> case (Or at least I think, it would be nice if someone internal to Apple
> could confirm this?). This rules out using `sysctl()` and the like.
>
> AFAIK this just leaves `Gestalt()` and Objective-C's `NSProcessInfo`, the
> latter would mean pulling in the Objective-C runtime, which would be
> unfortunate for C users (using the `__builtin_available` spelling). I don't
> think `Gestalt()` is in any danger of actually being removed, so we might
> as well use it. The only alternative I know of to those would be manually
> parsing the `SystemVersion.plist` XML file, but I think that might cause
> problems with sandboxed processes (right?). Any thoughts here would be much
> appreciated, `Gestalt()` is by no means a perfect solution.
>
> Compiler-rt does seem like a good place it put this, should I move the
> runtime code there instead?
>
> Thanks for taking a look!
> Erik
>
>
> https://reviews.llvm.org/D27827
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D27858: Default to standalone debug info on Windows

2016-12-16 Thread Nico Weber via cfe-commits
Won't that make is_win_fastlink builds slow to link? And if we do this,
then this change here makes a then-not-very-tested config the default.

(I don't have a problem with this patch, go ahead and land if you think
it's the way to go. Just wondering aloud.)

On Fri, Dec 16, 2016 at 4:39 PM, Reid Kleckner via Phabricator <
revi...@reviews.llvm.org> wrote:

> rnk added a comment.
>
> In https://reviews.llvm.org/D27858#625367, @thakis wrote:
>
> > Did you measure what this does to link times?
>
>
> No, but I plan to recover it in Chromium by doing something like:
>
>   if (is_win && is_clang && !is_win_fastlink) {
> cflags += ["-flimit-debug-info"]
>   }
>
>
> https://reviews.llvm.org/D27858
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-16 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose updated this revision to Diff 81796.
jordan_rose added a comment.

Updated names to match LLVM style.


Repository:
  rL LLVM

https://reviews.llvm.org/D27837

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaType.cpp
  test/FixIt/Inputs/nullability.h
  test/FixIt/nullability.mm
  test/SemaObjCXX/Inputs/nullability-consistency-1.h
  test/SemaObjCXX/Inputs/nullability-consistency-2.h
  test/SemaObjCXX/Inputs/nullability-consistency-3.h
  test/SemaObjCXX/Inputs/nullability-consistency-4.h
  test/SemaObjCXX/Inputs/nullability-consistency-5.h
  test/SemaObjCXX/Inputs/nullability-consistency-6.h
  test/SemaObjCXX/Inputs/nullability-consistency-7.h
  test/SemaObjCXX/Inputs/nullability-consistency-8.h
  test/SemaObjCXX/Inputs/nullability-consistency-arrays.h
  
test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
  test/SemaObjCXX/Inputs/nullability-pragmas-1.h

Index: test/SemaObjCXX/Inputs/nullability-pragmas-1.h
===
--- test/SemaObjCXX/Inputs/nullability-pragmas-1.h
+++ test/SemaObjCXX/Inputs/nullability-pragmas-1.h
@@ -9,6 +9,8 @@
 struct X { };
 
 void f1(int *x); // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
 
 typedef struct __attribute__((objc_bridge(NSError))) __CFError *CFErrorRef;
 typedef NSError *NSErrorPtr;
@@ -39,15 +41,29 @@
 A * _Null_unspecified f16(void);
 void f17(CFErrorRef *error); // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef  _Nullable * _Nullable' (aka '__CFError **') for 1st argument}}
 void f18(A **); // expected-warning 2{{pointer is missing a nullability type specifier}}
+// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
 void f19(CFErrorRefPtr error); // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
 
 void g1(int (^)(int, int));
 void g2(int (^ *bp)(int, int)); // expected-warning{{block pointer is missing a nullability type specifier}}
-// expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
+// expected-warning@-3{{pointer is missing a nullability type specifier}}
+// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
 void g3(block_ptr *bp); // expected-warning{{block pointer is missing a nullability type specifier}}
-// expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
+// expected-warning@-3{{pointer is missing a nullability type specifier}}
+// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
 void g4(int (*fp)(int, int));
 void g5(int (**fp)(int, int)); // expected-warning 2{{pointer is missing a nullability type specifier}}
+// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
 
 @interface A(Pragmas1)
 + (instancetype)aWithA:(A *)a;
@@ -57,17 +73,23 @@
 - (void)method4:(NSErrorPtr *)error; // expected-note{{passing argument to parameter 'error' here}}
 - (void)method5:(NSErrorPtrPtr)error;
 // expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-2{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-3{{insert '_Nonnull' if the pointer should never be null}}
 
 @property A *aProp;
 @property NSError **anError; // expected-warning 2{{pointer is missing a nullability type specifier}}
+// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
 @end
 
 int *global_int_ptr;
 
 // typedefs not inferred _Nonnull
 typedef int *int_ptr_2;
 
 typedef int * // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
 *int_ptr_ptr;
 
 static inline void f30(void) {
@@ -90,12 +112,22 @@
 #pragma clang assume_nonnull end
 
 void f20(A *a); // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if 

Re: r289991 - Revert r289979 due to regressions

2016-12-16 Thread Reid Kleckner via cfe-commits
This revert broke the build because you failed to resolve conflicts
in include/clang/Basic/OpenCLOptions.h caused by r289985. I've reverted
that file in r289997.

On Fri, Dec 16, 2016 at 1:23 PM, Yaxun Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yaxunl
> Date: Fri Dec 16 15:23:55 2016
> New Revision: 289991
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289997 - Really revert all changes from r289979. Apparently conflict resolution failed

2016-12-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec 16 16:11:28 2016
New Revision: 289997

URL: http://llvm.org/viewvc/llvm-project?rev=289997=rev
Log:
Really revert all changes from r289979. Apparently conflict resolution failed

Modified:
cfe/trunk/include/clang/Basic/OpenCLOptions.h

Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLOptions.h?rev=289997=289996=289997=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLOptions.h (original)
+++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Fri Dec 16 16:11:28 2016
@@ -15,122 +15,81 @@
 #ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H
 #define LLVM_CLANG_BASIC_OPENCLOPTIONS_H
 
-#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 
 /// \brief OpenCL supported extensions and optional core features
 class OpenCLOptions {
-  struct Info {
-bool Supported; // Is this option supported
-bool Enabled;   // Is this option enabled
-unsigned Avail; // Option starts to be available in this OpenCL version
-unsigned Core;  // Option becomes (optional) core feature in this OpenCL
-// version
-Info(bool S = false, bool E = false, unsigned A = 100, unsigned C = ~0U)
-  :Supported(S), Enabled(E), Avail(A), Core(C){}
-  };
-  llvm::StringMap OptMap;
 public:
-  bool isKnown(llvm::StringRef Ext) const {
-return OptMap.find(Ext) != OptMap.end();
-  }
-
-  bool isEnabled(llvm::StringRef Ext) const {
-return OptMap.find(Ext)->second.Enabled;
-  }
-
-  // Is supported as either an extension or an (optional) core feature for
-  // OpenCL version \p CLVer.
-  bool isSupported(llvm::StringRef Ext, unsigned CLVer) const {
-auto I = OptMap.find(Ext)->getValue();
-return I.Supported && I.Avail <= CLVer;
-  }
+#define OPENCLEXT(nm) unsigned nm : 1;
+#include "clang/Basic/OpenCLExtensions.def"
 
-  // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
-  // For supported extension, return false.
-  bool isSupportedCore(llvm::StringRef Ext, unsigned CLVer) const {
-auto I = OptMap.find(Ext)->getValue();
-return I.Supported && I.Avail <= CLVer &&
-  I.Core != ~0U && CLVer >= I.Core;
-  }
-
-  // Is supported OpenCL extension for OpenCL version \p CLVer.
-  // For supported (optional) core feature, return false.
- bool isSupportedExtension(llvm::StringRef Ext, unsigned CLVer) const {
-auto I = OptMap.find(Ext)->getValue();
-return I.Supported && I.Avail <= CLVer &&
-  (I.Core == ~0U || CLVer < I.Core);
+  OpenCLOptions() {
+#define OPENCLEXT(nm)   nm = 0;
+#include "clang/Basic/OpenCLExtensions.def"
   }
 
-  void enable(llvm::StringRef Ext, bool V = true) {
-OptMap[Ext].Enabled = V;
+  // Enable or disable all options.
+  void setAll(bool Enable = true) {
+#define OPENCLEXT(nm)   nm = Enable;
+#include "clang/Basic/OpenCLExtensions.def"
   }
 
   /// \brief Enable or disable support for OpenCL extensions
   /// \param Ext name of the extension optionally prefixed with
   ///'+' or '-'
   /// \param Enable used when \p Ext is not prefixed by '+' or '-'
-  void support(llvm::StringRef Ext, bool V = true) {
+  void set(llvm::StringRef Ext, bool Enable = true) {
 assert(!Ext.empty() && "Extension is empty.");
 
 switch (Ext[0]) {
 case '+':
-  V = true;
+  Enable = true;
   Ext = Ext.drop_front();
   break;
 case '-':
-  V = false;
+  Enable = false;
   Ext = Ext.drop_front();
   break;
 }
 
 if (Ext.equals("all")) {
-  supportAll(V);
+  setAll(Enable);
   return;
 }
-OptMap[Ext].Supported = V;
-  }
 
-  OpenCLOptions(){
-#define OPENCLEXT_INTERNAL(Ext, AvailVer, CoreVer) \
-OptMap[#Ext].Avail = AvailVer; \
-OptMap[#Ext].Core = CoreVer;
+#define OPENCLEXT(nm)   \
+if (Ext.equals(#nm)) {  \
+  nm = Enable;  \
+}
 #include "clang/Basic/OpenCLExtensions.def"
   }
 
-  void addSupport(const OpenCLOptions ) {
-for (auto :Opts.OptMap)
-  if (I.second.Supported)
-OptMap[I.getKey()].Supported = true;
+  // Is supported with OpenCL version \p OCLVer.
+#define OPENCLEXT_INTERNAL(Ext, Avail, ...) \
+  bool is_##Ext##_supported(unsigned OCLVer) const { \
+return Ext && OCLVer >= Avail; \
   }
+#include "clang/Basic/OpenCLExtensions.def"
 
-  void copy(const OpenCLOptions ) {
-OptMap = Opts.OptMap;
-  }
 
-  // Turn on or off support of all options.
-  void supportAll(bool On = true) {
-for (llvm::StringMap::iterator I = OptMap.begin(),
- E = OptMap.end(); I != E; ++I)
-  I->second.Supported = On;
-  }
-
-  void disableAll() {
-for (llvm::StringMap::iterator I = OptMap.begin(),
- E = OptMap.end(); I != E; ++I)
-  I->second.Enabled = false;
+  // Is supported OpenCL extension with OpenCL version \p OCLVer.
+  // For supported optional core feature, return false.

r289996 - IRGen: Fix assertion failure when creating debug info for an integer constant wider than 64 bits.

2016-12-16 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Dec 16 16:10:52 2016
New Revision: 289996

URL: http://llvm.org/viewvc/llvm-project?rev=289996=rev
Log:
IRGen: Fix assertion failure when creating debug info for an integer constant 
wider than 64 bits.

Added:
cfe/trunk/test/CodeGen/dbg-const-int128.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289996=289995=289996=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Dec 16 16:10:52 2016
@@ -3759,12 +3759,15 @@ void CGDebugInfo::EmitGlobalVariable(con
   if (GV)
 return;
   llvm::DIExpression *InitExpr = nullptr;
-  if (Init.isInt())
-InitExpr =
-DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
-  else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64)
-InitExpr = DBuilder.createConstantValueExpression(
-Init.getFloat().bitcastToAPInt().getZExtValue());
+  if (CGM.getContext().getTypeSize(VD->getType()) <= 64) {
+// FIXME: Add a representation for integer constants wider than 64 bits.
+if (Init.isInt())
+  InitExpr =
+  DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
+else if (Init.isFloat())
+  InitExpr = DBuilder.createConstantValueExpression(
+  Init.getFloat().bitcastToAPInt().getZExtValue());
+  }
   GV.reset(DBuilder.createGlobalVariable(
   DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
   true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),

Added: cfe/trunk/test/CodeGen/dbg-const-int128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dbg-const-int128.c?rev=289996=auto
==
--- cfe/trunk/test/CodeGen/dbg-const-int128.c (added)
+++ cfe/trunk/test/CodeGen/dbg-const-int128.c Fri Dec 16 16:10:52 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited  %s -o - | FileCheck 
%s
+// CHECK: !DIGlobalVariable({{.*}}
+// CHECK-NOT: expr:
+
+static const __uint128_t ro = 18446744073709551615;
+
+void bar(__uint128_t);
+void foo() { bar(ro); }


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


r289995 - [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

2016-12-16 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Dec 16 15:40:16 2016
New Revision: 289995

URL: http://llvm.org/viewvc/llvm-project?rev=289995=rev
Log:
[libclang] Restore the CXXRecordDecl path for 
clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType

Patch by Emilio Cobos Álvarez!
See https://reviews.llvm.org/D26907

Modified:
cfe/trunk/test/Index/keep-going.cpp
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/test/Index/keep-going.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/keep-going.cpp?rev=289995=289994=289995=diff
==
--- cfe/trunk/test/Index/keep-going.cpp (original)
+++ cfe/trunk/test/Index/keep-going.cpp Fri Dec 16 15:40:16 2016
@@ -19,10 +19,10 @@ class C : public A { };
 // CHECK: FieldDecl=a:4:13 (Definition) [type=T] [typekind=Unexposed] 
[canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
 // CHECK: TypeRef=T:3:16 [type=T] [typekind=Unexposed] 
[canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
 // CHECK: ClassDecl=B:6:7 (Definition) [type=B] [typekind=Record] [isPOD=0]
-// CHECK: C++ base class specifier=A:4:7 [access=public isVirtual=false] 
[type=A] [typekind=Unexposed] [canonicaltype=A] 
[canonicaltypekind=Record] [templateargs/1= [type=int] [typekind=Int]] 
[isPOD=0] [nbFields=1]
+// CHECK: C++ base class specifier=A:4:7 [access=public isVirtual=false] 
[type=A] [typekind=Unexposed] [templateargs/1= [type=int] [typekind=Int]] 
[canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= 
[type=int] [typekind=Int]] [isPOD=0] [nbFields=1]
 // CHECK: TemplateRef=A:4:7 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ClassDecl=C:10:7 (Definition) [type=C] [typekind=Record] [isPOD=0]
-// CHECK: C++ base class specifier=A:4:7 [access=public 
isVirtual=false] [type=A] [typekind=Unexposed] [canonicaltype=A] 
[canonicaltypekind=Record] [templateargs/1= [type=float] [typekind=Float]] 
[isPOD=0] [nbFields=1]
+// CHECK: C++ base class specifier=A:4:7 [access=public 
isVirtual=false] [type=A] [typekind=Unexposed] [templateargs/1= 
[type=float] [typekind=Float]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=float] 
[typekind=Float]] [isPOD=0] [nbFields=1]
 // CHECK: TemplateRef=A:4:7 [type=] [typekind=Invalid] [isPOD=0]
 
 // CHECK-DIAG: keep-going.cpp:1:10: error: 'missing1.h' file not found

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=289995=289994=289995=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Fri Dec 16 15:40:16 2016
@@ -61,6 +61,15 @@ using TypeAlias = outer::Qux;
 
 struct TypeAliasUser { TypeAlias foo; };
 
+template
+struct Specialization {};
+
+template<>
+struct Specialization;
+
+Specialization templRefParam;
+auto autoTemplRefParam = templRefParam;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -100,11 +109,11 @@ struct TypeAliasUser { TypeAlias fo
 // CHECK: TypedefDecl=OtherType:25:18 (Definition) [type=OtherType] 
[typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double] [isPOD=1]
 // CHECK: TypedefDecl=ArrayType:26:15 (Definition) [type=ArrayType] 
[typekind=Typedef] [canonicaltype=int [5]] [canonicaltypekind=ConstantArray] 
[isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
-// CHECK: FieldDecl=baz:27:20 (Definition) [type=Baz] 
[typekind=Unexposed] [canonicaltype=outer::Baz] 
[canonicaltypekind=Record] [templateargs/3= [type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=baz:27:20 (Definition) [type=Baz] 
[typekind=Unexposed] [templateargs/3= [type=int] [typekind=Int]] 
[canonicaltype=outer::Baz] [canonicaltypekind=Record] 
[canonicaltemplateargs/3= [type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:28:29 (Definition) [type=Qux] 
[typekind=Unexposed] [canonicaltype=outer::Qux] 
[canonicaltypekind=Record] [templateargs/3= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=Foo] [typekind=Unexposed]] [isPOD=1]
+// CHECK: FieldDecl=qux:28:29 (Definition) [type=Qux] 
[typekind=Unexposed] [templateargs/3= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=Foo] [typekind=Unexposed]] 

[PATCH] D27858: Default to standalone debug info on Windows

2016-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D27858#625367, @thakis wrote:

> Did you measure what this does to link times?


No, but I plan to recover it in Chromium by doing something like:

  if (is_win && is_clang && !is_win_fastlink) {
cflags += ["-flimit-debug-info"]
  }


https://reviews.llvm.org/D27858



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


[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2016-12-16 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

I seem to remember that mapping from kernel versions to marketing versions was 
tossed around as a potential alternative to Gestalt. I think that the problem 
was Apple sometimes introduces (or reserves the right to introduce) new SDKs in 
a patch release (ie, Z in X.Y.Z), which wouldn't necessary imply a new kernel 
version, and would still need to be queried by @available. This makes it 
impossible to use kernel version in the general case (Or at least I think, it 
would be nice if someone internal to Apple could confirm this?). This rules out 
using `sysctl()` and the like.

AFAIK this just leaves `Gestalt()` and Objective-C's `NSProcessInfo`, the 
latter would mean pulling in the Objective-C runtime, which would be 
unfortunate for C users (using the `__builtin_available` spelling). I don't 
think `Gestalt()` is in any danger of actually being removed, so we might as 
well use it. The only alternative I know of to those would be manually parsing 
the `SystemVersion.plist` XML file, but I think that might cause problems with 
sandboxed processes (right?). Any thoughts here would be much appreciated, 
`Gestalt()` is by no means a perfect solution.

Compiler-rt does seem like a good place it put this, should I move the runtime 
code there instead?

Thanks for taking a look!
Erik


https://reviews.llvm.org/D27827



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


r289991 - Revert r289979 due to regressions

2016-12-16 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Dec 16 15:23:55 2016
New Revision: 289991

URL: http://llvm.org/viewvc/llvm-project?rev=289991=rev
Log:
Revert r289979 due to regressions

Removed:
cfe/trunk/test/CodeGenOpenCL/extension-begin.cl
cfe/trunk/test/SemaOpenCL/extension-begin.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenCLImageTypes.def
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Parser/opencl-atomics-cl20.cl
cfe/trunk/test/Parser/opencl-pragma.cl
cfe/trunk/test/SemaOpenCL/extensions.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=289991=289990=289991=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Dec 16 15:23:55 
2016
@@ -968,10 +968,8 @@ def err_opencl_unroll_hint_on_non_loop :
 // OpenCL EXTENSION pragma (OpenCL 1.1 [9.1])
 def warn_pragma_expected_colon : Warning<
   "missing ':' after %0 - ignoring">, InGroup;
-def warn_pragma_expected_predicate : Warning<
-  "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - 
ignoring">, InGroup;
-def warn_pragma_begin_end_mismatch : Warning<
-  "OpenCL extension end directive mismatches begin directive - ignoring">, 
InGroup;
+def warn_pragma_expected_enable_disable : Warning<
+  "expected 'enable' or 'disable' - ignoring">, InGroup;
 def warn_pragma_unknown_extension : Warning<
   "unknown OpenCL extension %0 - ignoring">, InGroup;
 def warn_pragma_unsupported_extension : Warning<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=289991=289990=289991=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 16 15:23:55 
2016
@@ -3359,8 +3359,6 @@ def note_ovl_candidate_has_pass_object_s
 "pass_object_size attribute">;
 def note_ovl_candidate_disabled_by_enable_if_attr : Note<
 "candidate disabled: %0">;
-def note_ovl_candidate_disabled_by_extension : Note<
-"candidate disabled due to OpenCL extension">;
 def err_addrof_function_disabled_by_enable_if_attr : Error<
 "cannot take address of function %0 becuase it has one or more "
 "non-tautological enable_if conditions">;
@@ -7938,6 +7936,8 @@ def ext_c99_array_usage : Extension<
 def err_c99_array_usage_cxx : Error<
   "%select{qualifier in |static |}0array size %select{||'[*] '}0is a C99 "
   "feature, not permitted in C++">;
+ def err_type_requires_extension : Error<
+  "use of type %0 requires %1 extension to be enabled">;
 def err_type_unsupported : Error<
   "%0 is not supported on this target">;
 def err_nsconsumed_attribute_mismatch : Error<
@@ -8143,8 +8143,6 @@ def warn_opencl_attr_deprecated_ignored
   InGroup;
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
-def err_opencl_requires_extension : Error<
-  "use of %select{type |declaration}0%1 requires %2 extension to be enabled">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<

Modified: cfe/trunk/include/clang/Basic/OpenCLImageTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLImageTypes.def?rev=289991=289990=289991=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLImageTypes.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLImageTypes.def Fri Dec 16 15:23:55 2016
@@ -7,79 +7,73 @@
 //
 
//===--===//
 //  This file extends builtin types database with OpenCL image singleton types.
-//  Custom code should define one of those three macros:
-//

r289990 - [Sema] Transform the default arguments of a lambda expression when the

2016-12-16 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Dec 16 15:16:57 2016
New Revision: 289990

URL: http://llvm.org/viewvc/llvm-project?rev=289990=rev
Log:
[Sema] Transform the default arguments of a lambda expression when the
lambda expression is instantiated.

Rather than waiting until Sema::CheckCXXDefaultArgExpr tries to
transform the default arguments (which fails because it can't get the
template arguments that are used), transform the default arguments
earlier when the lambda expression is transformed in
TransformLambdaExpr.

rdar://problem/27535319

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

Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=289990=289989=289990=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Dec 16 15:16:57 2016
@@ -10356,6 +10356,18 @@ TreeTransform::TransformLambdaE
 
   LSI->CallOperator = NewCallOperator;
 
+  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
+   I != NumParams; ++I) {
+auto *P = NewCallOperator->getParamDecl(I);
+if (P->hasUninstantiatedDefaultArg()) {
+  EnterExpressionEvaluationContext Eval(
+  getSema(), Sema::PotentiallyEvaluatedIfUsed, P);
+  ExprResult R = getDerived().TransformExpr(
+  E->getCallOperator()->getParamDecl(I)->getDefaultArg());
+  P->setDefaultArg(R.get());
+}
+  }
+
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
 

Modified: cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp?rev=289990=289989=289990=diff
==
--- cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp (original)
+++ cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp Fri Dec 16 15:16:57 2016
@@ -1,18 +1,36 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  auto fn0 = [] {};
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
+template auto v1 = [](int a = T(1)) { return a; }();
+
+struct S {
+  template
+  static constexpr T t = [](int f = T(7)){return f;}(); // 
expected-error{{constexpr variable 't' must be initialized by a constant 
expression}} expected-error{{a lambda expression may not appear inside of a 
constant expression}} expected-note{{cannot be used in a constant expression}}
+};
 
 template 
 int foo2() {
   X a = 0x61;
   fn1(a);
+  (void)v1;
+  (void)S::t; // expected-note{{in instantiation of static data member 
'S::t' requested here}}
   return 0;
 }
 
+template
+int foo3() {
+  C::m1(); // expected-error{{type 'long long' cannot be used prior to '::' 
because it has no members}}
+  return 1;
+}
+
+template
+auto v2 = [](int a = foo3()){};  // expected-note{{in instantiation of 
function template specialization 'foo3' requested here}}
+
 int main() {
+  v2();  // This line causes foo3 to be instantiated.
+  v2(2); // This line does not.
   foo2();
 }


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


[PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

2016-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289990: [Sema] Transform the default arguments of a lambda 
expression when the (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D23096?vs=81171=81787#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23096

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp


Index: cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
===
--- cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
+++ cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
@@ -1,18 +1,36 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  auto fn0 = [] {};
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
+template auto v1 = [](int a = T(1)) { return a; }();
+
+struct S {
+  template
+  static constexpr T t = [](int f = T(7)){return f;}(); // 
expected-error{{constexpr variable 't' must be initialized by a constant 
expression}} expected-error{{a lambda expression may not appear inside of a 
constant expression}} expected-note{{cannot be used in a constant expression}}
+};
 
 template 
 int foo2() {
   X a = 0x61;
   fn1(a);
+  (void)v1;
+  (void)S::t; // expected-note{{in instantiation of static data member 
'S::t' requested here}}
   return 0;
 }
 
+template
+int foo3() {
+  C::m1(); // expected-error{{type 'long long' cannot be used prior to '::' 
because it has no members}}
+  return 1;
+}
+
+template
+auto v2 = [](int a = foo3()){};  // expected-note{{in instantiation of 
function template specialization 'foo3' requested here}}
+
 int main() {
+  v2();  // This line causes foo3 to be instantiated.
+  v2(2); // This line does not.
   foo2();
 }
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -10356,6 +10356,18 @@
 
   LSI->CallOperator = NewCallOperator;
 
+  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
+   I != NumParams; ++I) {
+auto *P = NewCallOperator->getParamDecl(I);
+if (P->hasUninstantiatedDefaultArg()) {
+  EnterExpressionEvaluationContext Eval(
+  getSema(), Sema::PotentiallyEvaluatedIfUsed, P);
+  ExprResult R = getDerived().TransformExpr(
+  E->getCallOperator()->getParamDecl(I)->getDefaultArg());
+  P->setDefaultArg(R.get());
+}
+  }
+
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
 


Index: cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
===
--- cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
+++ cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
@@ -1,18 +1,36 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  auto fn0 = [] {};
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
+template auto v1 = [](int a = T(1)) { return a; }();
+
+struct S {
+  template
+  static constexpr T t = [](int f = T(7)){return f;}(); // expected-error{{constexpr variable 't' must be initialized by a constant expression}} expected-error{{a lambda expression may not appear inside of a constant expression}} expected-note{{cannot be used in a constant expression}}
+};
 
 template 
 int foo2() {
   X a = 0x61;
   fn1(a);
+  (void)v1;
+  (void)S::t; // expected-note{{in instantiation of static data member 'S::t' requested here}}
   return 0;
 }
 
+template
+int foo3() {
+  C::m1(); // expected-error{{type 'long long' cannot be used prior to '::' because it has no members}}
+  return 1;
+}
+
+template
+auto v2 = [](int a = foo3()){};  // expected-note{{in instantiation of function template specialization 'foo3' requested here}}
+
 int main() {
+  v2();  // This line causes foo3 to be instantiated.
+  v2(2); // This line does not.
   foo2();
 }
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -10356,6 +10356,18 @@
 
   LSI->CallOperator = NewCallOperator;
 
+  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
+   I != NumParams; ++I) {
+auto *P = NewCallOperator->getParamDecl(I);
+if (P->hasUninstantiatedDefaultArg()) {
+  EnterExpressionEvaluationContext Eval(
+  getSema(), Sema::PotentiallyEvaluatedIfUsed, P);
+  ExprResult R = getDerived().TransformExpr(
+  E->getCallOperator()->getParamDecl(I)->getDefaultArg());
+  P->setDefaultArg(R.get());
+}
+  }
+
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
 

[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-12-16 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!


https://reviews.llvm.org/D26453



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


[PATCH] D27821: [OpenMP] support is_device_ptr clause with 'target parallel' pragma

2016-12-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289989: [OpenMP] support the 'is_device_ptr' clause with 
'target parallel' pragma (authored by kli).

Changed prior to commit:
  https://reviews.llvm.org/D27821?vs=81627=81785#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27821

Files:
  cfe/trunk/include/clang/Basic/OpenMPKinds.def
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
  cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_messages.cpp

Index: cfe/trunk/include/clang/Basic/OpenMPKinds.def
===
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def
@@ -451,7 +451,6 @@
 OPENMP_TARGET_EXIT_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'target parallel'.
-// TODO: add target clauses 'is_device_ptr'
 OPENMP_TARGET_PARALLEL_CLAUSE(if)
 OPENMP_TARGET_PARALLEL_CLAUSE(device)
 OPENMP_TARGET_PARALLEL_CLAUSE(map)
@@ -465,6 +464,7 @@
 OPENMP_TARGET_PARALLEL_CLAUSE(proc_bind)
 OPENMP_TARGET_PARALLEL_CLAUSE(shared)
 OPENMP_TARGET_PARALLEL_CLAUSE(reduction)
+OPENMP_TARGET_PARALLEL_CLAUSE(is_device_ptr)
 
 // Clauses allowed for OpenMP directive 'target parallel for'.
 // TODO: add target clauses 'is_device_ptr'
Index: cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
@@ -0,0 +1,294 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct ST {
+  int *a;
+};
+typedef int arr[10];
+typedef ST STarr[10];
+struct SA {
+  const int da[5] = { 0 };
+  ST g[10];
+  STarr  = g;
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  arr  = aa;
+  void func(int arg) {
+#pragma omp target parallel is_device_ptr(k)
+{}
+#pragma omp target parallel is_device_ptr(z)
+{}
+#pragma omp target parallel is_device_ptr(aa) // OK
+{}
+#pragma omp target parallel is_device_ptr(raa) // OK
+{}
+#pragma omp target parallel is_device_ptr(g) // OK
+{}
+#pragma omp target parallel is_device_ptr(rg) // OK
+{}
+#pragma omp target parallel is_device_ptr(da) // OK
+{}
+  return;
+ }
+};
+// CHECK: struct SA
+// CHECK-NEXT: const int da[5] = {0};
+// CHECK-NEXT: ST g[10];
+// CHECK-NEXT: STarr  = this->g;
+// CHECK-NEXT: int i;
+// CHECK-NEXT: int  = this->i;
+// CHECK-NEXT: int *k = >j;
+// CHECK-NEXT: int * = this->k;
+// CHECK-NEXT: int aa[10];
+// CHECK-NEXT: arr  = this->aa;
+// CHECK-NEXT: func(
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->k)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->z)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->aa)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->raa)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->g)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->rg)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->da)
+
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef struct {
+  int a;
+} S6;
+
+template 
+T tmain(T argc) {
+  const T da[5] = { 0 };
+  S6 h[10];
+  auto  = h;
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+  auto  = aa;
+#pragma omp target parallel is_device_ptr(k)
+  {}
+#pragma omp target parallel is_device_ptr(z)
+  {}
+#pragma omp target parallel is_device_ptr(aa)
+  {}
+#pragma omp target parallel is_device_ptr(raa)
+ 

r289989 - [OpenMP] support the 'is_device_ptr' clause with 'target parallel' pragma

2016-12-16 Thread Kelvin Li via cfe-commits
Author: kli
Date: Fri Dec 16 14:50:46 2016
New Revision: 289989

URL: http://llvm.org/viewvc/llvm-project?rev=289989=rev
Log:
[OpenMP] support the 'is_device_ptr' clause with 'target parallel' pragma

This patch is to add support of the 'is_device_ptr' clause in the 'target 
parallel' pragma.

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

Added:
cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=289989=289988=289989=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Fri Dec 16 14:50:46 2016
@@ -451,7 +451,6 @@ OPENMP_TARGET_EXIT_DATA_CLAUSE(nowait)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'target parallel'.
-// TODO: add target clauses 'is_device_ptr'
 OPENMP_TARGET_PARALLEL_CLAUSE(if)
 OPENMP_TARGET_PARALLEL_CLAUSE(device)
 OPENMP_TARGET_PARALLEL_CLAUSE(map)
@@ -465,6 +464,7 @@ OPENMP_TARGET_PARALLEL_CLAUSE(default)
 OPENMP_TARGET_PARALLEL_CLAUSE(proc_bind)
 OPENMP_TARGET_PARALLEL_CLAUSE(shared)
 OPENMP_TARGET_PARALLEL_CLAUSE(reduction)
+OPENMP_TARGET_PARALLEL_CLAUSE(is_device_ptr)
 
 // Clauses allowed for OpenMP directive 'target parallel for'.
 // TODO: add target clauses 'is_device_ptr'

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=289989=289988=289989=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Dec 16 14:50:46 2016
@@ -7265,7 +7265,8 @@ OMPClause *Sema::ActOnOpenMPPrivateClaus
 // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
 // A list item cannot appear in both a map clause and a data-sharing
 // attribute clause on the same construct
-if (DSAStack->getCurrentDirective() == OMPD_target) {
+if (DSAStack->getCurrentDirective() == OMPD_target ||
+DSAStack->getCurrentDirective() == OMPD_target_parallel) {
   OpenMPClauseKind ConflictKind;
   if (DSAStack->checkMappableExprComponentListsForDecl(
   VD, /*CurrentRegionOnly=*/true,
@@ -7522,7 +7523,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
   // OpenMP 4.5 [2.15.5.1, Restrictions, p.3]
   // A list item cannot appear in both a map clause and a data-sharing
   // attribute clause on the same construct
-  if (CurrDir == OMPD_target) {
+  if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel) {
 OpenMPClauseKind ConflictKind;
 if (DSAStack->checkMappableExprComponentListsForDecl(
 VD, /*CurrentRegionOnly=*/true,

Added: cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp?rev=289989=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp Fri Dec 
16 14:50:46 2016
@@ -0,0 +1,294 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct ST {
+  int *a;
+};
+typedef int arr[10];
+typedef ST STarr[10];
+struct SA {
+  const int da[5] = { 0 };
+  ST g[10];
+  STarr  = g;
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  arr  = aa;
+  void func(int arg) {
+#pragma omp target parallel is_device_ptr(k)
+{}
+#pragma omp target parallel is_device_ptr(z)
+{}
+#pragma omp target parallel is_device_ptr(aa) // OK
+{}
+#pragma omp target parallel is_device_ptr(raa) // OK
+{}
+#pragma omp target parallel is_device_ptr(g) // OK
+{}
+#pragma omp target parallel is_device_ptr(rg) // OK
+{}
+#pragma omp target parallel is_device_ptr(da) // OK
+{}
+  return;
+ }
+};
+// CHECK: struct SA
+// CHECK-NEXT: const int da[5] = {0};
+// CHECK-NEXT: ST g[10];
+// CHECK-NEXT: STarr  = this->g;
+// CHECK-NEXT: int i;
+// CHECK-NEXT: int  = this->i;
+// CHECK-NEXT: int *k = >j;
+// CHECK-NEXT: int * = this->k;
+// CHECK-NEXT: int aa[10];
+// CHECK-NEXT: arr  = this->aa;
+// CHECK-NEXT: func(
+// CHECK-NEXT: #pragma omp target parallel is_device_ptr(this->k)
+// CHECK-NEXT: {
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp target parallel 

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

The provided example (typoing "i" for "j") sounds like the sort of thing that 
PVS-Studio catches; maybe see what wording they use for that kind of mistake?  
Without investigating, I would suggest "cut-and-paste-error" or "likely-typo".

However, the attached patch *doesn't implement* the provided example 
diagnostic, so right now it's really hard to say what the intent of this patch 
*is*. It's hard to argue about whether the name "obvious-" is correct for this 
group of diagnostics when the group is, er, empty.  I suggest that the way 
forward is to implement some of the intended diagnostics under an existing 
group and then later refactor them into a new group as needed; or else to 
implement so many of the intended diagnostics in *this* patch that the 
necessity for the new group is "obvious" :) to everyone involved.

Coincidentally, I was just reading 
https://en.wikipedia.org/wiki/WP:LEADFOLLOWSBODY last night. I think it's 
applicable here. :)


https://reviews.llvm.org/D27815



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


[PATCH] D20710: Lit C++11 Compatibility Patch #9

2016-12-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 81784.
tigerleapgorge added a comment.

Forgot to include all context inside the previous revision.

Previous patch: svn diff
This patch:svn diff --diff-cmd=diff -x -U99


https://reviews.llvm.org/D20710

Files:
  test/CodeGenCXX/debug-info-use-after-free.cpp
  test/CodeGenCXX/dynamic-cast-hint.cpp
  test/OpenMP/distribute_collapse_messages.cpp
  test/OpenMP/ordered_messages.cpp
  test/OpenMP/target_parallel_for_collapse_messages.cpp
  test/OpenMP/target_parallel_for_ordered_messages.cpp
  test/SemaCXX/i-c-e-cxx.cpp
  test/SemaCXX/implicit-virtual-member-functions.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/no-wchar.cpp
  test/SemaCXX/virtual-member-functions-key-function.cpp
  test/SemaCXX/warn-bool-conversion.cpp
  test/SemaCXX/zero-length-arrays.cpp
  test/SemaTemplate/instantiate-c99.cpp
  test/SemaTemplate/temp_explicit.cpp
  test/SemaTemplate/value-dependent-null-pointer-constant.cpp
  test/SemaTemplate/virtual-member-functions.cpp

Index: test/SemaTemplate/virtual-member-functions.cpp
===
--- test/SemaTemplate/virtual-member-functions.cpp
+++ test/SemaTemplate/virtual-member-functions.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++98 -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++11 -verify %s
 
 namespace PR5557 {
 template  struct A {
@@ -76,34 +80,76 @@
 }
 
 namespace PR7114 {
-  class A { virtual ~A(); }; // expected-note{{declared private here}}
+  class A { virtual ~A(); };
+#if __cplusplus <= 199711L
+  // expected-note@-2{{declared private here}}
+#else
+  // expected-note@-4 3 {{overridden virtual function is here}}
+#endif
 
   template
   class B {
   public:
-class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}}
+class Inner : public A { };
+#if __cplusplus <= 199711L
+// expected-error@-2{{base class 'PR7114::A' has private destructor}}
+#else
+// expected-error@-4 2 {{deleted function '~Inner' cannot override a non-deleted function}}
+// expected-note@-5 2 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#ifdef MSABI
+// expected-note@-7 1 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
+#endif
+
 static Inner i;
 static const unsigned value = sizeof(i) == 4;
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+// expected-note@-3 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+#endif
   };
 
   int f() { return B::value; }
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
 
 #ifdef MSABI
-  void test_typeid(B::Inner bfi) { // expected-note{{implicit destructor}}
+  void test_typeid(B::Inner bfi) {
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor}}
+#else
+// expected-error@-4 {{attempt to use a deleted function}}
+// expected-note@-5 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
+
 (void)typeid(bfi);
 #else
   void test_typeid(B::Inner bfi) {
-(void)typeid(bfi); // expected-note{{implicit destructor}}
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
+(void)typeid(bfi);
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor}}
+#endif
 #endif
   }
 
   template
   struct X : A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~X' cannot override a non-deleted function}}
+// expected-note@-3  {{destructor of 'X' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
 void f() { }
   };
 
   void test_X(X , X ) {
 xi.f();
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::X' requested here}}
+#endif
   }
 }
 
Index: test/SemaTemplate/value-dependent-null-pointer-constant.cpp
===
--- test/SemaTemplate/value-dependent-null-pointer-constant.cpp
+++ test/SemaTemplate/value-dependent-null-pointer-constant.cpp
@@ -1,17 +1,30 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 template
 struct X0 {
   const char *f0(bool Cond) {
 return Cond? "honk" : N;
+#if 

r289986 - Remove the temporary fix to the RUN line that was committed in r289924.

2016-12-16 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Dec 16 14:25:11 2016
New Revision: 289986

URL: http://llvm.org/viewvc/llvm-project?rev=289986=rev
Log:
Remove the temporary fix to the RUN line that was committed in r289924.

Also, dump the AST and run FileCheck to make sure the expected nodes are
created in the AST.

Modified:
cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289986=289985=289986=diff
==
--- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Fri Dec 16 
14:25:11 2016
@@ -1,10 +1,12 @@
-// FIXME: Remove the next line after a bit; this test used to
-// write a .ll file and that confuses the bots. The next line
-// cleans that up.
-// RUN: rm -f %S/default-expr-arguments-3.ll
-// RUN: %clang_cc1 -std=c++14 -verify %s
+// RUN: %clang_cc1 -std=c++14 -verify -ast-dump %s | FileCheck %s
 // expected-no-diagnostics
 
+// CHECK: FunctionDecl {{.*}} used func 'void (void)'
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK: LambdaExpr {{.*}} 'class (lambda at
+// CHECK: ParmVarDecl {{.*}} used f 'enum foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+
 namespace PR28795 {
   template
   void func() {
@@ -18,6 +20,12 @@ namespace PR28795 {
   }
 }
 
+// CHECK: ClassTemplateSpecializationDecl {{.*}} struct class2 definition
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK: LambdaExpr {{.*}} 'class (lambda at
+// CHECK: ParmVarDecl {{.*}} used f 'enum foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+
 // Template struct case:
 template  struct class2 {
   void bar() {
@@ -28,6 +36,14 @@ template  struct class2 {
 
 template struct class2;
 
+// CHECK: FunctionTemplateDecl {{.*}} f1
+// CHECK-NEXT: TemplateTypeParmDecl {{.*}} typename T
+// CHECK-NEXT: FunctionDecl {{.*}} f1 'void (void)'
+// CHECK: FunctionDecl {{.*}} f1 'void (void)'
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK: ParmVarDecl {{.*}} n 'enum foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+
 template
 void f1() {
   enum class foo { a, b };


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


[PATCH] D27858: Default to standalone debug info on Windows

2016-12-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Did you measure what this does to link times?


https://reviews.llvm.org/D27858



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


r289985 - Fix clang build

2016-12-16 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Fri Dec 16 13:49:14 2016
New Revision: 289985

URL: http://llvm.org/viewvc/llvm-project?rev=289985=rev
Log:
Fix clang build

Modified:
cfe/trunk/include/clang/Basic/OpenCLOptions.h

Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLOptions.h?rev=289985=289984=289985=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLOptions.h (original)
+++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Fri Dec 16 13:49:14 2016
@@ -32,24 +32,24 @@ class OpenCLOptions {
   };
   llvm::StringMap OptMap;
 public:
-  bool isKnown(StringRef Ext) const {
+  bool isKnown(llvm::StringRef Ext) const {
 return OptMap.find(Ext) != OptMap.end();
   }
 
-  bool isEnabled(StringRef Ext) const {
+  bool isEnabled(llvm::StringRef Ext) const {
 return OptMap.find(Ext)->second.Enabled;
   }
 
   // Is supported as either an extension or an (optional) core feature for
   // OpenCL version \p CLVer.
-  bool isSupported(StringRef Ext, unsigned CLVer) const {
+  bool isSupported(llvm::StringRef Ext, unsigned CLVer) const {
 auto I = OptMap.find(Ext)->getValue();
 return I.Supported && I.Avail <= CLVer;
   }
 
   // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
   // For supported extension, return false.
-  bool isSupportedCore(StringRef Ext, unsigned CLVer) const {
+  bool isSupportedCore(llvm::StringRef Ext, unsigned CLVer) const {
 auto I = OptMap.find(Ext)->getValue();
 return I.Supported && I.Avail <= CLVer &&
   I.Core != ~0U && CLVer >= I.Core;
@@ -57,13 +57,13 @@ public:
 
   // Is supported OpenCL extension for OpenCL version \p CLVer.
   // For supported (optional) core feature, return false.
- bool isSupportedExtension(StringRef Ext, unsigned CLVer) const {
+ bool isSupportedExtension(llvm::StringRef Ext, unsigned CLVer) const {
 auto I = OptMap.find(Ext)->getValue();
 return I.Supported && I.Avail <= CLVer &&
   (I.Core == ~0U || CLVer < I.Core);
   }
 
-  void enable(StringRef Ext, bool V = true) {
+  void enable(llvm::StringRef Ext, bool V = true) {
 OptMap[Ext].Enabled = V;
   }
 
@@ -71,7 +71,7 @@ public:
   /// \param Ext name of the extension optionally prefixed with
   ///'+' or '-'
   /// \param Enable used when \p Ext is not prefixed by '+' or '-'
-  void support(StringRef Ext, bool V = true) {
+  void support(llvm::StringRef Ext, bool V = true) {
 assert(!Ext.empty() && "Extension is empty.");
 
 switch (Ext[0]) {


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


[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D27627#621533, @yaxunl wrote:

> In https://reviews.llvm.org/D27627#621473, @rjmccall wrote:
>
> > In https://reviews.llvm.org/D27627#619928, @yaxunl wrote:
> >
> > > > Because, notably, if you do that, then an attempt to pass  as an int* 
> > > > will fail, which means this isn't really C++ anymore... and yet that 
> > > > appears to be exactly what you want.
> > >
> > > How about when generating alloca instruction, I insert addrspacecast to 
> > > the default address space, then everything is in default address space.
> >
> >
> > My question is really about your language design.  You have multiple 
> > address spaces in the implementation, but you're (apparently?) pretending 
> > that they're all part of the same address space in the source language.  
> > How is that expected to work?  Does the default address space embed all 
> > other address spaces?
>
>
> Yes the default address space embeds all other address spaces.


Since the default address space (generic address space 4) can represent all 
other address spaces, we want to use it uniformly. For any pointer which is not 
in the default address space, e.g. alloca, we want to cast it to default 
address space and then use it. Therefore, in the address space agnostic 
languages, we can assume everything is in the default address space. Our 
backend is able to handle load/store in the default address space.


https://reviews.llvm.org/D27627



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


[PATCH] D27858: Default to standalone debug info on Windows

2016-12-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: thakis, hans, dblaikie.
rnk added a subscriber: cfe-commits.

PDB-based debuggers do not support looking up type names across type
stream boundaries. There are two ways where users end up being unable to
look into variables with types that were required to be complete:

1. The type was provided by another DLL, but was not marked dllimport. In this 
case, the type stream is in the PDB, and it will contain all types that had 
complete definitions within the DLL. If the type had a vtable that was only 
emitted in another DLL, we will not have type information for it.

2. The user is using /DEBUG:FASTLINK. This flag tells the linker to leave debug 
information in object files, similar to the default build flow on MacOS. When 
/DEBUG:FASTLINK is used with /Z7, each individual object file needs to have 
complete definitions of all types required to be complete in that TU. This 
isn't so bad for MSVC because it supports using type servers with /Zi, so they 
still get some amount of type deduplication.

I did an experiment some time ago on Chrome and found that changing the
default here increased the object file sizes in a Chrome debug build by
17%[1], which is quite significant. If those savings are important to
users and they aren't using /DEBUG:FASTLINK, they can opt into limited
debug info by passing -flimit-debug-info.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=642812#c15


https://reviews.llvm.org/D27858

Files:
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -452,11 +452,11 @@
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
-// Zi: "-debug-info-kind=limited"
+// Zi: "-debug-info-kind=standalone"
 
 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
 // Z7: "-gcodeview"
-// Z7: "-debug-info-kind=limited"
+// Z7: "-debug-info-kind=standalone"
 
 // RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
 // Z7GMLT: "-gcodeview"
@@ -466,6 +466,10 @@
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"
 
+// RUN: %clang_cl /Z7 -flimit-debug-info /c -### -- %s 2>&1 | FileCheck 
-check-prefix=Z7LIMITED %s
+// Z7LIMITED: "-gcodeview"
+// Z7LIMITED: "-debug-info-kind=limited"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"
 
@@ -485,7 +489,7 @@
 // which made it "win". This test could not detect that bug.
 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck 
-check-prefix=Z7_gdwarf %s
 // Z7_gdwarf: "-gcodeview"
-// Z7_gdwarf: "-debug-info-kind=limited"
+// Z7_gdwarf: "-debug-info-kind=standalone"
 // Z7_gdwarf: "-dwarf-version=4"
 
 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck 
-check-prefix=CXX11 %s
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1139,6 +1139,7 @@
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
+  bool GetDefaultStandaloneDebug() const override;
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -94,6 +94,18 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
+bool MSVCToolChain::GetDefaultStandaloneDebug() const {
+  // Microsoft debuggers can't lookup type names across type stream boundaries.
+  // This means that types implemented in b.dll used by a.dll sometimes can't 
be
+  // found when debugging a.dll. Clang will emit types marked with dllimport to
+  // try to cope with this case, but is not a complete heuristic. 
Non-standalone
+  // type info is also incompatble with /DEBUG:FASTLINK, which leaves all debug
+  // info, including types, in object files. In this case, the type stream is
+  // limited to the TU, and every TU needs to have all the types required to be
+  // complete by that TU for debugging.
+  return true;
+}
+
 #ifdef USE_WIN32
 static bool readFullStringValue(HKEY hkey, const char *valueName,
 std::string ) {


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -452,11 +452,11 @@
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
-// Zi: "-debug-info-kind=limited"
+// Zi: "-debug-info-kind=standalone"
 
 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
 // Z7: "-gcodeview"
-// Z7: "-debug-info-kind=limited"
+// 

r289984 - Revert "Update for LLVM global variable debug info API change."

2016-12-16 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Dec 16 13:39:18 2016
New Revision: 289984

URL: http://llvm.org/viewvc/llvm-project?rev=289984=rev
Log:
Revert "Update for LLVM global variable debug info API change."

This reverts commit r289921.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
cfe/trunk/test/CodeGen/2010-08-10-DbgConstant.c
cfe/trunk/test/CodeGen/debug-info-atomic.c
cfe/trunk/test/CodeGen/debug-info-global-constant.c
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
cfe/trunk/test/CodeGen/debug-info-static.c
cfe/trunk/test/CodeGenCXX/debug-info-global.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/debug-info.cpp
cfe/trunk/test/CodeGenCXX/inline-dllexport-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289984=289983=289984=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Dec 16 13:39:18 2016
@@ -2855,7 +2855,7 @@ CGDebugInfo::getGlobalVariableForwardDec
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, nullptr, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -2873,12 +2873,8 @@ llvm::DINode *CGDebugInfo::getDeclaratio
getOrCreateFile(TD->getLocation()));
   auto I = DeclCache.find(D->getCanonicalDecl());
 
-  if (I != DeclCache.end()) {
-auto N = I->second;
-if (auto *GVE = dyn_cast_or_null(N))
-  return GVE->getVariable();
-return dyn_cast_or_null(N);
-  }
+  if (I != DeclCache.end())
+return dyn_cast_or_null(I->second);
 
   // No definition for now. Emit a forward definition that might be
   // merged with a potential upcoming definition.
@@ -3654,10 +3650,10 @@ CGDebugInfo::getOrCreateStaticDataMember
   return CreateRecordStaticField(D, Ctxt, cast(DC));
 }
 
-llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
+llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
 const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
 StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) 
{
-  llvm::DIGlobalVariableExpression *GVE = nullptr;
+  llvm::DIGlobalVariable *GV = nullptr;
 
   for (const auto *Field : RD->fields()) {
 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -3666,17 +3662,16 @@ llvm::DIGlobalVariableExpression *CGDebu
 // Ignore unnamed fields, but recurse into anonymous records.
 if (FieldName.empty()) {
   if (const auto *RT = dyn_cast(Field->getType()))
-GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
+GV = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
 Var, DContext);
   continue;
 }
 // Use VarDecl's Tag, Scope and Line number.
-GVE = DBuilder.createGlobalVariableExpression(
-DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
-Var->hasLocalLinkage());
-Var->addDebugInfo(GVE);
+GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
+   LineNo, FieldTy, 
Var->hasLocalLinkage());
+Var->addDebugInfo(GV);
   }
-  return GVE;
+  return GV;
 }
 
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
@@ -3689,8 +3684,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
   if (Cached != DeclCache.end())
-return Var->addDebugInfo(
-cast(Cached->second));
+return Var->addDebugInfo(cast(Cached->second));
 
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
@@ -3702,7 +3696,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
 
   // Attempt to store one global variable for the declaration - even if we
   // emit a lot of fields.
-  llvm::DIGlobalVariableExpression *GVE = nullptr;
+  llvm::DIGlobalVariable *GV = nullptr;
 
   // If this is an anonymous union then we'll want to emit a global
   // variable for each member of the anonymous union so that it's possible
@@ -3711,16 +3705,16 @@ void CGDebugInfo::EmitGlobalVariable(llv
 const RecordDecl *RD = T->castAs()->getDecl();
 assert(RD->isAnonymousStructOrUnion() &&
"unnamed non-anonymous struct or union?");
-GVE = CollectAnonRecordDecls(RD, 

[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8772
+def note_nullability_fix_it : Note<
+  "insert '%select{_Nonnull|_Nullable|_Null_unspecified}0' if the "
+  "%select{pointer|block pointer|member pointer|array parameter}1 "

jordan_rose wrote:
> ahatanak wrote:
> > Is the third option (_Null_unspecified) going to be used somewhere? I see 
> > the first two options are used in emitNullabilityConsistencyWarning, but 
> > not the third one.
> I think it's better not to suggest it to people, but it seemed weirder to 
> have a reusable diagnostic that's intended to take a NullabilityKind and then 
> have it blow up if someone ever decided to use it with NullUnspecified. I can 
> take it out if you like.
It seems that the code in lib/Basic/Diagnostic.cpp would assert at runtime if 
you tried to pass a value that isn't in the expected range (0 or 1 if 
_Null_unspecified were removed). But I guess you can leave _Null_unspecified 
there if you think it makes more sense to do so.


Repository:
  rL LLVM

https://reviews.llvm.org/D27837



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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-16 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 2 inline comments as done.
Closed by commit rL289979: [OpenCL] Allow disabling types and declarations 
associated with extensions (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D21698?vs=81471=81782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21698

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/OpenCLImageTypes.def
  cfe/trunk/include/clang/Basic/OpenCLOptions.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/include/clang/Sema/Overload.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/include/clang/Serialization/ASTWriter.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/lib/Headers/opencl-c.h
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenOpenCL/extension-begin.cl
  cfe/trunk/test/Parser/opencl-atomics-cl20.cl
  cfe/trunk/test/Parser/opencl-pragma.cl
  cfe/trunk/test/SemaOpenCL/extension-begin.cl
  cfe/trunk/test/SemaOpenCL/extensions.cl

Index: cfe/trunk/include/clang/Serialization/ASTReader.h
===
--- cfe/trunk/include/clang/Serialization/ASTReader.h
+++ cfe/trunk/include/clang/Serialization/ASTReader.h
@@ -807,7 +807,13 @@
   SourceLocation PointersToMembersPragmaLocation;
 
   /// \brief The OpenCL extension settings.
-  SmallVector OpenCLExtensions;
+  OpenCLOptions OpenCLExtensions;
+
+  /// \brief Extensions required by an OpenCL type.
+  llvm::DenseMap> OpenCLTypeExtMap;
+
+  /// \brief Extensions required by an OpenCL declaration.
+  llvm::DenseMap> OpenCLDeclExtMap;
 
   /// \brief A list of the namespaces we've seen.
   SmallVector KnownNamespaces;
Index: cfe/trunk/include/clang/Serialization/ASTWriter.h
===
--- cfe/trunk/include/clang/Serialization/ASTWriter.h
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h
@@ -459,6 +459,8 @@
   void WriteDeclContextVisibleUpdate(const DeclContext *DC);
   void WriteFPPragmaOptions(const FPOptions );
   void WriteOpenCLExtensions(Sema );
+  void WriteOpenCLExtensionTypes(Sema );
+  void WriteOpenCLExtensionDecls(Sema );
   void WriteCUDAPragmas(Sema );
   void WriteObjCCategories();
   void WriteLateParsedTemplates(Sema );
Index: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
===
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h
@@ -344,7 +344,7 @@
   ///
   /// The TYPE_OFFSET constant describes the record that occurs
   /// within the AST block. The record itself is an array of offsets that
-  /// point into the declarations and types block (identified by 
+  /// point into the declarations and types block (identified by
   /// DECLTYPES_BLOCK_ID). The index into the array is based on the ID
   /// of a type. For a given type ID @c T, the lower three bits of
   /// @c T are its qualifiers (const, volatile, restrict), as in
@@ -446,10 +446,10 @@
 
   /// \brief Record code for the set of ext_vector type names.
   EXT_VECTOR_DECLS = 16,
-  
+
   /// \brief Record code for the array of unused file scoped decls.
   UNUSED_FILESCOPED_DECLS = 17,
-  
+
   /// \brief Record code for the table of offsets to entries in the
   /// preprocessing record.
   PPD_ENTITIES_OFFSETS = 18,
@@ -465,7 +465,7 @@
   /// \brief Record code for an update to the TU's lexically contained
   /// declarations.
   TU_UPDATE_LEXICAL = 22,
-  
+
   // ID 23 used to be for a list of local redeclarations.
 
   /// \brief Record code for declarations that Sema keeps references of.
@@ -490,15 +490,15 @@
 
   // ID 30 used to be a decl update record. These are now in the DECLTYPES
   // block.
-  
+
   // ID 31 used to be a list of offsets to DECL_CXX_BASE_SPECIFIERS records.
 
   /// \brief Record code for \#pragma diagnostic mappings.
   DIAG_PRAGMA_MAPPINGS = 32,
 
   /// \brief Record code for special CUDA declarations.
   CUDA_SPECIAL_DECL_REFS = 33,
-  
+
   /// \brief Record code for header search information.
   HEADER_SEARCH_TABLE = 34,
 
@@ -516,29 +516,29 @@
   KNOWN_NAMESPACES = 38,
 
   /// \brief 

r289979 - [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-16 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Dec 16 13:22:08 2016
New Revision: 289979

URL: http://llvm.org/viewvc/llvm-project?rev=289979=rev
Log:
[OpenCL] Allow disabling types and declarations associated with extensions

Added a map to associate types and declarations with extensions.

Refactored existing diagnostic for disabled types associated with extensions 
and extended it to declarations for generic situation.

Fixed some bugs for types associated with extensions.

Allow users to use pragma to declare types and functions for supported 
extensions, e.g.

#pragma OPENCL EXTENSION the_new_extension_name : begin
// declare types and functions associated with the extension here
#pragma OPENCL EXTENSION the_new_extension_name : end

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

Added:
cfe/trunk/test/CodeGenOpenCL/extension-begin.cl
cfe/trunk/test/SemaOpenCL/extension-begin.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenCLImageTypes.def
cfe/trunk/include/clang/Basic/OpenCLOptions.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Parser/opencl-atomics-cl20.cl
cfe/trunk/test/Parser/opencl-pragma.cl
cfe/trunk/test/SemaOpenCL/extensions.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=289979=289978=289979=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Dec 16 13:22:08 
2016
@@ -968,8 +968,10 @@ def err_opencl_unroll_hint_on_non_loop :
 // OpenCL EXTENSION pragma (OpenCL 1.1 [9.1])
 def warn_pragma_expected_colon : Warning<
   "missing ':' after %0 - ignoring">, InGroup;
-def warn_pragma_expected_enable_disable : Warning<
-  "expected 'enable' or 'disable' - ignoring">, InGroup;
+def warn_pragma_expected_predicate : Warning<
+  "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - 
ignoring">, InGroup;
+def warn_pragma_begin_end_mismatch : Warning<
+  "OpenCL extension end directive mismatches begin directive - ignoring">, 
InGroup;
 def warn_pragma_unknown_extension : Warning<
   "unknown OpenCL extension %0 - ignoring">, InGroup;
 def warn_pragma_unsupported_extension : Warning<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=289979=289978=289979=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 16 13:22:08 
2016
@@ -3359,6 +3359,8 @@ def note_ovl_candidate_has_pass_object_s
 "pass_object_size attribute">;
 def note_ovl_candidate_disabled_by_enable_if_attr : Note<
 "candidate disabled: %0">;
+def note_ovl_candidate_disabled_by_extension : Note<
+"candidate disabled due to OpenCL extension">;
 def err_addrof_function_disabled_by_enable_if_attr : Error<
 "cannot take address of function %0 becuase it has one or more "
 "non-tautological enable_if conditions">;
@@ -7936,8 +7938,6 @@ def ext_c99_array_usage : Extension<
 def err_c99_array_usage_cxx : Error<
   "%select{qualifier in |static |}0array size %select{||'[*] '}0is a C99 "
   "feature, not permitted in C++">;
- def err_type_requires_extension : Error<
-  "use of type %0 requires %1 extension to be enabled">;
 def err_type_unsupported : Error<
   "%0 is not supported on this target">;
 def err_nsconsumed_attribute_mismatch : Error<
@@ -8143,6 +8143,8 @@ def warn_opencl_attr_deprecated_ignored
   InGroup;
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
+def err_opencl_requires_extension : Error<
+  "use of %select{type |declaration}0%1 requires %2 extension to be enabled">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-16 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 81779.
Alpha added a comment.

It was tested against the clang extra unit tests, but not tests run with 
check-clang-tools.
Updated Yaml test files to match the new format, this might need further review.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  tools/extra/test/clang-apply-replacements/Inputs/basic/file1.yaml
  tools/extra/test/clang-apply-replacements/Inputs/basic/file2.yaml
  tools/extra/test/clang-apply-replacements/Inputs/conflict/file1.yaml
  tools/extra/test/clang-apply-replacements/Inputs/conflict/file2.yaml
  tools/extra/test/clang-apply-replacements/Inputs/conflict/file3.yaml
  tools/extra/test/clang-apply-replacements/Inputs/crlf/file1.yaml
  tools/extra/test/clang-apply-replacements/Inputs/format/no.yaml
  tools/extra/test/clang-apply-replacements/Inputs/format/yes.yaml
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,46 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), 

[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: clang-tidy/obvious/InvalidRangeCheck.cpp:20-36
+"std::for_each; std::find; std::find_if; std::find_end; "
+"std::find_first_of; std::adjacent_find; std::count; std::count_if;"
+"std::mismatch; std::equal; std::search; std::copy; "
+"std::copy_backward; std::swap_ranges; std::transform; std::replace"
+"std::replace_if; std::replace_copy; std::replace_copy_if; std::fill; "
+"std::fill_n; std::generate; std::generate_n; std::remove; std::remove_if"
+"std::remove_copy; std::remove_copy_if; std::unique; std::unique_copy;"

Prazek wrote:
> sbarzowski wrote:
> > Prazek wrote:
> > > sbarzowski wrote:
> > > > I would go with one per line. It will be much more diff-friendly this 
> > > > way.  And also much easier to add stuff in the middle and maybe keep it 
> > > > sorted. 
> > > I don't expect this list to change in any way in the future, and it 
> > > already take more than 20 lines. I don't want to put about 80 lines only 
> > > to define the names
> > Ok, I don't think it's important enough to argue about it if it was your 
> > deliberate decision.
> > 
> > But I still think your argument is invalid :-). If anything that calls for 
> > putting it in a separate file.
> By moving it to another file I would expose it to other checks, which is not 
> my intention.
> I also want to keep this simple and short, and by making this list less 
> readable (which is not something that some next developer should care about) 
> I make the whole file more readable, because it is shorter.
ok I think I will remove the list and instead will check if the name starts 
with std::, because if someone calls std::.


https://reviews.llvm.org/D27806



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


[PATCH] D20710: Lit C++11 Compatibility Patch #9

2016-12-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 81776.
tigerleapgorge added a comment.

Lit C++11 compatibility patch #9

Update patch again to expect for latest Trunk C++11 diagnostics.
Tests in CXX directory are already passing in C++11, so they are removed from 
this patch.
Of the remaining tests, 4 tests are modified to accommodate for changes is 
diagnostics.

SemaCXX/implicit-virtual-member-functions.cpp

  Additional Note message in latest Trunk (3 instances).
Note: virtual destructor requires an unambiguous, accessible 'operator 
delete'

SemaCXX/new-delete.cpp

  Warning no longer exist in latest Trunk
Warning: function previously declared with an explicit exception 
specification redeclared with an implicit exception specification
  
  Previous severity change (C++98 Warning  to C++11 Error) has been fixed in 
latest Trunk.
  Revert following 2 message back to Error.
Error: array size is negative
Error: array is too large (20 elements)
  
  Additional Note message (1 instance).
Note: virtual destructor requires an unambiguous, accessible 'operator 
delete'

SemaCXX/virtual-member-functions-key-function.cpp

  Additional Note message (2 instances)
Note: virtual destructor requires an unambiguous, accessible 'operator 
delete'

SemaTemplate/virtual-member-functions.cpp

  Additional Note message (3 instances)
Note: destructor of 'Inner' is implicitly deleted because base class 
'PR7114::A' has an inaccessible destructor
Note: destructor of 'Inner' is implicitly deleted because base class 
'PR7114::A' has an inaccessible destructor
Note: destructor of 'X' is implicitly deleted because base class 
'PR7114::A' has an inaccessible destructor


https://reviews.llvm.org/D20710

Files:
  test/CodeGenCXX/debug-info-use-after-free.cpp
  test/CodeGenCXX/dynamic-cast-hint.cpp
  test/OpenMP/distribute_collapse_messages.cpp
  test/OpenMP/ordered_messages.cpp
  test/OpenMP/target_parallel_for_collapse_messages.cpp
  test/OpenMP/target_parallel_for_ordered_messages.cpp
  test/SemaCXX/i-c-e-cxx.cpp
  test/SemaCXX/implicit-virtual-member-functions.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/no-wchar.cpp
  test/SemaCXX/virtual-member-functions-key-function.cpp
  test/SemaCXX/warn-bool-conversion.cpp
  test/SemaCXX/zero-length-arrays.cpp
  test/SemaTemplate/instantiate-c99.cpp
  test/SemaTemplate/temp_explicit.cpp
  test/SemaTemplate/value-dependent-null-pointer-constant.cpp
  test/SemaTemplate/virtual-member-functions.cpp

Index: test/SemaTemplate/virtual-member-functions.cpp
===
--- test/SemaTemplate/virtual-member-functions.cpp
+++ test/SemaTemplate/virtual-member-functions.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++98 -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++11 -verify %s
 
 namespace PR5557 {
 template  struct A {
@@ -76,34 +80,76 @@
 }
 
 namespace PR7114 {
-  class A { virtual ~A(); }; // expected-note{{declared private here}}
+  class A { virtual ~A(); };
+#if __cplusplus <= 199711L
+  // expected-note@-2{{declared private here}}
+#else
+  // expected-note@-4 3 {{overridden virtual function is here}}
+#endif
 
   template
   class B {
   public:
-class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}}
+class Inner : public A { };
+#if __cplusplus <= 199711L
+// expected-error@-2{{base class 'PR7114::A' has private destructor}}
+#else
+// expected-error@-4 2 {{deleted function '~Inner' cannot override a non-deleted function}}
+// expected-note@-5 2 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#ifdef MSABI
+// expected-note@-7 1 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
+#endif
+
 static Inner i;
 static const unsigned value = sizeof(i) == 4;
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+// expected-note@-3 {{in instantiation of member class 'PR7114::B::Inner' requested here}}
+#endif
   };
 
   int f() { return B::value; }
+#if __cplusplus >= 201103L
+// expected-note@-2 {{in instantiation of template class 'PR7114::B' requested here}}
+#endif
 
 #ifdef MSABI
-  void test_typeid(B::Inner bfi) { // expected-note{{implicit destructor}}
+  void test_typeid(B::Inner bfi) {
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor}}
+#else
+// expected-error@-4 {{attempt to use a deleted function}}
+// expected-note@-5 {{in 

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D27815#625271, @Prazek wrote:

> In https://reviews.llvm.org/D27815#625102, @aaron.ballman wrote:
>
> > I am really not keen on the name "obvious" for this module. What is obvious 
> > to one person is not always obvious to another. Also, if the checks are 
> > finding *obvious bugs*, then that suggests they should be implemented in 
> > the clang frontend rather than a tool that is run less frequently.
> >
> > Since the checks are meant to be finding bugs rather than enforcing a 
> > coding standard, performance, readability, etc, a few possible alternative 
> > names:
> >
> > `bugs-`
> >  `correctness-`
>
>
> My intention is to have kind of bugs that you facepalm when you find it. 
> Mostly simple typos.
>  As I said this can't make it to clang because it would have some false 
> positives.


Many warnings in clang have some false positives. Do you envision these having 
a fairly high false positive rate, or expensive to check for?

> I am ok with making group like `bugs` that would have some checks that are 
> curently in misc (misc-use-after-move), but still, this group would be 
> special in the sense that it looks for very simple bugs that you can make 
> during coding, but you won't be able to find it in code that seem to work.

I'm having a hard time imagining how many checks would be in this module from 
that description. Are you expecting to move items from misc to populate this 
module (if so, which ones, aside from misc-use-after-move?), or are you 
intending to add some checks we don't currently have (if so, can you list a few 
of them)? From your description, it sounds like these are not obvious bugs 
(since the code seems to work and the bugs are hard to spot), but it may be 
that "bugs" or "correctness" could also be a poor name. With some examples of 
checks that could go in the module, we may be able to pick a more appropriate 
name.


https://reviews.llvm.org/D27815



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked an inline comment as done.
Prazek added inline comments.



Comment at: clang-tidy/obvious/InvalidRangeCheck.cpp:20-36
+"std::for_each; std::find; std::find_if; std::find_end; "
+"std::find_first_of; std::adjacent_find; std::count; std::count_if;"
+"std::mismatch; std::equal; std::search; std::copy; "
+"std::copy_backward; std::swap_ranges; std::transform; std::replace"
+"std::replace_if; std::replace_copy; std::replace_copy_if; std::fill; "
+"std::fill_n; std::generate; std::generate_n; std::remove; std::remove_if"
+"std::remove_copy; std::remove_copy_if; std::unique; std::unique_copy;"

sbarzowski wrote:
> Prazek wrote:
> > sbarzowski wrote:
> > > I would go with one per line. It will be much more diff-friendly this 
> > > way.  And also much easier to add stuff in the middle and maybe keep it 
> > > sorted. 
> > I don't expect this list to change in any way in the future, and it already 
> > take more than 20 lines. I don't want to put about 80 lines only to define 
> > the names
> Ok, I don't think it's important enough to argue about it if it was your 
> deliberate decision.
> 
> But I still think your argument is invalid :-). If anything that calls for 
> putting it in a separate file.
By moving it to another file I would expose it to other checks, which is not my 
intention.
I also want to keep this simple and short, and by making this list less 
readable (which is not something that some next developer should care about) I 
make the whole file more readable, because it is shorter.


https://reviews.llvm.org/D27806



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


[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D27815#625102, @aaron.ballman wrote:

> I am really not keen on the name "obvious" for this module. What is obvious 
> to one person is not always obvious to another. Also, if the checks are 
> finding *obvious bugs*, then that suggests they should be implemented in the 
> clang frontend rather than a tool that is run less frequently.
>
> Since the checks are meant to be finding bugs rather than enforcing a coding 
> standard, performance, readability, etc, a few possible alternative names:
>
> `bugs-`
>  `correctness-`


My intention is to have kind of bugs that you facepalm when you find it. Mostly 
simple typos.
As I said this can't make it to clang because it would have some false 
positives.

I am ok with making group like `bugs` that would have some checks that are 
curently in misc (misc-use-after-move), but still, this group would be special 
in the sense that it looks for very simple bugs that you can make during 
coding, but you won't be able to find it in code that seem to work.


https://reviews.llvm.org/D27815



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


[PATCH] D27849: crash in MallocChecker

2016-12-16 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289970: [analyzer] Fix crash in MallocChecker. (authored by 
dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D27849?vs=81751=81774#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27849

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/out-of-bounds-new.cpp


Index: cfe/trunk/test/Analysis/out-of-bounds-new.cpp
===
--- cfe/trunk/test/Analysis/out-of-bounds-new.cpp
+++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp
@@ -148,3 +148,9 @@
   int *buf = new int[s];
   buf[0] = 1; // no-warning
 }
+//Tests complex arithmetic
+//in new expression
+void test_dynamic_size2(unsigned m,unsigned n){
+  unsigned *U = nullptr;
+  U = new unsigned[m + n + 1];
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1026,8 +1026,7 @@
   ASTContext  = C.getASTContext();
   CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType);
 
-  if (Optional DefinedSize =
-  ElementCount.getAs()) {
+  if (ElementCount.getAs()) {
 DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder);
 // size in Bytes = ElementCount*TypeSize
 SVal SizeInBytes = svalBuilder.evalBinOpNN(


Index: cfe/trunk/test/Analysis/out-of-bounds-new.cpp
===
--- cfe/trunk/test/Analysis/out-of-bounds-new.cpp
+++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp
@@ -148,3 +148,9 @@
   int *buf = new int[s];
   buf[0] = 1; // no-warning
 }
+//Tests complex arithmetic
+//in new expression
+void test_dynamic_size2(unsigned m,unsigned n){
+  unsigned *U = nullptr;
+  U = new unsigned[m + n + 1];
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1026,8 +1026,7 @@
   ASTContext  = C.getASTContext();
   CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType);
 
-  if (Optional DefinedSize =
-  ElementCount.getAs()) {
+  if (ElementCount.getAs()) {
 DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder);
 // size in Bytes = ElementCount*TypeSize
 SVal SizeInBytes = svalBuilder.evalBinOpNN(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289970 - [analyzer] Fix crash in MallocChecker.

2016-12-16 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Dec 16 12:41:40 2016
New Revision: 289970

URL: http://llvm.org/viewvc/llvm-project?rev=289970=rev
Log:
[analyzer] Fix crash in MallocChecker.

Fix a crash in the MallocChecker when the extent size for the argument
to new[] is not known.

A patch by Abramo Bagnara and Dániel Krupp!

https://reviews.llvm.org/D27849

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/Analysis/out-of-bounds-new.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=289970=289969=289970=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Dec 16 12:41:40 
2016
@@ -1026,8 +1026,7 @@ ProgramStateRef MallocChecker::addExtent
   ASTContext  = C.getASTContext();
   CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType);
 
-  if (Optional DefinedSize =
-  ElementCount.getAs()) {
+  if (ElementCount.getAs()) {
 DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder);
 // size in Bytes = ElementCount*TypeSize
 SVal SizeInBytes = svalBuilder.evalBinOpNN(

Modified: cfe/trunk/test/Analysis/out-of-bounds-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/out-of-bounds-new.cpp?rev=289970=289969=289970=diff
==
--- cfe/trunk/test/Analysis/out-of-bounds-new.cpp (original)
+++ cfe/trunk/test/Analysis/out-of-bounds-new.cpp Fri Dec 16 12:41:40 2016
@@ -148,3 +148,9 @@ void test_dynamic_size(int s) {
   int *buf = new int[s];
   buf[0] = 1; // no-warning
 }
+//Tests complex arithmetic
+//in new expression
+void test_dynamic_size2(unsigned m,unsigned n){
+  unsigned *U = nullptr;
+  U = new unsigned[m + n + 1];
+}


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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

In https://reviews.llvm.org/D21698#624967, @Anastasia wrote:

> LGTM! Small nitpicks below can be done before committing. Also it would be 
> nice to double check the compile time is still fine after the last rebase.


Thanks. I did the measurement again and did not see significant difference in 
compilation time before/after this change.




Comment at: include/clang/Basic/OpenCLOptions.h:43
 
-  // Enable or disable all options.
-  void setAll(bool Enable = true) {
-#define OPENCLEXT(nm)   nm = Enable;
-#include "clang/Basic/OpenCLExtensions.def"
+  // Is supported OpenCL extension or (optional) core feature for OpenCL 
version
+  // \p CLVer.

Anastasia wrote:
> Did you mean "and (optional) core feature?"
My understanding is that once an extension becomes an (optional) core feature, 
it is no longer called an extension. So for for a specific OpenCL version, \p 
Ext is either is an extension, or an (optional) core feature.  However this 
wording may be confusing. How about rewording as

Is supported as either an extension or an (optional) core feature for OpenCL 
version \p CLVer



Comment at: test/SemaOpenCL/extension-begin.cl:5
+// Test with pch.
+// RUN: %clang_cc1 %s -DHEADER -triple spir-unknown-unknown -emit-pch 
-DHEADER_ONLY -o %t -verify -pedantic
+// RUN: %clang_cc1 %s -DHEADER_USER -triple spir-unknown-unknown -include-pch 
%t -fsyntax-only -verify -pedantic

Anastasia wrote:
> Do we need -DHEADER_ONLY here?
I will remove it.


https://reviews.llvm.org/D21698



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


Re: r288493 - [ClangFormat] Only insert #include into the #include block in the beginning of the file.

2016-12-16 Thread Mehdi Amini via cfe-commits
Hi Eric,

> On Dec 2, 2016, at 3:01 AM, Eric Liu via cfe-commits 
>  wrote:
> 
> Author: ioeric
> Date: Fri Dec  2 05:01:43 2016
> New Revision: 288493
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=288493=rev
> Log:
> [ClangFormat] Only insert #include into the #include block in the beginning 
> of the file.
> 
> Summary:
> This avoid inserting #include into:
> - raw string literals containing #include.
> - #if block.
> - Special #include among declarations (e.g. functions).
> 
> Reviewers: djasper
> 
> Subscribers: cfe-commits, klimek
> 
> Differential Revision: https://reviews.llvm.org/D26909
> 
> Modified:
>cfe/trunk/include/clang/Format/Format.h
>cfe/trunk/lib/Format/Format.cpp
>cfe/trunk/unittests/Format/CleanupTest.cpp
> 
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=288493=288492=288493=diff
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Fri Dec  2 05:01:43 2016
> @@ -786,7 +786,14 @@ formatReplacements(StringRef Code, const
> /// This also supports inserting/deleting C++ #include directives:
> /// - If a replacement has offset UINT_MAX, length 0, and a replacement text
> ///   that is an #include directive, this will insert the #include into the
> -///   correct block in the \p Code.
> +///   correct block in the \p Code. When searching for points to insert new
> +///   header, this ignores #include's after the #include block(s) in the
> +///   beginning of a file to avoid inserting headers into code sections where
> +///   new #include's should not be added by default. These code sections
> +///   include:
> +/// - raw string literals (containing #include).
> +/// - #if blocks.
> +/// - Special #include's among declarations (e.g. functions).
> /// - If a replacement has offset UINT_MAX, length 1, and a replacement text
> ///   that is the name of the header to be removed, the header will be removed
> ///   from \p Code if it exists.
> 
> Modified: cfe/trunk/lib/Format/Format.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=288493=288492=288493=diff
> ==
> --- cfe/trunk/lib/Format/Format.cpp (original)
> +++ cfe/trunk/lib/Format/Format.cpp Fri Dec  2 05:01:43 2016
> @@ -1514,10 +1514,23 @@ inline bool isHeaderDeletion(const tooli
>   return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1;
> }
> 
> -void skipComments(Lexer , Token ) {
> -  while (Tok.is(tok::comment))
> -if (Lex.LexFromRawLexer(Tok))
> -  return;
> +// Returns the offset after skipping a sequence of tokens, matched by \p
> +// GetOffsetAfterSequence, from the start of the code.
> +// \p GetOffsetAfterSequence should be a function that matches a sequence of
> +// tokens and returns an offset after the sequence.
> +unsigned getOffsetAfterTokenSequence(
> +StringRef FileName, StringRef Code, const FormatStyle ,
> +std::function
> +GetOffsetAfterSequense) {
> +  std::unique_ptr Env =
> +  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
> +  const SourceManager  = Env->getSourceManager();
> +  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), 
> SourceMgr,
> +getFormattingLangOpts(Style));
> +  Token Tok;
> +  // Get the first token.
> +  Lex.LexFromRawLexer(Tok);
> +  return GetOffsetAfterSequense(SourceMgr, Lex, Tok);
> }
> 
> // Check if a sequence of tokens is like "# ". If it is,
> @@ -1527,31 +1540,88 @@ bool checkAndConsumeDirectiveWithName(Le
>   bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
>  Tok.is(tok::raw_identifier) &&
>  Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) 
> &&
> - Tok.is(tok::raw_identifier);
> + tok::raw_identifier;


Can you elaborate on this line change? I don’t get it. (It was flagged by 
coverity).

Thanks,

— 
Mehdi




>   if (Matched)
> Lex.LexFromRawLexer(Tok);
>   return Matched;
> }
> 
> +void skipComments(Lexer , Token ) {
> +  while (Tok.is(tok::comment))
> +if (Lex.LexFromRawLexer(Tok))
> +  return;
> +}
> +
> +// Returns the offset after header guard directives and any comments
> +// before/after header guards. If no header guard presents in the code, this
> +// will returns the offset after skipping all comments from the start of the
> +// code.
> unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName,
>StringRef Code,
>const FormatStyle ) {
> -  std::unique_ptr Env =
> -  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
> - 

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

And thank you for the awesome work and addressing the review comments!!!


https://reviews.llvm.org/D25660



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-16 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> I am doing it right now. Unfortunately I found a crash which I fixed,

Is it fixed in this patch?

> but then it turned out that overwrites of the iterator variable are not 
> handled. I am working on this 
>  problem.

My suggestion is to commit this patch and address the iterator variable 
overwrites separately, so that it would be more incremental and easier to 
review. Does this sound good to you?


https://reviews.llvm.org/D25660



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


[libcxx] r289963 - [CMake] Put headers relative to clang

2016-12-16 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Dec 16 11:30:51 2016
New Revision: 289963

URL: http://llvm.org/viewvc/llvm-project?rev=289963=rev
Log:
[CMake] Put headers relative to clang

When libcxx isn't building with an installed LLVM we copy the libcxx headers 
into the LLVM build directory so that a clang in that build tree can find the 
headers relative to itself.

This is only important in situations where you don't have headers installed 
under /, which is common these days on Darwin.

Modified:
libcxx/trunk/include/CMakeLists.txt

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=289963=289962=289963=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Fri Dec 16 11:30:51 2016
@@ -10,18 +10,14 @@ set(LIBCXX_HEADER_PATTERN
   ${LIBCXX_SUPPORT_HEADER_PATTERN}
   )
 
-if (LIBCXX_STANDALONE_BUILD)
-  set(LIBCXX_BUILD_ROOT "${LIBCXX_BINARY_DIR}")
-else()
-  set(LIBCXX_BUILD_ROOT "${LLVM_BINARY_DIR}")
+if(NOT LIBCXX_USING_INSTALLED_LLVM)
+  file(COPY .
+DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
+FILES_MATCHING
+${LIBCXX_HEADER_PATTERN}
+)
 endif()
 
-file(COPY .
-  DESTINATION "${LIBCXX_BUILD_ROOT}/include/c++/v1"
-  FILES_MATCHING
-  ${LIBCXX_HEADER_PATTERN}
-)
-
 if (LIBCXX_INSTALL_HEADERS)
   install(DIRECTORY .
 DESTINATION include/c++/v1


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


[PATCH] D27854: [analyzer] Add check for mutex acquisition during interrupt context in Magenta kernel

2016-12-16 Thread Kareem Khazem via Phabricator via cfe-commits
khazem created this revision.
khazem added reviewers: dcoughlin, dergachev.a.
khazem added subscribers: cfe-commits, phosek, seanklein.
Herald added a subscriber: mgorny.

Acquiring a mutex during the Magenta kernel exception handler can cause 
deadlocks and races. This patch adds a checker that ensures that no mutexes are 
acquired during an interrupt context.


https://reviews.llvm.org/D27854

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MagentaInterruptContextChecker.cpp
  test/Analysis/mutex-in-interrupt-context.cpp

Index: test/Analysis/mutex-in-interrupt-context.cpp
===
--- /dev/null
+++ test/Analysis/mutex-in-interrupt-context.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,optin.magenta.MutexInInterruptContext -std=c++11 -verify %s
+
+// Exit critical region
+void thread_preempt() {}
+void panic() {}
+void _panic() {}
+
+// Don't call these during critical region
+void mutex_acquire() {}
+void mutex_acquire_timeout() {}
+void mutex_acquire_timeout_internal() {}
+
+void call_ma() {
+  mutex_acquire(); // expected-warning {{Mutex acquired during interrupt context}}
+}
+
+void call_mat() {
+  mutex_acquire_timeout(); // expected-warning {{Mutex acquired during interrupt context}}
+}
+
+void call_mati() {
+  mutex_acquire_timeout_internal(); // expected-warning {{Mutex acquired during interrupt context}}
+}
+
+void call_ma_safe() {
+  mutex_acquire(); // no-warning
+}
+
+// The exception handler doesn't get called from C code. We start
+// exploring from the beginning of this function
+void x86_exception_handler(int foo) {
+  switch (foo) {
+case 0:
+  mutex_acquire(); // expected-warning {{Mutex acquired during interrupt context}}
+  break;
+
+case 1:
+  mutex_acquire_timeout(); // expected-warning {{Mutex acquired during interrupt context}}
+  break;
+
+case 2:
+  mutex_acquire_timeout_internal(); // expected-warning {{Mutex acquired during interrupt context}}
+  break;
+
+case 3:
+  call_ma();
+  break;
+
+case 4:
+  call_mat();
+  break;
+
+case 5:
+  call_mati();
+  break;
+
+case 6:
+  thread_preempt();
+  call_ma_safe();
+  break;
+
+case 7:
+  panic();
+  call_ma_safe();
+  break;
+
+case 8:
+  _panic();
+  call_ma_safe();
+  break;
+  }
+}
Index: lib/StaticAnalyzer/Checkers/MagentaInterruptContextChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/MagentaInterruptContextChecker.cpp
@@ -0,0 +1,148 @@
+//===-- MagentaInterruptContextChecker.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker checks for acquisitions of mutexes during an interrupt context
+// in the Magenta kernel, as such an acquisition can lead to race conditions and
+// deadlocks.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class MagentaInterruptContextChecker : public Checker {
+  std::unique_ptr MagentaInterruptContextBugType;
+  void reportMutexAcquisition(SymbolRef FileDescSym,
+const CallEvent ,
+CheckerContext ) const;
+
+  /// An interrupt context starts from this function
+  StringRef ExceptionHandler;
+
+  /// A list of functions that break out of an interrupt context
+  std::vector ExitFuns;
+
+  /// A list of functions that must not be called during an interrupt context
+  std::vector ProhibitedCalls;
+
+public:
+  MagentaInterruptContextChecker();
+
+  /// \brief Check if we've just started an interrupt context.
+  ///
+  /// We don't use PreCall for this because the interrupt context function is
+  /// never called from C code (thus there will never be a CallEvent for
+  /// x86_exception_handler). Therefore, we consider an interrupt context to
+  /// have started at the beginning of the body of ExceptionHandler, rather than
+  /// a call to that function.
+  void checkBeginFunction(CheckerContext ) const;
+
+  /// \brief Check if we have exited from an interrupt context
+  

[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-16 Thread Graydon Hoare via Phabricator via cfe-commits
graydon created this revision.
graydon added reviewers: manmanren, doug.gregor.
graydon added a subscriber: cfe-commits.

The module system supports accompanying a primary module (say Foo) with
an auxiliary "private" module (defined in an adjacent module.private.modulemap
file) that augments the primary module when associated private headers are
available. The feature is intended to be used to augment the primary
module with a submodule (say Foo.Private), however some users in the wild
are choosing to augment the primary module with an additional top-level module
with a "similar" name (in all cases so far: FooPrivate).

This "works" when a user of the module initially imports a private header,
such as '#import "Foo/something_private.h"' since the Foo import winds up
importing FooPrivate in passing. But if the import is subsequently recorded
in a PCH file, reloading the PCH will fail to validate because of a cross-check
that attempts to find the module.modulemap (or module.private.modulemap) using
HeaderSearch algorithm, applied to the "FooPrivate" name. Since it's stored in
Foo.framework/Modules, not FooPrivate.framework/Modules, the check fails and
the PCH is rejected.

This patch adds a compensatory workaround in the HeaderSearch algorithm
when searching (and failing to find) a module of the form FooPrivate: the
name used to derive filesystem paths is decoupled from the module name
being searched for, and if the initial search fails and the module is
named "FooPrivate", the filesystem search name is altered to remove the
"Private" suffix, and the algorithm is run a second time (still looking for
a module named FooPrivate, but looking in directories derived from Foo).

Accompanying this change is a new warning that triggers when a user loads
a module.private.modulemap that defines a top-level module with a different
name from the top-level module defined in its adjacent module.modulemap.


https://reviews.llvm.org/D27852

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/HeaderSearch.h
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
  test/Modules/implicit-private-with-different-name.m

Index: test/Modules/implicit-private-with-different-name.m
===
--- /dev/null
+++ test/Modules/implicit-private-with-different-name.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+
+// Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s
+
+// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only
+
+// expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{expected a submodule}}
+
+#ifndef HEADER
+#define HEADER
+#import "A/aprivate.h"
+const int *y = 
+#endif
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
@@ -0,0 +1,4 @@
+framework module APrivate {
+  header "aprivate.h"
+  export *
+}
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module A {
+  header "a.h"
+  export *
+}
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
@@ -0,0 +1 @@
+extern int APRIVATE;
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
@@ -0,0 +1 @@
+extern int APUBLIC;
Index: lib/Lex/ModuleMap.cpp
===
--- 

[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 81763.
hokein added a comment.

Update outdated comment.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/HelperDeclRefGraph.cpp
  clang-move/HelperDeclRefGraph.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,202 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp 

[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the awesome suggestions on the names.  I refactored the patch, hope 
it is clearer now.




Comment at: clang-move/UsedHelperDeclFinder.cpp:30
+  Result = FD;
+  if (const auto *RD = dyn_cast(FD->getParent()))
+Result = RD;

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > Why do you need this? And when is a function's parent a class?
> > This is for the template method in a class.
> Wouldn't that be handled in the next iteration?
> 
> Also, if you do another `getParent` here, do you also need to update `DC`?
Yep, that would be handled in next iteration, removed it.



Comment at: clang-move/UsedHelperDeclFinder.cpp:103
+
+UsedHelperDeclFinder::HelperDeclsSet UsedHelperDeclFinder::getUsedHelperDecls(
+const std::vector ) const {

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > Do you assume that all nodes/decls in the graph are helpers?
> > > 
> > > What if some moved `Decl` refers to unmoved decls?
> > The node in the graph can present moved/unmoved decls and helpers.
> > 
> > > What if some moved Decl refers to unmoved decls?
> > 
> > The graph doesn't contain this information, it only contains the reference  
> > between moved/unmoved decls and helpers. So in this case, we just move the 
> > moved Decl.
> So, IIUC, the graph can contain both non-helper decls and helper decls. In 
> that case, why do we name it `HelperDecl` Graph? And this 
> `getUsedHelperDecls` does not make sense either. Would be less confusing if 
> it is just `getUsedDecls`.
Good point. Renamed to `getUsedDecls`, but I still keep the `Helper` keyword in 
`HelperDeclRefGraph`, because "helper" indicates we use it for helpers.


https://reviews.llvm.org/D27673



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 81762.
hokein marked 3 inline comments as done.
hokein added a comment.

refactoring the patch.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/HelperDeclRefGraph.cpp
  clang-move/HelperDeclRefGraph.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,202 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h 

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I am really not keen on the name "obvious" for this module. What is obvious to 
one person is not always obvious to another. Also, if the checks are finding 
*obvious bugs*, then that suggests they should be implemented in the clang 
frontend rather than a tool that is run less frequently.

Since the checks are meant to be finding bugs rather than enforcing a coding 
standard, performance, readability, etc, a few possible alternative names:

`bugs-`
`correctness-`


https://reviews.llvm.org/D27815



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


[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-16 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8772
+def note_nullability_fix_it : Note<
+  "insert '%select{_Nonnull|_Nullable|_Null_unspecified}0' if the "
+  "%select{pointer|block pointer|member pointer|array parameter}1 "

ahatanak wrote:
> Is the third option (_Null_unspecified) going to be used somewhere? I see the 
> first two options are used in emitNullabilityConsistencyWarning, but not the 
> third one.
I think it's better not to suggest it to people, but it seemed weirder to have 
a reusable diagnostic that's intended to take a NullabilityKind and then have 
it blow up if someone ever decided to use it with NullUnspecified. I can take 
it out if you like.



Comment at: lib/Sema/SemaType.cpp:3491
+/// taking into account whitespace before and after.
+static FixItHint fixItNullability(Sema , SourceLocation pointerLoc,
+  NullabilityKind nullability) {

arphaman wrote:
> NIT: I noticed that you don't follow LLVM's naming style for variables here 
> (the parameter and variable names should start with an upper case letter). I 
> realise that there are some functions around the new functions in this file 
> that don't follow this style, so this might be better for local consistency, 
> but it would be nice if the new code follows LLVM's style.
Fair enough, will change. Been working in Swift too much. :-)



Comment at: lib/Sema/SemaType.cpp:3495
+
+  SmallString<32> insertionTextBuf{" "};
+  insertionTextBuf += getNullabilitySpelling(nullability);

arphaman wrote:
> Another NIT: I think it's better to avoid the braced initializer here, and 
> use `SmallString<32> insertionTextBuf = " "` instead
I tried that first, but SmallString doesn't have a valid copy-constructor. If 
it really bugs you I could make it a `+=` line too.


Repository:
  rL LLVM

https://reviews.llvm.org/D27837



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


[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

2016-12-16 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 81759.
danielcdh added a comment.

add a test.


https://reviews.llvm.org/D27832

Files:
  lib/Driver/Tools.cpp
  test/Driver/gold-lto-samplepgo.c


Index: test/Driver/gold-lto-samplepgo.c
===
--- /dev/null
+++ test/Driver/gold-lto-samplepgo.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fprofile-sample-use=%s \
+// RUN: | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2206,6 +2206,15 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef fname = A->getValue();
+if (!llvm::sys::fs::exists(fname))
+  D.Diag(diag::err_drv_no_such_file) << fname;
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + fname));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step


Index: test/Driver/gold-lto-samplepgo.c
===
--- /dev/null
+++ test/Driver/gold-lto-samplepgo.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fprofile-sample-use=%s \
+// RUN: | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2206,6 +2206,15 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef fname = A->getValue();
+if (!llvm::sys::fs::exists(fname))
+  D.Diag(diag::err_drv_no_such_file) << fname;
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + fname));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r289952 - [include-fixer] Desugar incomplete types.

2016-12-16 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Dec 16 10:09:06 2016
New Revision: 289952

URL: http://llvm.org/viewvc/llvm-project?rev=289952=rev
Log:
[include-fixer] Desugar incomplete types.

This will look through typedefs so include-fixer will look up the target
of the typedef instead of the typedef itself (which is already in
scope).

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=289952=289951=289952=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri Dec 16 10:09:06 
2016
@@ -153,8 +153,8 @@ bool IncludeFixerSemaSource::MaybeDiagno
 return false;
 
   clang::ASTContext  = CI->getASTContext();
-  std::string QueryString =
-  T.getUnqualifiedType().getAsString(context.getPrintingPolicy());
+  std::string QueryString = QualType(T->getUnqualifiedDesugaredType(), 0)
+.getAsString(context.getPrintingPolicy());
   DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString << "'");
   // Pass an empty range here since we don't add qualifier in this case.
   std::vector MatchedSymbols =

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=289952=289951=289952=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri 
Dec 16 10:09:06 2016
@@ -136,6 +136,10 @@ TEST(IncludeFixer, IncompleteType) {
   "namespace std {\nclass string;\n}\nstd::string foo;\n",
   runIncludeFixer("#include \"foo.h\"\n"
   "namespace std {\nclass string;\n}\nstring foo;\n"));
+
+  EXPECT_EQ("#include \n"
+"class string;\ntypedef string foo;\nfoo f;\n",
+runIncludeFixer("class string;\ntypedef string foo;\nfoo f;\n"));
 }
 
 TEST(IncludeFixer, MinimizeInclude) {


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


[PATCH] D26530: Fix the spelling of 'bitfield' in diagnostics to be consistently 'bit-field'.

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! This is the way it is spelled in the C and C++ standards as well.


https://reviews.llvm.org/D26530



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


[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8772
+def note_nullability_fix_it : Note<
+  "insert '%select{_Nonnull|_Nullable|_Null_unspecified}0' if the "
+  "%select{pointer|block pointer|member pointer|array parameter}1 "

Is the third option (_Null_unspecified) going to be used somewhere? I see the 
first two options are used in emitNullabilityConsistencyWarning, but not the 
third one.


Repository:
  rL LLVM

https://reviews.llvm.org/D27837



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


r289786 - [ARM] Implement execute-only support in CodeGen

2016-12-16 Thread Prakhar Bahuguna via cfe-commits
Author: prakhar
Date: Thu Dec 15 01:59:24 2016
New Revision: 289786

URL: http://llvm.org/viewvc/llvm-project?rev=289786=rev
Log:
[ARM] Implement execute-only support in CodeGen

Summary:
This implements execute-only support for ARM code generation, which
prevents the compiler from generating data accesses to code sections.
The following changes are involved:

* Add the CodeGen option "-arm-execute-only" to the ARM code generator.
* Add the clang flag "-mexecute-only" as well as the GCC-compatible
  alias "-mpure-code" to enable this option.
* When enabled, literal pools are replaced with MOVW/MOVT instructions,
  with VMOV used in addition for floating-point literals. As the MOVT
  instruction is required, execute-only support is only available in
  Thumb mode for targets supporting ARMv8-M baseline or Thumb2.
* Jump tables are placed in data sections when in execute-only mode.
* The execute-only text section is assigned section ID 0, and is
  marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'.
  This also overrides selection of ELF sections for globals.

Reviewers: t.p.northover, rengolin

Subscribers: llvm-commits, aemerson

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

Added:
cfe/trunk/test/Driver/arm-execute-only.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=289786=289785=289786=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Dec 15 01:59:24 
2016
@@ -190,6 +190,8 @@ def err_target_unsupported_fpmath : Erro
 "the '%0' unit is not supported with this instruction set">;
 def err_target_unsupported_unaligned : Error<
   "the %0 sub-architecture does not support unaligned accesses">;
+def err_target_unsupported_execute_only : Error<
+  "execute only is not supported for the %0 sub-architecture">;
 def err_opt_not_valid_with_opt : Error<
   "option '%0' cannot be specified with '%1'">;
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=289786=289785=289786=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Dec 15 01:59:24 2016
@@ -1455,6 +1455,12 @@ def mlong_calls : Flag<["-"], "mlong-cal
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
+def mexecute_only : Flag<["-"], "mexecute-only">, Group,
+  HelpText<"Disallow generation of data access to code sections (ARM only)">;
+def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
+  HelpText<"Allow generation of data access to code sections (ARM only)">;
+def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility
+def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias;
 def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;
 def mappletvos_version_min_EQ : Joined<["-"], "mappletvos-version-min=">, 
Alias;
 def mtvos_simulator_version_min_EQ : Joined<["-"], 
"mtvos-simulator-version-min=">, Alias;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=289786=289785=289786=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec 15 01:59:24 2016
@@ -1001,6 +1001,7 @@ arm::FloatABI arm::getARMFloatABI(const
 static void getARMTargetFeatures(const ToolChain ,
  const llvm::Triple ,
  const ArgList ,
+ ArgStringList ,
  std::vector ,
  bool ForAS) {
   const Driver  = TC.getDriver();
@@ -1139,6 +1140,28 @@ static void getARMTargetFeatures(const T
   Features.push_back("+long-calls");
   }
 
+  // Generate execute-only output (no data access to code sections).
+  // Supported only on ARMv6T2 and ARMv7 and above.
+  // Cannot be combined with -mno-movt or -mlong-calls
+  if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, 
options::OPT_mno_execute_only)) {
+if (A->getOption().matches(options::OPT_mexecute_only)) {
+  if (getARMSubArchVersionNumber(Triple) < 7 &&
+  llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
+

[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:862
+def FormatDynamicKeyArg : InheritableAttr {
+  let Spellings = [GCC<"format_dynamic_key_arg">];
+  let Args = [IntArgument<"FormatIdx">];

Does GCC support this attribute as well? If not, this should use the GNU 
spelling instead of the GCC one. Also, should this have a C++11 spelling in the 
clang namespace?

The name doesn't really convey much about what the attribute is doing, mostly 
because it doesn't seem obvious what "key" means.

It seems that the crux of what this attribute says is that the attributed 
function accepts a string argument of a format specifier and returns the same 
format specifier. Perhaps `returns_format_specifier` is a better name?



Comment at: lib/Sema/SemaDeclAttr.cpp:5632
+  case AttributeList::AT_FormatDynamicKeyArg:
+handleFormatArgAttr(S, D, Attr, /*IsDynamicKey=*/true);
+break;

We ask that all of these `handle*Attr()` functions have the same signature, so 
adding extra parameters isn't something we do. At some point, we want to 
generate more boilerplate code from the attribute definition files, and so 
having different parameter lists makes that much harder to accomplish. A better 
approach would be to make a function called `handleFormatDynamicKeyArg()` that 
calls a helper function with the extra argument, and modify 
`handleFormatArgAttr()` to call that helper function as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D27165



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-16 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski added inline comments.



Comment at: clang-tidy/obvious/InvalidRangeCheck.cpp:20-36
+"std::for_each; std::find; std::find_if; std::find_end; "
+"std::find_first_of; std::adjacent_find; std::count; std::count_if;"
+"std::mismatch; std::equal; std::search; std::copy; "
+"std::copy_backward; std::swap_ranges; std::transform; std::replace"
+"std::replace_if; std::replace_copy; std::replace_copy_if; std::fill; "
+"std::fill_n; std::generate; std::generate_n; std::remove; std::remove_if"
+"std::remove_copy; std::remove_copy_if; std::unique; std::unique_copy;"

Prazek wrote:
> sbarzowski wrote:
> > I would go with one per line. It will be much more diff-friendly this way.  
> > And also much easier to add stuff in the middle and maybe keep it sorted. 
> I don't expect this list to change in any way in the future, and it already 
> take more than 20 lines. I don't want to put about 80 lines only to define 
> the names
Ok, I don't think it's important enough to argue about it if it was your 
deliberate decision.

But I still think your argument is invalid :-). If anything that calls for 
putting it in a separate file.


https://reviews.llvm.org/D27806



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


[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2016-12-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Driver/Options.td:1324
+  HelpText<"Use C++ undefined behaviour optimization for control flow paths"
+ "that reach the end of the function without executing a required return">;
+def fno_strict_return : Flag<["-"], "fno-strict-return">, Group,

mehdi_amini wrote:
> Quuxplusone wrote:
> > Nit: looks like Clang spells it "behavior"?
> > 
> > Nit: I'm still pedantically uncomfortable with describing the strict-return 
> > behavior as an "optimization". I suggest rephrasing this as 
> > "-fstrict-return: Treat control flow paths that fall off the end of a 
> > non-void function as unreachable."
> > 
> > (I notice that neither -fstrict-aliasing nor -fstrict-overflow have any 
> > help text at all.)
> >  I suggest rephrasing this as "-fstrict-return: Treat control flow paths 
> > that fall off the end of a non-void function as unreachable."
> 
> Is it an accurate description? `-fno-strict-return` would only disable this 
> for trivial types.
> Nit: looks like Clang spells it "behavior"?

Thanks, I forgot to use the US spelling.

> Nit: I'm still pedantically uncomfortable with describing the strict-return 
> behavior as an "optimization". I suggest rephrasing this as "-fstrict-return: 
> Treat control flow paths that fall off the end of a non-void function as 
> unreachable."

I like your suggestion, but Mehdi brought up a good point. Maybe "Always treat 
control flow paths that fall off the end of a non-void function as unreachable" 
would be better, since then `-fno-strict-return` would imply that the 
optimisation can still be used sometimes, like for the non-trivially 
destructible types.


Repository:
  rL LLVM

https://reviews.llvm.org/D27163



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-12-16 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:8051
+  if (!LHSVecType) {
+assert(RHSVecType && "RHSVecType is not a vector!");
 if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : ),

bruno wrote:
> `tryVectorConvertAndSplat` does more than plain scalar splat; it supports a 
> more general type of CK_IntegralCast, see the comment on one of your changes 
> to the tests below.
> 
> I suggest that instead of reusing this function, you should create another 
> one that only handles the cases we actually want to support for non-ext 
> vectors (i.e. for GCC compat). 
(ignore this, phabricator's web interface is acting up)



Comment at: lib/Sema/SemaExpr.cpp:8267
+  }
+
   // Otherwise, use the generic diagnostic.

bruno wrote:
> sdardis wrote:
> > bruno wrote:
> > > This change seems orthogonal to this patch. Can you make it a separated 
> > > patch with the changes from test/Sema/vector-cast.c?
> > This change is a necessary part of this patch and it can't be split out in 
> > sensible fashion.
> > 
> > For example, line 329 of test/Sema/zvector.c adds a scalar signed character 
> > to a vector of signed characters. With just this change we would report 
> > "cannot convert between scalar type 'signed char' and vector type '__vector 
> > signed char' (vector of 16 'signed char' values) as implicit conversion 
> > would cause truncation".
> > 
> > This is heavily misleading for C and C++ code as we don't perform implicit 
> > conversions and signed char could be implicitly converted to a vector of 
> > signed char without the loss of precision.
> > 
> > To make this diagnostic precise without performing implicit conversions 
> > requires determining cases where implicit conversion would cause truncation 
> > and reporting that failure reason, or defaulting to the generic diagnostic.
> > 
> > Keeping this change as part of this patch is cleaner and simpler as it 
> > covers both implicit conversions and more precise diagnostics.
> Can you double check whether we should support these GCC semantics for 
> getLangOpts().ZVector? If not, then this should be introduced in a separate 
> patch/commit.
See my comment above.



Comment at: lib/Sema/SemaExpr.cpp:8171
+return LHSType;
+}
   }

bruno wrote:
> It's not clear to me whether clang should support the GCC semantics when in 
> `getLangOpts().AltiVec || getLangOpts().ZVector`, do you?
> 
> You can remove the curly braces for the `if` and `else` here.
We should, GCC performs scalar to vector conversions regardless of what cpu 
features are available. If the target machine doesn't have vector support, GCC 
silently scalarizes the operation.

https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Vector-Extensions.html#Vector-Extensions


https://reviews.llvm.org/D25866



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


[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2016-12-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:1078
+  QualType T = FD->getReturnType();
+  if (T.isTriviallyCopyableType(Context)) {
+// Avoid the optimization for functions that return trivially copyable

rjmccall wrote:
> arphaman wrote:
> > Quuxplusone wrote:
> > > Peanut-gallery question: Does `isTriviallyCopyableType` also check that 
> > > the type is trivially destructible and/or default-constructible? Do those 
> > > things matter?
> > Yes for trivially destructible, since it calls 
> > `CXXRecordDecl::isTriviallyCopyable()` which checks. No for trivially 
> > default-constructible, I fixed that. 
> > 
> > I think that for us it doesn't really matter that much, since we're mostly 
> > worried about C code compiled in C++ mode.
> The right condition is just hasTrivialDestructor().  The goal of 
> -fno-strict-return is to not treat falling off the end of a function as 
> undefined behavior in itself: it might still be a *problem* if users don't 
> ignore the result, but we shouldn't escalate to UB in the callee because they 
> legitimately might ignore the result.  The argument for having an exception 
> around non-trivial types is that callers never *really* ignore the result 
> when there's a non-trivial destructor.  Calling a destructor on storage that 
> doesn't have a valid object of that type constructed there is already 
> definitely U.B. in the caller, so it's fine to also treat it as U.B. on the 
> callee side.  That reasoning is entirely based on the behavior of the 
> destructor, though, not any of the copy/move constructors, and definitely not 
> the presence or absence of a trivial default constructor.
> 
> In practice, all of these things tend to vary together, of course, except 
> that sometimes trivial types do have non-trivial default constructors.  We 
> should not treat that as a UB case.
I see what you mean, this kind of reasoning makes sense. I'll use just the 
`hasTrivialDestructor` check when committing.


Repository:
  rL LLVM

https://reviews.llvm.org/D27163



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-12-16 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 81755.
sdardis marked an inline comment as done.
sdardis added a comment.

Addressed review comments, fixed assertion issue with expressions like scalar 
-= vector.


https://reviews.llvm.org/D25866

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-gcc-compat.c
  test/Sema/zvector.c
  test/SemaCXX/vector-no-lax.cpp

Index: test/SemaCXX/vector-no-lax.cpp
===
--- test/SemaCXX/vector-no-lax.cpp
+++ test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@
 
 vSInt32 foo (vUInt32 a) {
   vSInt32 b = { 0, 0, 0, 0 };
-  b += a; // expected-error{{cannot convert between vector values}}
+  b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}}
   return b;
 }
Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-gcc-compat.c
===
--- /dev/null
+++ test/Sema/vector-gcc-compat.c
@@ -0,0 +1,304 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+typedef long long v2i64 __attribute__((vector_size(16)));
+typedef int v2i32 __attribute__((vector_size(8)));
+typedef short v2i16 __attribute__((vector_size(4)));
+typedef char v2i8 __attribute__((vector_size(2)));
+
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+typedef unsigned int v2u32 __attribute__((vector_size(8)));
+typedef unsigned short v2u16 __attribute__((vector_size(4)));
+typedef unsigned char v2u8 __attribute__((vector_size(2)));
+
+typedef float v4f32 __attribute__((vector_size(16)));
+typedef double v4f64 __attribute__((vector_size(32)));
+
+void arithmeticTest(void);
+void logicTest(void);
+void comparisonTest(void);
+void floatTestSignedType(char a, short b, int c, long long d);
+void floatTestUnsignedType(unsigned char a, unsigned short b, unsigned int c,
+   unsigned long long d);
+void floatTestConstant(void);
+void intTestType(char a, short b, int c, long long d);
+void intTestTypeUnsigned(unsigned char a, unsigned short b, unsigned int c,
+ unsigned long long d);
+void uintTestType(char a, short b, int c, long long d);
+void uintTestTypeUnsigned(unsigned char a, unsigned short b, unsigned int c,
+  unsigned long long d);
+void uintTestConstant(v2u64 v2u64_a, v2u32 v2u32_a, v2u16 

[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2016-12-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D27163#623811, @majnemer wrote:

> My 2 cents: If making this a target-specific default is not OK, why not turn 
> on -fno-strict-return if -fapple-kext is specified? I believe that would 
> cover the critical use case in question.


We've had issues with more than just kexts, so this won't be that beneficial to 
us.


Repository:
  rL LLVM

https://reviews.llvm.org/D27163



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


[PATCH] D14274: Add alloc_size attribute to clang

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I still think that this looks good, so if @rsmith doesn't comment over the 
weekend, you can go ahead and commit on Monday -- we can handle any feedback in 
post-commit review.




Comment at: include/clang/Basic/AttrDocs.td:240
+  Specifically, clang will only trace ``const`` pointers (as above); we give up
+  on pointers that are not marked as ``const``.  In the vast majority of cases,
+  this is unimportant, because LLVM has support for the ``alloc_size``

Double space after the full stop should be a single space (here and below).


https://reviews.llvm.org/D14274



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


[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or

2016-12-16 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner created this revision.
cpplearner added reviewers: mclow.lists, EricWF, howard.hinnant.
cpplearner added a subscriber: cfe-commits.

See https://github.com/cplusplus/draft/pull/839 and 
https://github.com/cplusplus/fundamentals-ts/pull/73.


https://reviews.llvm.org/D27850

Files:
  include/experimental/optional
  include/optional


Index: include/optional
===
--- include/optional
+++ include/optional
@@ -893,7 +893,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible_v,
   "optional::value_or: T must be move constructible");
Index: include/experimental/optional
===
--- include/experimental/optional
+++ include/experimental/optional
@@ -562,7 +562,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible::value,
   "optional::value_or: T must be move constructible");


Index: include/optional
===
--- include/optional
+++ include/optional
@@ -893,7 +893,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible_v,
   "optional::value_or: T must be move constructible");
Index: include/experimental/optional
===
--- include/experimental/optional
+++ include/experimental/optional
@@ -562,7 +562,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-value_type value_or(_Up&& __v) &&
+constexpr value_type value_or(_Up&& __v) &&
 {
 static_assert(is_move_constructible::value,
   "optional::value_or: T must be move constructible");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26800: [Sema] Make __attribute__((notnull)) inheritable through function parameters

2016-12-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Modulo the comment from @ahatanak, I think this looks good. Once you have 
addressed that comment, I can commit for you.


https://reviews.llvm.org/D26800



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Code is almost good. I'm just still a bit confused by names.




Comment at: clang-move/ClangMove.cpp:459
   
//
-  auto InOldCCNamedOrGlobalNamespace =
-  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
- translationUnitDecl(,
-InOldCC);
-  // Matching using decls/type alias decls which are in named namespace or
-  // global namespace. Those in classes, functions and anonymous namespaces are
-  // covered in other matchers.
+  auto InOldCCNamespace = allOf(
+  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(, InOldCC);

hokein wrote:
> ioeric wrote:
> > I got the meaning here, but the name is a bit inaccurate since this also 
> > includes `TranslationUnitDecl`.
> but`TranslationUnitDecl` also means in global namespace, right?
Maybe, but it is not straight-forward. I think what you really want here is 
top-level declarations in old cc. The name does not really imply that. For 
example, something defined in a function in a namespace is also in that 
namespace.



Comment at: clang-move/UsedHelperDeclFinder.cpp:30
+  Result = FD;
+  if (const auto *RD = dyn_cast(FD->getParent()))
+Result = RD;

hokein wrote:
> ioeric wrote:
> > Why do you need this? And when is a function's parent a class?
> This is for the template method in a class.
Wouldn't that be handled in the next iteration?

Also, if you do another `getParent` here, do you also need to update `DC`?



Comment at: clang-move/UsedHelperDeclFinder.cpp:103
+
+UsedHelperDeclFinder::HelperDeclsSet UsedHelperDeclFinder::getUsedHelperDecls(
+const std::vector ) const {

hokein wrote:
> ioeric wrote:
> > Do you assume that all nodes/decls in the graph are helpers?
> > 
> > What if some moved `Decl` refers to unmoved decls?
> The node in the graph can present moved/unmoved decls and helpers.
> 
> > What if some moved Decl refers to unmoved decls?
> 
> The graph doesn't contain this information, it only contains the reference  
> between moved/unmoved decls and helpers. So in this case, we just move the 
> moved Decl.
So, IIUC, the graph can contain both non-helper decls and helper decls. In that 
case, why do we name it `HelperDecl` Graph? And this `getUsedHelperDecls` does 
not make sense either. Would be less confusing if it is just `getUsedDecls`.



Comment at: clang-move/UsedHelperDeclFinder.h:22
+
+// Call graph for helper declarations in a single translation unit e.g. old.cc.
+// Helper declarations include following types:

hokein wrote:
> ioeric wrote:
> > hokein wrote:
> > > ioeric wrote:
> > > > What's the relationship between this and the `CallGraph` class in 
> > > > `clang/Analysis/CallGraph.h`?
> > > There is no relationship between them. We build our own CallGraph class 
> > > to meet our use cases. The CallGraph in `clang/Analysis` only supports 
> > > function decls, and it seems hard to reuse it. The thing we reuse is the 
> > > `CallGraphNode`. 
> > So, this should be named something like reference graph instead of call 
> > graph? Call graph might be confusing for readers without context.
> But the "HelperDecl" indicates our special use case. Might be 
> "HelperDeclGraph" or "HelperDeclDependencyGraph"?
The problem is not with `HelperDecl` part. It's the `CallGraph` part that's a 
bit confusing. I think `HelperDeclReferenceGraph` might be better?



Comment at: clang-move/UsedHelperDeclFinder.h:110
+  // before checking it in UsedDecls.
+  static bool isUsed(const Decl *D, const HelperDeclsSet );
+

This is still a bit confusing even with the comment.

I think the confusing part is `Used`, which makes it hard to understand what 
this function does, and I think the reason why it is hard to find a good name 
might due to the wrong abstraction here.  Maybe just inline this function? It 
is just one line after all.


https://reviews.llvm.org/D27673



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


[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/queue_t_overload.cl:10
+  foo(0, src2);
+  foo(q, src3); // expected-error {{call to 'foo' is ambiguous}}
+}

could we also add something non-convertible for queue i.e.
  foo(1, src3);


https://reviews.llvm.org/D27569



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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Small nitpicks below can be done before committing. Also it would be nice 
to double check the compile time is still fine after the last rebase.

Thanks!




Comment at: include/clang/Basic/OpenCLOptions.h:28
+unsigned Avail; // Option starts to be available in this OpenCL version
+unsigned Core;  // Options becomes (optional) core feature in this OpenCL
+// version

Options -> Option



Comment at: include/clang/Basic/OpenCLOptions.h:43
 
-  // Enable or disable all options.
-  void setAll(bool Enable = true) {
-#define OPENCLEXT(nm)   nm = Enable;
-#include "clang/Basic/OpenCLExtensions.def"
+  // Is supported OpenCL extension or (optional) core feature for OpenCL 
version
+  // \p CLVer.

Did you mean "and (optional) core feature?"



Comment at: test/SemaOpenCL/extension-begin.cl:5
+// Test with pch.
+// RUN: %clang_cc1 %s -DHEADER -triple spir-unknown-unknown -emit-pch 
-DHEADER_ONLY -o %t -verify -pedantic
+// RUN: %clang_cc1 %s -DHEADER_USER -triple spir-unknown-unknown -include-pch 
%t -fsyntax-only -verify -pedantic

Do we need -DHEADER_ONLY here?


https://reviews.llvm.org/D21698



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


[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-16 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 81742.
echuraev marked 3 inline comments as done.

https://reviews.llvm.org/D27569

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Sema/Initialization.h
  include/clang/Sema/Overload.h
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGenOpenCL/null_queue.cl
  test/SemaOpenCL/null_queue.cl
  test/SemaOpenCL/queue_t_overload.cl

Index: test/SemaOpenCL/queue_t_overload.cl
===
--- /dev/null
+++ test/SemaOpenCL/queue_t_overload.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+
+void __attribute__((overloadable)) foo(queue_t, __local char *); // expected-note {{candidate function}}
+void __attribute__((overloadable)) foo(queue_t, __local float *); // expected-note {{candidate function}}
+
+void kernel ker(__local char *src1, __local float *src2, __global int *src3) {
+  queue_t q;
+  foo(q, src1);
+  foo(0, src2);
+  foo(q, src3); // expected-error {{call to 'foo' is ambiguous}}
+}
Index: test/SemaOpenCL/null_queue.cl
===
--- /dev/null
+++ test/SemaOpenCL/null_queue.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+extern queue_t get_default_queue();
+
+bool compare() {
+  return 1 == get_default_queue() && // expected-error{{invalid operands to binary expression ('int' and 'queue_t')}}
+ get_default_queue() == 1; // expected-error{{invalid operands to binary expression ('queue_t' and 'int')}}
+}
+
+void init() {
+  queue_t q1 = 1; // expected-error{{initializing 'queue_t' with an expression of incompatible type 'int'}}
+  queue_t q = 0;
+}
Index: test/CodeGenOpenCL/null_queue.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/null_queue.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0  -emit-llvm %s -o - | FileCheck %s
+extern queue_t get_default_queue();
+
+bool compare() {
+  return 0 == get_default_queue() &&
+ get_default_queue() == 0;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+  // CHECK: icmp eq %opencl.queue_t* %{{.*}}, null
+}
+
+void func(queue_t q);
+
+void init() {
+  queue_t q = 0;
+  func(0);
+  // CHECK: store %opencl.queue_t* null, %opencl.queue_t** %q
+  // CHECK: call void @func(%opencl.queue_t* null)
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1781,6 +1781,11 @@
  From->EvaluateKnownConstInt(S.getASTContext()) == 0) {
 SCS.Second = ICK_Zero_Event_Conversion;
 FromType = ToType;
+  } else if (ToType->isQueueT() &&
+ From->isIntegerConstantExpr(S.getASTContext()) &&
+ (From->EvaluateKnownConstInt(S.getASTContext()) == 0)) {
+SCS.Second = ICK_Zero_Queue_Conversion;
+FromType = ToType;
   } else {
 // No second conversion required.
 SCS.Second = ICK_Identity;
@@ -5155,6 +5160,7 @@
   case ICK_Function_Conversion:
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion: // Narrowing conversions are checked elsewhere.
+  case ICK_Zero_Queue_Conversion:
 return true;
 
   case ICK_Boolean_Conversion:
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -3073,6 +3073,7 @@
   case SK_StdInitializerListConstructorCall:
   case SK_OCLSamplerInit:
   case SK_OCLZeroEvent:
+  case SK_OCLZeroQueue:
 break;
 
   case SK_ConversionSequence:
@@ -3334,6 +3335,13 @@
   Steps.push_back(S);
 }
 
+void InitializationSequence::AddOCLZeroQueueStep(QualType T) {
+  Step S;
+  S.Kind = SK_OCLZeroQueue;
+  S.Type = T;
+  Steps.push_back(S);
+}
+
 void InitializationSequence::RewrapReferenceInitList(QualType T,
  InitListExpr *Syntactic) {
   assert(Syntactic->getNumInits() == 1 &&
@@ -4981,6 +4989,20 @@
   return true;
 }
 
+static bool TryOCLZeroQueueInitialization(Sema ,
+  InitializationSequence ,
+  QualType DestType,
+  Expr *Initializer) {
+  if (!S.getLangOpts().OpenCL || S.getLangOpts().OpenCLVersion < 200 ||
+  !DestType->isQueueT() ||
+  !Initializer->isIntegerConstantExpr(S.getASTContext()) ||
+  (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0))
+return false;
+
+  Sequence.AddOCLZeroQueueStep(DestType);
+  return true;
+}
+
 InitializationSequence::InitializationSequence(Sema ,
const InitializedEntity ,
 

[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-16 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Yes.. return non-zero seems right. This is an error condition.


https://reviews.llvm.org/D27440



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-move/ClangMove.cpp:492
+  isDefinition(), unless(InMovedClass), InOldCC,
+  anyOf(isStaticStorageClass(), hasParent(namespaceDecl(isAnonymous();
+  auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition),

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > It seems that `isStaticStorageClass` is preventing combining matchers for 
> > > functions, variables, and classes. Maybe only apply this matcher on 
> > > `functionDecl` and `varDecl` below, so that helper classes can be matched 
> > > with the same matcher?
> > Seems that it is hard to reuse the same matcher for 
> > `functionDecl`/`varDecl` and `CXXRecordDecl` since `isStaticStorageClass` 
> > is not available to  `CXXRecordDecl`. So we have to match helper classes, 
> > helper functions/vars separately.  Have cleaned the code to make it clearer.
> I mean merging helper classes into `helperFuncOrVar` (maybe need to be 
> renamed) so that class helpers are parallel with `functionDecl` and `varDecl` 
> here.
We need to match helper classes separately because we want to reuse these two 
matchers (HelperFuncOrVar, HelperClasses) in finding helpers' usage below.



Comment at: clang-move/ClangMove.cpp:459
   
//
-  auto InOldCCNamedOrGlobalNamespace =
-  allOf(hasParent(decl(anyOf(namespaceDecl(unless(isAnonymous())),
- translationUnitDecl(,
-InOldCC);
-  // Matching using decls/type alias decls which are in named namespace or
-  // global namespace. Those in classes, functions and anonymous namespaces are
-  // covered in other matchers.
+  auto InOldCCNamespace = allOf(
+  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(, InOldCC);

ioeric wrote:
> I got the meaning here, but the name is a bit inaccurate since this also 
> includes `TranslationUnitDecl`.
but`TranslationUnitDecl` also means in global namespace, right?



Comment at: clang-move/ClangMove.cpp:461
+  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(, InOldCC);
+  // Matching using decls/type alias decls which are in named/anonymous/global
+  // namespace. Those in classes, functions are covered in other matchers.

ioeric wrote:
> Maybe also explain a bit on how you handle these using and alias decls here.
> 
> Are they always copied/moved regardless where they are?
Yeah, added comment.



Comment at: clang-move/ClangMove.cpp:493
+ varDecl(IsOldCCHelperDefinition)));
+  auto HelperClasses =
+  cxxRecordDecl(isDefinition(), unless(InMovedClass), InOldCC,

ioeric wrote:
> Thinking about this some more. Helpers might be (incorrectly) defined in 
> non-anonymous namespaces without static qualifier. Do we want to consider 
> these?
hmm, in theory, "helpers" defined accidently in non-anonymous namespaces are 
not helpers as they are visible outside of the current TU. The implementation 
relies on the invisible property of helpers to verify whether a 
function/variable is a helper, so this would be hard to achieve.



Comment at: clang-move/UsedHelperDeclFinder.cpp:22
+// by a single node which belongs to the class.
+const Decl *getOutmostEnclosingClassOrFunDecl(const Decl *D) {
+  const auto *DC = D->getDeclContext();

ioeric wrote:
> If we always only match outermost decls, we might be able to get rid of this. 
> I feel that this kind of function (that traverse up AST) can easily hit into 
> corner cases.
Beside construction of the graph, this function is also used in checking 
whether a given Declaration is used or not.



Comment at: clang-move/UsedHelperDeclFinder.cpp:22
+// by a single node which belongs to that class.
+const Decl *getOutmostEnclosingClassOrFunDecl(const Decl *D) {
+  const auto *DC = D->getDeclContext();

ioeric wrote:
> Maybe just `getOutermostDecls` and add FIXME for other data types.
The name might be too long, I have renamed it to `getOutermostClassOrFunDecls` 
(I prefer to keep the `ClassOrFunDecl` postfix which clearly indicates what 
this function exactly does without reading the comment, I'm happy to rename it 
in the future if needed).

Is there any types we want to support? From my understanding, it is sufficient 
to cover our usage now.



Comment at: clang-move/UsedHelperDeclFinder.cpp:30
+  Result = FD;
+  if (const auto *RD = dyn_cast(FD->getParent()))
+Result = RD;

ioeric wrote:
> Why do you need this? And when is a function's parent a class?
This is for the template method in a class.



Comment at: clang-move/UsedHelperDeclFinder.cpp:103
+
+UsedHelperDeclFinder::HelperDeclsSet UsedHelperDeclFinder::getUsedHelperDecls(

[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 81741.
hokein marked 15 inline comments as done.
hokein added a comment.



- address code review comments
- add more tests


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/UsedHelperDeclFinder.cpp
  clang-move/UsedHelperDeclFinder.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,202 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h 

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D25660#613519, @zaks.anna wrote:

> Also, have you evaluated this on real codebases? What results do you see? Are 
> there any false positives found? Are there any true positives found?


I am doing it right now. Unfortunately I found a crash which I fixed, but then 
it turned out that overwrites of the iterator variable are not handled. I am 
working on this problem.


https://reviews.llvm.org/D25660



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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-16 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D27440#624773, @djasper wrote:

> I agree that fallback-style should only be used when there is no 
> .clang-format file. If we find one, and it doesn't parse correctly, we should 
> neither use the fallback style nor scan in higher-level directories (not sure 
> whether we currently do that).


Cool, and do you agree that clang-format should also return non-zero when this 
happens? If so, I'll just abort this change. Perhaps I'll take a look at fixing 
this in clang-format as discussed.


https://reviews.llvm.org/D27440



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-16 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked 2 inline comments as done.
Prazek added inline comments.



Comment at: clang-tidy/obvious/InvalidRangeCheck.cpp:20-36
+"std::for_each; std::find; std::find_if; std::find_end; "
+"std::find_first_of; std::adjacent_find; std::count; std::count_if;"
+"std::mismatch; std::equal; std::search; std::copy; "
+"std::copy_backward; std::swap_ranges; std::transform; std::replace"
+"std::replace_if; std::replace_copy; std::replace_copy_if; std::fill; "
+"std::fill_n; std::generate; std::generate_n; std::remove; std::remove_if"
+"std::remove_copy; std::remove_copy_if; std::unique; std::unique_copy;"

sbarzowski wrote:
> I would go with one per line. It will be much more diff-friendly this way.  
> And also much easier to add stuff in the middle and maybe keep it sorted. 
I don't expect this list to change in any way in the future, and it already 
take more than 20 lines. I don't want to put about 80 lines only to define the 
names


https://reviews.llvm.org/D27806



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


[PATCH] D27794: Make some diagnostic tests C++11 clean

2016-12-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG for OpenMP part


https://reviews.llvm.org/D27794



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


[PATCH] D27717: [analyzer] Suppress a leak false positive in Qt's QObject::connectImpl()

2016-12-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289939: [analyzer] Add another exception for Qt in 
MallocChecker (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D27717?vs=81239=81738#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27717

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/Inputs/qt-simulator.h
  cfe/trunk/test/Analysis/qt_malloc.cpp


Index: cfe/trunk/test/Analysis/qt_malloc.cpp
===
--- cfe/trunk/test/Analysis/qt_malloc.cpp
+++ cfe/trunk/test/Analysis/qt_malloc.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -std=c++11 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
 // expected-no-diagnostics
 #include "Inputs/qt-simulator.h"
 
@@ -13,3 +13,9 @@
   QEvent *e4 = new QEvent(QEvent::None);
   QApplication::postEvent(obj, e4);
 }
+
+void connect(QObject *obj) {
+  obj->connectImpl(nullptr, nullptr, nullptr, nullptr,
+   new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
+   nullptr, nullptr);
+}
Index: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
===
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h
@@ -1,6 +1,23 @@
 #pragma clang system_header
 
+namespace QtPrivate {
+struct QSlotObjectBase {};
+}
+
+namespace Qt {
+enum ConnectionType {};
+}
+
+struct QMetaObject {
+  struct Connection {};
+};
+
 struct QObject {
+  static QMetaObject::Connection connectImpl(const QObject *, void **,
+ const QObject *, void **,
+ QtPrivate::QSlotObjectBase *,
+ Qt::ConnectionType,
+ const int *, const QMetaObject *);
 };
 
 struct QEvent {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2579,6 +2579,11 @@
 return true;
   }
 
+  if (FName == "connectImpl" &&
+  FD->getQualifiedNameAsString() == "QObject::connectImpl") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the


Index: cfe/trunk/test/Analysis/qt_malloc.cpp
===
--- cfe/trunk/test/Analysis/qt_malloc.cpp
+++ cfe/trunk/test/Analysis/qt_malloc.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s
 // expected-no-diagnostics
 #include "Inputs/qt-simulator.h"
 
@@ -13,3 +13,9 @@
   QEvent *e4 = new QEvent(QEvent::None);
   QApplication::postEvent(obj, e4);
 }
+
+void connect(QObject *obj) {
+  obj->connectImpl(nullptr, nullptr, nullptr, nullptr,
+   new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
+   nullptr, nullptr);
+}
Index: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
===
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h
@@ -1,6 +1,23 @@
 #pragma clang system_header
 
+namespace QtPrivate {
+struct QSlotObjectBase {};
+}
+
+namespace Qt {
+enum ConnectionType {};
+}
+
+struct QMetaObject {
+  struct Connection {};
+};
+
 struct QObject {
+  static QMetaObject::Connection connectImpl(const QObject *, void **,
+ const QObject *, void **,
+ QtPrivate::QSlotObjectBase *,
+ Qt::ConnectionType,
+ const int *, const QMetaObject *);
 };
 
 struct QEvent {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2579,6 +2579,11 @@
 return true;
   }
 
+  if (FName == "connectImpl" &&
+  FD->getQualifiedNameAsString() == 

r289939 - [analyzer] Add another exception for Qt in MallocChecker

2016-12-16 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Dec 16 06:21:55 2016
New Revision: 289939

URL: http://llvm.org/viewvc/llvm-project?rev=289939=rev
Log:
[analyzer] Add another exception for Qt in MallocChecker

Treat pointers passed to QObject::connectImpl() as escaping.

rdar://problem/29550440

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/Analysis/Inputs/qt-simulator.h
cfe/trunk/test/Analysis/qt_malloc.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=289939=289938=289939=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Dec 16 06:21:55 
2016
@@ -2579,6 +2579,11 @@ bool MallocChecker::mayFreeAnyEscapedMem
 return true;
   }
 
+  if (FName == "connectImpl" &&
+  FD->getQualifiedNameAsString() == "QObject::connectImpl") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the

Modified: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/qt-simulator.h?rev=289939=289938=289939=diff
==
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h (original)
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h Fri Dec 16 06:21:55 2016
@@ -1,6 +1,23 @@
 #pragma clang system_header
 
+namespace QtPrivate {
+struct QSlotObjectBase {};
+}
+
+namespace Qt {
+enum ConnectionType {};
+}
+
+struct QMetaObject {
+  struct Connection {};
+};
+
 struct QObject {
+  static QMetaObject::Connection connectImpl(const QObject *, void **,
+ const QObject *, void **,
+ QtPrivate::QSlotObjectBase *,
+ Qt::ConnectionType,
+ const int *, const QMetaObject *);
 };
 
 struct QEvent {

Modified: cfe/trunk/test/Analysis/qt_malloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/qt_malloc.cpp?rev=289939=289938=289939=diff
==
--- cfe/trunk/test/Analysis/qt_malloc.cpp (original)
+++ cfe/trunk/test/Analysis/qt_malloc.cpp Fri Dec 16 06:21:55 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -std=c++11 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
 // expected-no-diagnostics
 #include "Inputs/qt-simulator.h"
 
@@ -13,3 +13,9 @@ void send(QObject *obj)
   QEvent *e4 = new QEvent(QEvent::None);
   QApplication::postEvent(obj, e4);
 }
+
+void connect(QObject *obj) {
+  obj->connectImpl(nullptr, nullptr, nullptr, nullptr,
+   new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
+   nullptr, nullptr);
+}


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


[PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-12-16 Thread Attila Török via Phabricator via cfe-commits
torokati44 added a comment.

I see this has been reverted in r281612, but I can no longer access the build 
log serving as a reason linked in the message: 
https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg35386.html
We have a few false-positive warnings that (I think) would be silenced by this 
change. I'm just wondering if something like this, if not this, could be 
included anyway? Not critical of course, it just would be nice.


https://reviews.llvm.org/D23921



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


[PATCH] D27700: [clang-tidy] refactor ExprSequence out of misc-use-after-move check

2016-12-16 Thread Marek Sokołowski via Phabricator via cfe-commits
mnbvmar marked 9 inline comments as done.
mnbvmar added inline comments.



Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:18
 using namespace clang::ast_matchers;
+using namespace clang::tidy::utils;
+

mboehme wrote:
> Prazek wrote:
> > Prazek wrote:
> > > I don't think it is required
> > ok I guess I am wrong
> I would suggest instead adding an explicit "utils::" qualifier -- it's only 
> needed in two places anyway. I don't feel strongly about this though.
It's actually needed in more places (I think at least four). I feel like 
leaving it here.


https://reviews.llvm.org/D27700



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


[PATCH] D27700: [clang-tidy] refactor ExprSequence out of misc-use-after-move check

2016-12-16 Thread Marek Sokołowski via Phabricator via cfe-commits
mnbvmar updated this revision to Diff 81732.
mnbvmar marked 2 inline comments as done.
mnbvmar added a comment.

Minor changes, according to the request.


https://reviews.llvm.org/D27700

Files:
  clang-tidy/misc/UseAfterMoveCheck.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/ExprSequence.cpp
  clang-tidy/utils/ExprSequence.h

Index: clang-tidy/utils/ExprSequence.h
===
--- /dev/null
+++ clang-tidy/utils/ExprSequence.h
@@ -0,0 +1,124 @@
+//===- ExprSequence.h - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_EXPRSEQUENCE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_EXPRSEQUENCE_H
+
+#include "clang/Analysis/CFG.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+/// Provides information about the evaluation order of (sub-)expressions within
+/// a `CFGBlock`.
+///
+/// While a `CFGBlock` does contain individual `CFGElement`s for some
+/// sub-expressions, the order in which those `CFGElement`s appear reflects
+/// only one possible order in which the sub-expressions may be evaluated.
+/// However, we want to warn if any of the potential evaluation orders can lead
+/// to a use-after-move, not just the one contained in the `CFGBlock`.
+///
+/// This class implements only a simplified version of the C++ sequencing
+/// rules. The main limitation is that we do not distinguish between value
+/// computation and side effect -- see the "Implementation" section for more
+/// details.
+///
+/// Note: `SequenceChecker` from SemaChecking.cpp does a similar job (and much
+/// more thoroughly), but using it would require
+/// - Pulling `SequenceChecker` out into a header file (i.e. making it part of
+///   the API),
+/// - Removing the dependency of `SequenceChecker` on `Sema`, and
+/// - (Probably) modifying `SequenceChecker` to make it suitable to be used in
+///   this context.
+/// For the moment, it seems preferable to re-implement our own version of
+/// sequence checking that is special-cased to what we need here.
+///
+/// Implementation
+/// --
+///
+/// `ExprSequence` uses two types of sequencing edges between nodes in the AST:
+///
+/// - Every `Stmt` is assumed to be sequenced after its children. This is
+///   overly optimistic because the standard only states that value computations
+///   of operands are sequenced before the value computation of the operator,
+///   making no guarantees about side effects (in general).
+///
+///   For our purposes, this rule is sufficient, however, because this check is
+///   interested in operations on objects, which are generally performed through
+///   function calls (whether explicit and implicit). Function calls guarantee
+///   that the value computations and side effects for all function arguments
+///   are sequenced before the execution of the function.
+///
+/// - In addition, some `Stmt`s are known to be sequenced before or after
+///   their siblings. For example, the `Stmt`s that make up a `CompoundStmt`are
+///   all sequenced relative to each other. The function
+///   `getSequenceSuccessor()` implements these sequencing rules.
+class ExprSequence {
+public:
+  /// Initializes this `ExprSequence` with sequence information for the given
+  /// `CFG`.
+  ExprSequence(const CFG *TheCFG, ASTContext *TheContext);
+
+  /// Returns whether \p Before is sequenced before \p After.
+  bool inSequence(const Stmt *Before, const Stmt *After) const;
+
+  /// Returns whether \p After can potentially be evaluated after \p Before.
+  /// This is exactly equivalent to `!inSequence(After, Before)` but makes some
+  /// conditions read more naturally.
+  bool potentiallyAfter(const Stmt *After, const Stmt *Before) const;
+
+private:
+  // Returns the sibling of \p S (if any) that is directly sequenced after \p S,
+  // or nullptr if no such sibling exists. For example, if \p S is the child of
+  // a `CompoundStmt`, this would return the Stmt that directly follows \p S in
+  // the `CompoundStmt`.
+  //
+  // As the sequencing of many constructs that change control flow is already
+  // encoded in the `CFG`, this function only implements the sequencing rules
+  // for those constructs where sequencing cannot be inferred from the `CFG`.
+  const Stmt *getSequenceSuccessor(const Stmt *S) const;
+
+  const Stmt *resolveSyntheticStmt(const Stmt *S) const;
+
+  ASTContext *Context;
+
+  llvm::DenseMap SyntheticStmtSourceMap;
+};
+
+/// Maps `Stmt`s to the `CFGBlock` that contains them. Some `Stmt`s may be

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-16 Thread Firat Kasmis via Phabricator via cfe-commits
firolino updated this revision to Diff 81731.
firolino added a comment.

further cleanup in getUserWrittenType


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,142 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = , * long3 = 
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = 
+// CHECK-FIXES: {{^}}long * long3 = 
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+/* *& */ int /* *& */ ** /* *& */ pp,*xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}/* *& */ int /* *& */ ** /* *& */ pp;
+// CHECK-FIXES: {{^}}int *xx;
+
+unsigned int uint1 = 0,uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+const int * const cpc = , simple = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int * const cpc = 
+// CHECK-FIXES: {{^}}const int simple = 0;
+
+double darray1[] = {}, darray2[] = {1,	2},dv1 = 3,dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int cx = 1;
+// CHECK-FIXES: {{^}}const int cy = 2;
+
+volatile int vx, vy;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}volatile int vx;
+// CHECK-FIXES: {{^}}volatile int vy;
+
+signed char sc1 = 'h', sc2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}signed char sc1 = 'h';
+// CHECK-FIXES: {{^}}signed char sc2;
+
+long long ll1, ll2, ***ft;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long ll1;
+// CHECK-FIXES: {{^}}long long ll2;
+// 

  1   2   >