[clang-tools-extra] r305057 - Revert "[clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed."

2017-06-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jun  9 02:34:58 2017
New Revision: 305057

URL: http://llvm.org/viewvc/llvm-project?rev=305057&view=rev
Log:
Revert "[clang-tidy] When" -fno-exceptions is used", this warning is better to 
be suppressed."

This reverts commit r304949.

https://reviews.llvm.org/D34002#775830

Modified:
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?rev=305057&r1=305056&r2=305057&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp 
Fri Jun  9 02:34:58 2017
@@ -20,7 +20,7 @@ namespace misc {
 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11 || !getLangOpts().CXXExceptions)
+  if (!getLangOpts().CPlusPlus11)
 return;
 
   Finder->addMatcher(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?rev=305057&r1=305056&r2=305057&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp 
Fri Jun  9 02:34:58 2017
@@ -1,25 +1,16 @@
-// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-std=c++11 \
-// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
-// RUN:   -implicit-check-not="{{warning|error}}:"
-// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- 
-fno-exceptions -std=c++11 \
-// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
-// RUN:   -implicit-check-not="{{warning|error}}:"
-
+// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
 
 class A {
   A(A &&);
-  // CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: move constructors should be 
marked noexcept [misc-noexcept-move-constructor]
-  // CHECK-NONEXCEPTIONS-NOT: warning:
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be 
marked noexcept [misc-noexcept-move-constructor]
   A &operator=(A &&);
-  // CHECK-EXCEPTIONS: :[[@LINE-1]]:6: warning: move assignment operators 
should
-  // CHECK-NONEXCEPTIONS-NOT: warning:
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
 };
 
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-EXCEPTIONS: :[[@LINE-1]]:20: warning: noexcept specifier on the 
move constructor evaluates to 'false' [misc-noexcept-move-constructor]
-  // CHECK-NONEXCEPTIONS-NOT: warning:
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move 
constructor evaluates to 'false' [misc-noexcept-move-constructor]
 };
 
 class OK {};


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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34002#776551, @chh wrote:

> Android source is suppressing misc-noexcept-move-constructor warnings
>  because -fno-exceptions is used and Android does not like to add more
>  exception specific code.


As I've said, the lack of `noexcept` on move constructor of a type will make 
certain operations on STL containers of that type slower regardless of whether 
exceptions are turned on or off. `-fno-exceptions` will in no way help to 
recover the lost performance, so there's absolutely no reason to silence this 
check on the code that is otherwise not using exceptions.

Reverted in r305057.

> It's not a big deal for Android to suppress this check one way or the other.
>  I don't mind reverting it, just curious why a compiler cannot assume 
> noexcept under -fno-exceptions.

One reason for compiler not to treat each function as `noexcept`, when compiled 
with `-fno-exceptions` is that it would make it hard to link this code together 
with code compiled with `-fexceptions` without causing ODR violations.


https://reviews.llvm.org/D34002



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


Re: [clang-tools-extra] r304977 - [clang-tidy] New checker to replace dynamic exception specifications

2017-06-09 Thread Alexander Kornienko via cfe-commits
Fixes committed in r305024 and r305057.

On Fri, Jun 9, 2017 at 12:07 AM, Alexander Kornienko 
wrote:

> It looks like the buildbots have exceptions turned off by default, so the
> tests need to use `-fexceptions` explicitly. Testing a fix...
>
> On Thu, Jun 8, 2017 at 11:26 PM, Galina Kistanova 
> wrote:
>
>> Hello Alexander,
>>
>> Couple of our builders do not like this commit:
>>
>> Failing Tests:
>>
>> Clang Tools :: clang-tidy/modernize-use-noexcept-opt.cpp
>> Clang Tools :: clang-tidy/modernize-use-noexcept.cpp
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-ubuntu-fast/builds/12431
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast
>>
>> Please have a look at this?
>>
>> Thanks
>>
>> Galina
>>
>> On Thu, Jun 8, 2017 at 7:04 AM, Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Thu Jun  8 09:04:16 2017
>>> New Revision: 304977
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304977&view=rev
>>> Log:
>>> [clang-tidy] New checker to replace dynamic exception specifications
>>>
>>> Summary:
>>> New checker to replace dynamic exception
>>> specifications
>>>
>>> This is an alternative to D18575 which relied on reparsing the decl to
>>> find the location of dynamic exception specifications, but couldn't
>>> deal with preprocessor conditionals correctly without reparsing the
>>> entire file.
>>>
>>> This approach uses D20428 to find dynamic exception specification
>>> locations and handles all cases correctly.
>>>
>>> Reviewers: aaron.ballman, alexfh
>>>
>>> Reviewed By: aaron.ballman, alexfh
>>>
>>> Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere,
>>> cfe-commits, Eugene.Zelenko, etienneb
>>>
>>> Patch by Don Hinton!
>>>
>>> Differential Revision: https://reviews.llvm.org/D20693
>>>
>>> Added:
>>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use
>>> -noexcept.rst
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
>>> pt-macro.cpp
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
>>> pt-opt.cpp
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>>> clang-tools-extra/trunk/docs/ReleaseNotes.rst
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=304976&r2=
>>> 304977&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> (original)
>>> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu
>>> Jun  8 09:04:16 2017
>>> @@ -22,6 +22,7 @@ add_clang_library(clangTidyModernizeModu
>>>UseEmplaceCheck.cpp
>>>UseEqualsDefaultCheck.cpp
>>>UseEqualsDeleteCheck.cpp
>>> +  UseNoexceptCheck.cpp
>>>UseNullptrCheck.cpp
>>>UseOverrideCheck.cpp
>>>UseTransparentFunctorsCheck.cpp
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyMo
>>> dule.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clang-tidy/modernize/ModernizeTidyModule.cpp?rev=304977&r1=3
>>> 04976&r2=304977&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>>> (original)
>>> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>>> Thu Jun  8 09:04:16 2017
>>> @@ -28,6 +28,7 @@
>>>  #include "UseEmplaceCheck.h"
>>>  #include "UseEqualsDefaultCheck.h"
>>>  #include "UseEqualsDeleteCheck.h"
>>> +#include "UseNoexceptCheck.h"
>>>  #include "UseNullptrCheck.h"
>>>  #include "UseOverrideCheck.h"
>>>  #include "UseTransparentFunctorsCheck.h"
>>> @@ -69,6 +70,7 @@ public:
>>>  CheckFactories.registerCheck("modern
>>> ize-use-equals-default");
>>>  CheckFactories.registerCheck(
>>>  "modernize-use-equals-delete");
>>> +CheckFactories.registerCheck("modernize-us
>>> e-noexcept");
>>>  CheckFactories.registerCheck("modernize-us
>>> e-nullptr");
>>>  CheckFactories.registerCheck("modernize-u
>>> se-override");
>>>  CheckFactories.registerCheck(
>>>
>>> Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clang-tidy/modernize/UseNoexceptCheck.cpp?rev=304977&view=auto
>>> 
>>> ==
>>> --- cla

[PATCH] D33493: Speed up preamble loading

2017-06-09 Thread Erik Verbruggen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305061: Speed up preamble loading (authored by erikjv).

Changed prior to commit:
  https://reviews.llvm.org/D33493?vs=101995&id=102003#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33493

Files:
  cfe/trunk/include/clang/Frontend/ASTUnit.h
  cfe/trunk/lib/Frontend/ASTUnit.cpp


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1159,6 +1159,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+PreambleSrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -2602,23 +2604,26 @@
   // remap all the locations to the new view. This includes the diag location,
   // any associated source ranges, and the source ranges of associated fix-its.
   // FIXME: There should be a cleaner way to do this.
-
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
-  FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+SourceLocation FileLoc;
+auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
+if (ItFileID == PreambleSrcLocCache.end()) {
+  FileID FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  PreambleSrcLocCache[SD.Filename] = FileLoc;
+} else {
+  FileLoc = ItFileID->getValue();
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -188,6 +188,14 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// Cache contains only source locations from preamble so it is
+  /// guaranteed that they stay valid when the SourceManager is recreated.
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading. It must be cleared when preamble is recreated.
+  llvm::StringMap PreambleSrcLocCache;
+
 public:
   class PreambleData {
 const FileEntry *File;


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1159,6 +1159,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+PreambleSrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -2602,23 +2604,26 @@
   // remap all the locations to the new view. This includes the diag location,
   // any associated source ranges, and the source ranges of associated fix-its.
   // FIXME: There should be a cleaner way to do this.
-
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
-  FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+SourceLocation FileLoc;
+auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
+if (ItFileID == PreambleSrcLocCache.end()) {
+  FileID FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  PreambleSrcLocCache[SD.Filename] = FileLoc;
+} else {
+  FileLoc = ItFileID->getValue();
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -188,6 +188,14 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// Cache contains only source locations from preamble so it is
+  /// guaranteed that they stay valid when the SourceManager is recreated.
+  /// This cache is used when load

r305061 - Speed up preamble loading

2017-06-09 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Fri Jun  9 03:29:58 2017
New Revision: 305061

URL: http://llvm.org/viewvc/llvm-project?rev=305061&view=rev
Log:
Speed up preamble loading

Cache filename - SourceLocation pairs to speed up preamble loading and
global completion. This is especially relevant for windows, where
preamble loading takes a while.

Patch by Ivan Donchevskii!

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

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=305061&r1=305060&r2=305061&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Fri Jun  9 03:29:58 2017
@@ -188,6 +188,14 @@ private:
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// Cache contains only source locations from preamble so it is
+  /// guaranteed that they stay valid when the SourceManager is recreated.
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading. It must be cleared when preamble is recreated.
+  llvm::StringMap PreambleSrcLocCache;
+
 public:
   class PreambleData {
 const FileEntry *File;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=305061&r1=305060&r2=305061&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Jun  9 03:29:58 2017
@@ -1159,6 +1159,8 @@ bool ASTUnit::Parse(std::shared_ptrExecute())
 goto error;
@@ -2602,11 +2604,9 @@ void ASTUnit::TranslateStoredDiagnostics
   // remap all the locations to the new view. This includes the diag location,
   // any associated source ranges, and the source ranges of associated fix-its.
   // FIXME: There should be a cleaner way to do this.
-
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
@@ -2614,11 +2614,16 @@ void ASTUnit::TranslateStoredDiagnostics
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
-  FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+SourceLocation FileLoc;
+auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
+if (ItFileID == PreambleSrcLocCache.end()) {
+  FileID FID = SrcMgr.translateFile(FE);
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  PreambleSrcLocCache[SD.Filename] = FileLoc;
+} else {
+  FileLoc = ItFileID->getValue();
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);


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


Re: r305044 - [libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for parsing a single file only.

2017-06-09 Thread Manuel Klimek via cfe-commits
Hey ho,

this looks like a really cool new feature, and the CL looks good to me; I
was wondering whether in the future we can send CLs like this through
pre-commit review, or have an RFC email thread. If you have more stuff
landing, a single RFC email thread describing how the features work
together would also be super useful, as it makes it easier to follow along
the patches later.

Cheers,
/Manuel

On Fri, Jun 9, 2017 at 3:21 AM Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: akirtzidis
> Date: Thu Jun  8 20:20:48 2017
> New Revision: 305044
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305044&view=rev
> Log:
> [libclang] Introduce a new parsing option
> 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for
> parsing a single file only.
>
> This is useful for parsing a single file, as a fast/inaccurate 'mode' that
> can still provide declarations from the file, like the classes and their
> methods.
>
> Added:
> cfe/trunk/test/Index/singe-file-parse.m
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/Frontend/ASTUnit.h
> cfe/trunk/include/clang/Lex/PreprocessorOptions.h
> cfe/trunk/lib/Frontend/ASTUnit.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=305044&r1=305043&r2=305044&view=diff
>
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Thu Jun  8 20:20:48 2017
> @@ -32,7 +32,7 @@
>   * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>   */
>  #define CINDEX_VERSION_MAJOR 0
> -#define CINDEX_VERSION_MINOR 42
> +#define CINDEX_VERSION_MINOR 43
>
>  #define CINDEX_VERSION_ENCODE(major, minor) ( \
>((major) * 1)   \
> @@ -1234,7 +1234,12 @@ enum CXTranslationUnit_Flags {
> * purposes of an IDE, this is undesirable behavior and as much
> information
> * as possible should be reported. Use this flag to enable this
> behavior.
> */
> -  CXTranslationUnit_KeepGoing = 0x200
> +  CXTranslationUnit_KeepGoing = 0x200,
> +
> +  /**
> +   * \brief Sets the preprocessor in a mode for parsing a single file
> only.
> +   */
> +  CXTranslationUnit_SingleFileParse = 0x400
>  };
>
>  /**
>
> Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=305044&r1=305043&r2=305044&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jun  8 20:20:48 2017
> @@ -871,6 +871,7 @@ public:
>bool CacheCodeCompletionResults = false,
>bool IncludeBriefCommentsInCodeCompletion = false,
>bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies =
> false,
> +  bool SingleFileParse = false,
>bool UserFilesAreVolatile = false, bool ForSerialization = false,
>llvm::Optional ModuleFormat = llvm::None,
>std::unique_ptr *ErrAST = nullptr,
>
> Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=305044&r1=305043&r2=305044&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
> +++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jun  8 20:20:48
> 2017
> @@ -95,6 +95,9 @@ public:
>/// If given, a PTH cache file to use for speeding up header parsing.
>std::string TokenCache;
>
> +  /// When enabled, preprocessor is in a mode for parsing a single file
> only.
> +  bool SingleFileParseMode = false;
> +
>/// \brief True if the SourceManager should report the original file
> name for
>/// contents of files that were remapped to other files. Defaults to
> true.
>bool RemappedFilesKeepOriginalName;
> @@ -181,6 +184,7 @@ public:
>  ImplicitPCHInclude.clear();
>  ImplicitPTHInclude.clear();
>  TokenCache.clear();
> +SingleFileParseMode = false;
>  RetainRemappedFileBuffers = true;
>  PrecompiledPreambleBytes.first = 0;
>  PrecompiledPreambleBytes.second = 0;
>
> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=305044&r1=305043&r2=305044&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jun  8 20:20:48 2017
> @@ -1982,7 +1982,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
>  unsigned Precompi

r305066 - Reapply "Frontend support for Nios2 target"

2017-06-09 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Fri Jun  9 05:56:18 2017
New Revision: 305066

URL: http://llvm.org/viewvc/llvm-project?rev=305066&view=rev
Log:
Reapply "Frontend support for Nios2 target"

Summary:
- Implements TargetInfo class for Nios2 target.
- Enables handling of -march and -mcpu options for Nios2 target.
- Definition of Nios2 builtin functions.

Reviewed By: craig.topper

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

Author: belickim 

Added:
cfe/trunk/include/clang/Basic/BuiltinsNios2.def
cfe/trunk/test/Driver/nios2-cpu.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/TargetBuiltins.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Added: cfe/trunk/include/clang/Basic/BuiltinsNios2.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNios2.def?rev=305066&view=auto
==
--- cfe/trunk/include/clang/Basic/BuiltinsNios2.def (added)
+++ cfe/trunk/include/clang/Basic/BuiltinsNios2.def Fri Jun  9 05:56:18 2017
@@ -0,0 +1,70 @@
+//===-- BuiltinsNios2.def - Nios2 Builtin function database *- C++ 
-*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines the Nios2-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===--===//
+
+// The format of this database matches clang/Basic/Builtins.def.
+
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+// Nios2 R1 builtins:
+
+//int __builtin_ldbio(volatile const void *);
+BUILTIN(__builtin_ldbio, "ivDC*", "")
+//int __builtin_ldbuio(volatile const void *);
+BUILTIN(__builtin_ldbuio, "ivDC*", "")
+//int __builtin_ldhio(volatile const void *);
+BUILTIN(__builtin_ldhio, "ivDC*", "")
+//int __builtin_ldhuio(volatile const void *);
+BUILTIN(__builtin_ldhuio, "ivDC*", "")
+//int __builtin_ldwio(volatile const void *);
+BUILTIN(__builtin_ldwio, "ivDC*", "")
+//int __builtin_ldwuio(int);
+BUILTIN(__builtin_ldwuio, "ii", "")
+// int __builtin_rdctl(int);
+BUILTIN(__builtin_rdctl, "iIi", "")
+// void __builtin_wrctl(int, int);
+BUILTIN(__builtin_wrctl, "vIii", "")
+// int __builtin_rdprs(int, int);
+BUILTIN(__builtin_rdprs, "iii", "")
+//void __builtin_stbio(volatile void *, int);
+BUILTIN(__builtin_stbio, "vvD*i", "")
+//void __builtin_sthio(volatile void *, int);
+BUILTIN(__builtin_sthio, "vvD*i", "")
+//void __builtin_stwio(volatile void *, int);
+BUILTIN(__builtin_stwio, "vvD*i", "")
+//void __builtin_sync(void);
+BUILTIN(__builtin_sync, "v", "")
+// void __builtin_flushd(volatile void *);
+BUILTIN(__builtin_flushd, "vvD*", "")
+// void __builtin_flushda(volatile void *);
+BUILTIN(__builtin_flushda, "vvD*", "")
+
+// Nios2 R2 builtins:
+
+// int __builtin_wrpie(int);
+TARGET_BUILTIN(__builtin_wrpie, "ii", "", "nios2r2mandatory")
+// void __builtin_eni(int);
+TARGET_BUILTIN(__builtin_eni, "vi", "", "nios2r2mandatory")
+// int __builtin_ldex(volatile const void *);
+TARGET_BUILTIN(__builtin_ldex, "ivDC*", "", "nios2r2mandatory")
+// int __builtin_stex(volatile void *, int);
+TARGET_BUILTIN(__builtin_stex, "ivD*i", "", "nios2r2mandatory")
+// int __builtin_ldsex(volatile const void *);
+TARGET_BUILTIN(__builtin_ldsex, "ivDC*", "", "nios2r2mpx")
+// int __builtin_stsex(volatile void *, int);
+TARGET_BUILTIN(__builtin_stsex, "ivDC*i", "", "nios2r2mpx")
+
+#undef BUILTIN
+#undef TARGET_BUILTIN

Modified: cfe/trunk/include/clang/Basic/TargetBuiltins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetBuiltins.h?rev=305066&r1=305065&r2=305066&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h Fri Jun  9 05:56:18 2017
@@ -150,6 +150,16 @@ namespace clang {
 };
   }
 
+  /// \brief Nios2 builtins
+  namespace Nios2 {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsNios2.def"
+LastTSBuiltin
+  };
+  }
+
   /// \brief MIPS builtins
   namespace Mips {
 enum {

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=305066&r1=305065&r2=305066&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun  9 05:56:18 2017
@@ -7702,6 +7702,148 @@ public:
   }
 };
 
+class Nios2TargetInfo : pu

[clang-tools-extra] r305067 - [clang-tools-extra] ReleaseNotes.rst: test commit: whitespace fix

2017-06-09 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun  9 07:00:04 2017
New Revision: 305067

URL: http://llvm.org/viewvc/llvm-project?rev=305067&view=rev
Log:
[clang-tools-extra] ReleaseNotes.rst: test commit: whitespace fix

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=305067&r1=305066&r2=305067&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Jun  9 07:00:04 2017
@@ -100,10 +100,10 @@ Improvements to clang-tidy
   to remove user-defined make functions from ``push_back`` calls on containers
   of custom tuple-like types by providing `TupleTypes` and 
`TupleMakeFunctions`.
 
- - New `modernize-use-noexcept
-   
`_ 
check
+- New `modernize-use-noexcept
+  
`_ 
check
 
-   Replaces dynamic exception specifications with ``noexcept`` or a user 
defined macro.
+  Replaces dynamic exception specifications with ``noexcept`` or a user 
defined macro.
 
 - New `performance-inefficient-vector-operation
   
`_
 check


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


r305068 - Revert of r305066 "Reapply Frontend support for Nios2 target"

2017-06-09 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Fri Jun  9 07:09:29 2017
New Revision: 305068

URL: http://llvm.org/viewvc/llvm-project?rev=305068&view=rev
Log:
Revert of r305066 "Reapply Frontend support for Nios2 target"

Removed:
cfe/trunk/include/clang/Basic/BuiltinsNios2.def
cfe/trunk/test/Driver/nios2-cpu.c
Modified:
cfe/trunk/include/clang/Basic/TargetBuiltins.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Removed: cfe/trunk/include/clang/Basic/BuiltinsNios2.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNios2.def?rev=305067&view=auto
==
--- cfe/trunk/include/clang/Basic/BuiltinsNios2.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNios2.def (removed)
@@ -1,70 +0,0 @@
-//===-- BuiltinsNios2.def - Nios2 Builtin function database *- C++ 
-*-==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the Nios2-specific builtin function database. Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-// Nios2 R1 builtins:
-
-//int __builtin_ldbio(volatile const void *);
-BUILTIN(__builtin_ldbio, "ivDC*", "")
-//int __builtin_ldbuio(volatile const void *);
-BUILTIN(__builtin_ldbuio, "ivDC*", "")
-//int __builtin_ldhio(volatile const void *);
-BUILTIN(__builtin_ldhio, "ivDC*", "")
-//int __builtin_ldhuio(volatile const void *);
-BUILTIN(__builtin_ldhuio, "ivDC*", "")
-//int __builtin_ldwio(volatile const void *);
-BUILTIN(__builtin_ldwio, "ivDC*", "")
-//int __builtin_ldwuio(int);
-BUILTIN(__builtin_ldwuio, "ii", "")
-// int __builtin_rdctl(int);
-BUILTIN(__builtin_rdctl, "iIi", "")
-// void __builtin_wrctl(int, int);
-BUILTIN(__builtin_wrctl, "vIii", "")
-// int __builtin_rdprs(int, int);
-BUILTIN(__builtin_rdprs, "iii", "")
-//void __builtin_stbio(volatile void *, int);
-BUILTIN(__builtin_stbio, "vvD*i", "")
-//void __builtin_sthio(volatile void *, int);
-BUILTIN(__builtin_sthio, "vvD*i", "")
-//void __builtin_stwio(volatile void *, int);
-BUILTIN(__builtin_stwio, "vvD*i", "")
-//void __builtin_sync(void);
-BUILTIN(__builtin_sync, "v", "")
-// void __builtin_flushd(volatile void *);
-BUILTIN(__builtin_flushd, "vvD*", "")
-// void __builtin_flushda(volatile void *);
-BUILTIN(__builtin_flushda, "vvD*", "")
-
-// Nios2 R2 builtins:
-
-// int __builtin_wrpie(int);
-TARGET_BUILTIN(__builtin_wrpie, "ii", "", "nios2r2mandatory")
-// void __builtin_eni(int);
-TARGET_BUILTIN(__builtin_eni, "vi", "", "nios2r2mandatory")
-// int __builtin_ldex(volatile const void *);
-TARGET_BUILTIN(__builtin_ldex, "ivDC*", "", "nios2r2mandatory")
-// int __builtin_stex(volatile void *, int);
-TARGET_BUILTIN(__builtin_stex, "ivD*i", "", "nios2r2mandatory")
-// int __builtin_ldsex(volatile const void *);
-TARGET_BUILTIN(__builtin_ldsex, "ivDC*", "", "nios2r2mpx")
-// int __builtin_stsex(volatile void *, int);
-TARGET_BUILTIN(__builtin_stsex, "ivDC*i", "", "nios2r2mpx")
-
-#undef BUILTIN
-#undef TARGET_BUILTIN

Modified: cfe/trunk/include/clang/Basic/TargetBuiltins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetBuiltins.h?rev=305068&r1=305067&r2=305068&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h Fri Jun  9 07:09:29 2017
@@ -150,16 +150,6 @@ namespace clang {
 };
   }
 
-  /// \brief Nios2 builtins
-  namespace Nios2 {
-  enum {
-LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
-#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
-#include "clang/Basic/BuiltinsNios2.def"
-LastTSBuiltin
-  };
-  }
-
   /// \brief MIPS builtins
   namespace Mips {
 enum {

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=305068&r1=305067&r2=305068&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jun  9 07:09:29 2017
@@ -7702,148 +7702,6 @@ public:
   }
 };
 
-class Nios2TargetInfo : public TargetInfo {
-  void setDataLayout() {
-if (BigEndian)
-  resetDataLayout("E-p:32:32:32-i8:8:32-i16:16:32-n32");
-else
-  resetDataLayout("e-p:32:32:32-i8:8:32-i16:16:32-n32");
-  }
-
-  static const Builtin::Info BuiltinInfo[];
-  std::string CPU;
-

[PATCH] D34050: Support capturing the implicit `this` argument to C++ class member functions

2017-06-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris abandoned this revision.
dberris added a comment.

Fail... it's been a while since I've done this. Will try again.


https://reviews.llvm.org/D34050



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


[PATCH] D34052: [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions

2017-06-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.

Before this change, we couldn't capture the `this` pointer that's
implicitly the first argument of class member functions. There are some
interesting things we can do with capturing even just this single
argument for zero-argument member functions.


https://reviews.llvm.org/D34052

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/xray-log-args-class.cpp


Index: test/Sema/xray-log-args-class.cpp
===
--- /dev/null
+++ test/Sema/xray-log-args-class.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+
+class Class {
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
+  [[clang::xray_log_args(-1)]] void Invalid(); // expected-error 
{{'xray_log_args' attribute parameter 1 is out of bounds}}
+  [[clang::xray_log_args("invalid")]] void InvalidStringArg(); // 
expected-error {{'xray_log_args'}}
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4604,14 +4604,40 @@
 static void handleXRayLogArgsAttr(Sema &S, Decl *D,
   const AttributeList &Attr) {
   uint64_t ArgCount;
+
+  // Treat member functions especially, since we do want to support saving the
+  // implicit this argument for member functions.
+  if (isInstanceMethod(D)) {
+auto *IdxExpr = Attr.getArgAsExpr(0);
+llvm::APSInt IdxInt;
+if (!IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << 1u << AANT_ArgumentIntegerConstant
+  << IdxExpr->getSourceRange();
+  return;
+}
+ArgCount = IdxInt.getLimitedValue();
+bool HP = hasFunctionProto(D);
+unsigned NumParams = HP ? getFunctionOrMethodNumParams(D) + 1 : 1;
+if (ArgCount > NumParams) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
+  << getAttrName(Attr) << 1 << IdxExpr->getSourceRange();
+  return;
+}
+D->addAttr(::new (S.Context)
+   XRayLogArgsAttr(Attr.getRange(), S.Context, ArgCount,
+   Attr.getAttributeSpellingListIndex()));
+return;
+  }
+
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
ArgCount))
 return;
 
   // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
   D->addAttr(::new (S.Context)
- XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
- Attr.getAttributeSpellingListIndex()));
+ XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
+ Attr.getAttributeSpellingListIndex()));
 }
 
 
//===--===//


Index: test/Sema/xray-log-args-class.cpp
===
--- /dev/null
+++ test/Sema/xray-log-args-class.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+
+class Class {
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
+  [[clang::xray_log_args(-1)]] void Invalid(); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+  [[clang::xray_log_args("invalid")]] void InvalidStringArg(); // expected-error {{'xray_log_args'}}
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4604,14 +4604,40 @@
 static void handleXRayLogArgsAttr(Sema &S, Decl *D,
   const AttributeList &Attr) {
   uint64_t ArgCount;
+
+  // Treat member functions especially, since we do want to support saving the
+  // implicit this argument for member functions.
+  if (isInstanceMethod(D)) {
+auto *IdxExpr = Attr.getArgAsExpr(0);
+llvm::APSInt IdxInt;
+if (!IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << 1u << AANT_ArgumentIntegerConstant
+  << IdxExpr->getSourceRange();
+  return;
+}
+ArgCount = IdxInt.getLimitedValue();
+bool HP = hasFunctionProto(D);
+unsigned NumParams = HP ? getFunctionOrMethodNumParams(D) + 1 : 1;
+if (ArgCount > NumParams) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
+  << getAttrName(Attr) << 1 << IdxExpr->getSourceRange();
+  return;
+}
+D->addAttr(::new (S.Context)
+   XRayLogArgsAttr(Attr.getRange(), S.Context, ArgCount,
+   Attr.getAttributeSpellingListIndex()));
+return;
+  }
+
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),

[PATCH] D34052: [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions

2017-06-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 102018.
dberris edited the summary of this revision.
dberris added a comment.

Adding related bug.


https://reviews.llvm.org/D34052

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/xray-log-args-class.cpp


Index: test/Sema/xray-log-args-class.cpp
===
--- /dev/null
+++ test/Sema/xray-log-args-class.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+
+class Class {
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
+  [[clang::xray_log_args(-1)]] void Invalid(); // expected-error 
{{'xray_log_args' attribute parameter 1 is out of bounds}}
+  [[clang::xray_log_args("invalid")]] void InvalidStringArg(); // 
expected-error {{'xray_log_args'}}
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4604,14 +4604,40 @@
 static void handleXRayLogArgsAttr(Sema &S, Decl *D,
   const AttributeList &Attr) {
   uint64_t ArgCount;
+
+  // Treat member functions especially, since we do want to support saving the
+  // implicit this argument for member functions.
+  if (isInstanceMethod(D)) {
+auto *IdxExpr = Attr.getArgAsExpr(0);
+llvm::APSInt IdxInt;
+if (!IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << 1u << AANT_ArgumentIntegerConstant
+  << IdxExpr->getSourceRange();
+  return;
+}
+ArgCount = IdxInt.getLimitedValue();
+bool HP = hasFunctionProto(D);
+unsigned NumParams = HP ? getFunctionOrMethodNumParams(D) + 1 : 1;
+if (ArgCount > NumParams) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
+  << getAttrName(Attr) << 1 << IdxExpr->getSourceRange();
+  return;
+}
+D->addAttr(::new (S.Context)
+   XRayLogArgsAttr(Attr.getRange(), S.Context, ArgCount,
+   Attr.getAttributeSpellingListIndex()));
+return;
+  }
+
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
ArgCount))
 return;
 
   // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
   D->addAttr(::new (S.Context)
- XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
- Attr.getAttributeSpellingListIndex()));
+ XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
+ Attr.getAttributeSpellingListIndex()));
 }
 
 
//===--===//


Index: test/Sema/xray-log-args-class.cpp
===
--- /dev/null
+++ test/Sema/xray-log-args-class.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+
+class Class {
+  [[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
+  [[clang::xray_log_args(-1)]] void Invalid(); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+  [[clang::xray_log_args("invalid")]] void InvalidStringArg(); // expected-error {{'xray_log_args'}}
+};
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4604,14 +4604,40 @@
 static void handleXRayLogArgsAttr(Sema &S, Decl *D,
   const AttributeList &Attr) {
   uint64_t ArgCount;
+
+  // Treat member functions especially, since we do want to support saving the
+  // implicit this argument for member functions.
+  if (isInstanceMethod(D)) {
+auto *IdxExpr = Attr.getArgAsExpr(0);
+llvm::APSInt IdxInt;
+if (!IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << 1u << AANT_ArgumentIntegerConstant
+  << IdxExpr->getSourceRange();
+  return;
+}
+ArgCount = IdxInt.getLimitedValue();
+bool HP = hasFunctionProto(D);
+unsigned NumParams = HP ? getFunctionOrMethodNumParams(D) + 1 : 1;
+if (ArgCount > NumParams) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
+  << getAttrName(Attr) << 1 << IdxExpr->getSourceRange();
+  return;
+}
+D->addAttr(::new (S.Context)
+   XRayLogArgsAttr(Attr.getRange(), S.Context, ArgCount,
+   Attr.getAttributeSpellingListIndex()));
+return;
+  }
+
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
ArgCount))
 return;
 
   // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
   D->addAttr(::new (S.C

r305075 - [DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.

2017-06-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun  9 08:40:18 2017
New Revision: 305075

URL: http://llvm.org/viewvc/llvm-project?rev=305075&view=rev
Log:
[DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.

Summary:
If the first parameter of the function is the ImplicitParamDecl, codegen
automatically marks it as an implicit argument with `this` or `self`
pointer. Added internal kind of the ImplicitParamDecl to separate
'this', 'self', 'vtt' and other implicit parameters from other kind of
parameters.

Reviewers: rjmccall, aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGen/captured-statements.c
cfe/trunk/test/CodeGenCXX/captured-statements.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=305075&r1=305074&r2=305075&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jun  9 08:40:18 2017
@@ -851,6 +851,7 @@ protected:
 
   class NonParmVarDeclBitfields {
 friend class VarDecl;
+friend class ImplicitParamDecl;
 friend class ASTDeclReader;
 
 unsigned : NumVarDeclBits;
@@ -894,6 +895,10 @@ protected:
 /// declared in the same block scope. This controls whether we should merge
 /// the type of this declaration with its previous declaration.
 unsigned PreviousDeclInSameBlockScope : 1;
+
+/// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or
+/// something else.
+unsigned ImplicitParamKind : 3;
   };
 
   union {
@@ -1376,20 +1381,50 @@ public:
 
 class ImplicitParamDecl : public VarDecl {
   void anchor() override;
+
 public:
+  /// Defines the kind of the implicit parameter: is this an implicit parameter
+  /// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured
+  /// context or something else.
+  enum ImplicitParamKind : unsigned {
+ObjCSelf,/// Parameter for Objective-C 'self' argument
+ObjCCmd, /// Parameter for Objective-C '_cmd' argument
+CXXThis, /// Parameter for C++ 'this' argument
+CXXVTT,  /// Parameter for C++ virtual table pointers
+CapturedContext, /// Parameter for captured context
+Other,   /// Other implicit parameter
+  };
+
+  /// Create implicit parameter.
   static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation IdLoc, IdentifierInfo *Id,
-   QualType T);
+   QualType T, ImplicitParamKind ParamKind);
+  static ImplicitParamDecl *Create(ASTContext &C, QualType T,
+   ImplicitParamKind ParamKind);
 
   static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID);
 
   ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc,
-IdentifierInfo *Id, QualType Type)
-: VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
-  /*tinfo*/ nullptr, SC_None) {
+IdentifierInfo *Id, QualType Type,
+ImplicitParamKind ParamKind)
+  : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
+/*TInfo=*/nullptr, SC_None) {
+NonParmVarDeclBits.ImplicitParamKind = ParamKind;
 setImplicit();
   }
 
+  ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind)
+  : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
+SourceLocation(), /*Id=*/nullptr, Type,
+/*TInfo=*/nullptr, SC_None) {
+NonParmVarDeclBits.ImplicitParamKind = ParamKind;
+setImplicit();
+  }
+
+  /// Returns the implicit parameter kind.
+  ImplicitParamKind getParameterKind() const {
+return 
static_cast(NonParmVarDeclBits.ImplicitParamKind);
+  }
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ImplicitParam; }

Modified: cfe/t

[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-09 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305075: [DebugInfo] Add kind of ImplicitParamDecl for 
emission of FlagObjectPointer. (authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D33735?vs=101908&id=102024#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33735

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/AST/DeclObjC.cpp
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/CodeGen/captured-statements.c
  cfe/trunk/test/CodeGenCXX/captured-statements.cpp

Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -851,6 +851,7 @@
 
   class NonParmVarDeclBitfields {
 friend class VarDecl;
+friend class ImplicitParamDecl;
 friend class ASTDeclReader;
 
 unsigned : NumVarDeclBits;
@@ -894,6 +895,10 @@
 /// declared in the same block scope. This controls whether we should merge
 /// the type of this declaration with its previous declaration.
 unsigned PreviousDeclInSameBlockScope : 1;
+
+/// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or
+/// something else.
+unsigned ImplicitParamKind : 3;
   };
 
   union {
@@ -1376,20 +1381,50 @@
 
 class ImplicitParamDecl : public VarDecl {
   void anchor() override;
+
 public:
+  /// Defines the kind of the implicit parameter: is this an implicit parameter
+  /// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured
+  /// context or something else.
+  enum ImplicitParamKind : unsigned {
+ObjCSelf,/// Parameter for Objective-C 'self' argument
+ObjCCmd, /// Parameter for Objective-C '_cmd' argument
+CXXThis, /// Parameter for C++ 'this' argument
+CXXVTT,  /// Parameter for C++ virtual table pointers
+CapturedContext, /// Parameter for captured context
+Other,   /// Other implicit parameter
+  };
+
+  /// Create implicit parameter.
   static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation IdLoc, IdentifierInfo *Id,
-   QualType T);
+   QualType T, ImplicitParamKind ParamKind);
+  static ImplicitParamDecl *Create(ASTContext &C, QualType T,
+   ImplicitParamKind ParamKind);
 
   static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID);
 
   ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc,
-IdentifierInfo *Id, QualType Type)
-: VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
-  /*tinfo*/ nullptr, SC_None) {
+IdentifierInfo *Id, QualType Type,
+ImplicitParamKind ParamKind)
+  : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
+/*TInfo=*/nullptr, SC_None) {
+NonParmVarDeclBits.ImplicitParamKind = ParamKind;
 setImplicit();
   }
 
+  ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind)
+  : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
+SourceLocation(), /*Id=*/nullptr, Type,
+/*TInfo=*/nullptr, SC_None) {
+NonParmVarDeclBits.ImplicitParamKind = ParamKind;
+setImplicit();
+  }
+
+  /// Returns the implicit parameter kind.
+  ImplicitParamKind getParameterKind() const {
+return static_cast(NonParmVarDeclBits.ImplicitParamKind);
+  }
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == ImplicitParam; }
Index: cfe/trunk/test/CodeGen/captured-statements.c
===
--- cfe/trunk/test/CodeGen/captured-statements.c
+++ cfe/trunk/test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-fil

Re: [clang-tools-extra] r304977 - [clang-tidy] New checker to replace dynamic exception specifications

2017-06-09 Thread don hinton via cfe-commits
Thanks Alex...

On Fri, Jun 9, 2017 at 1:02 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Fixes committed in r305024 and r305057.
>
> On Fri, Jun 9, 2017 at 12:07 AM, Alexander Kornienko 
> wrote:
>
>> It looks like the buildbots have exceptions turned off by default, so the
>> tests need to use `-fexceptions` explicitly. Testing a fix...
>>
>> On Thu, Jun 8, 2017 at 11:26 PM, Galina Kistanova 
>> wrote:
>>
>>> Hello Alexander,
>>>
>>> Couple of our builders do not like this commit:
>>>
>>> Failing Tests:
>>>
>>> Clang Tools :: clang-tidy/modernize-use-noexcept-opt.cpp
>>> Clang Tools :: clang-tidy/modernize-use-noexcept.cpp
>>>
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei
>>> -ps4-ubuntu-fast/builds/12431
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei
>>> -ps4-windows10pro-fast
>>>
>>> Please have a look at this?
>>>
>>> Thanks
>>>
>>> Galina
>>>
>>> On Thu, Jun 8, 2017 at 7:04 AM, Alexander Kornienko via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: alexfh
 Date: Thu Jun  8 09:04:16 2017
 New Revision: 304977

 URL: http://llvm.org/viewvc/llvm-project?rev=304977&view=rev
 Log:
 [clang-tidy] New checker to replace dynamic exception specifications

 Summary:
 New checker to replace dynamic exception
 specifications

 This is an alternative to D18575 which relied on reparsing the decl to
 find the location of dynamic exception specifications, but couldn't
 deal with preprocessor conditionals correctly without reparsing the
 entire file.

 This approach uses D20428 to find dynamic exception specification
 locations and handles all cases correctly.

 Reviewers: aaron.ballman, alexfh

 Reviewed By: aaron.ballman, alexfh

 Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere,
 cfe-commits, Eugene.Zelenko, etienneb

 Patch by Don Hinton!

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

 Added:
 clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
 clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
 clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use
 -noexcept.rst
 clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
 pt-macro.cpp
 clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexce
 pt-opt.cpp
 clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
 Modified:
 clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
 clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyMo
 dule.cpp
 clang-tools-extra/trunk/docs/ReleaseNotes.rst
 clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

 Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=304976&r2=
 304977&view=diff
 
 ==
 --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
 (original)
 +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu
 Jun  8 09:04:16 2017
 @@ -22,6 +22,7 @@ add_clang_library(clangTidyModernizeModu
UseEmplaceCheck.cpp
UseEqualsDefaultCheck.cpp
UseEqualsDeleteCheck.cpp
 +  UseNoexceptCheck.cpp
UseNullptrCheck.cpp
UseOverrideCheck.cpp
UseTransparentFunctorsCheck.cpp

 Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyMo
 dule.cpp
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clang-tidy/modernize/ModernizeTidyModule.cpp?rev=304977&r1=3
 04976&r2=304977&view=diff
 
 ==
 --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
 (original)
 +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
 Thu Jun  8 09:04:16 2017
 @@ -28,6 +28,7 @@
  #include "UseEmplaceCheck.h"
  #include "UseEqualsDefaultCheck.h"
  #include "UseEqualsDeleteCheck.h"
 +#include "UseNoexceptCheck.h"
  #include "UseNullptrCheck.h"
  #include "UseOverrideCheck.h"
  #include "UseTransparentFunctorsCheck.h"
 @@ -69,6 +70,7 @@ public:
  CheckFactories.registerCheck("modern
 ize-use-equals-default");
  CheckFactories.registerCheck(
  "modernize-use-equals-delete");
 +CheckFactories.registerCheck("modernize-us
 e-noexcept");
  CheckFactories.registerCheck("modernize-us
 e-nullptr");
  CheckFactories.registerCheck("modernize-u
 se-override");
  CheckFactories.registerCheck(

 Added: clang-tools-extra/trunk/clang-tidy/mod

r305076 - [DebugInfo] Fix comment, NFC.

2017-06-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun  9 08:55:08 2017
New Revision: 305076

URL: http://llvm.org/viewvc/llvm-project?rev=305076&view=rev
Log:
[DebugInfo] Fix comment, NFC.

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=305076&r1=305075&r2=305076&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jun  9 08:55:08 2017
@@ -3466,8 +3466,8 @@ void CGDebugInfo::EmitDeclare(const VarD
   unsigned AddressSpace = 
CGM.getContext().getTargetAddressSpace(VD->getType());
   AppendAddressSpaceXDeref(AddressSpace, Expr);
 
-  // If this is implicit parameter and has IPK_CXXThis or IPK_ObjCSelf 
attribute
-  // then give it an object pointer flag.
+  // If this is implicit parameter of CXXThis or ObjCSelf kind, then give it an
+  // object pointer flag.
   if (const auto *IPD = dyn_cast(VD)) {
 if (IPD->getParameterKind() == ImplicitParamDecl::CXXThis ||
 IPD->getParameterKind() == ImplicitParamDecl::ObjCSelf)


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


[clang-tools-extra] r305082 - [clang-tidy] readability-function-size: add NestingThreshold param.

2017-06-09 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Jun  9 09:22:10 2017
New Revision: 305082

URL: http://llvm.org/viewvc/llvm-project?rev=305082&view=rev
Log:
[clang-tidy] readability-function-size: add NestingThreshold param.

Summary:
Finds compound statements which create next nesting level after 
`NestingThreshold` and emits a warning.
Do note that it warns about each compound statement that breaches the 
threshold, but not any of it's sub-statements, to have readable warnings.

I was able to find only one coding style referencing nesting:
  - https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation
 > In short, 8-char indents make things easier to read, and have the added 
benefit of warning you when you’re nesting your functions too deep.

This seems too basic, i'm not sure what else to test. Are more tests needed?

Reviewers: alexfh, aaron.ballman, sbenza

Reviewed By: alexfh, aaron.ballman

Subscribers: xazax.hun

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-function-size.rst
clang-tools-extra/trunk/test/clang-tidy/readability-function-size.cpp

Modified: clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp?rev=305082&r1=305081&r2=305082&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp Fri 
Jun  9 09:22:10 2017
@@ -38,6 +38,13 @@ public:
   ++Info.Branches;
 // fallthrough
 case Stmt::CompoundStmtClass:
+  // If this new compound statement is located in a compound statement,
+  // which is already nested NestingThreshold levels deep, record the start
+  // location of this new compound statement
+  if (CurrentNestingLevel == Info.NestingThreshold)
+Info.NestingThresholders.push_back(Node->getLocStart());
+
+  ++CurrentNestingLevel;
   TrackedParent.push_back(true);
   break;
 default:
@@ -47,7 +54,10 @@ public:
 
 Base::TraverseStmt(Node);
 
+if (TrackedParent.back())
+  --CurrentNestingLevel;
 TrackedParent.pop_back();
+
 return true;
   }
 
@@ -59,13 +69,15 @@ public:
   }
 
   struct FunctionInfo {
-FunctionInfo() : Lines(0), Statements(0), Branches(0) {}
-unsigned Lines;
-unsigned Statements;
-unsigned Branches;
+unsigned Lines = 0;
+unsigned Statements = 0;
+unsigned Branches = 0;
+unsigned NestingThreshold = 0;
+std::vector NestingThresholders;
   };
   FunctionInfo Info;
   std::vector TrackedParent;
+  unsigned CurrentNestingLevel = 0;
 };
 
 FunctionSizeCheck::FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
@@ -73,13 +85,15 @@ FunctionSizeCheck::FunctionSizeCheck(Str
   LineThreshold(Options.get("LineThreshold", -1U)),
   StatementThreshold(Options.get("StatementThreshold", 800U)),
   BranchThreshold(Options.get("BranchThreshold", -1U)),
-  ParameterThreshold(Options.get("ParameterThreshold", -1U)) {}
+  ParameterThreshold(Options.get("ParameterThreshold", -1U)),
+  NestingThreshold(Options.get("NestingThreshold", -1U)) {}
 
 void FunctionSizeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "LineThreshold", LineThreshold);
   Options.store(Opts, "StatementThreshold", StatementThreshold);
   Options.store(Opts, "BranchThreshold", BranchThreshold);
   Options.store(Opts, "ParameterThreshold", ParameterThreshold);
+  Options.store(Opts, "NestingThreshold", NestingThreshold);
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
@@ -90,6 +104,7 @@ void FunctionSizeCheck::check(const Matc
   const auto *Func = Result.Nodes.getNodeAs("func");
 
   FunctionASTVisitor Visitor;
+  Visitor.Info.NestingThreshold = NestingThreshold;
   Visitor.TraverseDecl(const_cast(Func));
   auto &FI = Visitor.Info;
 
@@ -109,7 +124,8 @@ void FunctionSizeCheck::check(const Matc
 
   if (FI.Lines > LineThreshold || FI.Statements > StatementThreshold ||
   FI.Branches > BranchThreshold ||
-  ActualNumberParameters > ParameterThreshold) {
+  ActualNumberParameters > ParameterThreshold ||
+  !FI.NestingThresholders.empty()) {
 diag(Func->getLocation(),
  "function %0 exceeds recommended size/complexity thresholds")
 << Func;
@@ -138,6 +154,12 @@ void FunctionSizeCheck::check(const Matc
  DiagnosticIDs::Note)
 << ActualNumberParameters << ParameterThreshold;
   }
+
+  for (const auto &CSPos : FI.NestingThresholders) {
+diag(CSPos, "nesting level %0 starts

[PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: rsmith.
v.g.vassilev added a comment.

@rsmith, what's the right way to proceed here?


Repository:
  rL LLVM

https://reviews.llvm.org/D33467



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


Re: r305044 - [libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for parsing a single file only.

2017-06-09 Thread Argyrios Kyrtzidis via cfe-commits
Hi Manuel,

Apologies, I will start a RFC giving more context. Also I’ll ask for feedback 
for another preprocessor change related to this I’d propose as follow-up.

> On Jun 9, 2017, at 3:07 AM, Manuel Klimek  wrote:
> 
> Hey ho,
> 
> this looks like a really cool new feature, and the CL looks good to me; I was 
> wondering whether in the future we can send CLs like this through pre-commit 
> review, or have an RFC email thread. If you have more stuff landing, a single 
> RFC email thread describing how the features work together would also be 
> super useful, as it makes it easier to follow along the patches later.
> 
> Cheers,
> /Manuel
> 
> On Fri, Jun 9, 2017 at 3:21 AM Argyrios Kyrtzidis via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: akirtzidis
> Date: Thu Jun  8 20:20:48 2017
> New Revision: 305044
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=305044&view=rev 
> 
> Log:
> [libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' 
> that puts preprocessor in a mode for parsing a single file only.
> 
> This is useful for parsing a single file, as a fast/inaccurate 'mode' that 
> can still provide declarations from the file, like the classes and their 
> methods.
> 
> Added:
> cfe/trunk/test/Index/singe-file-parse.m
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/Frontend/ASTUnit.h
> cfe/trunk/include/clang/Lex/PreprocessorOptions.h
> cfe/trunk/lib/Frontend/ASTUnit.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
> 
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=305044&r1=305043&r2=305044&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Thu Jun  8 20:20:48 2017
> @@ -32,7 +32,7 @@
>   * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>   */
>  #define CINDEX_VERSION_MAJOR 0
> -#define CINDEX_VERSION_MINOR 42
> +#define CINDEX_VERSION_MINOR 43
> 
>  #define CINDEX_VERSION_ENCODE(major, minor) ( \
>((major) * 1)   \
> @@ -1234,7 +1234,12 @@ enum CXTranslationUnit_Flags {
> * purposes of an IDE, this is undesirable behavior and as much information
> * as possible should be reported. Use this flag to enable this behavior.
> */
> -  CXTranslationUnit_KeepGoing = 0x200
> +  CXTranslationUnit_KeepGoing = 0x200,
> +
> +  /**
> +   * \brief Sets the preprocessor in a mode for parsing a single file only.
> +   */
> +  CXTranslationUnit_SingleFileParse = 0x400
>  };
> 
>  /**
> 
> Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=305044&r1=305043&r2=305044&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jun  8 20:20:48 2017
> @@ -871,6 +871,7 @@ public:
>bool CacheCodeCompletionResults = false,
>bool IncludeBriefCommentsInCodeCompletion = false,
>bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = 
> false,
> +  bool SingleFileParse = false,
>bool UserFilesAreVolatile = false, bool ForSerialization = false,
>llvm::Optional ModuleFormat = llvm::None,
>std::unique_ptr *ErrAST = nullptr,
> 
> Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=305044&r1=305043&r2=305044&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
> +++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jun  8 20:20:48 2017
> @@ -95,6 +95,9 @@ public:
>/// If given, a PTH cache file to use for speeding up header parsing.
>std::string TokenCache;
> 
> +  /// When enabled, preprocessor is in a mode for parsing a single file only.
> +  bool SingleFileParseMode = false;
> +
>/// \brief True if the SourceManager should report the original file name 
> for
>/// contents of files that were remapped to other files. Defaults to true.
>bool RemappedFilesKeepOriginalName;
> @@ -181,6 +184,7 @@ public:
>  ImplicitPCHIncl

[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:60
+
+  LangOptions LangOpts = getLangOpts();
+  SourceRange FlagsRange(FlagArg->getLocStart(), FlagArg->getLocEnd());

No need for this variable, since it's just used once. Same below.



Comment at: clang-tidy/android/FileOpenFlagCheck.cpp:62-65
+  StringRef FlagsText = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(FlagsRange), SM, LangOpts);
+  std::string ReplacementText =
+  (llvm::Twine(FlagsText) + " | " + O_CLOEXEC).str();

No need to replace the text with itself. Just insert the part that is missing. 
The more local the changes - the fewer are chances of conflicts.



Comment at: clang-tidy/android/FileOpenFlagCheck.h:38
+
+  static constexpr const char *O_CLOEXEC = "O_CLOEXEC";
+};

This doesn't have to be a class member. It could be local to the function where 
it's used or to the .cc file.



Comment at: docs/clang-tidy/checks/android-file-open-flag.rst:6
+
+A common source of security bugs has been code that opens file without using
+the ``O_CLOEXEC`` flag.  Without that flag, an opened sensitive file would

I'm not sure about using of "has been" here. Maybe just use present tense? You 
might want to consult a nearby native speaker though. Alternatively, you might 
want to rephrase this as "Opening files using POSIX ``open`` or similar system 
calls without specifying the ``O_CLOEXEC`` flag is a common source of security 
bugs."



Comment at: docs/clang-tidy/checks/android-file-open-flag.rst:9
+remain open across a fork+exec to a lower-privileged SELinux domain, leaking
+that sensitive data Functions including ``open()``, ``openat()``, and
+``open64()`` must include ``O_CLOEXEC`` in their flags argument.

Missing period before "Functions".



Comment at: docs/clang-tidy/checks/android-file-open-flag.rst:9
+remain open across a fork+exec to a lower-privileged SELinux domain, leaking
+that sensitive data Functions including ``open()``, ``openat()``, and
+``open64()`` must include ``O_CLOEXEC`` in their flags argument.

alexfh wrote:
> Missing period before "Functions".
Just "functions" is too broad. I'd say "`open`-like functions", "POSIX 
functions that open files" or something like that.


https://reviews.llvm.org/D33304



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


[PATCH] D33499: [PPC] PPC32/Darwin ABI info

2017-06-09 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

Ping.  The bug reporter has verified that this patch fixes the problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D33499



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


[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-09 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Make sure you add cfe-commits to the mailing list for clang changes (and 
llvm-commits for llvm changes, I accidentally added that one first and then 
fixed it), since all patches should go to the full mailing list.

This fix looks correct to me. Please add a test case though. Perhaps there 
should be an error if the value is something other than "thin" or "lto"? E.g. 
see the error that will get emitted if the value is not one of those in 
clang/lib/Driver/Driver.cpp.


https://reviews.llvm.org/D34055



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-09 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Thanks for providing the ODR reason for Android -fno-exceptions users to change 
source code or suppress this warning themselves.


https://reviews.llvm.org/D34002



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 102045.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Address comments.


https://reviews.llvm.org/D29951

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReaderDecl.cpp

Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -216,6 +216,30 @@
   TypedefNameForLinkage(nullptr), HasPendingBody(false),
   IsDeclMarkedUsed(false) {}
 
+template  static
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  if (IDs.empty())
+return;
+
+  // FIXME: We should avoid this pattern of getting the ASTContext.
+  ASTContext &C = D->getASTContext();
+
+  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
+
+  if (auto &Old = LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  LazySpecializations = Result;
+}
+
 template 
 static Decl *getMostRecentDeclImpl(Redeclarable *D);
 static Decl *getMostRecentDeclImpl(...);
@@ -244,7 +268,7 @@
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D);
+void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1951,35 +1975,15 @@
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
- SmallVectorImpl &IDs) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
   if (ThisDeclID == Redecl.getFirstID()) {
 // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2006,12 +2010,7 @@
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2117,12 +2116,7 @@
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3666,6 +3660,9 @@
   Decl *D = Record.D;
   ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
   DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
+
+  llvm::SmallVector PendingLazySpecializationIDs;
+
   if (UpdI != DeclUpdateOffsets.end()) {
 auto UpdateOffsets = std::move(UpdI->second);
 DeclUpdateOffsets.erase(UpdI);
@@ -3690,7 +3687,7 @@
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
SourceLocation());
-  Reader.UpdateDecl(D);
+  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
 
   // We might have made this declaration interesting. If so, remember that
   // we need to hand it off to the consumer.
@@ -3702,6 +3699,17 @@
   }
 }
   }
+  // Add the lazy specializations to the template.
+  assert((PendingLazySpecializationIDs.empty() || isa(D) ||
+  isa(D) || isa(D)) &&
+ "Must not have pending specializations");
+  if (auto *CTD = dyn_cast(D))
+ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs);
+  else if (auto *FTD = dyn_cast(D))
+ASTDeclReader::AddLazySpecializations(FTD, PendingLazySp

[PATCH] D34059: Get the file name for the symbol from the Module, not the SourceManager.

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.

This allows multi-module / incremental compilation environments to have unique 
initializer symbols.

Patch by Axel Naumann!


Repository:
  rL LLVM

https://reviews.llvm.org/D34059

Files:
  lib/CodeGen/CGDeclCXX.cpp


Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -449,16 +449,12 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  SmallString<128> FileName;
-  SourceManager &SM = Context.getSourceManager();
-  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-// Include the filename in the symbol name. Including "sub_" matches gcc 
and
-// makes sure these symbols appear lexicographically behind the symbols 
with
-// priority emitted above.
-FileName = llvm::sys::path::filename(MainFile->getName());
-  } else {
+  // Include the filename in the symbol name. Including "sub_" matches gcc and
+  // makes sure these symbols appear lexicographically behind the symbols with
+  // priority emitted above.
+  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
+  if (FileName.empty())
 FileName = "";
-  }
 
   for (size_t i = 0; i < FileName.size(); ++i) {
 // Replace everything that's not [a-zA-Z0-9._] with a _. This set happens


Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -449,16 +449,12 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  SmallString<128> FileName;
-  SourceManager &SM = Context.getSourceManager();
-  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-// Include the filename in the symbol name. Including "sub_" matches gcc and
-// makes sure these symbols appear lexicographically behind the symbols with
-// priority emitted above.
-FileName = llvm::sys::path::filename(MainFile->getName());
-  } else {
+  // Include the filename in the symbol name. Including "sub_" matches gcc and
+  // makes sure these symbols appear lexicographically behind the symbols with
+  // priority emitted above.
+  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
+  if (FileName.empty())
 FileName = "";
-  }
 
   for (size_t i = 0; i < FileName.size(); ++i) {
 // Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305087 - support operator keywords used in Windows SDK

2017-06-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jun  9 11:29:35 2017
New Revision: 305087

URL: http://llvm.org/viewvc/llvm-project?rev=305087&view=rev
Log:
support operator keywords used in Windows SDK

to support operator keywords used in Windows SDK, alter token type when 
seen in system headers

Hello, I submitted D33505 to address this problem, but the 
proposal was rejected as too big a hammer.
This change will allow clang to parse the WindowsSDK header  
which uses the operator name "or" as a field name. Treat cpp operator 
keywords as ordinary identifiers inside the Microsoft headers, but 
treat them as usual in the user's program.

Original Submitter: Melanie Blower (mibintc)

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



Added:
cfe/trunk/test/Headers/ms-cppoperkey.cpp
cfe/trunk/test/Headers/ms-cppoperkey1.cpp
cfe/trunk/test/Headers/ms-cppoperkey2.cpp
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=305087&r1=305086&r2=305087&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun  9 11:29:35 2017
@@ -580,7 +580,11 @@ IdentifierInfo *Preprocessor::LookUpIden
 
   // Update the token info (identifier info and appropriate token kind).
   Identifier.setIdentifierInfo(II);
-  Identifier.setKind(II->getTokenID());
+  if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() &&
+  getSourceManager().isInSystemHeader(Identifier.getLocation()))
+Identifier.setKind(clang::tok::identifier);
+  else
+Identifier.setKind(II->getTokenID());
 
   return II;
 }

Added: cfe/trunk/test/Headers/ms-cppoperkey.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 \
+// RUN: -fms-compatibility -x c++-cpp-output \
+// RUN: -ffreestanding -fsyntax-only -Werror \
+// RUN: %s -verify
+// expected-no-diagnostics
+# 1 "t.cpp"
+# 1 "query.h" 1 3
+// MS header  uses operator keyword as field name.  
+// Compile without syntax errors.
+struct tagRESTRICTION
+  {
+   union _URes 
+ {
+   int or; // Note use of cpp operator token
+ } res;
+  };

Added: cfe/trunk/test/Headers/ms-cppoperkey1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey1.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey1.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey1.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 \
+// RUN: -fms-compatibility -x c++-cpp-output \
+// RUN: -ffreestanding -fsyntax-only -Werror \
+// RUN: %s -verify
+
+
+# 1 "t.cpp"
+# 1 "query.h" 1 3 4
+// MS header  uses operator keyword as field name.  
+// Compile without syntax errors.
+struct tagRESTRICTION
+  {
+   union _URes 
+ {
+   int or; // Note use of cpp operator token
+ } res;
+  };
+   ;
+
+int aa ( int x)
+{
+  // In system header code, treat operator keyword as identifier.
+  if ( // expected-note{{to match this '('}}
+x>1 or x<0) return 1; // expected-error{{expected ')'}}
+  else return 0;  
+}
+

Added: cfe/trunk/test/Headers/ms-cppoperkey2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-cppoperkey2.cpp?rev=305087&view=auto
==
--- cfe/trunk/test/Headers/ms-cppoperkey2.cpp (added)
+++ cfe/trunk/test/Headers/ms-cppoperkey2.cpp Fri Jun  9 11:29:35 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
+// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
+// RUN: %clang_cc1 \
+// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
+// expected-no-diagnostics
+int bb ( int x)
+{
+  // In user code, treat operator keyword as operator keyword.
+  if ( x>1 or x<0) return 1;
+  else return 0;  
+}


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


r305089 - Repair 2010-05-31-palignr.c test

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 11:42:26 2017
New Revision: 305089

URL: http://llvm.org/viewvc/llvm-project?rev=305089&view=rev
Log:
Repair 2010-05-31-palignr.c test

This test was silently failing since a long time because it failed to include
stdlib.h (as it's running in a freestanding environment). However, because we
 used just not clang_cc1 instead of the verify mode, this regression was never
 noticed and the test was just always passing.

This adds -ffreestanding to the invocation, so that tmmintrin.h doesn't
indirectly include mm_malloc.h, which in turns includes the unavailable 
stdlib.h.
We also run now in the -verify mode to prevent that we silently regress again.

I've also updated the test to no longer check the return value of 
_mm_alignr_epi8
as this is also causing it to fail (and it's not really the job of this test to
test this).


Patch by Raphael Isemann (D34022)

Modified:
cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305089&r1=305088&r2=305089&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 11:42:26 2017
@@ -1,13 +1,12 @@
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
+// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
 
 #include 
+#include 
 
 extern int i;
 
 int main ()
 {
-#if defined( __SSSE3__ )
-
   typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
 
   short   dtbl[] = {1,2,3,4,5,6,7,8};
@@ -15,8 +14,7 @@ int main ()
 
   vSInt16 v0;
   v0 = *vdtbl;
-  v0 = _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to 
'__builtin_ia32_palignr128' must be a constant integer}}
+  _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to 
'__builtin_ia32_palignr128' must be a constant integer}}
 
   return 0;
-#endif
 }


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


[PATCH] D34022: Repair 2010-05-31-palignr.c test

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r305089.


https://reviews.llvm.org/D34022



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


[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D34002#776948, @chh wrote:

> Thanks for providing the ODR reason for Android -fno-exceptions users to 
> change source code or suppress this warning themselves.


I'm not sure I understand your comment. Could you clarify?

Here's an explanation about the possibility of an ODR violation in case the 
compiler would assume `noexcept` for all functions compiled with 
`-fno-exceptions`. Consider the following code:
a.h:

  struct A {
A(A&&);
A(const A&);
...
  };

b.cc:

  #include "a.h"
  #include 
  ...
std::vector v1;
  ...

c.cc:

  #include "a.h"
  #include 
  ...
std::vector v2;
  ...

Now if we compile b.cc with `-fexceptions` and c.cc with `-fno-exceptions`, and 
IF the compiler was changed to treat all functions in c.cc as `noexcept`, then 
the instantiation of some methods of std::vector in b.cc would use the copy 
constructor of A, but the same methods would use the move constructor of A in 
c.cc. When these two were linked together, that would be an ODR violation.


https://reviews.llvm.org/D34002



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


[PATCH] D17143: [Sema] PR25156 Crash when parsing dtor call on incomplete type

2017-06-09 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 102049.
hintonda added a comment.

Rebase and move test to existing file.


https://reviews.llvm.org/D17143

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/nested-name-spec.cpp


Index: test/SemaCXX/nested-name-spec.cpp
===
--- test/SemaCXX/nested-name-spec.cpp
+++ test/SemaCXX/nested-name-spec.cpp
@@ -169,6 +169,13 @@
 struct Y;  // expected-note{{forward declaration of 'Y'}}
 Y::foo y; // expected-error{{incomplete type 'Y' named in nested name 
specifier}}
 
+namespace PR25156 {
+struct Y;  // expected-note{{forward declaration of 'PR25156::Y'}}
+void foo() {
+  Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested 
name specifier}}
+}
+}
+
 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
 
 struct foo_S {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,7 +189,7 @@
 // have one) and, if that fails to find a match, in the scope (if
 // we're allowed to look there).
 Found.clear();
-if (Step == 0 && LookupCtx)
+if (Step == 0 && LookupCtx && !RequireCompleteDeclContext(SS, LookupCtx))
   LookupQualifiedName(Found, LookupCtx);
 else if (Step == 1 && LookInScope && S)
   LookupName(Found, S);


Index: test/SemaCXX/nested-name-spec.cpp
===
--- test/SemaCXX/nested-name-spec.cpp
+++ test/SemaCXX/nested-name-spec.cpp
@@ -169,6 +169,13 @@
 struct Y;  // expected-note{{forward declaration of 'Y'}}
 Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
 
+namespace PR25156 {
+struct Y;  // expected-note{{forward declaration of 'PR25156::Y'}}
+void foo() {
+  Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested name specifier}}
+}
+}
+
 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
 
 struct foo_S {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,7 +189,7 @@
 // have one) and, if that fails to find a match, in the scope (if
 // we're allowed to look there).
 Found.clear();
-if (Step == 0 && LookupCtx)
+if (Step == 0 && LookupCtx && !RequireCompleteDeclContext(SS, LookupCtx))
   LookupQualifiedName(Found, LookupCtx);
 else if (Step == 1 && LookInScope && S)
   LookupName(Found, S);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32942: [clang-tidy] readability-function-size: add NestingThreshold param.

2017-06-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D32942#776915, @malcolm.parsons wrote:

> Does this check consider `else if` chains to be nesting?
>
>   void nesting() { // 1
> if (true) { // 2
>int j;
> } else if (true) { // 2 or 3?
>int j;
> } else if (true) { // 2 or 4?
>int j;
> } else if (true) { // 2 or 5?
>int j;
> }
>   }
>


Yes, this check, like  does consider `else if` chains to be nesting, as you can 
see from the following output:

  $ ./bin/clang-tidy -checks=readability-function-size -config='{CheckOptions: 
[{key: readability-function-size.NestingThreshold, value: 2}]}' /tmp/if-nest.cpp
  Error while trying to load a compilation database:
  Could not auto-detect compilation database for file "/tmp/if-nest.cpp"
  No compilation database found in /tmp or any parent directory
  json-compilation-database: Error while opening JSON database: No such file or 
directory
  Running without flags.
  1 warning generated.
  /tmp/if-nest.cpp:1:6: warning: function 'nesting' exceeds recommended 
size/complexity thresholds [readability-function-size]
  void nesting() { // 1
   ^
  /tmp/if-nest.cpp:2:13: note: nesting level 3 starts here (threshold 2)
if (true) { // 2
  ^
  /tmp/if-nest.cpp:4:10: note: nesting level 3 starts here (threshold 2)
} else if (true) { // 2 or 3?
   ^

Which makes sense, since in AST, they are nested:

  $ clang -Xclang -ast-dump -fsyntax-only  /tmp/if-nest.cpp
  TranslationUnitDecl 0x560a93687b60 <> 
  |-TypedefDecl 0x560a936880f0 <>  implicit 
__int128_t '__int128'
  | `-BuiltinType 0x560a93687dd0 '__int128'
  |-TypedefDecl 0x560a93688160 <>  implicit 
__uint128_t 'unsigned __int128'
  | `-BuiltinType 0x560a93687df0 'unsigned __int128'
  |-TypedefDecl 0x560a936884a8 <>  implicit 
__NSConstantString 'struct __NSConstantString_tag'
  | `-RecordType 0x560a93688250 'struct __NSConstantString_tag'
  |   `-CXXRecord 0x560a936881b8 '__NSConstantString_tag'
  |-TypedefDecl 0x560a93688540 <>  implicit 
__builtin_ms_va_list 'char *'
  | `-PointerType 0x560a93688500 'char *'
  |   `-BuiltinType 0x560a93687bf0 'char'
  |-TypedefDecl 0x560a936bd730 <>  implicit 
__builtin_va_list 'struct __va_list_tag [1]'
  | `-ConstantArrayType 0x560a93688820 'struct __va_list_tag [1]' 1 
  |   `-RecordType 0x560a93688630 'struct __va_list_tag'
  | `-CXXRecord 0x560a93688598 '__va_list_tag'
  `-FunctionDecl 0x560a936bd7e0  line:1:6 
nesting 'void (void)'
`-CompoundStmt 0x560a936bdcb8 
  `-IfStmt 0x560a936bdc80 
|-<<>>
|-<<>>
|-CXXBoolLiteralExpr 0x560a936bd8b8  '_Bool' true
|-CompoundStmt 0x560a936bd960 
| `-DeclStmt 0x560a936bd948 
|   `-VarDecl 0x560a936bd8e8  col:10 j 'int'
`-IfStmt 0x560a936bdc48 
  |-<<>>
  |-<<>>
  |-CXXBoolLiteralExpr 0x560a936bd980  '_Bool' true
  |-CompoundStmt 0x560a936bda28 
  | `-DeclStmt 0x560a936bda10 
  |   `-VarDecl 0x560a936bd9b0  col:10 j 'int'
  `-IfStmt 0x560a936bdc10 
|-<<>>
|-<<>>
|-CXXBoolLiteralExpr 0x560a936bda48  '_Bool' true
|-CompoundStmt 0x560a936bdaf0 
| `-DeclStmt 0x560a936bdad8 
|   `-VarDecl 0x560a936bda78  col:10 j 'int'
`-IfStmt 0x560a936bdbd8 
  |-<<>>
  |-<<>>
  |-CXXBoolLiteralExpr 0x560a936bdb10  '_Bool' true
  |-CompoundStmt 0x560a936bdbb8 
  | `-DeclStmt 0x560a936bdba0 
  |   `-VarDecl 0x560a936bdb40  col:10 j 'int'
  `-<<>>

However what i'm not totally understanding right now is

  /tmp/if-nest.cpp:2:13: note: nesting level 3 starts here (threshold 2)
if (true) { // 2
  ^

If we look at `clang-query` output, that *should* be second nesting level...

  $ clang-query-5.0 /tmp/if-nest.cpp
  Error while trying to load a compilation database:
  Could not auto-detect compilation database for file "/tmp/if-nest.cpp"
  No compilation database found in /tmp or any parent directory
  json-compilation-database: Error while opening JSON database: No such file or 
directory
  Running without flags.
  clang-query> match compoundStmt()
  
  Match #1:
  
  /tmp/if-nest.cpp:1:16: note: "root" binds here
  void nesting() { // 1
 ^~
  
  Match #2:
  
  /tmp/if-nest.cpp:2:13: note: "root" binds here
if (true) { // 2
  ^~
  
  Match #3:
  
  /tmp/if-nest.cpp:4:20: note: "root" binds here
} else if (true) { // 2 or 3?
 ^~~~
  
  Match #4:
  
  /tmp/if-nest.cpp:6:20: note: "root" binds here
} else if (true) { // 2 or 4?
 ^~~~
  
  Match #5:
  
  /tmp/if-nest.cpp:8:20: note: "root" binds here
} else if (true) { // 2 or 5?
 ^~~~
  5 matches.


Repository:
  rL LLVM

https://reviews.llvm.org/D32942



_

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler updated this revision to Diff 102050.
rdwampler added a comment.

Remove an unnecessary check when determining a mismatch of availabilities
Simplify invocation of FileCheck in availability.c


https://reviews.llvm.org/D33478

Files:
  test/Index/availability.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7200,15 +7200,11 @@
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability *availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7220,7 +7216,7 @@
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7231,38 +7227,71 @@
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->getMessage());
-  }
-  ++N;
 }
   }
 
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst = dyn_cast(D))
   return getCursorPlatformAvailabilityForDecl(
-cast(EnumConst->getDeclContext()),
-  always_deprecated,
-  deprecated_message,
-  always_unavailable,
-  unavailable_message,
-  availability,
-  availability_size);
-  
-  return N;
+  cast(EnumConst->getDeclContext()), always_deprecated,
+  deprecated_message, always_unavailable, unavailable_message,
+  AvailabilityAttrs);
+
+  if (AvailabilityAttrs.empty())
+return;
+
+  std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
+[](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+  return LHS->getPlatform() > RHS->getPlatform();
+});
+  ASTContext &Ctx = D->getASTContext();
+  auto It = std::unique(
+  AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
+  [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+if (LHS->getPlatform() != RHS->getPlatform())
+  return false;
+
+if (LHS->getIntroduced() == RHS->getIntroduced() &&
+LHS->getDeprecated() == RHS->getDeprecated() &&
+LHS->getObsoleted() == RHS->getObsoleted() &&
+LHS->getMessage() == RHS->getMessage() &&
+LHS->getReplacement() == RHS->getReplacement())
+  return true;
+
+if ((!LHS->getIntroduced().empty() && !RHS->getIntroduced().empty()) ||
+(!LHS->getDeprecated().empty() && !RHS->getDeprecated().empty()) ||
+(!LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()))
+  return false;
+
+if (LHS->getIntroduced().empty() && !RHS->getIntroduced().empty())
+  LHS->setIntroduced(Ctx, RHS->getIntroduced());
+
+if (LHS->getDeprecated().empty() && !RHS->getDeprecated().empty()) {
+  LHS->setDeprecated(Ctx, RHS->getDeprecated());
+  if (LHS->getMessage().empty())
+LHS->setMessage(Ctx, RHS->getMessage());
+  if (LHS->getReplacement().empty())
+LHS->setReplacement(Ctx, RHS->getReplacement());
+}
+
+if (LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) {
+  LHS->setObsoleted(Ctx, RHS->getObsoleted());
+  if (LHS->getMessage().empty())
+LHS->setMessage(Ctx, RHS->getMessage());
+  if (LHS->getRep

[PATCH] D34002: [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

2017-06-09 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

I understood the mentioned ODR issue, which is useful for users to understand 
the compiler choice. For -fno-exceptions users, they should change source code 
to work with mixed cases, or just ignore mixed cases and suppress this warning.


https://reviews.llvm.org/D34002



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


[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-09 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 102051.
yamaguchi added a comment.

I think we don't need additional testcase, because this is non-functional 
change. Driver.cpp will emit error if value was not "thin" nor "full". This 
testcase is at clang/test/CodeGen/thinlto-backend-option.ll.


https://reviews.llvm.org/D34055

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,9 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex =
+  Args.hasArg(OPT_flto_EQ) &&
+  StringRef(Args.getLastArgValue(OPT_flto_EQ)) == "thin";
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -649,8 +649,9 @@
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = A && A->containsValue("thin");
+  Opts.EmitSummaryIndex =
+  Args.hasArg(OPT_flto_EQ) &&
+  StringRef(Args.getLastArgValue(OPT_flto_EQ)) == "thin";
   Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false);
   if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
 if (IK.getLanguage() != InputKind::LLVM_IR)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305094 - [ASTMatchers] Fix use after free.

2017-06-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  9 12:55:42 2017
New Revision: 305094

URL: http://llvm.org/viewvc/llvm-project?rev=305094&view=rev
Log:
[ASTMatchers] Fix use after free.

Found by asan.

Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=305094&r1=305093&r2=305094&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Fri Jun  9 12:55:42 2017
@@ -206,7 +206,8 @@ private:
 if (isFloatingLiteral) {
   char *end;
   errno = 0;
-  double doubleValue = strtod(Result->Text.str().c_str(), &end);
+  std::string Text = Result->Text.str();
+  double doubleValue = strtod(Text.c_str(), &end);
   if (*end == 0 && errno == 0) {
 Result->Kind = TokenInfo::TK_Literal;
 Result->Value = doubleValue;


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


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

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

LGTM


https://reviews.llvm.org/D33478



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


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Do you have commit access or shall I commit it on your behalf?


https://reviews.llvm.org/D33478



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


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler marked 2 inline comments as done.
rdwampler added a comment.

I don't have commit access, but I would grateful if you can commit it.


https://reviews.llvm.org/D33478



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


[PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.

2017-06-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

  // Don't warn on dependent types in templates.

Hmm, i wanted to try to fix my Bug 32683 
  about templated references being 
ignored, and i found out that it is actually intentional...
Reading https://google.github.io/styleguide/cppguide.html#Reference_Arguments i 
do not see why non-const `T &` should be ignored.
Is there a reason for this? Or perhaps, looking at the `g9()`/`g10()`, this 
implicit whitelisting should be more fine-grained, specific?


Repository:
  rL LLVM

https://reviews.llvm.org/D16717



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


[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-09 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 102064.
yawanng marked 6 inline comments as done.

https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/android-file-open-flag.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -25,6 +25,7 @@
   clangFrontend
   clangLex
   clangTidy
+  clangTidyAndroidModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: test/clang-tidy/android-file-open-flag.cpp
===
--- /dev/null
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s android-file-open-flag %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+
+extern "C" int open(const char *fn, int flags, ...);
+extern "C" int open64(const char *fn, int flags, ...);
+extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void f() {
+  open("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  open64("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  openat(0, "filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+
+  int flag = 3;
+  open("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int open(const char *pathname, int flags, ...);
+int open64(const char *pathname, int flags, ...);
+int openat(int dirfd, const char *pathname, int flags, ...);
+
+void d() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int open(const char *pathname, int flags, ...);
+  int open64(const char *pathname, int flags, ...);
+  int openat(int dirfd, const char *pathname, int flags, ...);
+
+  void h() {
+open("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+open64("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+openat(0, "filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -55,6 +55,7 @@
 == =
 Name prefixDescrip

r305101 - Add #pragma clang module build/endbuild pragmas for performing a module build

2017-06-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  9 14:22:32 2017
New Revision: 305101

URL: http://llvm.org/viewvc/llvm-project?rev=305101&view=rev
Log:
Add #pragma clang module build/endbuild pragmas for performing a module build
as part of a compilation.

This is intended for two purposes:

1) Writing self-contained test cases for modules: we can now write a single
source file test that builds some number of module files on the side and
imports them.

2) Debugging / test case reduction. A single-source testcase is much more
amenable to reduction, compared to a VFS tarball or .pcm files.

Added:
cfe/trunk/test/Modules/preprocess-build.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Lex/ModuleLoader.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=305101&r1=305100&r2=305101&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  9 14:22:32 2017
@@ -527,6 +527,10 @@ def err_pp_module_end_without_module_beg
   "'#pragma clang module end'">;
 def note_pp_module_begin_here : Note<
   "entering module '%0' due to this pragma">;
+def err_pp_module_build_pth : Error<
+  "'#pragma clang module build' not supported in pretokenized header">;
+def err_pp_module_build_missing_end : Error<
+  "no matching '#pragma clang module endbuild' for this '#pragma clang module 
build'">;
 
 def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
 def err_paste_at_start : Error<

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=305101&r1=305100&r2=305101&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Fri Jun  9 14:22:32 2017
@@ -67,7 +67,7 @@ class FileSystem;
 
 /// \brief Utility class for loading a ASTContext from an AST file.
 ///
-class ASTUnit : public ModuleLoader {
+class ASTUnit {
 public:
   struct StandaloneFixIt {
 std::pair RemoveRange;
@@ -119,10 +119,13 @@ private:
   /// LoadFromCommandLine available.
   std::shared_ptr Invocation;
 
+  /// Fake module loader: the AST unit doesn't need to load any modules.
+  TrivialModuleLoader ModuleLoader;
+
   // OnlyLocalDecls - when true, walking this AST should only visit 
declarations
   // that come from the AST itself, not from included precompiled headers.
   // FIXME: This is temporary; eventually, CIndex will always do this.
-  bool  OnlyLocalDecls;
+  bool OnlyLocalDecls;
 
   /// \brief Whether to capture any diagnostics produced.
   bool CaptureDiagnostics;
@@ -496,7 +499,7 @@ public:
   };
   friend class ConcurrencyCheck;
 
-  ~ASTUnit() override;
+  ~ASTUnit();
 
   bool isMainFileAST() const { return MainFileIsAST; }
 
@@ -945,21 +948,6 @@ public:
   ///
   /// \returns True if an error occurred, false otherwise.
   bool serialize(raw_ostream &OS);
-
-  ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path,
-  Module::NameVisibilityKind Visibility,
-  bool IsInclusionDirective) override {
-// ASTUnit doesn't know how to load modules (not that this matters).
-return ModuleLoadResult();
-  }
-
-  void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility,
- SourceLocation ImportLoc) override {}
-
-  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override
-{ return nullptr; }
-  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override
-{ return 0; }
 };
 
 } // namespace clang

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=305101&r1=305100&r2=305101&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Jun  9 14:22:32 2017
@@ -136,6 +136,10 @@ class CompilerInstance : public ModuleLo
   /// along with the module map
   llvm::DenseMap KnownModules;
 
+  /// \br

[PATCH] D34059: Get the file name for the symbol from the Module, not the SourceManager.

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

Is there any way to add a test for this? Does it affect the behavior of clang 
or any in-tree clang-based tools?

If this isn't visible through existing in-tree tools, it would be useful to add 
to unittests/ a rough skeleton of what you're doing, so you can add tests for 
this kind of thing, and so we don't regress functionality you're depending on.


Repository:
  rL LLVM

https://reviews.llvm.org/D34059



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

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

Looks great, thanks!


https://reviews.llvm.org/D29951



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


r305103 - Bringt back -triple so the test passes on non-x86.

2017-06-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  9 14:47:36 2017
New Revision: 305103

URL: http://llvm.org/viewvc/llvm-project?rev=305103&view=rev
Log:
Bringt back -triple so the test passes on non-x86.

Modified:
cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305103&r1=305102&r2=305103&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 14:47:36 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -verify 
-fsyntax-only %s
 
 #include 
 #include 


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


r305104 - [ODRHash] Skip inline namespaces when hashing.

2017-06-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun  9 15:11:51 2017
New Revision: 305104

URL: http://llvm.org/viewvc/llvm-project?rev=305104&view=rev
Log:
[ODRHash] Skip inline namespaces when hashing.

Speculatively try to fix the underlying issue from r304592, of underlying types
being confused when inline namespaces are used.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/AST/StmtProfile.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305104&r1=305103&r2=305104&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 15:11:51 2017
@@ -82,13 +82,25 @@ void ODRHash::AddDeclarationName(Declara
 }
 
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-  assert(NNS && "Expecting non-null pointer.");
-  const auto *Prefix = NNS->getPrefix();
-  AddBoolean(Prefix);
-  if (Prefix) {
-AddNestedNameSpecifier(Prefix);
+  // Unlike the other pointer handling functions, allow null pointers here.
+  if (!NNS) {
+AddBoolean(false);
+return;
   }
+
+  // Skip inlined namespaces.
   auto Kind = NNS->getKind();
+  if (Kind == NestedNameSpecifier::Namespace) {
+if (NNS->getAsNamespace()->isInline()) {
+  return AddNestedNameSpecifier(NNS->getPrefix());
+}
+  }
+
+  AddBoolean(true);
+
+  // Process prefix
+  AddNestedNameSpecifier(NNS->getPrefix());
+
   ID.AddInteger(Kind);
   switch (Kind) {
   case NestedNameSpecifier::Identifier:
@@ -381,10 +393,7 @@ public:
   }
 
   void AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
-Hash.AddBoolean(NNS);
-if (NNS) {
-  Hash.AddNestedNameSpecifier(NNS);
-}
+Hash.AddNestedNameSpecifier(NNS);
   }
 
   void AddIdentifierInfo(const IdentifierInfo *II) {

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=305104&r1=305103&r2=305104&view=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Jun  9 15:11:51 2017
@@ -186,10 +186,7 @@ namespace {
   Hash.AddTemplateName(Name);
 }
 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
-  ID.AddBoolean(NNS);
-  if (NNS) {
-Hash.AddNestedNameSpecifier(NNS);
-  }
+  Hash.AddNestedNameSpecifier(NNS);
 }
   };
 }


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


Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-09 Thread David Blaikie via cfe-commits
Looks all good, please commit whenever you're ready - if you don't have
commit access, I (or anyone else with commit access) can commit this for
you.

On Tue, Jun 6, 2017 at 1:57 PM Roman Lebedev  wrote:

> On Tue, Jun 6, 2017 at 8:52 PM, David Blaikie  wrote:
> >
> >
> > On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator
> >  wrote:
> >>
> >> lebedev.ri added a comment.
> >>
> >> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote:
> >>
> >> > I still feel like that's more testing than would be ideal (does the
> >> > context of the cast matter? Wether it's dereferenced, a struct member
> >> > access, assigned, initialized, etc - it doesn't look like it from the
> code,
> >> > etc).
> >>
> >>
> >> Looking at the `CastsAwayConstness()` function in lib/Sema/SemaCast.cpp:
> >>
> https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510
> >> You can see that it asserts that the pointer is one of three types. So i
> >> think it it is best to have maybe slightly overlapping test coverage
> here,
> >> rather than be surprised one day that such trivial cases no longer
> warn...
> >>
> >> > But sure. Could you also (manually, I guess) confirm that this matches
> >> > GCC's cast-qual behavior (insofar as the warning fires in the same
> >> > situations). If there are any deviations, let's chat about them.
> >>
> >> Sure.
> >>
> >> 1. Gcc produces the same //count// of the warnings:
> >>
> >>   $ pwd
> >>   llvm/tools/clang/test
> >>   $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l
> >>   14
> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
> >> grep ": warning: " | wc -l
> >>   14
> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
> >> grep ": warning: " | wc -l
> >>   14
> >>   $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l
> >>   39
> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp
> >> 2>&1 | grep ": warning: " | wc -l
> >>   39
> >>
> >> 2. I'm not quite sure how to non-manually compare the warnings, so i'll
> >> just show the gcc output on these three cases. Since the clang warnings
> are
> >> appended as comments at the end of the each line that should warn,
> visual
> >> comparison is possible:
>
> > Works for the positive cases, not the negative ones. (though if the
> counts
> > are exactly the same, then so long as there are no false positives there
> > aren't any false negatives either)
> Yes, fair enough, i do not have anything to add here.
>
> >>
> >>
> >> 2.1.
> >>
> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c
> >>   Sema/warn-cast-qual.c: In function ‘foo’:
> >>   Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier
> >> from pointer target type [-Wcast-qual]
> >>  char *y = (char *)ptr; // expected-warning {{cast from 'const char
> *'
> >> to 'char *' drops const qualifier}}
> >>^
> >>   Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier
> >> from pointer target type [-Wcast-qual]
> >>  char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const
> >> char *const' to 'char *' drops const qualifier}}
> >>  ^
> >>   Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier
> >> from pointer target type [-Wcast-qual]
> >>  const char **y2 = (const char **)ptrptr; // expected-warning {{cast
> >> from 'const char *const *' to 'const char **' drops const qualifier}}
> >>^
> >>   Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier
> >> from pointer target type [-Wcast-qual]
> >>  char *z1 = (char *)(const void *)ptr; // expected-warning {{cast
> from
> >> 'const void *' to 'char *' drops const qualifier}}
> >> ^
> >>   Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’
> qualifier
> >> from pointer target type [-Wcast-qual]
> >>  char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile
> >> char *' to 'char *' drops volatile qualifier}}
> >>   ^
> >>   Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’
> >> qualifier from pointer target type [-Wcast-qual]
> >>  char *volc2 = (char *)volc; // expected-warning {{cast from 'const
> >> volatile char *' to 'char *' drops const and volatile qualifiers}}
> >>^
> >>   Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate
> >> pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’
> qualified
> >> [-Wcast-qual]
> >>  const int **intptrptrc = (const int **)intptrptr; //
> expected-warning
> >> {{cast from 'int **' to 'const int **' must have all intermediate
> pointers
> >> const qualified}}
> >>   ^
> >>   Sema/warn-cast-qual.c:23:31: warning: to be safe all intermediate
> >> pointers in cast from ‘int **’ to ‘volatile int **’ must be ‘const’
> >> qualified [-Wcast-qual]
> 

Re: r305103 - Bringt back -triple so the test passes on non-x86.

2017-06-09 Thread Vassil Vassilev via cfe-commits

Thanks!

Maybe we could run it on any -triple x86_64...
On 09/06/17 21:47, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Fri Jun  9 14:47:36 2017
New Revision: 305103

URL: http://llvm.org/viewvc/llvm-project?rev=305103&view=rev
Log:
Bringt back -triple so the test passes on non-x86.

Modified:
 cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305103&r1=305102&r2=305103&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 14:47:36 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -verify 
-fsyntax-only %s
  
  #include 

  #include 


___
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: [PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-09 Thread Roman Lebedev via cfe-commits
On Fri, Jun 9, 2017 at 11:28 PM, David Blaikie  wrote:
> Looks all good
OK, thank you.

> please commit whenever you're ready - if you don't have
> commit access, I (or anyone else with commit access) can commit this for
> you.
Will re-test and commit in +~12 hours.

> On Tue, Jun 6, 2017 at 1:57 PM Roman Lebedev  wrote:
>>
>> On Tue, Jun 6, 2017 at 8:52 PM, David Blaikie  wrote:
>> >
>> >
>> > On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator
>> >  wrote:
>> >>
>> >> lebedev.ri added a comment.
>> >>
>> >> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote:
>> >>
>> >> > I still feel like that's more testing than would be ideal (does the
>> >> > context of the cast matter? Wether it's dereferenced, a struct member
>> >> > access, assigned, initialized, etc - it doesn't look like it from the
>> >> > code,
>> >> > etc).
>> >>
>> >>
>> >> Looking at the `CastsAwayConstness()` function in
>> >> lib/Sema/SemaCast.cpp:
>> >>
>> >> https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510
>> >> You can see that it asserts that the pointer is one of three types. So
>> >> i
>> >> think it it is best to have maybe slightly overlapping test coverage
>> >> here,
>> >> rather than be surprised one day that such trivial cases no longer
>> >> warn...
>> >>
>> >> > But sure. Could you also (manually, I guess) confirm that this
>> >> > matches
>> >> > GCC's cast-qual behavior (insofar as the warning fires in the same
>> >> > situations). If there are any deviations, let's chat about them.
>> >>
>> >> Sure.
>> >>
>> >> 1. Gcc produces the same //count// of the warnings:
>> >>
>> >>   $ pwd
>> >>   llvm/tools/clang/test
>> >>   $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l
>> >>   14
>> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 |
>> >> grep ": warning: " | wc -l
>> >>   14
>> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1
>> >> |
>> >> grep ": warning: " | wc -l
>> >>   14
>> >>   $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l
>> >>   39
>> >>   $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp
>> >> 2>&1 | grep ": warning: " | wc -l
>> >>   39
>> >>
>> >> 2. I'm not quite sure how to non-manually compare the warnings, so i'll
>> >> just show the gcc output on these three cases. Since the clang warnings
>> >> are
>> >> appended as comments at the end of the each line that should warn,
>> >> visual
>> >> comparison is possible:
>>
>> > Works for the positive cases, not the negative ones. (though if the
>> > counts
>> > are exactly the same, then so long as there are no false positives there
>> > aren't any false negatives either)
>> Yes, fair enough, i do not have anything to add here.
>>
>> >>
>> >>
>> >> 2.1.
>> >>
>> >>   $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c
>> >>   Sema/warn-cast-qual.c: In function ‘foo’:
>> >>   Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *y = (char *)ptr; // expected-warning {{cast from 'const char
>> >> *'
>> >> to 'char *' drops const qualifier}}
>> >>^
>> >>   Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char **y1 = (char **)ptrptr; // expected-warning {{cast from
>> >> 'const
>> >> char *const' to 'char *' drops const qualifier}}
>> >>  ^
>> >>   Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  const char **y2 = (const char **)ptrptr; // expected-warning
>> >> {{cast
>> >> from 'const char *const *' to 'const char **' drops const qualifier}}
>> >>^
>> >>   Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *z1 = (char *)(const void *)ptr; // expected-warning {{cast
>> >> from
>> >> 'const void *' to 'char *' drops const qualifier}}
>> >> ^
>> >>   Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’
>> >> qualifier
>> >> from pointer target type [-Wcast-qual]
>> >>  char *vol2 = (char *)vol; // expected-warning {{cast from
>> >> 'volatile
>> >> char *' to 'char *' drops volatile qualifier}}
>> >>   ^
>> >>   Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’
>> >> qualifier from pointer target type [-Wcast-qual]
>> >>  char *volc2 = (char *)volc; // expected-warning {{cast from 'const
>> >> volatile char *' to 'char *' drops const and volatile qualifiers}}
>> >>^
>> >>   Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate
>> >> pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’
>> >> qualified
>> >> [-Wcast-qual]
>> >>  const int **intptrptrc = (const int **)intptrptr; //
>> >> expected-warning
>> >> {{c

r305110 - [ODRHash] Add support for TemplateArgument types.

2017-06-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun  9 16:00:10 2017
New Revision: 305110

URL: http://llvm.org/viewvc/llvm-project?rev=305110&view=rev
Log:
[ODRHash] Add support for TemplateArgument types.

Recommit r304592 that was reverted in r304618.  r305104 should have fixed the
issue.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305110&r1=305109&r2=305110&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 16:00:10 2017
@@ -140,7 +140,25 @@ void ODRHash::AddTemplateName(TemplateNa
   }
 }
 
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+
+  switch (Kind) {
+  case TemplateArgument::Null:
+  case TemplateArgument::Declaration:
+  case TemplateArgument::NullPtr:
+  case TemplateArgument::Integral:
+  case TemplateArgument::Template:
+  case TemplateArgument::TemplateExpansion:
+  case TemplateArgument::Expression:
+  case TemplateArgument::Pack:
+break;
+  case TemplateArgument::Type:
+AddQualType(TA.getAsType());
+break;
+  }
+}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305110&r1=305109&r2=305110&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  9 16:00:10 2017
@@ -900,6 +900,24 @@ S2 s2;
 #endif
 }
 
+namespace TemplateArgument {
+#if defined(FIRST)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#elif defined(SECOND)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'TemplateArgument::S1::u' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'u' does not match}}
+#endif
+}
+
 // Interesting cases that should not cause errors.  struct S should not error
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {


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


r305116 - Add -frewrite-imports flag.

2017-06-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  9 16:24:02 2017
New Revision: 305116

URL: http://llvm.org/viewvc/llvm-project?rev=305116&view=rev
Log:
Add -frewrite-imports flag.

If specified, when preprocessing, the contents of imported .pcm files will be
included in preprocessed output. The resulting preprocessed file can then be
compiled standalone without the module sources or .pcm files.

Added:
cfe/trunk/test/Modules/preprocess-build-diamond.m
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/PreprocessorOutputOptions.h
cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=305116&r1=305115&r2=305116&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jun  9 16:24:02 2017
@@ -932,6 +932,10 @@ def frewrite_includes : Flag<["-"], "fre
   Flags<[CC1Option]>;
 def fno_rewrite_includes : Flag<["-"], "fno-rewrite-includes">, Group;
 
+def frewrite_imports : Flag<["-"], "frewrite-imports">, Group,
+  Flags<[CC1Option]>;
+def fno_rewrite_imports : Flag<["-"], "fno-rewrite-imports">, Group;
+
 def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
 Group,
 Flags<[ DriverOption, CC1Option ]>;

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=305116&r1=305115&r2=305116&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Jun  9 16:24:02 2017
@@ -140,6 +140,9 @@ class CompilerInstance : public ModuleLo
   /// fly as part of this overall compilation action.
   std::map BuiltModules;
 
+  /// Should we delete the BuiltModules when we're done?
+  bool DeleteBuiltModules = true;
+
   /// \brief The location of the module-import keyword for the last module
   /// import. 
   SourceLocation LastModuleImportLoc;

Modified: cfe/trunk/include/clang/Frontend/PreprocessorOutputOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PreprocessorOutputOptions.h?rev=305116&r1=305115&r2=305116&view=diff
==
--- cfe/trunk/include/clang/Frontend/PreprocessorOutputOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOutputOptions.h Fri Jun  9 
16:24:02 2017
@@ -24,6 +24,7 @@ public:
   unsigned ShowMacros : 1; ///< Print macro definitions.
   unsigned ShowIncludeDirectives : 1;  ///< Print includes, imports etc. 
within preprocessed output.
   unsigned RewriteIncludes : 1;///< Preprocess include directives only.
+  unsigned RewriteImports  : 1;///< Include contents of 
transitively-imported modules.
 
 public:
   PreprocessorOutputOptions() {
@@ -35,6 +36,7 @@ public:
 ShowMacros = 0;
 ShowIncludeDirectives = 0;
 RewriteIncludes = 0;
+RewriteImports = 0;
   }
 };
 

Modified: cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=305116&r1=305115&r2=305116&view=diff
==
--- cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h Fri Jun  9 
16:24:02 2017
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_REWRITE_FRONTEND_FRONTENDACTIONS_H
 
 #include "clang/Frontend/FrontendAction.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 class FixItRewriter;
@@ -73,7 +74,10 @@ protected:
 };
 
 class RewriteIncludesAction : public PreprocessorFrontendAction {
+  std::shared_ptr OutputStream;
+  class RewriteImportsListener;
 protected:
+  bool BeginSourceFileAction(CompilerInstance &CI) override;
   void ExecuteAction() override;
 };
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=305116&r1=305115&r2=305116&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jun  9 16:24:02 2017
@@ -2672,6 +2672,8 @@ Action *Driver::ConstructPhaseAction(Com
   Ou

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305117: [libclang] Merge multiple availability clauses when 
getting the platform's (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D33478?vs=102050&id=102074#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33478

Files:
  cfe/trunk/test/Index/availability.c
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/test/Index/availability.c
===
--- cfe/trunk/test/Index/availability.c
+++ cfe/trunk/test/Index/availability.c
@@ -8,13 +8,15 @@
 
 enum {
   old_enum_plat
-} __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
+} __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
 
-// RUN: c-index-test -test-load-source all %s > %t
-// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
-// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
-// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
-// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar(void) __attribute__((availability(macosx,introduced=10.4))) __attribute__((availability(macosx,obsoleted=10.6))) __attribute__((availability(ios,introduced=3.2))) __attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
 
-// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar2(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7))) __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7))) __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: FunctionDecl=foo:3:6 {{.*}} (ios, introduced=3.2, deprecated=4.1) (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK: FunctionDecl=bar:13:6 {{.*}} (ios, introduced=3.2) (macos, introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
+// CHECK: FunctionDecl=bar2:15:6 {{.*}} (ios, introduced=3.2, deprecated=10.0) (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -7216,15 +7216,11 @@
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability *availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7236,7 +7232,7 @@
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7247,38 +7243,71 @@
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->getMessage());
-  }
-  ++N;
 }
   }
 
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst = dyn_cast(D))
   return getCursorPlatformAvailabilityForDecl(
-cast(EnumConst->getDeclContext()),
-  always_deprecated,
-  deprecated_message,
-  always_unavailable,
-

r305117 - [libclang] Merge multiple availability clauses when getting the platform's

2017-06-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  9 16:29:45 2017
New Revision: 305117

URL: http://llvm.org/viewvc/llvm-project?rev=305117&view=rev
Log:
[libclang] Merge multiple availability clauses when getting the platform's
availability

Patch by Ronald Wampler!

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

Modified:
cfe/trunk/test/Index/availability.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.c?rev=305117&r1=305116&r2=305117&view=diff
==
--- cfe/trunk/test/Index/availability.c (original)
+++ cfe/trunk/test/Index/availability.c Fri Jun  9 16:29:45 2017
@@ -8,13 +8,15 @@ enum {
 
 enum {
   old_enum_plat
-} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
+} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
 
-// RUN: c-index-test -test-load-source all %s > %t
-// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
-// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
-// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
-// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar(void) __attribute__((availability(macosx,introduced=10.4))) 
__attribute__((availability(macosx,obsoleted=10.6))) 
__attribute__((availability(ios,introduced=3.2))) 
__attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
 
-// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.7)
+void bar2(void) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: FunctionDecl=foo:3:6 {{.*}} (ios, introduced=3.2, deprecated=4.1) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, 
deprecated=10.5, obsoleted=10.7)
+// CHECK: FunctionDecl=bar:13:6 {{.*}} (ios, introduced=3.2) (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
+// CHECK: FunctionDecl=bar2:15:6 {{.*}} (ios, introduced=3.2, deprecated=10.0) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=305117&r1=305116&r2=305117&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jun  9 16:29:45 2017
@@ -7216,15 +7216,11 @@ static CXVersion convertVersion(VersionT
   return Out;
 }
 
-static int getCursorPlatformAvailabilityForDecl(const Decl *D,
-int *always_deprecated,
-CXString *deprecated_message,
-int *always_unavailable,
-CXString *unavailable_message,
-   CXPlatformAvailability 
*availability,
-int availability_size) {
+static void getCursorPlatformAvailabilityForDecl(
+const Decl *D, int *always_deprecated, CXString *deprecated_message,
+int *always_unavailable, CXString *unavailable_message,
+SmallVectorImpl &AvailabilityAttrs) {
   bool HadAvailAttr = false;
-  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7236,7 +7232,7 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7247,38 +7243,71 @@ static int getCursorPlatformAvailability
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
+  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
-  if (N < availability_size) {
-availability[N].Platform
-  = cxstring::createDup(Avail->getPlatform()->getName());
-availability[N].Introduced = convertVersion(Avail->getIntroduced());
-availability[N].Deprecated = convertVersion(Avail->getDeprecated());
-availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
-availability[N].Unavailable = Avail->getUnavailable();
-availability[N].Message = cxstring::createDup(Avail->getMessage());

r305118 - [modules] Fix that global delete operator get's assigned to a submodule.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 16:36:28 2017
New Revision: 305118

URL: http://llvm.org/viewvc/llvm-project?rev=305118&view=rev
Log:
[modules] Fix that global delete operator get's assigned to a submodule.

n the current local-submodule-visibility mode, as soon as we discover a virtual
destructor, we declare on demand a global delete operator. However, this causes
that this delete operator is owned by the submodule which contains said virtual
destructor. This means that other modules no longer can see the global delete
operator which is hidden inside another submodule and fail to compile.

This patch unhides those global allocation function once they're created to
prevent this issue.

Patch by Raphael Isemann (D33366)!

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=305118&r1=305117&r2=305118&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun  9 16:36:28 2017
@@ -2658,6 +2658,8 @@ void Sema::DeclareGlobalAllocationFuncti
 Context, GlobalCtx, SourceLocation(), SourceLocation(), Name,
 FnType, /*TInfo=*/nullptr, SC_None, false, true);
 Alloc->setImplicit();
+// Global allocation functions should always be visible.
+Alloc->setHidden(false);
 
 // Implicit sized deallocation functions always have default visibility.
 Alloc->addAttr(


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


[PATCH] D33366: Fix that global delete operator get's assigned to a submodule.

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

r305118.


https://reviews.llvm.org/D33366



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


[PATCH] D34066: [clang] Cleanup fixit.c

2017-06-09 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

This diff removes temporary file t2 in fixit.c and updates the test command 
accordingly.
NFC.


Repository:
  rL LLVM

https://reviews.llvm.org/D34066

Files:
  fixit.c


Index: fixit.c
===
--- fixit.c
+++ fixit.c
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
-// RUN: grep -v CHECK %t > %t2
 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
-// RUN: FileCheck -input-file=%t2 %t
+// RUN: grep -v CHECK %t | FileCheck %t
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the


Index: fixit.c
===
--- fixit.c
+++ fixit.c
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
-// RUN: grep -v CHECK %t > %t2
 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
-// RUN: FileCheck -input-file=%t2 %t
+// RUN: grep -v CHECK %t | FileCheck %t
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305120 - [modules] D29951: Load lazily the template specialization in multi-module setups.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 16:54:18 2017
New Revision: 305120

URL: http://llvm.org/viewvc/llvm-project?rev=305120&view=rev
Log:
[modules] D29951: Load lazily the template specialization in multi-module 
setups.

Currently, we load all template specialization if we have more than one module
attached and we touch anything around the template definition.

This patch registers the template specializations as lazily-loadable entities.
In some TUs it reduces the amount of deserializations by 1%.


Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=305120&r1=305119&r2=305120&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jun  9 16:54:18 2017
@@ -216,6 +216,30 @@ namespace clang {
   TypedefNameForLinkage(nullptr), HasPendingBody(false),
   IsDeclMarkedUsed(false) {}
 
+template  static
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  if (IDs.empty())
+return;
+
+  // FIXME: We should avoid this pattern of getting the ASTContext.
+  ASTContext &C = D->getASTContext();
+
+  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
+
+  if (auto &Old = LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  LazySpecializations = Result;
+}
+
 template 
 static Decl *getMostRecentDeclImpl(Redeclarable *D);
 static Decl *getMostRecentDeclImpl(...);
@@ -244,7 +268,7 @@ namespace clang {
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D);
+void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1952,21 +1976,6 @@ ASTDeclReader::VisitRedeclarableTemplate
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
- SmallVectorImpl &IDs) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1975,12 +1984,7 @@ void ASTDeclReader::VisitClassTemplateDe
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2007,12 +2011,7 @@ void ASTDeclReader::VisitVarTemplateDecl
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2118,12 +2117,7 @@ void ASTDeclReader::VisitFunctionTemplat
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3667,6 +3661,9 @@ void ASTReader::loadDeclUpdateRecords(Pe
   Decl *D = Record.D;
   ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
   DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
+
+  llvm::SmallVector PendingLazySpecializationIDs;
+
   if (UpdI != DeclUpdateOffsets.end()) {
 auto UpdateOffsets = std::move(UpdI->second);
 DeclUpdateOffsets.erase(UpdI);
@@ -3691,7 +3688,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
Sour

Re: r305087 - support operator keywords used in Windows SDK

2017-06-09 Thread Evgenii Stepanov via cfe-commits
Hi,

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5571/steps/check-clang%20ubsan/logs/stdio

tools/clang/lib/Parse/ParseExprCXX.cpp:383:26: runtime error:
reference binding to null pointer of type 'clang::IdentifierInfo'
#0 0x5313046 in
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr, bool, bool*, bool,
clang::IdentifierInfo**, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp:383:21
#1 0x52d3dc7 in
clang::Parser::ParseDirectDeclarator(clang::Declarator&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5433:7
#2 0x52d349d in
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5254:7
#3 0x52ee74c in
clang::Parser::ParseCXXMemberDeclaratorBeforeInitializer(clang::Declarator&,
clang::VirtSpecifiers&, clang::ActionResult&,
clang::Parser::LateParsedAttrList&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2248:5
#4 0x52efaef in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2619:7
#5 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#6 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#7 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#8 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#9 0x52ef702 in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2550:3
#10 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#11 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#12 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#13 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#14 0x52a89c6 in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:912:3
#15 0x52a8542 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:993:12
#16 0x52a7b5f in
clang::Parser::ParseExternalDeclarat

Re: r305110 - [ODRHash] Add support for TemplateArgument types.

2017-06-09 Thread Richard Smith via cfe-commits
Could this failure be due to your change:

http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/8365/steps/compile.llvm.stage2/logs/stdio

?

On 9 June 2017 at 14:00, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Fri Jun  9 16:00:10 2017
> New Revision: 305110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305110&view=rev
> Log:
> [ODRHash] Add support for TemplateArgument types.
>
> Recommit r304592 that was reverted in r304618.  r305104 should have fixed
> the
> issue.
>
> Modified:
> cfe/trunk/lib/AST/ODRHash.cpp
> cfe/trunk/test/Modules/odr_hash.cpp
>
> Modified: cfe/trunk/lib/AST/ODRHash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ODRHash.cpp?rev=305110&r1=305109&r2=305110&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> +++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 16:00:10 2017
> @@ -140,7 +140,25 @@ void ODRHash::AddTemplateName(TemplateNa
>}
>  }
>
> -void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
> +void ODRHash::AddTemplateArgument(TemplateArgument TA) {
> +  auto Kind = TA.getKind();
> +  ID.AddInteger(Kind);
> +
> +  switch (Kind) {
> +  case TemplateArgument::Null:
> +  case TemplateArgument::Declaration:
> +  case TemplateArgument::NullPtr:
> +  case TemplateArgument::Integral:
> +  case TemplateArgument::Template:
> +  case TemplateArgument::TemplateExpansion:
> +  case TemplateArgument::Expression:
> +  case TemplateArgument::Pack:
> +break;
> +  case TemplateArgument::Type:
> +AddQualType(TA.getAsType());
> +break;
> +  }
> +}
>  void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL)
> {}
>
>  void ODRHash::clear() {
>
> Modified: cfe/trunk/test/Modules/odr_hash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/odr_hash.cpp?rev=305110&r1=305109&r2=305110&view=diff
> 
> ==
> --- cfe/trunk/test/Modules/odr_hash.cpp (original)
> +++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  9 16:00:10 2017
> @@ -900,6 +900,24 @@ S2 s2;
>  #endif
>  }
>
> +namespace TemplateArgument {
> +#if defined(FIRST)
> +template struct U1 {};
> +struct S1 {
> +  U1 u;
> +};
> +#elif defined(SECOND)
> +template struct U1 {};
> +struct S1 {
> +  U1 u;
> +};
> +#else
> +S1 s1;
> +// expected-error@first.h:* {{'TemplateArgument::S1::u' from module
> 'FirstModule' is not present in definition of 'TemplateArgument::S1' in
> module 'SecondModule'}}
> +// expected-note@second.h:* {{declaration of 'u' does not match}}
> +#endif
> +}
> +
>  // Interesting cases that should not cause errors.  struct S should not
> error
>  // while struct T should error at the access specifier mismatch at the
> end.
>  namespace AllDecls {
>
>
> ___
> 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: r305087 - support operator keywords used in Windows SDK

2017-06-09 Thread Keane, Erich via cfe-commits
Thanks, I didn't notice that one.  Looking into it.

-Erich

-Original Message-
From: Evgenii Stepanov [mailto:eugeni.stepa...@gmail.com] 
Sent: Friday, June 9, 2017 3:00 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r305087 - support operator keywords used in Windows SDK

Hi,

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5571/steps/check-clang%20ubsan/logs/stdio

tools/clang/lib/Parse/ParseExprCXX.cpp:383:26: runtime error:
reference binding to null pointer of type 'clang::IdentifierInfo'
#0 0x5313046 in
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr, bool, bool*, bool, clang::IdentifierInfo**, 
bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp:383:21
#1 0x52d3dc7 in
clang::Parser::ParseDirectDeclarator(clang::Declarator&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5433:7
#2 0x52d349d in
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5254:7
#3 0x52ee74c in
clang::Parser::ParseCXXMemberDeclaratorBeforeInitializer(clang::Declarator&,
clang::VirtSpecifiers&, clang::ActionResult&,
clang::Parser::LateParsedAttrList&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2248:5
#4 0x52efaef in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2619:7
#5 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#6 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#7 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo 
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#8 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#9 0x52ef702 in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2550:3
#10 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#11 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#12 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo 
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#13 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#14 0x52a89c6 in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:912:3
#15 0x52a8542 in
clang::Parser::

r305121 - Attempt to fix shared library build: RewriteFrontend depends on Serialization after r305116.

2017-06-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  9 17:02:33 2017
New Revision: 305121

URL: http://llvm.org/viewvc/llvm-project?rev=305121&view=rev
Log:
Attempt to fix shared library build: RewriteFrontend depends on Serialization 
after r305116.

Modified:
cfe/trunk/lib/Frontend/Rewrite/CMakeLists.txt

Modified: cfe/trunk/lib/Frontend/Rewrite/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/CMakeLists.txt?rev=305121&r1=305120&r2=305121&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/CMakeLists.txt (original)
+++ cfe/trunk/lib/Frontend/Rewrite/CMakeLists.txt Fri Jun  9 17:02:33 2017
@@ -19,4 +19,5 @@ add_clang_library(clangRewriteFrontend
   clangFrontend
   clangLex
   clangRewrite
+  clangSerialization
   )


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


r305122 - Revert r305117

2017-06-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  9 17:06:36 2017
New Revision: 305122

URL: http://llvm.org/viewvc/llvm-project?rev=305122&view=rev
Log:
Revert r305117

It caused `Index/availability.c` test failure on Linux

Modified:
cfe/trunk/test/Index/availability.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.c?rev=305122&r1=305121&r2=305122&view=diff
==
--- cfe/trunk/test/Index/availability.c (original)
+++ cfe/trunk/test/Index/availability.c Fri Jun  9 17:06:36 2017
@@ -8,15 +8,13 @@ enum {
 
 enum {
   old_enum_plat
-} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)));
+} 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)
 
-void bar(void) __attribute__((availability(macosx,introduced=10.4))) 
__attribute__((availability(macosx,obsoleted=10.6))) 
__attribute__((availability(ios,introduced=3.2))) 
__attribute__((availability(macosx,deprecated=10.5,message="use foobar")));
+// RUN: c-index-test -test-load-source all %s > %t
+// RUN: FileCheck -check-prefix=CHECK-1 %s < %t
+// RUN: FileCheck -check-prefix=CHECK-2 %s < %t
+// CHECK-1: (ios, introduced=3.2, deprecated=4.1) 
+// CHECK-2: (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
 
-void bar2(void) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7)))
 __attribute__((availability(ios,introduced=3.2,deprecated=10.0)));
-
-// RUN: c-index-test -test-load-source all %s | FileCheck %s
-// CHECK: FunctionDecl=foo:3:6 {{.*}} (ios, introduced=3.2, deprecated=4.1) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
-// CHECK: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
-// CHECK: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, introduced=10.4, 
deprecated=10.5, obsoleted=10.7)
-// CHECK: FunctionDecl=bar:13:6 {{.*}} (ios, introduced=3.2) (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.6, message="use foobar")
-// CHECK: FunctionDecl=bar2:15:6 {{.*}} (ios, introduced=3.2, deprecated=10.0) 
(macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
+// CHECK-2: EnumConstantDecl=old_enum:6:3 (Definition) (deprecated)
+// CHECK-2: EnumConstantDecl=old_enum_plat:10:3 {{.*}} (macos, 
introduced=10.4, deprecated=10.5, obsoleted=10.7)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=305122&r1=305121&r2=305122&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jun  9 17:06:36 2017
@@ -7216,11 +7216,15 @@ static CXVersion convertVersion(VersionT
   return Out;
 }
 
-static void getCursorPlatformAvailabilityForDecl(
-const Decl *D, int *always_deprecated, CXString *deprecated_message,
-int *always_unavailable, CXString *unavailable_message,
-SmallVectorImpl &AvailabilityAttrs) {
+static int getCursorPlatformAvailabilityForDecl(const Decl *D,
+int *always_deprecated,
+CXString *deprecated_message,
+int *always_unavailable,
+CXString *unavailable_message,
+   CXPlatformAvailability 
*availability,
+int availability_size) {
   bool HadAvailAttr = false;
+  int N = 0;
   for (auto A : D->attrs()) {
 if (DeprecatedAttr *Deprecated = dyn_cast(A)) {
   HadAvailAttr = true;
@@ -7232,7 +7236,7 @@ static void getCursorPlatformAvailabilit
   }
   continue;
 }
-
+
 if (UnavailableAttr *Unavailable = dyn_cast(A)) {
   HadAvailAttr = true;
   if (always_unavailable)
@@ -7243,71 +7247,38 @@ static void getCursorPlatformAvailabilit
   }
   continue;
 }
-
+
 if (AvailabilityAttr *Avail = dyn_cast(A)) {
-  AvailabilityAttrs.push_back(Avail);
   HadAvailAttr = true;
+  if (N < availability_size) {
+availability[N].Platform
+  = cxstring::createDup(Avail->getPlatform()->getName());
+availability[N].Introduced = convertVersion(Avail->getIntroduced());
+availability[N].Deprecated = convertVersion(Avail->getDeprecated());
+availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
+availability[N].Unavailable = Avail->getUnavailable();
+availability[N].Message = cxstring::createDup(Avail->getMessage());
+  }
+  ++N;
 }
   }
 
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst

[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ronald, I had to revert the commit as the `availability.c` test was failing on 
Linux (e.g. 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/12532).
 Can you please look into that? I think you might have to got back to the 
`CHECK-1` and `CHECK-2` thing


Repository:
  rL LLVM

https://reviews.llvm.org/D33478



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


[PATCH] D34066: [clang] Cleanup fixit.c

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

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D34066



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

r305120.


https://reviews.llvm.org/D29951



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


r305124 - [clang] Cleanup fixit.c

2017-06-09 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Fri Jun  9 17:20:52 2017
New Revision: 305124

URL: http://llvm.org/viewvc/llvm-project?rev=305124&view=rev
Log:
[clang] Cleanup fixit.c

This diff removes temporary file t2 in fixit.c and updates the test command 
accordingly.
NFC.

Test plan:
make check-all

Differential revision: https://reviews.llvm.org/D34066

Modified:
cfe/trunk/test/FixIt/fixit.c

Modified: cfe/trunk/test/FixIt/fixit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=305124&r1=305123&r2=305124&view=diff
==
--- cfe/trunk/test/FixIt/fixit.c (original)
+++ cfe/trunk/test/FixIt/fixit.c Fri Jun  9 17:20:52 2017
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
-// RUN: grep -v CHECK %t > %t2
 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
-// RUN: FileCheck -input-file=%t2 %t
+// RUN: grep -v CHECK %t | FileCheck %t
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the


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


[PATCH] D34066: [clang] Cleanup fixit.c

2017-06-09 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305124: [clang] Cleanup fixit.c (authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D34066?vs=102076&id=102079#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34066

Files:
  cfe/trunk/test/FixIt/fixit.c


Index: cfe/trunk/test/FixIt/fixit.c
===
--- cfe/trunk/test/FixIt/fixit.c
+++ cfe/trunk/test/FixIt/fixit.c
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
-// RUN: grep -v CHECK %t > %t2
 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
-// RUN: FileCheck -input-file=%t2 %t
+// RUN: grep -v CHECK %t | FileCheck %t
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the


Index: cfe/trunk/test/FixIt/fixit.c
===
--- cfe/trunk/test/FixIt/fixit.c
+++ cfe/trunk/test/FixIt/fixit.c
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
-// RUN: grep -v CHECK %t > %t2
 // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
-// RUN: FileCheck -input-file=%t2 %t
+// RUN: grep -v CHECK %t | FileCheck %t
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r305125 - [clang-tidy] D33930: Do not pick up by default the LLVM style if passing -format.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 17:23:03 2017
New Revision: 305125

URL: http://llvm.org/viewvc/llvm-project?rev=305125&view=rev
Log:
[clang-tidy] D33930: Do not pick up by default the LLVM style if passing 
-format.

This adds a new flag -style which is passed to clang-apply-replacements and
defaults to file meaning it would pick up the closest .clang-format file in 
tree.

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=305125&r1=305124&r2=305125&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Fri Jun  9 
17:23:03 2017
@@ -105,6 +105,8 @@ def apply_fixes(args, tmpdir):
   invocation = [args.clang_apply_replacements_binary]
   if args.format:
 invocation.append('-format')
+  if args.style:
+invocation.append('-style=' + args.style)
   invocation.append(tmpdir)
   subprocess.call(invocation)
 
@@ -148,6 +150,8 @@ def main():
   parser.add_argument('-fix', action='store_true', help='apply fix-its')
   parser.add_argument('-format', action='store_true', help='Reformat code '
   'after applying fixes')
+  parser.add_argument('-style', default='file', help='The style of reformat '
+  'code after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',


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


[PATCH] D33930: Do not pick up by default the LLVM style if passing -format

2017-06-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Changing the default of clang-apply-replacements makes sense to me.

This one landed in r305125.


https://reviews.llvm.org/D33930



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


[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call

2017-06-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305126: 27037: Use correct CVR qualifier on an upcast on 
method pointer call (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D33875?vs=101536&id=102081#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33875

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/PR27037.cpp


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -5106,7 +5106,9 @@
   return QualType();
 
 // Cast LHS to type of use.
-QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+QualType UseType = Context.getQualifiedType(Class, 
LHSType.getQualifiers());
+if (isIndirect)
+  UseType = Context.getPointerType(UseType);
 ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
 LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK,
 &BasePath);
Index: cfe/trunk/test/SemaCXX/PR27037.cpp
===
--- cfe/trunk/test/SemaCXX/PR27037.cpp
+++ cfe/trunk/test/SemaCXX/PR27037.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+  void f();
+};
+
+struct B : A {};
+
+void m() {
+  const B b;
+  (b.*&B::f)();  // expected-error{{drops 'const' qualifier}}
+  ((&b)->*&B::f)();  // expected-error{{drops 'const' qualifier}}
+}


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -5106,7 +5106,9 @@
   return QualType();
 
 // Cast LHS to type of use.
-QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+QualType UseType = Context.getQualifiedType(Class, LHSType.getQualifiers());
+if (isIndirect)
+  UseType = Context.getPointerType(UseType);
 ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
 LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK,
 &BasePath);
Index: cfe/trunk/test/SemaCXX/PR27037.cpp
===
--- cfe/trunk/test/SemaCXX/PR27037.cpp
+++ cfe/trunk/test/SemaCXX/PR27037.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+  void f();
+};
+
+struct B : A {};
+
+void m() {
+  const B b;
+  (b.*&B::f)();  // expected-error{{drops 'const' qualifier}}
+  ((&b)->*&B::f)();  // expected-error{{drops 'const' qualifier}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305126 - 27037: Use correct CVR qualifier on an upcast on method pointer call

2017-06-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  9 17:25:28 2017
New Revision: 305126

URL: http://llvm.org/viewvc/llvm-project?rev=305126&view=rev
Log:
27037: Use correct CVR qualifier on an upcast on method pointer call

Patch by Taiju Tsuiki!

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

Added:
cfe/trunk/test/SemaCXX/PR27037.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=305126&r1=305125&r2=305126&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun  9 17:25:28 2017
@@ -5106,7 +5106,9 @@ QualType Sema::CheckPointerToMemberOpera
   return QualType();
 
 // Cast LHS to type of use.
-QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+QualType UseType = Context.getQualifiedType(Class, 
LHSType.getQualifiers());
+if (isIndirect)
+  UseType = Context.getPointerType(UseType);
 ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
 LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK,
 &BasePath);

Added: cfe/trunk/test/SemaCXX/PR27037.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR27037.cpp?rev=305126&view=auto
==
--- cfe/trunk/test/SemaCXX/PR27037.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR27037.cpp Fri Jun  9 17:25:28 2017
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+  void f();
+};
+
+struct B : A {};
+
+void m() {
+  const B b;
+  (b.*&B::f)();  // expected-error{{drops 'const' qualifier}}
+  ((&b)->*&B::f)();  // expected-error{{drops 'const' qualifier}}
+}


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


r305128 - Support operator keywords used in Windows SDK(fix ubsan)

2017-06-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Jun  9 17:50:02 2017
New Revision: 305128

URL: http://llvm.org/viewvc/llvm-project?rev=305128&view=rev
Log:
Support operator keywords used in Windows SDK(fix ubsan)

UBSan found an issue with a nullptr being assigned to a reference.
This was because a following function went back and checked the 
identifier in the CPPOperatorName case.  This patch corrects that
location with the original logic as well.

Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=305128&r1=305127&r2=305128&view=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun  9 17:50:02 2017
@@ -713,7 +713,9 @@ bool Preprocessor::HandleIdentifier(Toke
   // C++ 2.11p2: If this is an alternative representation of a C++ operator,
   // then we act as if it is the actual operator and not the textual
   // representation of it.
-  if (II.isCPlusPlusOperatorKeyword())
+  if (II.isCPlusPlusOperatorKeyword() &&
+  !(getLangOpts().MSVCCompat &&
+getSourceManager().isInSystemHeader(Identifier.getLocation(
 Identifier.setIdentifierInfo(nullptr);
 
   // If this is an extension token, diagnose its use.


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


RE: r305087 - support operator keywords used in Windows SDK

2017-06-09 Thread Keane, Erich via cfe-commits
Should be fixed as of here: https://reviews.llvm.org/rL305128 .   Curious that 
none of the other tests found this, but thankfully UBSan did!  

Committed as no-wait due to the breakage and not wanting to leave it broken 
over the weekend.

-Original Message-
From: Evgenii Stepanov [mailto:eugeni.stepa...@gmail.com] 
Sent: Friday, June 9, 2017 3:00 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r305087 - support operator keywords used in Windows SDK

Hi,

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5571/steps/check-clang%20ubsan/logs/stdio

tools/clang/lib/Parse/ParseExprCXX.cpp:383:26: runtime error:
reference binding to null pointer of type 'clang::IdentifierInfo'
#0 0x5313046 in
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr, bool, bool*, bool, clang::IdentifierInfo**, 
bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp:383:21
#1 0x52d3dc7 in
clang::Parser::ParseDirectDeclarator(clang::Declarator&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5433:7
#2 0x52d349d in
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:5254:7
#3 0x52ee74c in
clang::Parser::ParseCXXMemberDeclaratorBeforeInitializer(clang::Declarator&,
clang::VirtSpecifiers&, clang::ActionResult&,
clang::Parser::LateParsedAttrList&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2248:5
#4 0x52efaef in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2619:7
#5 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#6 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#7 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo 
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#8 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#9 0x52ef702 in
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::AttributeList*, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2550:3
#10 0x52f147a in
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3079:12
#11 0x52ed276 in
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&,
unsigned int, clang::Decl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:3250:7
#12 0x52eb9ad in
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo 
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1910:7
#13 0x52c8c41 in
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, 
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3588:7
#14 0x52a89c6 in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::Par

[PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

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

This is a libstdc++ bug: https://gcc.gnu.org/PR79162 (They implemented a 
speculative fix for a different issue and ended up breaking this case.)

I think for now we should say we don't support building LLVM with libstdc++7.1 
in C++17 mode.


Repository:
  rL LLVM

https://reviews.llvm.org/D33467



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


r305130 - Revert r305110 to fix buildbot

2017-06-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun  9 18:03:40 2017
New Revision: 305130

URL: http://llvm.org/viewvc/llvm-project?rev=305130&view=rev
Log:
Revert r305110 to fix buildbot

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305130&r1=305129&r2=305130&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 18:03:40 2017
@@ -140,25 +140,7 @@ void ODRHash::AddTemplateName(TemplateNa
   }
 }
 
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {
-  auto Kind = TA.getKind();
-  ID.AddInteger(Kind);
-
-  switch (Kind) {
-  case TemplateArgument::Null:
-  case TemplateArgument::Declaration:
-  case TemplateArgument::NullPtr:
-  case TemplateArgument::Integral:
-  case TemplateArgument::Template:
-  case TemplateArgument::TemplateExpansion:
-  case TemplateArgument::Expression:
-  case TemplateArgument::Pack:
-break;
-  case TemplateArgument::Type:
-AddQualType(TA.getAsType());
-break;
-  }
-}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305130&r1=305129&r2=305130&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  9 18:03:40 2017
@@ -900,24 +900,6 @@ S2 s2;
 #endif
 }
 
-namespace TemplateArgument {
-#if defined(FIRST)
-template struct U1 {};
-struct S1 {
-  U1 u;
-};
-#elif defined(SECOND)
-template struct U1 {};
-struct S1 {
-  U1 u;
-};
-#else
-S1 s1;
-// expected-error@first.h:* {{'TemplateArgument::S1::u' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'u' does not match}}
-#endif
-}
-
 // Interesting cases that should not cause errors.  struct S should not error
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {


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


[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-09 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 102097.
mclow.lists added a comment.

Add extra tests to make sure that the calculations are not done using the 
source sequence value_type.


https://reviews.llvm.org/D34038

Files:
  include/numeric
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
+++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
@@ -0,0 +1,150 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op);
+
+
+#include 
+#include 
+#include 
+// #include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+//  Test not in-place
+std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+
+//  Test in-place
+v.clear();
+v.assign(first, last);
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,  5,   7,   9};
+const int pResI0[] = { 0,  1,  4,   9,  16};// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0};
+const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0};
+const int pResI2[] = { 2,  3,  6,  11,  18};// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210};
+const int pResN2[] = { 2,  1, -2,  -7, -14};// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210};
+const unsigned sa = sizeof(ia) / sizeof(ia[0]);
+static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, pResN2, pResN2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
+}
+}
+
+int triangle(int n) { return n*(n+1)/2; }
+
+//  Basic

[PATCH] D33526: Fix spurious Wunused-lambda-capture warning

2017-06-09 Thread Yi Kong via Phabricator via cfe-commits
kongyi updated this revision to Diff 102099.

Repository:
  rL LLVM

https://reviews.llvm.org/D33526

Files:
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/warn-unused-lambda-capture.cpp


Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -142,11 +142,14 @@
   auto implicit_by_reference = [&] { i++; };
 
   auto explicit_by_value_used = [i] { return i + 1; };
+  auto explicit_by_value_used_generic = [i](auto c) { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
+
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 
'i' is not used}}
   auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for this 
use}}
   auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
   auto explicit_by_value_unused_const = [k] { return k + 1; }; // 
expected-warning{{lambda capture 'k' is not required to be captured for this 
use}}
+  auto explicit_by_value_unused_const_generic = [k](auto c) { return k + 1; }; 
// expected-warning{{lambda capture 'k' is not required to be captured for this 
use}}
 
   auto explicit_by_reference_used = [&i] { i++; };
   auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda 
capture 'i' is not used}}
@@ -161,6 +164,8 @@
   auto explicit_initialized_value_trivial_init = [j = Trivial()]{}; // 
expected-warning{{lambda capture 'j' is not used}}
   auto explicit_initialized_value_non_trivial_init = [j = Trivial(42)]{};
   auto explicit_initialized_value_with_side_effect = [j = side_effect()]{};
+  auto explicit_initialized_value_generic_used = [i = 1](auto c) mutable { 
i++; };
+  auto explicit_initialized_value_generic_unused = [i = 1](auto c) mutable {}; 
// expected-warning{{lambda capture 'i' is not used}}
 
   auto nested = [&i] {
 auto explicit_by_value_used = [i] { return i + 1; };
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1492,15 +1492,17 @@
   bool ExplicitResultType;
   CleanupInfo LambdaCleanup;
   bool ContainsUnexpandedParameterPack;
+  bool IsGenericLambda;
   {
 CallOperator = LSI->CallOperator;
 Class = LSI->Lambda;
 IntroducerRange = LSI->IntroducerRange;
 ExplicitParams = LSI->ExplicitParams;
 ExplicitResultType = !LSI->HasImplicitReturnType;
 LambdaCleanup = LSI->Cleanup;
 ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;
-
+IsGenericLambda = Class->isGenericLambda();
+
 CallOperator->setLexicalDeclContext(Class);
 Decl *TemplateOrNonTemplateCallOperatorDecl = 
 CallOperator->getDescribedFunctionTemplate()  
@@ -1520,8 +1522,13 @@
   bool IsImplicit = I >= LSI->NumExplicitCaptures;
 
   // Warn about unused explicit captures.
-  if (!CurContext->isDependentContext() && !IsImplicit && 
!From.isODRUsed())
-DiagnoseUnusedLambdaCapture(From);
+  if (!CurContext->isDependentContext() && !IsImplicit && 
!From.isODRUsed()) {
+// Initialized captures that are non-ODR used may not be eliminated.
+bool NonODRUsedInitCapture =
+IsGenericLambda && From.isNonODRUsed() && From.getInitExpr();
+if (!NonODRUsedInitCapture)
+  DiagnoseUnusedLambdaCapture(From);
+  }
 
   // Handle 'this' capture.
   if (From.isThisCapture()) {
@@ -1568,8 +1575,7 @@
 //   same parameter and return types as the closure type's function call
 //   operator.
 // FIXME: Fix generic lambda to block conversions.
-if (getLangOpts().Blocks && getLangOpts().ObjC1 && 
-  !Class->isGenericLambda())
+if (getLangOpts().Blocks && getLangOpts().ObjC1 && !IsGenericLambda)
   addBlockPointerConversion(*this, IntroducerRange, Class, CallOperator);
 
 // Finalize the lambda class.


Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -142,11 +142,14 @@
   auto implicit_by_reference = [&] { i++; };
 
   auto explicit_by_value_used = [i] { return i + 1; };
+  auto explicit_by_value_used_generic = [i](auto c) { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
+
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
   auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not required to be captured for this use}}
   auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // expected-warning{{lambda capture 'i' is no

[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-09 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 102100.
mclow.lists added a comment.

Previous update was br0ken. This is better. :-)
Add a test to ensure that the calculations are done using the correct type.


https://reviews.llvm.org/D34038

Files:
  include/numeric
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
  
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
  
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp

Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
===
--- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
+++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
@@ -0,0 +1,155 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+//   OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init,
+//   BinaryOperation binary_op,
+//   UnaryOperation unary_op);
+
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+struct identity : std::unary_function<_Tp, _Tp>
+{
+constexpr const _Tp& operator()(const _Tp& __x) const { return __x;}
+};
+
+template <>
+struct identity
+{
+template 
+constexpr auto operator()(_Tp&& __x) const
+_NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x)))
+-> decltype(_VSTD::forward<_Tp>(__x))
+{ return_VSTD::forward<_Tp>(__x); }
+};
+
+template 
+void
+test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+//  Test not in-place
+std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+
+//  Test in-place
+v.clear();
+v.assign(first, last);
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop);
+assert(std::equal(v.begin(), v.end(), rFirst, rLast));
+}
+
+
+template 
+void
+test()
+{
+  int ia[] = { 1,  3,  5,   7,   9};
+const int pResI0[] = { 0,  1,  4,   9,  16};// with identity
+const int mResI0[] = { 0,  0,  0,   0,   0};
+const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
+const int mResN0[] = { 0,  0,  0,   0,   0};
+const int pResI2[] = { 2,  3,  6,  11,  18};// with identity
+const int mResI2[] = { 2,  2,  6,  30, 210};
+const int pResN2[] = { 2,  1, -2,  -7, -14};// with negate
+const int mResN2[] = { 2, -2,  6, -30, 210};
+const unsigned sa = sizeof(ia) / sizeof(ia[0]);
+static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to be sure
+static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to be sure
+static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0]));   // just to be sure
+static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0]));   // just to be sure
+static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0]));   // just to be sure
+static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0]));   // just to be sure
+static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0]));   // just to be sure
+static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to be sure
+
+for (unsigned int i = 0; i < sa; ++i ) {
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),0, pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),0, mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, pResN0, pResN0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   identity<>(),2, pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(),2, mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, pResN2, pResN2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i);
+}
+}
+
+int triangle(int n) { return n*(n+1)

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-06-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Looks like you haven't introduced proper constants in the header for scopes.




Comment at: docs/LanguageExtensions.rst:1855
+atomic builtins are in ``explicit`` form of the corresponding OpenCL 2.0
+builtin function, and are named with a ``__opencl__`` prefix.)
 

1. "an", not "in".
2. There's no need to put "explicit" in `` quotes.
3. The prefix you're using is "__opencl_", with only one trailing underscore.



Comment at: lib/CodeGen/CGAtomic.cpp:736
 OrderFail = EmitScalarExpr(E->getOrderFail());
-if (E->getNumSubExprs() == 6)
+if (E->getNumSubExprs() == 7)
   IsWeak = EmitScalarExpr(E->getWeak());

This is equivalent to checking for the two AO kinds, right?  Probably better to 
just do that.



Comment at: lib/CodeGen/CGExpr.cpp:50
+llvm::Value *CodeGenFunction::EmitCastToVoidPtr(llvm::Value *value,
+bool CastToGenericAddrSpace) {
+  unsigned addressSpace;

I think it would be better to keep this function simple and just add the cast 
outside in the two places you need it.

Also, please remember to use the target hook instead of using an addrspacecast 
directly.



Comment at: lib/Sema/SemaChecking.cpp:3046
   // The order(s) are always converted to int.
   Ty = Context.IntTy;
 }

This clause now covers the scope argument as well.



Comment at: lib/Sema/SemaChecking.cpp:3060
+  if (IsOpenCL) {
+Scope = TheCall->getArg(TheCall->getNumArgs() - 1);
+  } else {

You need to check that is a constant expression in the correct range, and you 
should add a test for that.



Comment at: lib/Sema/SemaChecking.cpp:3062
+  } else {
+Scope = IntegerLiteral::Create(
+Context, llvm::APInt(Context.getTypeSize(Context.IntTy), (uint64_t)1),

Please document the meaning of 1.


https://reviews.llvm.org/D28691



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


[PATCH] D17143: [Sema] PR25156 Crash when parsing dtor call on incomplete type

2017-06-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:192
 Found.clear();
-if (Step == 0 && LookupCtx)
+if (Step == 0 && LookupCtx && !RequireCompleteDeclContext(SS, LookupCtx))
   LookupQualifiedName(Found, LookupCtx);

You should probably respond to the incomplete context within this case (by 
returning nullptr, I guess) instead of falling down into the else.


https://reviews.llvm.org/D17143



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


[PATCH] D34055: Be more strict when checking the -flto option value

2017-06-09 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D34055#777005, @yamaguchi wrote:

> I think we don't need additional testcase, because this is non-functional 
> change. Driver.cpp will emit error if value was not "thin" nor "full". This 
> testcase is at clang/test/CodeGen/thinlto-backend-option.ll.


That test case is checking that -flto=thin is accepted by the driver. I don't 
see it checking for an unknown -flto= value. But in any case, you can go 
through the code you are fixing here without hitting the driver check by 
invoking clang -cc1 (%clang_cc1 in the test case). I just confirmed that 
-flto=thinfoo is flagged as an error by clang (when it goes through the 
driver), but is silently accepted if I pass directly to clang -cc1. So this is 
definitely a bug fix and it would be good to check for invalid -flto values and 
given an error,  then have a test that uses %clang_cc1 and confirms that an 
unknown -flto= value gets that error.


https://reviews.llvm.org/D34055



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


[PATCH] D17143: [Sema] PR25156 Crash when parsing dtor call on incomplete type

2017-06-09 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 102103.
hintonda added a comment.

- Addressed comments.


https://reviews.llvm.org/D17143

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/nested-name-spec.cpp


Index: test/SemaCXX/nested-name-spec.cpp
===
--- test/SemaCXX/nested-name-spec.cpp
+++ test/SemaCXX/nested-name-spec.cpp
@@ -169,6 +169,13 @@
 struct Y;  // expected-note{{forward declaration of 'Y'}}
 Y::foo y; // expected-error{{incomplete type 'Y' named in nested name 
specifier}}
 
+namespace PR25156 {
+struct Y;  // expected-note{{forward declaration of 'PR25156::Y'}}
+void foo() {
+  Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested 
name specifier}}
+}
+}
+
 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
 
 struct foo_S {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,12 +189,15 @@
 // have one) and, if that fails to find a match, in the scope (if
 // we're allowed to look there).
 Found.clear();
-if (Step == 0 && LookupCtx)
+if (Step == 0 && LookupCtx) {
+  if (RequireCompleteDeclContext(SS, LookupCtx))
+return nullptr;
   LookupQualifiedName(Found, LookupCtx);
-else if (Step == 1 && LookInScope && S)
+} else if (Step == 1 && LookInScope && S) {
   LookupName(Found, S);
-else
+} else {
   continue;
+}
 
 // FIXME: Should we be suppressing ambiguities here?
 if (Found.isAmbiguous())


Index: test/SemaCXX/nested-name-spec.cpp
===
--- test/SemaCXX/nested-name-spec.cpp
+++ test/SemaCXX/nested-name-spec.cpp
@@ -169,6 +169,13 @@
 struct Y;  // expected-note{{forward declaration of 'Y'}}
 Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
 
+namespace PR25156 {
+struct Y;  // expected-note{{forward declaration of 'PR25156::Y'}}
+void foo() {
+  Y::~Y(); // expected-error{{incomplete type 'PR25156::Y' named in nested name specifier}}
+}
+}
+
 X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}}
 
 struct foo_S {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -189,12 +189,15 @@
 // have one) and, if that fails to find a match, in the scope (if
 // we're allowed to look there).
 Found.clear();
-if (Step == 0 && LookupCtx)
+if (Step == 0 && LookupCtx) {
+  if (RequireCompleteDeclContext(SS, LookupCtx))
+return nullptr;
   LookupQualifiedName(Found, LookupCtx);
-else if (Step == 1 && LookInScope && S)
+} else if (Step == 1 && LookInScope && S) {
   LookupName(Found, S);
-else
+} else {
   continue;
+}
 
 // FIXME: Should we be suppressing ambiguities here?
 if (Found.isAmbiguous())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-09 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added a comment.

Alex, I will look into it. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D33478



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


[PATCH] D34038: Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan

2017-06-09 Thread Bryce Adelstein Lelbach via Phabricator via cfe-commits
wash added a comment.

The init typedef test looks good to me.

This all looks good to go.


https://reviews.llvm.org/D34038



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


[libcxx] r305136 - Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan. Reviewed as https://reviews.llvm.org/D34038.

2017-06-09 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Jun  9 21:22:13 2017
New Revision: 305136

URL: http://llvm.org/viewvc/llvm-project?rev=305136&view=rev
Log:
Implement the non-parallel versions of exclusive_scan and 
transform_exclusive_scan. Reviewed as https://reviews.llvm.org/D34038.

Added:
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp
Modified:
libcxx/trunk/include/numeric

Modified: libcxx/trunk/include/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/numeric?rev=305136&r1=305135&r2=305136&view=diff
==
--- libcxx/trunk/include/numeric (original)
+++ libcxx/trunk/include/numeric Fri Jun  9 21:22:13 2017
@@ -42,6 +42,23 @@ template 
+OutputIterator
+exclusive_scan(InputIterator first, InputIterator last,
+   OutputIterator result, T init); // C++17
+   
+template
+OutputIterator
+exclusive_scan(InputIterator first, InputIterator last, 
+   OutputIterator result, T init, BinaryOperation binary_op); 
// C++17
+
+template
+OutputIterator
+transform_exclusive_scan(InputIterator first, InputIterator last,
+ OutputIterator result, T init,
+ BinaryOperation binary_op, UnaryOperation 
unary_op);  // C++17
+
 template 
 OutputIterator
 adjacent_difference(InputIterator first, InputIterator last, 
OutputIterator result);
@@ -66,6 +83,7 @@ template 
 #include <__config>
 #include 
 #include  // for numeric_limits
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -154,6 +172,59 @@ partial_sum(_InputIterator __first, _Inp
 return __result;
 }
 
+#if _LIBCPP_STD_VER > 14
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last, 
+   _OutputIterator __result, _Tp __init, _BinaryOp __b)
+{
+if (__first != __last)
+{
+_Tp __saved = __init;
+do
+{
+__init = __b(__init, *__first);
+*__result = __saved;
+__saved = __init;
+++__result;
+} while (++__first != __last);
+}
+return __result;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+exclusive_scan(_InputIterator __first, _InputIterator __last, 
+   _OutputIterator __result, _Tp __init)
+{
+return _VSTD::exclusive_scan(__first, __last, __result, __init, 
_VSTD::plus<>());
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+transform_exclusive_scan(_InputIterator __first, _InputIterator __last, 
+   _OutputIterator __result, _Tp __init,
+   _BinaryOp __b, _UnaryOp __u)
+{
+if (__first != __last)
+{
+_Tp __saved = __init;
+do
+{
+__init = __b(__init, __u(*__first));
+*__result = __saved;
+__saved = __init;
+++__result;
+} while (++__first != __last);
+}
+return __result;
+}
+#endif
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _OutputIterator

Added: 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp?rev=305136&view=auto
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp
 Fri Jun  9 21:22:13 2017
@@ -0,0 +1,97 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// template
+// OutputIterator exclusive_scan(InputIterator first, InputIterator last,
+//   OutputIterator result, T init);
+// 
+
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+void
+test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast)
+{
+std::vector::value_type> v;
+
+//  Not in place
+