r311845 - Add forgotten file in r311844.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 04:31:01 2017
New Revision: 311845

URL: http://llvm.org/viewvc/llvm-project?rev=311845&view=rev
Log:
Add forgotten file in r311844.

Added:
cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp

Added: cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp?rev=311845&view=auto
==
--- cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp (added)
+++ cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp Sun Aug 27 
04:31:01 2017
@@ -0,0 +1,174 @@
+//=== unittests/CodeGen/IncrementalProcessingTest.cpp - IncrementalCodeGen 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/Parser.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+// Incremental processing produces several modules, all using the same "main
+// file". Make sure CodeGen can cope with that, e.g. for static initializers.
+const char TestProgram1[] =
+"extern \"C\" int funcForProg1() { return 17; }\n"
+"struct EmitCXXGlobalInitFunc1 {\n"
+"   EmitCXXGlobalInitFunc1() {}\n"
+"} test1;";
+
+const char TestProgram2[] =
+"extern \"C\" int funcForProg2() { return 42; }\n"
+"struct EmitCXXGlobalInitFunc2 {\n"
+"   EmitCXXGlobalInitFunc2() {}\n"
+"} test2;";
+
+
+/// An incremental version of ParseAST().
+static std::unique_ptr
+IncrementalParseAST(CompilerInstance& CI, Parser& P,
+CodeGenerator& CG, const char* code) {
+  static int counter = 0;
+  struct IncreaseCounterOnRet {
+~IncreaseCounterOnRet() {
+  ++counter;
+}
+  } ICOR;
+
+  Sema& S = CI.getSema();
+  clang::SourceManager &SM = S.getSourceManager();
+  if (!code) {
+// Main file
+SM.setMainFileID(SM.createFileID(
+llvm::MemoryBuffer::getMemBuffer(""), clang::SrcMgr::C_User));
+
+S.getPreprocessor().EnterMainSourceFile();
+P.Initialize();
+  } else {
+FileID FID = SM.createFileID(
+llvm::MemoryBuffer::getMemBuffer(code), clang::SrcMgr::C_User);
+SourceLocation MainStartLoc = SM.getLocForStartOfFile(SM.getMainFileID());
+SourceLocation InclLoc = MainStartLoc.getLocWithOffset(counter);
+S.getPreprocessor().EnterSourceFile(FID, 0, InclLoc);
+  }
+
+  ExternalASTSource *External = S.getASTContext().getExternalSource();
+  if (External)
+External->StartTranslationUnit(&CG);
+
+  Parser::DeclGroupPtrTy ADecl;
+  for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF;
+   AtEOF = P.ParseTopLevelDecl(ADecl)) {
+// If we got a null return and something *was* parsed, ignore it.  This
+// is due to a top-level semicolon, an action override, or a parse error
+// skipping something.
+if (ADecl && !CG.HandleTopLevelDecl(ADecl.get()))
+  return nullptr;
+  }
+
+  // Process any TopLevelDecls generated by #pragma weak.
+  for (Decl *D : S.WeakTopLevelDecls())
+CG.HandleTopLevelDecl(DeclGroupRef(D));
+
+  CG.HandleTranslationUnit(S.getASTContext());
+
+  std::unique_ptr M(CG.ReleaseModule());
+  // Switch to next module.
+  CG.StartModule("incremental-module-" + std::to_string(counter),
+ M->getContext());
+  return M;
+}
+
+const Function* getGlobalInit(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("_GLOBAL__sub_I_"))
+  return &Func;
+
+  return nullptr;
+}
+
+TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
+LLVMContext Context;
+CompilerInstance compiler;
+
+compiler.createDiagnostics();
+compiler.getLangOpts().CPlusPlus = 1;
+compiler.getLangOpts().CPlusPlus11 = 1;
+
+compiler.getTargetOpts().Triple = llvm::Triple::normalize(
+llvm::sys::getProcessTriple());
+compiler.setTarget(clang::TargetInfo::CreateTargetInfo(
+  compiler.getDiagnostics(),
+  std::make_shared(
+compiler.getTargetOpts(;
+
+compiler.createFileManager();
+compiler.createSourceManager(compiler.getFileManager());
+compiler.createPreprocessor(clang::TU_Prefix);
+compiler.getPreprocessor().enableIncrementalProcessing();
+
+compiler.createASTContext();
+

r311844 - D34059: Get the file name for the symbol from the Module, not the SourceManager.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 04:27:30 2017
New Revision: 311844

URL: http://llvm.org/viewvc/llvm-project?rev=311844&view=rev
Log:
D34059: Get the file name for the symbol from the Module, not the SourceManager.

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

Patch by Axel Naumann with minor modifications by me!

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=311844&r1=311843&r2=311844&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Aug 27 04:27:30 2017
@@ -487,16 +487,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
 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

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=311844&r1=311843&r2=311844&view=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Sun Aug 27 04:27:30 2017
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
+  IncrementalProcessingTest.cpp
   )
 
 target_link_libraries(ClangCodeGenTests


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


r311843 - D34444: Teach codegen to work in incremental processing mode.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 03:58:03 2017
New Revision: 311843

URL: http://llvm.org/viewvc/llvm-project?rev=311843&view=rev
Log:
D3: Teach codegen to work in incremental processing mode.

When isIncrementalProcessingEnabled is on we might want to produce multiple
llvm::Modules. This patch allows the clients to start a new llvm::Module,
allowing CodeGen to continue working after a HandleEndOfTranslationUnit call.

This should give the necessary facilities to write a unittest for D34059.

As discussed in the review this is meant to give us a way to proceed forward
in our efforts to upstream our interpreter-related patches. The design of this
will likely change soon.

Modified:
cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp

Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ModuleBuilder.h?rev=311843&r1=311842&r2=311843&view=diff
==
--- cfe/trunk/include/clang/CodeGen/ModuleBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ModuleBuilder.h Sun Aug 27 03:58:03 2017
@@ -84,6 +84,10 @@ public:
   ///   code generator will schedule the entity for emission if a
   ///   definition has been registered with this code generator.
   llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition);
+
+  /// Create a new \c llvm::Module after calling HandleTranslationUnit. This
+  /// enable codegen in interactive processing environments.
+  llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C);
 };
 
 /// CreateLLVMCodeGen - Create a CodeGenerator instance.

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=311843&r1=311842&r2=311843&view=diff
==
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Sun Aug 27 03:58:03 2017
@@ -119,6 +119,14 @@ namespace {
   return Builder->GetAddrOfGlobal(global, 
ForDefinition_t(isForDefinition));
 }
 
+llvm::Module *StartModule(llvm::StringRef ModuleName,
+  llvm::LLVMContext &C) {
+  assert(!M && "Replacing existing Module?");
+  M.reset(new llvm::Module(ModuleName, C));
+  Initialize(*Ctx);
+  return M.get();
+}
+
 void Initialize(ASTContext &Context) override {
   Ctx = &Context;
 
@@ -317,6 +325,11 @@ llvm::Constant *CodeGenerator::GetAddrOf
->GetAddrOfGlobal(global, isForDefinition);
 }
 
+llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName,
+ llvm::LLVMContext &C) {
+  return static_cast(this)->StartModule(ModuleName, C);
+}
+
 CodeGenerator *clang::CreateLLVMCodeGen(
 DiagnosticsEngine &Diags, llvm::StringRef ModuleName,
 const HeaderSearchOptions &HeaderSearchOpts,


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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

Hi,

  Ok that's a progress. Could you figure out which optimizer pass 
breaks it. I bet it is the inliner. I assume we could run a reducer on 
the ll file.


Cheers, Vassil
On 14/08/17 17:21, Diana Picus wrote:

Hi,

I didn't manage to reproduce this at -O0. Yes, I think the version in
1.8.0, slightly modified (see
llvm/utils/unittest/googletest/README.LLVM)

On 14 August 2017 at 17:06, Vassil Vassilev  wrote:

On 14/08/17 15:59, Diana Picus wrote:

No, the buildbots don't build with -O0 (at least not the ones that broke).

The command line for that particular object is:
build/./bin/clang -fPIC -fvisibility-inlines-hidden -Werror=date-time
-std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -pedantic -Wno-long-long
-Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
-Wstring-conversion -fcolor-diagnostics -ffunction-sections
-fdata-sections -Wall -std=c++11 -Wno-unused-parameter
-Wno-unknown-warning-option -Wno-covered-switch-default
-DGTEST_NO_LLVM_RAW_OSTREAM=1 -DGTEST_HAS_RTTI=0
-I$LLVM_SRC/llvm/utils/unittest/googletest/include
-I/home/diana.picus/linaro-scripts/bisect/llvm/utils/unittest/googletest
-I$LLVM_SRC/llvm/projects/compiler-rt/include
-I$LLVM_SRC/llvm/projects/compiler-rt/lib
-I$LLVM_SRC/llvm/projects/compiler-rt/lib/asan
-I$LLVM_SRC/llvm/projects/compiler-rt/lib/sanitizer_common/tests
-fno-rtti -O2 -Wno-format -Werror=sign-compare -Wno-non-virtual-dtor
-Wno-variadic-macros -gline-tables-only -DASAN_HAS_BLACKLIST=1
-DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -fsanitize=address

-fsanitize-blacklist=$LLVM_SRC/llvm/projects/compiler-rt/lib/asan/tests/asan_test.ignore
-mllvm -asan-instrumentation-with-call-threshold=0 -march=armv7-a
-mfloat-abi=hard -c -o
ASAN_INST_TEST_OBJECTS.asan_test.cc.armhf-with-calls.o
$LLVM_SRC/compiler-rt/lib/asan/tests/asan_test.cc

   Could you try to reproduce the issue with O0? This would rule out the
optimizer. Could you resend the O0 ll file, maybe I could find something
out. IIUC, the gtest version is 1.8.0?


Why would it contain gtest.cc? It seems to contain gtest.h and a bunch
of other internal gtest headers...


On 14 August 2017 at 16:51, Vassil Vassilev 
wrote:

On 14/08/17 15:08, Vassil Vassilev wrote:

On 14/08/17 13:04, Diana Picus wrote:

See attached.

Thanks! It looks like asan_test.i doesn't have gtest.cc which appears in
the stack trace. Am I missing something?

Could you paste the compiler invocation. Are we building with -O0 (I
see
quite a lot of things inline). Could it be an optimizer problem?


On 14 August 2017 at 13:30, Vassil Vassilev 
wrote:

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0
by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free
to
have a look at that code.

Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.

 disassembly and LLVM will greatly help as well.


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus 
wrote:

Well, these are ASAN tests, I'm not sure how that would interact
with
Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev 
wrote:

That's really strange. It looks like some random behavior. Did you
run
some memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.


On 11 Aug 2017, at 15:58, Diana Picus 
wrote:

Hi again,

I finally got the debug build, but unfortunately the stack traces
that
the tests print look the same. My suspicion is that this is
because
the addresses printed by the tests are funny (i.e. odd numbers
instead
of divisible by 4). I tried to follow those addresses in an
objdump
of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they
pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus 
wrote:
Hi guys,

I'm SO sorry about the delays. I've been 

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

On 14/08/17 15:59, Diana Picus wrote:

No, the buildbots don't build with -O0 (at least not the ones that broke).

The command line for that particular object is:
build/./bin/clang -fPIC -fvisibility-inlines-hidden -Werror=date-time
-std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -pedantic -Wno-long-long
-Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
-Wstring-conversion -fcolor-diagnostics -ffunction-sections
-fdata-sections -Wall -std=c++11 -Wno-unused-parameter
-Wno-unknown-warning-option -Wno-covered-switch-default
-DGTEST_NO_LLVM_RAW_OSTREAM=1 -DGTEST_HAS_RTTI=0
-I$LLVM_SRC/llvm/utils/unittest/googletest/include
-I/home/diana.picus/linaro-scripts/bisect/llvm/utils/unittest/googletest
-I$LLVM_SRC/llvm/projects/compiler-rt/include
-I$LLVM_SRC/llvm/projects/compiler-rt/lib
-I$LLVM_SRC/llvm/projects/compiler-rt/lib/asan
-I$LLVM_SRC/llvm/projects/compiler-rt/lib/sanitizer_common/tests
-fno-rtti -O2 -Wno-format -Werror=sign-compare -Wno-non-virtual-dtor
-Wno-variadic-macros -gline-tables-only -DASAN_HAS_BLACKLIST=1
-DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -fsanitize=address
-fsanitize-blacklist=$LLVM_SRC/llvm/projects/compiler-rt/lib/asan/tests/asan_test.ignore
-mllvm -asan-instrumentation-with-call-threshold=0 -march=armv7-a
-mfloat-abi=hard -c -o
ASAN_INST_TEST_OBJECTS.asan_test.cc.armhf-with-calls.o
$LLVM_SRC/compiler-rt/lib/asan/tests/asan_test.cc
  Could you try to reproduce the issue with O0? This would rule out the 
optimizer. Could you resend the O0 ll file, maybe I could find something 
out. IIUC, the gtest version is 1.8.0?


Why would it contain gtest.cc? It seems to contain gtest.h and a bunch
of other internal gtest headers...


On 14 August 2017 at 16:51, Vassil Vassilev  wrote:

On 14/08/17 15:08, Vassil Vassilev wrote:

On 14/08/17 13:04, Diana Picus wrote:

See attached.

Thanks! It looks like asan_test.i doesn't have gtest.cc which appears in
the stack trace. Am I missing something?

   Could you paste the compiler invocation. Are we building with -O0 (I see
quite a lot of things inline). Could it be an optimizer problem?


On 14 August 2017 at 13:30, Vassil Vassilev 
wrote:

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free to
have a look at that code.

Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.

disassembly and LLVM will greatly help as well.


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus  wrote:

Well, these are ASAN tests, I'm not sure how that would interact with
Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev 
wrote:

That's really strange. It looks like some random behavior. Did you
run
some memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.


On 11 Aug 2017, at 15:58, Diana Picus 
wrote:

Hi again,

I finally got the debug build, but unfortunately the stack traces
that
the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers
instead
of divisible by 4). I tried to follow those addresses in an objdump
of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they
pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus 
wrote:
Hi guys,

I'm SO sorry about the delays. I've been having all sorts of
trouble
getting that debug build on the board (from ld running out of
memory
to the board just crashing on me, in which case I need to ask
someone
else to reboot it because I can't power cycle it remotely). I can
assure you this is one of my top priorities, I'll get those stack
traces as soon as I can.

Thanks for your patience and sorry again,
Diana


On 10 August 2017 at 22:55, Richard Smith 
w

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

On 14/08/17 15:08, Vassil Vassilev wrote:

On 14/08/17 13:04, Diana Picus wrote:

See attached.
Thanks! It looks like asan_test.i doesn't have gtest.cc which appears 
in the stack trace. Am I missing something?
  Could you paste the compiler invocation. Are we building with -O0 (I 
see quite a lot of things inline). Could it be an optimizer problem?


On 14 August 2017 at 13:30, Vassil Vassilev  
wrote:

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free to
have a look at that code.

Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.

   disassembly and LLVM will greatly help as well.


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus  
wrote:

Well, these are ASAN tests, I'm not sure how that would interact with
Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev 
wrote:
That's really strange. It looks like some random behavior. Did 
you run

some memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.

On 11 Aug 2017, at 15:58, Diana Picus  
wrote:


Hi again,

I finally got the debug build, but unfortunately the stack 
traces that

the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers 
instead
of divisible by 4). I tried to follow those addresses in an 
objdump of

the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, 
they pass.


I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus 
wrote:
Hi guys,

I'm SO sorry about the delays. I've been having all sorts of 
trouble
getting that debug build on the board (from ld running out of 
memory
to the board just crashing on me, in which case I need to ask 
someone

else to reboot it because I can't power cycle it remotely). I can
assure you this is one of my top priorities, I'll get those stack
traces as soon as I can.

Thanks for your patience and sorry again,
Diana


On 10 August 2017 at 22:55, Richard Smith 
wrote:
Any news on this? We want this change in Clang 5, so the 
sooner we

can
understand and fix this regression the better...

On 10 August 2017 at 01:28, Diana Picus via cfe-commits
 wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's 
probably
going to take another couple of hours to complete. I'll let 
you know

when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev 


wrote:

It looks like I can not reproduce it on osx (non-arm)... :(

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:



http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142 





http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309 





http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819 



I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus 


wrote:

Hi,

See attached. FWIW, when I ran this on a very similar 
machine, I

got
194 failures, all of which went away after reverting. So 
there

might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev

wrote:

Hi Diana,

It seems the service is down. Could you send us the 
details

of the
failures (incl stack traces if any)

Many thanks,
Vassil


On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was
breaking
some ASAN tests on this bot:



http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452 



Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a
patc

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

On 14/08/17 13:04, Diana Picus wrote:

See attached.
Thanks! It looks like asan_test.i doesn't have gtest.cc which appears in 
the stack trace. Am I missing something?


On 14 August 2017 at 13:30, Vassil Vassilev  wrote:

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free to
have a look at that code.

Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.

   disassembly and LLVM will greatly help as well.


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus  wrote:

Well, these are ASAN tests, I'm not sure how that would interact with
Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev 
wrote:

That's really strange. It looks like some random behavior. Did you run
some memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.


On 11 Aug 2017, at 15:58, Diana Picus  wrote:

Hi again,

I finally got the debug build, but unfortunately the stack traces that
the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers instead
of divisible by 4). I tried to follow those addresses in an objdump of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus 
wrote:
Hi guys,

I'm SO sorry about the delays. I've been having all sorts of trouble
getting that debug build on the board (from ld running out of memory
to the board just crashing on me, in which case I need to ask someone
else to reboot it because I can't power cycle it remotely). I can
assure you this is one of my top priorities, I'll get those stack
traces as soon as I can.

Thanks for your patience and sorry again,
Diana


On 10 August 2017 at 22:55, Richard Smith 
wrote:
Any news on this? We want this change in Clang 5, so the sooner we
can
understand and fix this regression the better...

On 10 August 2017 at 01:28, Diana Picus via cfe-commits
 wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev 
wrote:

It looks like I can not reproduce it on osx (non-arm)... :(

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:



http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142



http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309



http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.


On 9 August 2017 at 16:17, Diana Picus 
wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I
got
194 failures, all of which went away after reverting. So there
might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev

wrote:

Hi Diana,

It seems the service is down. Could you send us the details
of the
failures (incl stack traces if any)

Many thanks,
Vassil


On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was
breaking
some ASAN tests on this bot:



http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a
patch by
Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/view

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free to
have a look at that code.

Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.

  disassembly and LLVM will greatly help as well.


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus  wrote:

Well, these are ASAN tests, I'm not sure how that would interact with Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev  wrote:

That's really strange. It looks like some random behavior. Did you run some 
memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.


On 11 Aug 2017, at 15:58, Diana Picus  wrote:

Hi again,

I finally got the debug build, but unfortunately the stack traces that
the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers instead
of divisible by 4). I tried to follow those addresses in an objdump of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus  wrote:
Hi guys,

I'm SO sorry about the delays. I've been having all sorts of trouble
getting that debug build on the board (from ld running out of memory
to the board just crashing on me, in which case I need to ask someone
else to reboot it because I can't power cycle it remotely). I can
assure you this is one of my top priorities, I'll get those stack
traces as soon as I can.

Thanks for your patience and sorry again,
Diana


On 10 August 2017 at 22:55, Richard Smith  wrote:
Any news on this? We want this change in Clang 5, so the sooner we can
understand and fix this regression the better...

On 10 August 2017 at 01:28, Diana Picus via cfe-commits
 wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev 
wrote:

It looks like I can not reproduce it on osx (non-arm)... :(

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:


http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.


On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev 
wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil


On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by
Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted
copy
constructors when deciding whether classes should be passed
indirectly.

This fixes ABI differences between Clang and 

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-14 Thread Vassil Vassilev via cfe-commits

Hi Diana,

On 14/08/17 11:27, Diana Picus wrote:

Hi,

Strangely enough, it turns out that if I run
Asan-armhf-with-calls-Noinst-Test on the command line it fails,
although it doesn't fail when run with lit. I've attached the stack
trace from gdb. It looks like some trouble passing down va_arg
parameters, but I haven't looked into too much details. The segfault
happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
the current function and r0 passed down from the caller. I'm not sure
if this is the exact same problem as the other tests, but feel free to
have a look at that code.

  That smells like our patch is interfering in some way...


Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
(which is the original failure that we were seeing) and left only one
failing test that seemed small enough. I'll try to look at the
disassembly before/after the patch and maybe even run valgrind on it
(running it on the original binary naturally takes forever).

Let me know if there's anything else I could try. I can also send you
disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
if you think it helps.
  Would you be able to run clang -E on the translation unit that 
crashes and send it over? If you could give us a minimal reproducer it 
would be even better.


Cheers, Vassil


Cheers,
Diana

On 11 August 2017 at 15:34, Diana Picus  wrote:

Well, these are ASAN tests, I'm not sure how that would interact with Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev  wrote:

That's really strange. It looks like some random behavior. Did you run some 
memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.


On 11 Aug 2017, at 15:58, Diana Picus  wrote:

Hi again,

I finally got the debug build, but unfortunately the stack traces that
the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers instead
of divisible by 4). I tried to follow those addresses in an objdump of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana


On 11 August 2017 at 11:14, Diana Picus  wrote:
Hi guys,

I'm SO sorry about the delays. I've been having all sorts of trouble
getting that debug build on the board (from ld running out of memory
to the board just crashing on me, in which case I need to ask someone
else to reboot it because I can't power cycle it remotely). I can
assure you this is one of my top priorities, I'll get those stack
traces as soon as I can.

Thanks for your patience and sorry again,
Diana


On 10 August 2017 at 22:55, Richard Smith  wrote:
Any news on this? We want this change in Clang 5, so the sooner we can
understand and fix this regression the better...

On 10 August 2017 at 01:28, Diana Picus via cfe-commits
 wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev 
wrote:

It looks like I can not reproduce it on osx (non-arm)... :(

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:


http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.


On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev 
wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil


On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:


http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by
Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&vie

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-11 Thread Vassil Vassilev via cfe-commits
That's really strange. It looks like some random behavior. Did you run some 
memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.

> On 11 Aug 2017, at 15:58, Diana Picus  wrote:
> 
> Hi again,
> 
> I finally got the debug build, but unfortunately the stack traces that
> the tests print look the same. My suspicion is that this is because
> the addresses printed by the tests are funny (i.e. odd numbers instead
> of divisible by 4). I tried to follow those addresses in an objdump of
> the executable, but I didn't have much success since most of them
> weren't really pointing to call instructions.
> 
> When I try to run the tests manually in the shell or in gdb, they pass.
> 
> I'm not sure what else to try. Thoughts?
> 
> Thanks,
> Diana
> 
>> On 11 August 2017 at 11:14, Diana Picus  wrote:
>> Hi guys,
>> 
>> I'm SO sorry about the delays. I've been having all sorts of trouble
>> getting that debug build on the board (from ld running out of memory
>> to the board just crashing on me, in which case I need to ask someone
>> else to reboot it because I can't power cycle it remotely). I can
>> assure you this is one of my top priorities, I'll get those stack
>> traces as soon as I can.
>> 
>> Thanks for your patience and sorry again,
>> Diana
>> 
>>> On 10 August 2017 at 22:55, Richard Smith  wrote:
>>> Any news on this? We want this change in Clang 5, so the sooner we can
>>> understand and fix this regression the better...
>>> 
>>> On 10 August 2017 at 01:28, Diana Picus via cfe-commits
>>>  wrote:
 
 Hi Vassil,
 
 My build is in progress, but since it's a full build it's probably
 going to take another couple of hours to complete. I'll let you know
 when it's done.
 
 Thanks,
 Diana
 
 On 10 August 2017 at 10:09, Vassil Vassilev 
 wrote:
> It looks like I can not reproduce it on osx (non-arm)... :(
>> On 09/08/17 22:54, Diana Picus wrote:
>> 
>> Reverting this also fixed the selfhost bots:
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819
>> 
>> I'm afraid the logs for those look even less helpful.
>> 
>>> On 9 August 2017 at 16:17, Diana Picus  wrote:
>>> 
>>> Hi,
>>> 
>>> See attached. FWIW, when I ran this on a very similar machine, I got
>>> 194 failures, all of which went away after reverting. So there might
>>> be something fishy going on.
>>> 
>>> Regards,
>>> Diana
>>> 
>>> On 9 August 2017 at 15:02, Vassil Vassilev 
>>> wrote:
 
 Hi Diana,
 
   It seems the service is down. Could you send us the details of the
 failures (incl stack traces if any)
 
 Many thanks,
 Vassil
 
> On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
> 
> Hi Richard,
> 
> I'm sorry but I've reverted this in r310464 because it was breaking
> some ASAN tests on this bot:
> 
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
> 
> Please let me know if I can help debug this.
> 
> Cheers,
> Diana
> 
> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>  wrote:
>> 
>> I forgot to say:
>> 
>> Based on a patch by Vassil Vassilev, which was based on a patch by
>> Bernd
>> Schmidt, which was based on a patch by Reid Kleckner.
>> 
>> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Tue Aug  8 12:12:28 2017
>>> New Revision: 310401
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
>>> Log:
>>> PR19668, PR23034: Fix handling of move constructors and deleted
>>> copy
>>> constructors when deciding whether classes should be passed
>>> indirectly.
>>> 
>>> This fixes ABI differences between Clang and GCC:
>>> 
>>>   * Previously, Clang ignored the move constructor when making
>>> this
>>> determination. It now takes the move constructor into
>>> account,
>>> per
>>> https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this
>>> change
>>> may
>>> seem recent, but the ABI change was agreed on the Itanium C++
>>> ABI
>>> list a long time ago).
>>> 
>>>   * Previously, Clang's behavior when the copy constructor was
>>> deleted
>>> was unstable -- dependi

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-10 Thread Vassil Vassilev via cfe-commits

Hi Diana,

  Thanks for helping us out!

Cheers, Vassil
On 10/08/17 11:28, Diana Picus wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev  wrote:

It looks like I can not reproduce it on osx (non-arm)... :(
On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev 
wrote:

Hi Diana,

It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by
Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed
indirectly.

This fixes ABI differences between Clang and GCC:

* Previously, Clang ignored the move constructor when making this
  determination. It now takes the move constructor into account,
per
  https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change
may
  seem recent, but the ABI change was agreed on the Itanium C++
ABI
  list a long time ago).

* Previously, Clang's behavior when the copy constructor was
deleted
  was unstable -- depending on whether the lazy declaration of the
  copy constructor had been triggered, you might get different
behavior.
  We now eagerly declare the copy constructor whenever its
deletedness
  is unclear, and ignore deleted copy/move constructors when
looking
for
  a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

* If the copy constructor would be implicitly deleted (but has not
been
  lazily declared yet), for instance because the class has an
rvalue
  reference member, we would pass it directly. We now pass such a
class
  indirectly, matching MSVC.

Modified:
   cfe/trunk/include/clang/AST/DeclCXX.h
   cfe/trunk/lib/AST/ASTImporter.cpp
   cfe/trunk/lib/AST/DeclCXX.cpp
   cfe/trunk/lib/CodeGen/CGCXXABI.cpp
   cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
   cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
   cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
   cfe/trunk/lib/Serialization/ASTWriter.cpp
   cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
   cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:


http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff



==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
/// \brief These flags are \c true if a defaulted
corresponding
special
/// member can't be fully analyzed without performing overload
resolution.
/// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
unsigned NeedOverloadResolutionForMoveConstructor : 1;
unsigned NeedOverloadResolutionForMoveAssignment : 1;
unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
/// \brief These flags are \c true if an implicit defaulted
corresponding
/// special member would be defined as deleted.
/// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
unsigned DefaultedMoveConstructorIsDeleted : 1;
unsigned DefaultedMoveAssignmentIsDeleted : 1;
unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRe

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-10 Thread Vassil Vassilev via cfe-commits

It looks like I can not reproduce it on osx (non-arm)... :(
On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev  wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making this
 determination. It now takes the move constructor into account, per
 https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
 seem recent, but the ABI change was agreed on the Itanium C++ ABI
 list a long time ago).

   * Previously, Clang's behavior when the copy constructor was deleted
 was unstable -- depending on whether the lazy declaration of the
 copy constructor had been triggered, you might get different
behavior.
 We now eagerly declare the copy constructor whenever its deletedness
 is unclear, and ignore deleted copy/move constructors when looking
for
 a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

   * If the copy constructor would be implicitly deleted (but has not
been
 lazily declared yet), for instance because the class has an rvalue
 reference member, we would pass it directly. We now pass such a
class
 indirectly, matching MSVC.

Modified:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff


==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if a defaulted corresponding
special
   /// member can't be fully analyzed without performing overload
resolution.
   /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
   unsigned NeedOverloadResolutionForMoveConstructor : 1;
   unsigned NeedOverloadResolutionForMoveAssignment : 1;
   unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if an implicit defaulted
corresponding
   /// special member would be defined as deleted.
   /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
   unsigned DefaultedMoveConstructorIsDeleted : 1;
   unsigned DefaultedMoveAssignmentIsDeleted : 1;
   unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
   /// constructor.
   unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+/// This does not imply anything about how the ABI in use will
actually
+/// pass an object of this clas

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

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

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.
Not helpful indeed :) Do you have access to the machine and would you be 
willing to build in debug mode and send us some stack traces. I do not 
have any arm machines :(


On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev  wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making this
 determination. It now takes the move constructor into account, per
 https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
 seem recent, but the ABI change was agreed on the Itanium C++ ABI
 list a long time ago).

   * Previously, Clang's behavior when the copy constructor was deleted
 was unstable -- depending on whether the lazy declaration of the
 copy constructor had been triggered, you might get different
behavior.
 We now eagerly declare the copy constructor whenever its deletedness
 is unclear, and ignore deleted copy/move constructors when looking
for
 a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

   * If the copy constructor would be implicitly deleted (but has not
been
 lazily declared yet), for instance because the class has an rvalue
 reference member, we would pass it directly. We now pass such a
class
 indirectly, matching MSVC.

Modified:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff


==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if a defaulted corresponding
special
   /// member can't be fully analyzed without performing overload
resolution.
   /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
   unsigned NeedOverloadResolutionForMoveConstructor : 1;
   unsigned NeedOverloadResolutionForMoveAssignment : 1;
   unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if an implicit defaulted
corresponding
   /// special member would be defined as deleted.
   /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
   unsigned DefaultedMoveConstructorIsDeleted : 1;
   unsigned DefaultedMoveAssignmentIsDeleted : 1;
   unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
   /// constructor.
   unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

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

Hi Diana,

  It seems the service is down. Could you send us the details of the 
failures (incl stack traces if any)


Many thanks,
Vassil
On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

  * Previously, Clang ignored the move constructor when making this
determination. It now takes the move constructor into account, per
https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
seem recent, but the ABI change was agreed on the Itanium C++ ABI
list a long time ago).

  * Previously, Clang's behavior when the copy constructor was deleted
was unstable -- depending on whether the lazy declaration of the
copy constructor had been triggered, you might get different behavior.
We now eagerly declare the copy constructor whenever its deletedness
is unclear, and ignore deleted copy/move constructors when looking for
a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

  * If the copy constructor would be implicitly deleted (but has not been
lazily declared yet), for instance because the class has an rvalue
reference member, we would pass it directly. We now pass such a class
indirectly, matching MSVC.

Modified:
 cfe/trunk/include/clang/AST/DeclCXX.h
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/lib/CodeGen/CGCXXABI.cpp
 cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
 cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
 cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff

==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
  /// \brief These flags are \c true if a defaulted corresponding
special
  /// member can't be fully analyzed without performing overload
resolution.
  /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
  unsigned NeedOverloadResolutionForMoveConstructor : 1;
  unsigned NeedOverloadResolutionForMoveAssignment : 1;
  unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
  /// \brief These flags are \c true if an implicit defaulted
corresponding
  /// special member would be defined as deleted.
  /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
  unsigned DefaultedMoveConstructorIsDeleted : 1;
  unsigned DefaultedMoveAssignmentIsDeleted : 1;
  unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
  /// constructor.
  unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+/// This does not imply anything about how the ABI in use will
actually
+/// pass an object of this class.
+unsigned CanPassInRegisters : 1;
+
  /// \brief True if a defaulted default constructor for this class
would
  /// be constexpr.
  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -811,18 +819,50 @@ public:
  return data().FirstFriend.isValid();
}

+  /// \brief \c true if a defaulted copy constructor for this class would
be
+  /// deleted.
+  bool defaultedCopyConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForCopyConstructor() ||
+(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted move constructor for this class would
be
+  

r306964 - [modules] Teach clang how to merge typedef over anonymous structs in C mode.

2017-07-01 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sat Jul  1 13:44:49 2017
New Revision: 306964

URL: http://llvm.org/viewvc/llvm-project?rev=306964&view=rev
Log:
[modules] Teach clang how to merge typedef over anonymous structs in C mode.

In C mode clang fails to merge the textually included definition with the one 
imported from a module. The C lookup rules fail to find the imported definition 
because its linkage is internal in non C++ mode.

This patch reinstates some of the ODR merging rules for typedefs of anonymous 
tags for languages other than C++.

Patch by Raphael Isemann and me (D34510).

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Index/usrs.m

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=306964&r1=306963&r2=306964&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Jul  1 13:44:49 2017
@@ -1259,8 +1259,7 @@ static LinkageInfo computeLVForDecl(cons
 case Decl::TypeAlias:
   // A typedef declaration has linkage if it gives a type a name for
   // linkage purposes.
-  if (!D->getASTContext().getLangOpts().CPlusPlus ||
-  !cast(D)
+  if (!cast(D)
->getAnonDeclWithTypedefName(/*AnyRedecl*/true))
 return LinkageInfo::none();
   break;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=306964&r1=306963&r2=306964&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jul  1 13:44:49 2017
@@ -1998,8 +1998,7 @@ static void filterNonConflictingPrevious
 
   // If both declarations give a tag declaration a typedef name for linkage
   // purposes, then they declare the same entity.
-  if (S.getLangOpts().CPlusPlus &&
-  OldTD->getAnonDeclWithTypedefName(/*AnyRedecl*/true) &&
+  if (OldTD->getAnonDeclWithTypedefName(/*AnyRedecl*/true) &&
   Decl->getAnonDeclWithTypedefName())
 continue;
 }
@@ -2117,7 +2116,7 @@ void Sema::MergeTypedefNameDecl(Scope *S
 auto *OldTag = OldTD->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
 auto *NewTag = New->getAnonDeclWithTypedefName();
 NamedDecl *Hidden = nullptr;
-if (getLangOpts().CPlusPlus && OldTag && NewTag &&
+if (OldTag && NewTag &&
 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
 !hasVisibleDefinition(OldTag, &Hidden)) {
   // There is a definition of this tag, but it is not visible. Use it

Modified: cfe/trunk/test/Index/usrs.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.m?rev=306964&r1=306963&r2=306964&view=diff
==
--- cfe/trunk/test/Index/usrs.m (original)
+++ cfe/trunk/test/Index/usrs.m Sat Jul  1 13:44:49 2017
@@ -119,7 +119,7 @@ int test_multi_declaration(void) {
 // CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2]
 // CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:3 - 16:9]
 // CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:3 - 17:10]
-// CHECK: usrs.m c:usrs.m@T@MyStruct Extent=[15:1 - 18:11]
+// CHECK: usrs.m c:@T@MyStruct Extent=[15:1 - 18:11]
 // CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2]
 // CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9]
 // CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12]


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


r306903 - Reinstate "Load lazily the template specialization in multi-module setups."

2017-06-30 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun 30 15:40:17 2017
New Revision: 306903

URL: http://llvm.org/viewvc/llvm-project?rev=306903&view=rev
Log:
Reinstate "Load lazily the template specialization in multi-module setups."

It was reverted in r305460 but the issue appears to only break our self-host
libcxx modules bot. Reapplying it will give us a chance to get a reproducer and
fix the issue.

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=306903&r1=306902&r2=306903&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jun 30 15:40:17 2017
@@ -219,6 +219,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(...);
@@ -247,7 +271,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) {
@@ -1971,21 +1995,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);
 
@@ -1994,12 +2003,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) {
@@ -2026,12 +2030,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);
   }
 }
 
@@ -2137,12 +2136,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);
   }
 }
 
@@ -3688,6 +3682,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);
@@ -3712,7 +3709,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
SourceLocation());
-  Reader.UpdateDecl(D);
+  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
 
   // We m

r306809 - Ambiguity might be also uninitialized. Use llvm::Optional.

2017-06-30 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun 30 02:25:43 2017
New Revision: 306809

URL: http://llvm.org/viewvc/llvm-project?rev=306809&view=rev
Log:
Ambiguity might be also uninitialized. Use llvm::Optional.


Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306809&r1=306808&r2=306809&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Jun 30 02:25:43 2017
@@ -18,6 +18,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/ADT/Optional.h"
+
 namespace clang {
 
 /// @brief Represents the results of name lookup.
@@ -465,9 +467,10 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK = Ambiguity;
+  llvm::Optional SavedAK;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
+SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;
@@ -478,7 +481,7 @@ public:
   if (ResultKind == Ambiguous) {
 (void)WasAmbiguous;
 assert(WasAmbiguous);
-Ambiguity = SavedAK;
+Ambiguity = SavedAK.getValue();
   } else if (Paths) {
 deletePaths(Paths);
 Paths = nullptr;


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


Re: r306692 - Initialize variable and silence potentially uninitialized warning.

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

On 30/06/17 01:03, Evgenii Stepanov wrote:

This change broke clang/ubsan bot.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6047/steps/check-clang%20ubsan/logs/stdio

It looks like the value you are initializing SavedAK with may itself 
be uninitialized? I see a few constructors that do not mention it.
Indeed. Do you have a solution in mind? The only way I see to fix this 
is by using an llvm::Optional.



On Thu, Jun 29, 2017 at 9:08 AM, Vassil Vassilev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: vvassilev
Date: Thu Jun 29 09:08:10 2017
New Revision: 306692

URL: http://llvm.org/viewvc/llvm-project?rev=306692&view=rev
<http://llvm.org/viewvc/llvm-project?rev=306692&view=rev>
Log:
Initialize variable and silence potentially uninitialized warning.

Patch by Liza Sakellari!

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306692&r1=306691&r2=306692&view=diff

<http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306692&r1=306691&r2=306692&view=diff>

==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Jun 29 09:08:10 2017
@@ -465,10 +465,9 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK;
+  AmbiguityKind SavedAK = Ambiguity;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
-SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
<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


r306692 - Initialize variable and silence potentially uninitialized warning.

2017-06-29 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jun 29 09:08:10 2017
New Revision: 306692

URL: http://llvm.org/viewvc/llvm-project?rev=306692&view=rev
Log:
Initialize variable and silence potentially uninitialized warning.

Patch by Liza Sakellari!

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306692&r1=306691&r2=306692&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Jun 29 09:08:10 2017
@@ -465,10 +465,9 @@ public:
 Paths = nullptr;
   }
 } else {
-  AmbiguityKind SavedAK;
+  AmbiguityKind SavedAK = Ambiguity;
   bool WasAmbiguous = false;
   if (ResultKind == Ambiguous) {
-SavedAK = Ambiguity;
 WasAmbiguous = true;
   }
   ResultKind = Found;


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


Re: r306127 - [GSoC] Add support for CC1 options.

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

On 27/06/17 07:17, Saleem Abdulrasool via cfe-commits wrote:
I think that we shouldn't be providing completion for `-cc1` options. 
 `-cc1as` options are fine as the IAS serves as a replacement for the 
traditional unix `as`.  But, the `NoDriverOption` values shouldn't be 
exposed to users.  They are internal details, with no compatibility.  
If users start using those options, it makes it harder to prevent 
command line incompatibilities.

Thanks for the feedback!

We probably should only expose the cc1 options if the user typed clang 
-cc1 -f[tab], i.e. the user already is looking for something internal or 
make sure they are noted as a cc1 arguments. On the other hand, this 
should be of great help to more advanced users.


On Fri, Jun 23, 2017 at 10:05 AM, Yuka Takahashi via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: yamaguchi
Date: Fri Jun 23 12:05:50 2017
New Revision: 306127

URL: http://llvm.org/viewvc/llvm-project?rev=306127&view=rev

Log:
[GSoC] Add support for CC1 options.

Summary:
Add value completion support for options which are defined in
CC1Options.td, because we only handled options in Options.td.

Reviewers: ruiu, v.g.vassilev, teemperor

Subscribers: llvm-commits

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


Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/test/Driver/autocomplete.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=306127&r1=306126&r2=306127&view=diff



==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun 23
12:05:50 2017
@@ -158,7 +158,7 @@ def msave_temp_labels : Flag<["-"], "msa
"Note this may change .s semantics and shouldn't
generally be used "
"on compiler-generated code.">;
 def mrelocation_model : Separate<["-"], "mrelocation-model">,
-  HelpText<"The relocation model to use">;
+  HelpText<"The relocation model to use">,
Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">;
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">;
 }
@@ -229,7 +229,7 @@ def no_struct_path_tbaa : Flag<["-"], "n
 def masm_verbose : Flag<["-"], "masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<["-"], "mcode-model">,
-  HelpText<"The code model to use">;
+  HelpText<"The code model to use">,
Values<"small,kernel,medium,large">;
 def mdebug_pass : Separate<["-"], "mdebug-pass">,
   HelpText<"Enable additional debug output">;
 def mdisable_fp_elim : Flag<["-"], "mdisable-fp-elim">,
@@ -308,7 +308,7 @@ def fsanitize_coverage_no_prune
   HelpText<"Disable coverage pruning (i.e. instrument all
blocks/edges)">;
 def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
 HelpText<"Enable PGO instrumentation. The accepted value is
clang, llvm, "
- "or none">;
+ "or none">, Values<"none,clang,llvm">;
 def fprofile_instrument_path_EQ : Joined<["-"],
"fprofile-instrument-path=">,
 HelpText<"Generate instrumented code to collect execution
counts into "
  " (overridden by LLVM_PROFILE_FILE env var)">;
@@ -348,9 +348,9 @@ def diagnostic_serialized_file : Separat
   HelpText<"File for serializing diagnostics in a binary format">;

 def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">,
-  HelpText<"Change diagnostic formatting to match IDE and command
line tools">;
+  HelpText<"Change diagnostic formatting to match IDE and command
line tools">, Values<"clang,msvc,msvc-fallback,vi">;
 def fdiagnostics_show_category : Separate<["-"],
"fdiagnostics-show-category">,
-  HelpText<"Print diagnostic category">;
+  HelpText<"Print diagnostic category">, Values<"none,id,name">;
 def fno_diagnostics_use_presumed_location : Flag<["-"],
"fno-diagnostics-use-presumed-location">,
   HelpText<"Ignore #line directives when displaying diagnostic
locations">;
 def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"">,
@@ -595,11 +595,11 @@ def fconstant_string_class : Separate<["
   MetaVarName<"">,
   HelpText<"Specify the class to use for constant Objective-C
string objects.">;
 def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">,
-  HelpText<"Objective-C++ Automatic Reference 

r305799 - D31187: Fix removal of out-of-line definitions.

2017-06-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Jun 20 09:59:57 2017
New Revision: 305799

URL: http://llvm.org/viewvc/llvm-project?rev=305799&view=rev
Log:
D31187: Fix removal of out-of-line definitions.

Consider:

struct MyClass {
  void f() {}
}
MyClass::f(){} // expected error redefinition of f. #1

Some clients (eg. cling) need to call removeDecl for the redefined (#1) decl.

This patch enables us to remove the lookup entry is registered in the semantic
decl context and not in the primary decl context of the lexical decl context
where we currently are trying to remove it from.

It is not trivial to test this piece and writing a full-blown unit test seems
too much.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=305799&r1=305798&r2=305799&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Jun 20 09:59:57 2017
@@ -1352,7 +1352,7 @@ void DeclContext::removeDecl(Decl *D) {
 // Remove only decls that have a name
 if (!ND->getDeclName()) return;
 
-auto *DC = this;
+auto *DC = D->getDeclContext();
 do {
   StoredDeclsMap *Map = DC->getPrimaryContext()->LookupPtr;
   if (Map) {


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


r305460 - Revert "Load lazily the template specialization in multi-module setups."

2017-06-15 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jun 15 06:05:32 2017
New Revision: 305460

URL: http://llvm.org/viewvc/llvm-project?rev=305460&view=rev
Log:
Revert "Load lazily the template specialization in multi-module setups."

This broke our libcxx modules builds.

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=305460&r1=305459&r2=305460&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Jun 15 06:05:32 2017
@@ -216,30 +216,6 @@ 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(...);
@@ -268,7 +244,7 @@ namespace clang {
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
+void UpdateDecl(Decl *D);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1976,6 +1952,21 @@ 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);
 
@@ -1984,7 +1975,12 @@ void ASTDeclReader::VisitClassTemplateDe
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2011,7 +2007,12 @@ void ASTDeclReader::VisitVarTemplateDecl
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 }
 
@@ -2117,7 +2118,12 @@ void ASTDeclReader::VisitFunctionTemplat
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 }
 
@@ -3661,9 +3667,6 @@ 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);
@@ -3688,7 +3691,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
SourceLocation());
-  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
+  Reader.UpdateDecl(D);
 
   // We might have made this declaration interesting. If so, remember that
   // we need to hand it off to the consumer.
@@ -3700,17 +3703,6 @

[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


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

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


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


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


r303432 - [modules] Further delay calling DeclMustBeEmitted until it's safe.

2017-05-19 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri May 19 11:46:06 2017
New Revision: 303432

URL: http://llvm.org/viewvc/llvm-project?rev=303432&view=rev
Log:
[modules] Further delay calling DeclMustBeEmitted until it's safe.

As discussed in D30793, we have some unsafe calls to isConsumerInterestedIn().
This patch implements Richard's suggestion (from the inline comment) that we
should track if we just deserialized an declaration. If we just deserialized,
we can skip the unsafe call because we know it's interesting. If we didn't just
deserialize the declaration, calling isConsumerInterestedIn() should be safe.

We tried to create a test case for this but we were not successful.

Patch by Raphael Isemann (D32499)!

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri May 19 11:46:06 2017
@@ -478,10 +478,18 @@ private:
   /// in the chain.
   DeclUpdateOffsetsMap DeclUpdateOffsets;
 
+  struct PendingUpdateRecord {
+Decl *D;
+serialization::GlobalDeclID ID;
+// Whether the declaration was just deserialized.
+bool JustLoaded;
+PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
+bool JustLoaded)
+: D(D), ID(ID), JustLoaded(JustLoaded) {}
+  };
   /// \brief Declaration updates for already-loaded declarations that we need
   /// to apply once we finish processing an import.
-  llvm::SmallVector, 16>
-  PendingUpdateRecords;
+  llvm::SmallVector PendingUpdateRecords;
 
   enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
 
@@ -1279,7 +1287,7 @@ private:
 
   RecordLocation DeclCursorForID(serialization::DeclID ID,
  SourceLocation &Location);
-  void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
+  void loadDeclUpdateRecords(PendingUpdateRecord &Record);
   void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
   void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
   unsigned PreviousGeneration = 0);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri May 19 11:46:06 2017
@@ -2756,7 +2756,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
   // If we've already loaded the decl, perform the updates when we finish
   // loading this block.
   if (Decl *D = GetExistingDecl(ID))
-PendingUpdateRecords.push_back(std::make_pair(ID, D));
+PendingUpdateRecords.push_back(
+PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
   break;
 }
 
@@ -3086,7 +3087,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
 // If we've already loaded the decl, perform the updates when we finish
 // loading this block.
 if (Decl *D = GetExistingDecl(ID))
-  PendingUpdateRecords.push_back(std::make_pair(ID, D));
+  PendingUpdateRecords.push_back(
+  PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
   }
   break;
 }
@@ -8956,7 +8958,7 @@ void ASTReader::finishPendingActions() {
 while (!PendingUpdateRecords.empty()) {
   auto Update = PendingUpdateRecords.pop_back_val();
   ReadingKindTracker ReadingKind(Read_Decl, *this);
-  loadDeclUpdateRecords(Update.first, Update.second);
+  loadDeclUpdateRecords(Update);
 }
   }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=303432&r1=303431&r2=303432&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri May 19 11:46:06 2017
@@ -3612,7 +3612,8 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
   assert(Record.getIdx() == Record.size());
 
   // Load any relevant update records.
-  PendingUpdateRecords.push_back(std::make_pair(ID, D));
+  PendingUpdateRecords.push_back(
+  PendingUpdateRecord(ID, D, /*JustLoaded=*/true));
 
   // Load the categories after recursive loading is finished.
   if (ObjCInterfaceDecl *Class = dyn_cast(D))
@@ -3657,20 +3658,24 @@ void ASTReader::PassInterestingDeclsToCo
   }
 }
 
-void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *

r303250 - Constify.

2017-05-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed May 17 07:09:11 2017
New Revision: 303250

URL: http://llvm.org/viewvc/llvm-project?rev=303250&view=rev
Log:
Constify.

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

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=303250&r1=303249&r2=303250&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed May 17 07:09:11 2017
@@ -865,7 +865,7 @@ public:
 const FileEntry *NewFile);
 
   /// \brief Returns true if the file contents have been overridden.
-  bool isFileOverridden(const FileEntry *File) {
+  bool isFileOverridden(const FileEntry *File) const {
 if (OverriddenFilesInfo) {
   if (OverriddenFilesInfo->OverriddenFilesWithBuffer.count(File))
 return true;


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


Re: [PATCH] D29877: Warn about unused static file scope function template declarations.

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

On 11/04/17 22:25, Richard Smith wrote:
On 11 April 2017 at 08:35, Marshall Clow via Phabricator via 
cfe-commits > wrote:


mclow.lists added a comment.

Complete reproducer:

// Tested with with:  clang++ -std=c++14 -Wunused-function
UnusedFVassily.cpp
//
// UnusedFVassily.cpp:8:39: warning: unused function '__test'
[-Wunused-function]
// template  static __two __test(...);
//   ^
// UnusedFVassily.cpp:9:38: warning: unused function '__test'
[-Wunused-function]
// template  static char __test(typename
_Up::pointer* = 0);
//  ^
// 2 warnings generated.

#include 

namespace foo {

struct __two {char __lx; char __lxx;};
namespace __has_pointer_type_imp
{

  template  static __two __test(...);
  template  static char __test(typename _Up::pointer* = 0);

}

template 
struct __has_pointer_type

  : public std::integral_constant(0)) == 1>


This is a bug in libc++. If this header is included into two 
translation units, they will be referencing different __test functions 
here (because the template has internal linkage due to the 'static'), 
resulting in an ODR violation.
Richard, shall we warn on template definitions marked static? This would 
keep this pattern still working.



{
};

}

struct S1 {};
struct S2 { typedef void *pointer; };

int main () {
static_assert (!foo::__has_pointer_type::value, "" );
static_assert ( foo::__has_pointer_type::value, "" );
}


https://reviews.llvm.org/D29877 



___
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


r302521 - PR5935: Adjust documentation.

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 07:37:15 2017
New Revision: 302521

URL: http://llvm.org/viewvc/llvm-project?rev=302521&view=rev
Log:
PR5935: Adjust documentation.

https://reviews.llvm.org/D31867

Patch by Johannes Altmanninger!

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

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=302521&r1=302520&r2=302521&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Tue May  9 07:37:15 2017
@@ -24,8 +24,7 @@ namespace clang {
 /// \brief Options for controlling the target.
 class TargetOptions {
 public:
-  /// If given, the name of the target triple to compile for. If not given the
-  /// target will be selected to match the host.
+  /// The name of the target triple to compile for.
   std::string Triple;
 
   /// When compiling for the device side, contains the triple used to compile


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


r302518 - Reland "Warn about unused static file scope function template declarations."

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 06:25:41 2017
New Revision: 302518

URL: http://llvm.org/viewvc/llvm-project?rev=302518&view=rev
Log:
Reland "Warn about unused static file scope function template declarations."

This patch reinstates r299930, reverted in r299956, as a separate diagnostic
option (-Wunused-template). 

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue May  9 06:25:41 2017
@@ -486,6 +486,7 @@ def UnneededInternalDecl : DiagGroup<"un
 def UnneededMemberFunction : DiagGroup<"unneeded-member-function">;
 def UnusedPrivateField : DiagGroup<"unused-private-field">;
 def UnusedFunction : DiagGroup<"unused-function", [UnneededInternalDecl]>;
+def UnusedTemplate : DiagGroup<"unused-template", [UnneededInternalDecl]>;
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
@@ -627,6 +628,7 @@ def Conversion : DiagGroup<"conversion",
 def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
+// UnusedTemplate, (clean-up libc++ before enabling)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
 UnusedPrivateField, UnusedLambdaCapture,
 UnusedLocalTypedef, UnusedValue, UnusedVariable,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May  9 06:25:41 
2017
@@ -303,6 +303,8 @@ def note_empty_parens_zero_initialize :
   "replace parentheses with an initializer to declare a variable">;
 def warn_unused_function : Warning<"unused function %0">,
   InGroup, DefaultIgnore;
+def warn_unused_template : Warning<"unused %select{function|variable}0 
template %1">,
+  InGroup, DefaultIgnore;
 def warn_unused_member_function : Warning<"unused member function %0">,
   InGroup, DefaultIgnore;
 def warn_used_but_marked_unused: Warning<"%0 was marked unused but was used">,

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue May  9 06:25:41 2017
@@ -477,6 +477,13 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and none of its specializations is used,
+// we should warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -500,6 +507,13 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  // If this is a variable template and none of its specializations is 
used,
+  // we should warn.
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();
@@ -905,10 +919,14 @@ void Sema::ActOnEndOfTranslationUnit() {
<< /*function*/0 << DiagD->getDeclName();
   }
 } else {
-  Diag(DiagD->getLocation(),
-   isa(DiagD) ? diag::warn_unused_member_function
- : diag::warn_unused_function)
-<< DiagD->getDeclName();
+  if (FD->getDescribedFunctionTemplate())
+Diag

Re: r302312 - Permit keywords in module names in #pragma clang module *.

2017-05-08 Thread Vassil Vassilev via cfe-commits

Thanks!
On 06/05/17 00:34, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri May  5 17:34:07 2017
New Revision: 302312

URL: http://llvm.org/viewvc/llvm-project?rev=302312&view=rev
Log:
Permit keywords in module names in #pragma clang module *.

This is necessary to be able to build a libc++ module from preprocessed source
(due to the submodule std.new).

Modified:
 cfe/trunk/lib/Lex/Pragma.cpp
 cfe/trunk/test/Preprocessor/pragma_module.c

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=302312&r1=302311&r2=302312&view=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Fri May  5 17:34:07 2017
@@ -1307,7 +1307,7 @@ static bool LexModuleName(
  &ModuleName) {
while (true) {
  PP.LexUnexpandedToken(Tok);
-if (Tok.isNot(tok::identifier)) {
+if (Tok.isAnnotation() || !Tok.getIdentifierInfo()) {
PP.Diag(Tok.getLocation(), diag::err_pp_expected_module_name)
  << ModuleName.empty();
return true;

Modified: cfe/trunk/test/Preprocessor/pragma_module.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_module.c?rev=302312&r1=302311&r2=302312&view=diff
==
--- cfe/trunk/test/Preprocessor/pragma_module.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_module.c Fri May  5 17:34:07 2017
@@ -1,13 +1,14 @@
  // RUN: rm -rf %t
  // RUN: mkdir %t
-// RUN: echo 'module foo { module a {} module b {} } module bar {}' > 
%t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo 
-fmodule-map-file=%t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo 
-fmodule-map-file=%t/module.map -fmodules-local-submodule-visibility -DLOCAL_VIS
+// RUN: echo 'module foo { module a {} module b {} } module bar {} module if {}' 
> %t/module.map
+// RUN: %clang -cc1 -fmodules -fmodule-name=if -x c %t/module.map -emit-module 
-o %t/if.pcm
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify 
-fmodule-name=foo -fmodule-map-file=%t/module.map
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify 
-fmodule-name=foo -fmodule-map-file=%t/module.map 
-fmodules-local-submodule-visibility -DLOCAL_VIS
  
  // Just checking the syntax here; the semantics are tested elsewhere.

  #pragma clang module import // expected-error {{expected module name}}
  #pragma clang module import ! // expected-error {{expected module name}}
-#pragma clang module import if // expected-error {{expected module name}}
+#pragma clang module import if // ok
  #pragma clang module import foo ? bar // expected-warning {{extra tokens at 
end of #pragma}}
  #pragma clang module import foo. // expected-error {{expected identifier 
after '.' in module name}}
  #pragma clang module import foo.bar.baz.quux // expected-error {{no submodule 
named 'bar' in module 'foo'}}


___
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


r301563 - Remove leaking UnknownPragmaHandlers right after we are done with them.

2017-04-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Apr 27 11:58:33 2017
New Revision: 301563

URL: http://llvm.org/viewvc/llvm-project?rev=301563&view=rev
Log:
Remove leaking UnknownPragmaHandlers right after we are done with them.

The UnknownPragmaHandlers added by DoPrintPreprocessedInput conflict with the
real PragmaHandlers from clang::Parser because they try to handle the same
#pragma directives. This makes it impossible to use a Preprocessor (that was
previously passed to DoPrintPreprocessedInput), as an Preprocessor for a
clang::Parser instance which is what we currently do in cling.

This patch removes the added UnknownPragmaHandler to avoid conflicts these
conflicts and leave the PragmaHandlers of the Preprocessors in a the same state
as before calling DoPrintPreprocessedInput.

Patch by Raphael Isemann (D32486)!

Modified:
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301563&r1=301562&r2=301563&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr 27 11:58:33 2017
@@ -775,26 +775,33 @@ void clang::DoPrintPreprocessedInput(Pre
 
   // Expand macros in pragmas with -fms-extensions.  The assumption is that
   // the majority of pragmas in such a file will be Microsoft pragmas.
-  PP.AddPragmaHandler(new UnknownPragmaHandler(
-  "#pragma", Callbacks,
+  // Remember the handlers we will add so that we can remove them later.
+  std::unique_ptr MicrosoftExtHandler(
+  new UnknownPragmaHandler(
+  "#pragma", Callbacks,
+  /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt));
+
+  std::unique_ptr GCCHandler(new UnknownPragmaHandler(
+  "#pragma GCC", Callbacks,
+  /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt));
+
+  std::unique_ptr ClangHandler(new UnknownPragmaHandler(
+  "#pragma clang", Callbacks,
   /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt));
-  PP.AddPragmaHandler(
-  "GCC", new UnknownPragmaHandler(
- "#pragma GCC", Callbacks,
- /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt));
-  PP.AddPragmaHandler(
-  "clang", new UnknownPragmaHandler(
-   "#pragma clang", Callbacks,
-   /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt));
+
+  PP.AddPragmaHandler(MicrosoftExtHandler.get());
+  PP.AddPragmaHandler("GCC", GCCHandler.get());
+  PP.AddPragmaHandler("clang", ClangHandler.get());
 
   // The tokens after pragma omp need to be expanded.
   //
   //  OpenMP [2.1, Directive format]
   //  Preprocessing tokens following the #pragma omp are subject to macro
   //  replacement.
-  PP.AddPragmaHandler("omp",
-  new UnknownPragmaHandler("#pragma omp", Callbacks,
-   
/*RequireTokenExpansion=*/true));
+  std::unique_ptr OpenMPHandler(
+  new UnknownPragmaHandler("#pragma omp", Callbacks,
+   /*RequireTokenExpansion=*/true));
+  PP.AddPragmaHandler("omp", OpenMPHandler.get());
 
   PP.addPPCallbacks(std::unique_ptr(Callbacks));
 
@@ -822,4 +829,11 @@ void clang::DoPrintPreprocessedInput(Pre
   // Read all the preprocessed tokens, printing them out to the stream.
   PrintPreprocessedTokens(PP, Tok, Callbacks, *OS);
   *OS << '\n';
+
+  // Remove the handlers we just added to leave the preprocessor in a sane 
state
+  // so that it can be reused (for example by a clang::Parser instance).
+  PP.RemovePragmaHandler(MicrosoftExtHandler.get());
+  PP.RemovePragmaHandler("GCC", GCCHandler.get());
+  PP.RemovePragmaHandler("clang", ClangHandler.get());
+  PP.RemovePragmaHandler("omp", OpenMPHandler.get());
 }


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


r300825 - PR19260: Teach doxygen to spell correctly the include paths.

2017-04-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Apr 20 03:57:41 2017
New Revision: 300825

URL: http://llvm.org/viewvc/llvm-project?rev=300825&view=rev
Log:
PR19260: Teach doxygen to spell correctly the include paths.

Currently we have #include  in the doxygen page documenting Sema. The
patch changes it ot #include "clang/Sema/Sema.h" which is what we would spell if
we need to include it in a real codebase.

Patch by Yuka Takahashi (D32113)!

Modified:
cfe/trunk/docs/doxygen.cfg.in

Modified: cfe/trunk/docs/doxygen.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/doxygen.cfg.in?rev=300825&r1=300824&r2=300825&view=diff
==
--- cfe/trunk/docs/doxygen.cfg.in (original)
+++ cfe/trunk/docs/doxygen.cfg.in Thu Apr 20 03:57:41 2017
@@ -132,7 +132,7 @@ INLINE_INHERITED_MEMB  = NO
 # shortest path that makes the file name unique will be used
 # The default value is: YES.
 
-FULL_PATH_NAMES= NO
+FULL_PATH_NAMES= YES
 
 # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
 # Stripping is only done if one of the specified strings matches the left-hand
@@ -144,7 +144,7 @@ FULL_PATH_NAMES= NO
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
-STRIP_FROM_PATH= ../..
+STRIP_FROM_PATH= @abs_srcdir@/..
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
@@ -153,7 +153,7 @@ STRIP_FROM_PATH= ../..
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
-STRIP_FROM_INC_PATH=
+STRIP_FROM_INC_PATH= @abs_srcdir@/../include
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
@@ -513,7 +513,7 @@ SHOW_GROUPED_MEMB_INC  = NO
 # files with double quotes in the documentation rather than with sharp 
brackets.
 # The default value is: NO.
 
-FORCE_LOCAL_INCLUDES   = NO
+FORCE_LOCAL_INCLUDES   = YES
 
 # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
 # documentation for inline members.


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


r300594 - PR30508: Downgrade error to warning if the umbrella folder doesn't exist.

2017-04-18 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Apr 18 15:57:29 2017
New Revision: 300594

URL: http://llvm.org/viewvc/llvm-project?rev=300594&view=rev
Log:
PR30508: Downgrade error to warning if the umbrella folder doesn't exist.

Patch by Yuka Takahashi (D32119)!

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/umbrella-header-include-builtin.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=300594&r1=300593&r2=300594&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Apr 18 15:57:29 2017
@@ -594,8 +594,6 @@ def err_mmap_expected_mmap_file : Error<
 def err_mmap_module_redefinition : Error<
   "redefinition of module '%0'">;
 def note_mmap_prev_definition : Note<"previously defined here">;
-def err_mmap_umbrella_dir_not_found : Error<
-  "umbrella directory '%0' not found">;
 def err_mmap_umbrella_clash : Error<
   "umbrella for module '%0' already covers this directory">;
 def err_mmap_module_id : Error<
@@ -656,6 +654,9 @@ def note_implicit_top_level_module_impor
 def warn_uncovered_module_header : Warning<
   "umbrella header for module '%0' does not include header '%1'">, 
   InGroup;
+def warn_mmap_umbrella_dir_not_found : Warning<
+  "umbrella directory '%0' not found">,
+  InGroup;
 def err_expected_id_building_module : Error<
   "expected a module name in '__building_module' expression">;
 def warn_use_of_private_header_outside_module : Warning<

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=300594&r1=300593&r2=300594&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Apr 18 15:57:29 2017
@@ -2002,9 +2002,8 @@ void ModuleMapParser::parseUmbrellaDirDe
   }
   
   if (!Dir) {
-Diags.Report(DirNameLoc, diag::err_mmap_umbrella_dir_not_found)
+Diags.Report(DirNameLoc, diag::warn_mmap_umbrella_dir_not_found)
   << DirName;
-HadError = true;
 return;
   }
 

Modified: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/umbrella-header-include-builtin.mm?rev=300594&r1=300593&r2=300594&view=diff
==
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm (original)
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm Tue Apr 18 
15:57:29 2017
@@ -4,3 +4,11 @@
 // RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "module NonExistent1 { umbrella \"NonExistent\" }" > 
%t/modules.modulemap
+// RUN: echo "" > %t/A.h
+// RUN: echo "#include \"A.h\"  int i;" > %t/T.cxx
+// RUN: %clang -I %t -fmodules -fsyntax-only %t/T.cxx
+// expected-warning {{ umbrella directory }}


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


Re: r300443 - Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions

2017-04-17 Thread Vassil Vassilev via cfe-commits

+ Richard

Thanks for the example. We've seen similar issue with inlines (without 
the reverted patch). My guess this patch exposed it.


It is not clear to me why we think the declaration is a definition there...
On 17/04/17 23:10, Benjamin Kramer via cfe-commits wrote:

This broke our internal build of libc++ with modules. Reduced test
case attached, courtesy of Richard Smith!

With your patch it doesn't compiler anymore:
While building module 'x':
In file included from :2:
In file included from ./c.h:1:
./a.h:3:32: error: inline declaration of 'f' follows non-inline definition
template inline void f() {}
^
./a.h:3:32: note: previous definition is here
template inline void f() {}


I reverted this change in r300497.

On Mon, Apr 17, 2017 at 10:51 AM, Yaron Keren via cfe-commits
 wrote:

Author: yrnkrn
Date: Mon Apr 17 03:51:20 2017
New Revision: 300443

URL: http://llvm.org/viewvc/llvm-project?rev=300443&view=rev
Log:
Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace 
a friend, and a visible friend can properly replace an invisible friend but not 
vice verse, and definitions are not replaced. This fixes the two FIXME in 
SemaTemplate/friend-template.cpp.

The code implements Richard Smith suggestion in comment 3 of the PR.

reviewer: Vassil Vassilev

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


Modified:
 cfe/trunk/include/clang/AST/DeclBase.h
 cfe/trunk/lib/AST/Decl.cpp
 cfe/trunk/lib/AST/DeclBase.cpp
 cfe/trunk/test/SemaTemplate/friend-template.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=300443&r1=300442&r2=300443&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Apr 17 03:51:20 2017
@@ -417,6 +417,8 @@ public:
  return const_cast(this)->getTranslationUnitDecl();
}

+  bool isThisDeclarationADefinition() const;
+
bool isInAnonymousNamespace() const;

bool isInStdNamespace() const;

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300443&r1=300442&r2=300443&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Apr 17 03:51:20 2017
@@ -1536,6 +1536,10 @@ bool NamedDecl::declarationReplaces(Name
if (isa(this))
  return false;

+  if (getFriendObjectKind() > OldD->getFriendObjectKind() &&
+  !isThisDeclarationADefinition())
+return false;
+
// For parameters, pick the newer one. This is either an error or (in
// Objective-C) permitted as an extension.
if (isa(this))

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=300443&r1=300442&r2=300443&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Apr 17 03:51:20 2017
@@ -861,6 +861,21 @@ const FunctionType *Decl::getFunctionTyp
return Ty->getAs();
  }

+bool Decl::isThisDeclarationADefinition() const {
+  if (auto *TD = dyn_cast(this))
+return TD->isThisDeclarationADefinition();
+  if (auto *FD = dyn_cast(this))
+return FD->isThisDeclarationADefinition();
+  if (auto *VD = dyn_cast(this))
+return VD->isThisDeclarationADefinition();
+  if (auto *CTD = dyn_cast(this))
+return CTD->isThisDeclarationADefinition();
+  if (auto *FTD = dyn_cast(this))
+return FTD->isThisDeclarationADefinition();
+  if (auto *VTD = dyn_cast(this))
+return VTD->isThisDeclarationADefinition();
+  return false;
+}

  /// Starting at a given context (a Decl or DeclContext), look for a
  /// code context that is not a closure (a lambda, block, etc.).

Modified: cfe/trunk/test/SemaTemplate/friend-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/friend-template.cpp?rev=300443&r1=300442&r2=300443&view=diff
==
--- cfe/trunk/test/SemaTemplate/friend-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/friend-template.cpp Mon Apr 17 03:51:20 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
  // PR5057
  namespace test0 {
namespace std {
@@ -68,17 +68,12 @@ namespace test3 {
Foo foo;

template struct X2a;
-
-  template struct X2b;
+  template struct X2b;// expected-note {{previous 
non-type template parameter with type 'int' is here}}

template
class X3 {
  template friend struct X2a;
-
-// FIXME: the redeclaration note ends up here because redeclaration
-// lookup ends up finding the friend target from X3.
-template friend stru

r300313 - PR32280: Do not crash on nested initializers.

2017-04-14 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Apr 14 03:48:08 2017
New Revision: 300313

URL: http://llvm.org/viewvc/llvm-project?rev=300313&view=rev
Log:
PR32280: Do not crash on nested initializers.

Patch by Yuka Takahashi (D31591)!

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Sema/designated-initializers.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=300313&r1=300312&r2=300313&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Apr 14 03:48:08 2017
@@ -2270,15 +2270,17 @@ InitListChecker::CheckDesignatedInitiali
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // We're about to throw away an initializer, emit warning.
-  SemaRef.Diag(D->getFieldLoc(),
-   diag::warn_initializer_overrides)
-<< D->getSourceRange();
   Expr *ExistingInit = StructuredList->getInit(0);
-  SemaRef.Diag(ExistingInit->getLocStart(),
-   diag::note_previous_initializer)
-<< /*FIXME:has side effects=*/0
-<< ExistingInit->getSourceRange();
+  if (ExistingInit) {
+// We're about to throw away an initializer, emit warning.
+SemaRef.Diag(D->getFieldLoc(),
+ diag::warn_initializer_overrides)
+  << D->getSourceRange();
+SemaRef.Diag(ExistingInit->getLocStart(),
+ diag::note_previous_initializer)
+  << /*FIXME:has side effects=*/0
+  << ExistingInit->getSourceRange();
+  }
 
   // remove existing initializer
   StructuredList->resizeInits(SemaRef.Context, 0);

Modified: cfe/trunk/test/Sema/designated-initializers.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/designated-initializers.c?rev=300313&r1=300312&r2=300313&view=diff
==
--- cfe/trunk/test/Sema/designated-initializers.c (original)
+++ cfe/trunk/test/Sema/designated-initializers.c Fri Apr 14 03:48:08 2017
@@ -351,3 +351,20 @@ overwrite_string4[] = {
   { { 'f', 'o', 'o' }, 1 },
   [0].L[4] = 'x' // no-warning
 };
+
+struct {
+  struct { } s1;
+  union {
+int a;
+int b;
+  } u1;
+} s = {
+  .s1 = {
+.x = 0, // expected-error{{field designator}}
+  },
+
+  .u1 = {
+.a = 0,
+.b = 0,
+  },
+};


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


r300110 - [modules] Delay calling DeclMustBeEmitted until it's safe.

2017-04-12 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Apr 12 16:56:05 2017
New Revision: 300110

URL: http://llvm.org/viewvc/llvm-project?rev=300110&view=rev
Log:
[modules] Delay calling DeclMustBeEmitted until it's safe.

This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in
the middle of deserialization should be avoided and that the actual check should
be deferred until it's safe to do so.

This patch fixes a crash when accessing the invalid redecl chains while trying
to evaluate the value of a const VarDecl that contains a function call.

Patch by Raphael Isemann (D30793)!

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=300110&r1=300109&r2=300110&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Apr 12 16:56:05 2017
@@ -984,14 +984,26 @@ private:
   /// \brief The generation number of each identifier, which keeps track of
   /// the last time we loaded information about this identifier.
   llvm::DenseMap IdentifierGeneration;
-  
-  /// \brief Contains declarations and definitions that will be
+
+  class InterestingDecl {
+Decl *D;
+bool DeclHasPendingBody;
+
+  public:
+InterestingDecl(Decl *D, bool HasBody)
+: D(D), DeclHasPendingBody(HasBody) {}
+Decl *getDecl() { return D; }
+/// Whether the declaration has a pending body.
+bool hasPendingBody() { return DeclHasPendingBody; }
+  };
+
+  /// \brief Contains declarations and definitions that could be
   /// "interesting" to the ASTConsumer, when we get that AST consumer.
   ///
   /// "Interesting" declarations are those that have data that may
   /// need to be emitted, such as inline function definitions or
   /// Objective-C protocols.
-  std::deque InterestingDecls;
+  std::deque PotentiallyInterestingDecls;
 
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed, and the local offset to the corresponding list

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=300110&r1=300109&r2=300110&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Apr 12 16:56:05 2017
@@ -7234,31 +7234,6 @@ static void PassObjCImplDeclToConsumer(O
   Consumer->HandleInterestingDecl(DeclGroupRef(ImplD));
 }
 
-void ASTReader::PassInterestingDeclsToConsumer() {
-  assert(Consumer);
-
-  if (PassingDeclsToConsumer)
-return;
-
-  // Guard variable to avoid recursively redoing the process of passing
-  // decls to consumer.
-  SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
-   true);
-
-  // Ensure that we've loaded all potentially-interesting declarations
-  // that need to be eagerly loaded.
-  for (auto ID : EagerlyDeserializedDecls)
-GetDecl(ID);
-  EagerlyDeserializedDecls.clear();
-
-  while (!InterestingDecls.empty()) {
-Decl *D = InterestingDecls.front();
-InterestingDecls.pop_front();
-
-PassInterestingDeclToConsumer(D);
-  }
-}
-
 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
   if (ObjCImplDecl *ImplD = dyn_cast(D))
 PassObjCImplDeclToConsumer(ImplD, Consumer);

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=300110&r1=300109&r2=300110&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Apr 12 16:56:05 2017
@@ -3626,12 +3626,37 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
   // AST consumer might need to know about, queue it.
   // We don't pass it to the consumer immediately because we may be in 
recursive
   // loading, and some declarations may still be initializing.
-  if (isConsumerInterestedIn(Context, D, Reader.hasPendingBody()))
-InterestingDecls.push_back(D);
+  PotentiallyInterestingDecls.push_back(
+  InterestingDecl(D, Reader.hasPendingBody()));
 
   return D;
 }
 
+void ASTReader::PassInterestingDeclsToConsumer() {
+  assert(Consumer);
+
+  if (PassingDeclsToConsumer)
+return;
+
+  // Guard variable to avoid recursively redoing the process of passing
+  // decls to consumer.
+  SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
+   true);
+
+  // Ensure that we've loaded all potentially-interesting declarations

r299956 - Revert temporarily D29877 "Warn about unused static file scope function template declarations."

2017-04-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Apr 11 11:05:23 2017
New Revision: 299956

URL: http://llvm.org/viewvc/llvm-project?rev=299956&view=rev
Log:
Revert temporarily D29877 "Warn about unused static file scope function 
template declarations."

We need to address cases (breaking libc++) such as

template  static int __test(...);

template
auto v = __test<_Tp>(0);




Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=299956&r1=299955&r2=299956&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Apr 11 11:05:23 2017
@@ -470,13 +470,6 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
-// If this is a function template and none of its specializations is used,
-// we should warn.
-if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
-  for (const auto *Spec : Template->specializations())
-if (ShouldRemoveFromUnused(SemaRef, Spec))
-  return true;
-
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -500,13 +493,6 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
-if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
-  // If this is a variable template and none of its specializations is 
used,
-  // we should warn.
-  for (const auto *Spec : Template->specializations())
-if (ShouldRemoveFromUnused(SemaRef, Spec))
-  return true;
-
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299956&r1=299955&r2=299956&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 11 11:05:23 2017
@@ -8887,7 +8887,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
-  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
   }
@@ -10988,7 +10987,8 @@ static bool hasDependentAlignment(VarDec
 
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
-void Sema::FinalizeDeclaration(Decl *ThisDecl) {
+void
+Sema::FinalizeDeclaration(Decl *ThisDecl) {
   // Note that we are no longer parsing the initializer for this declaration.
   ParsingInitForAutoVars.erase(ThisDecl);
 
@@ -11153,8 +11153,9 @@ void Sema::FinalizeDeclaration(Decl *Thi
   if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible())
 AddPushedVisibilityAttribute(VD);
 
-  // FIXME: Warn on unused var template partial specializations.
-  if (VD->isFileVarDecl() && !isa(VD))
+  // FIXME: Warn on unused templates.
+  if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() &&
+  !isa(VD))
 MarkUnusedFileScopedDecl(VD);
 
   // Now we have parsed the initializer and can update the table of magic

Modified: cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp?rev=299956&r1=299955&r2=299956&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp Tue Apr 11 11:05:23 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++11 %s
 
 #ifdef HEADER
 
@@ -65,7 +65,7 @@ namespace {
   template <> void TS::m() { }  // expected-warning{{unused}}
 
   template 
-  void tf() { }  // expected-warning{{unused}}
+  void tf() { }
   template <> void tf() { }  // expected-warning{{unused}}
   
   struct VS {
@@ -200,18 +200,6 @@ void bar() { void func() __attribute__((
 static void func() {}
 }
 
-namespace test9 {
-template
-static void completeRedeclChainForTemplateSpecialization() { } // 
expected-warning {{unused}}
-}
-
-namespace test10 {
-#if __cplusplus >= 201103L
-temp

r299930 - Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Apr 11 05:13:54 2017
New Revision: 299930

URL: http://llvm.org/viewvc/llvm-project?rev=299930&view=rev
Log:
Warn about unused static file scope function template declarations.

Reviewed by Richard Smith (D29877)!


Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=299930&r1=299929&r2=299930&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Apr 11 05:13:54 2017
@@ -470,6 +470,13 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and none of its specializations is used,
+// we should warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -493,6 +500,13 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  // If this is a variable template and none of its specializations is 
used,
+  // we should warn.
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299930&r1=299929&r2=299930&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 11 05:13:54 2017
@@ -8887,6 +8887,7 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
+  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
   }
@@ -10987,8 +10988,7 @@ static bool hasDependentAlignment(VarDec
 
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
-void
-Sema::FinalizeDeclaration(Decl *ThisDecl) {
+void Sema::FinalizeDeclaration(Decl *ThisDecl) {
   // Note that we are no longer parsing the initializer for this declaration.
   ParsingInitForAutoVars.erase(ThisDecl);
 
@@ -11153,9 +11153,8 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
   if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible())
 AddPushedVisibilityAttribute(VD);
 
-  // FIXME: Warn on unused templates.
-  if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() &&
-  !isa(VD))
+  // FIXME: Warn on unused var template partial specializations.
+  if (VD->isFileVarDecl() && !isa(VD))
 MarkUnusedFileScopedDecl(VD);
 
   // Now we have parsed the initializer and can update the table of magic

Modified: cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp?rev=299930&r1=299929&r2=299930&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp Tue Apr 11 05:13:54 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++14 %s
 
 #ifdef HEADER
 
@@ -65,7 +65,7 @@ namespace {
   template <> void TS::m() { }  // expected-warning{{unused}}
 
   template 
-  void tf() { }
+  void tf() { }  // expected-warning{{unused}}
   template <> void tf() { }  // expected-warning{{unused}}
   
   struct VS {
@@ -200,6 +200,18 @@ void bar() { void func() __attribute__((
 static void func() {}
 }
 
+namespace test9 {
+template
+static void completeRedeclChainForTemplateSpecialization() { } // 
expected-warning {{unused}}
+}
+
+namespace test10 {
+#if __cplusplus >= 201103L
+template
+constexpr T pi = T(3.14); // expected-warning {{unused}}
+#endif
+}
+
 namespace pr19713 {
 #if __cplusplus >=

r299639 - PR16106: Correct the docs to reflect the actual behavior of the interface.

2017-04-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Apr  6 05:05:46 2017
New Revision: 299639

URL: http://llvm.org/viewvc/llvm-project?rev=299639&view=rev
Log:
PR16106: Correct the docs to reflect the actual behavior of the interface.

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=299639&r1=299638&r2=299639&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Apr  6 05:05:46 2017
@@ -478,8 +478,8 @@ CINDEX_LINKAGE void clang_getExpansionLo
unsigned *offset);
 
 /**
- * \brief Retrieve the file, line, column, and offset represented by
- * the given source location, as specified in a # line directive.
+ * \brief Retrieve the file, line and column represented by the given source
+ * location, as specified in a # line directive.
  *
  * Example: given the following source code in a file somefile.c
  *


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


r298842 - Publish one more parser RAII for external use.

2017-03-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Mar 27 08:11:32 2017
New Revision: 298842

URL: http://llvm.org/viewvc/llvm-project?rev=298842&view=rev
Log:
Publish one more parser RAII for external use.

Modified:
cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h?rev=298842&r1=298841&r2=298842&view=diff
==
--- cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h (original)
+++ cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h Mon Mar 27 08:11:32 
2017
@@ -18,6 +18,7 @@
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Sema/DelayedDiagnostic.h"
+#include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Sema.h"
 
 namespace clang {
@@ -442,6 +443,25 @@ namespace clang {
 void skipToEnd();
   };
 
+  /// \brief RAIIObject to destroy the contents of a SmallVector of
+  /// TemplateIdAnnotation pointers and clear the vector.
+  class DestroyTemplateIdAnnotationsRAIIObj {
+SmallVectorImpl &Container;
+
+  public:
+DestroyTemplateIdAnnotationsRAIIObj(
+SmallVectorImpl &Container)
+: Container(Container) {}
+
+~DestroyTemplateIdAnnotationsRAIIObj() {
+  for (SmallVectorImpl::iterator I =
+   Container.begin(),
+ E = Container.end();
+   I != E; ++I)
+(*I)->Destroy();
+  Container.clear();
+}
+  };
 } // end namespace clang
 
 #endif

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=298842&r1=298841&r2=298842&view=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Mar 27 08:11:32 2017
@@ -37,26 +37,6 @@ public:
 return false;
   }
 };
-
-/// \brief RAIIObject to destroy the contents of a SmallVector of
-/// TemplateIdAnnotation pointers and clear the vector.
-class DestroyTemplateIdAnnotationsRAIIObj {
-  SmallVectorImpl &Container;
-
-public:
-  DestroyTemplateIdAnnotationsRAIIObj(
-  SmallVectorImpl &Container)
-  : Container(Container) {}
-
-  ~DestroyTemplateIdAnnotationsRAIIObj() {
-for (SmallVectorImpl::iterator I =
- Container.begin(),
-   E = Container.end();
- I != E; ++I)
-  (*I)->Destroy();
-Container.clear();
-  }
-};
 } // end anonymous namespace
 
 IdentifierInfo *Parser::getSEHExceptKeyword() {


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


r298824 - Revert r298742 "[ODRHash] Add error messages for mismatched parameters in methods."

2017-03-26 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Mar 26 16:39:16 2017
New Revision: 298824

URL: http://llvm.org/viewvc/llvm-project?rev=298824&view=rev
Log:
Revert r298742 "[ODRHash] Add error messages for mismatched parameters in 
methods."

I failed to revert this in r298816.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=298824&r1=298823&r2=298824&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Sun Mar 26 
16:39:16 2017
@@ -146,12 +146,7 @@ def err_module_odr_violation_mismatch_de
   "method %4 is %select{not static|static}5|"
   "method %4 is %select{not volatile|volatile}5|"
   "method %4 is %select{not const|const}5|"
-  "method %4 is %select{not inline|inline}5|"
-  "method %4 that has %5 parameter%s5|"
-  "method %4 with %ordinal5 parameter of type %6|"
-  "method %4 with %ordinal5 parameter named %6|"
-  "method %4 with %ordinal5 parameter with %select{no |}6default argument|"
-  "method %4 with %ordinal5 parameter with default argument}3">;
+  "method %4 is %select{not inline|inline}5}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -171,12 +166,7 @@ def note_module_odr_violation_mismatch_d
   "method %2 is %select{not static|static}3|"
   "method %2 is %select{not volatile|volatile}3|"
   "method %2 is %select{not const|const}3|"
-  "method %2 is %select{not inline|inline}3|"
-  "method %2 that has %3 parameter%s3|"
-  "method %2 with %ordinal3 parameter of type %4|"
-  "method %2 with %ordinal3 parameter named %4|"
-  "method %2 with %ordinal3 parameter with %select{no |}4default argument|"
-  "method %2 with %ordinal3 parameter with different default argument}1">;
+  "method %2 is %select{not inline|inline}3}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=298824&r1=298823&r2=298824&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Sun Mar 26 16:39:16 2017
@@ -169,11 +169,6 @@ public:
 Inherited::VisitValueDecl(D);
   }
 
-  void VisitParmVarDecl(const ParmVarDecl *D) {
-AddStmt(D->getDefaultArg());
-Inherited::VisitParmVarDecl(D);
-  }
-
   void VisitAccessSpecDecl(const AccessSpecDecl *D) {
 ID.AddInteger(D->getAccess());
 Inherited::VisitAccessSpecDecl(D);
@@ -207,12 +202,6 @@ public:
 Hash.AddBoolean(D->isPure());
 Hash.AddBoolean(D->isDeletedAsWritten());
 
-ID.AddInteger(D->param_size());
-
-for (auto *Param : D->parameters()) {
-  Hash.AddSubDecl(Param);
-}
-
 Inherited::VisitFunctionDecl(D);
   }
 
@@ -326,10 +315,6 @@ public:
 }
   }
 
-  void AddQualType(QualType T) {
-Hash.AddQualType(T);
-  }
-
   void Visit(const Type *T) {
 ID.AddInteger(T->getTypeClass());
 Inherited::Visit(T);
@@ -342,50 +327,6 @@ public:
 VisitType(T);
   }
 
-  void VisitFunctionType(const FunctionType *T) {
-AddQualType(T->getReturnType());
-T->getExtInfo().Profile(ID);
-Hash.AddBoolean(T->isConst());
-Hash.AddBoolean(T->isVolatile());
-Hash.AddBoolean(T->isRestrict());
-VisitType(T);
-  }
-
-  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
-VisitFunctionType(T);
-  }
-
-  void VisitFunctionProtoType(const FunctionProtoType *T) {
-ID.AddInteger(T->getNumParams());
-for (auto ParamType : T->getParamTypes())
-  AddQualType(ParamType);
-
-const auto &epi = T->getExtProtoInfo();
-ID.AddInteger(epi.Variadic);
-ID.AddInteger(epi.TypeQuals);
-ID.AddInteger(epi.RefQualifier);
-ID.AddInteger(epi.ExceptionSpec.Type);
-
-if (epi.ExceptionSpec.Type == EST_Dynamic) {
-  for (QualType Ex : epi.ExceptionSpec.Exceptions)
-AddQualType(Ex);
-} else if (epi.ExceptionSpec.Type == EST_ComputedNoexcept &&
-   epi.ExceptionSpec.NoexceptExpr) {
-  AddStmt(epi.ExceptionSpec.NoexceptExpr);
-} else if (epi.ExceptionSpec.Type == EST_Uninstantiated ||
-   epi.ExceptionSpec.Type == EST_Unevaluated) {
-  AddDecl(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
-}
-if (epi.ExtParameterInfos) {
-  for (unsigned i = 0; i != T->getNumParams(); ++i)
-ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
-}
-epi.ExtInfo.Profile(ID);
-Hash.AddBoolean(epi.HasTrailingReturn);
-

r298816 - Revert 298754 and 298742.

2017-03-26 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Mar 26 13:32:53 2017
New Revision: 298816

URL: http://llvm.org/viewvc/llvm-project?rev=298816&view=rev
Log:
Revert 298754 and 298742.

They broke llvm modules builds and our internal modules infrastructure.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=298816&r1=298815&r2=298816&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Sun Mar 26 
13:32:53 2017
@@ -148,7 +148,7 @@ def err_module_odr_violation_mismatch_de
   "method %4 is %select{not const|const}5|"
   "method %4 is %select{not inline|inline}5|"
   "method %4 that has %5 parameter%s5|"
-  "method %4 with %ordinal5 parameter of type %6%select{| decayed from %8}7|"
+  "method %4 with %ordinal5 parameter of type %6|"
   "method %4 with %ordinal5 parameter named %6|"
   "method %4 with %ordinal5 parameter with %select{no |}6default argument|"
   "method %4 with %ordinal5 parameter with default argument}3">;
@@ -173,7 +173,7 @@ def note_module_odr_violation_mismatch_d
   "method %2 is %select{not const|const}3|"
   "method %2 is %select{not inline|inline}3|"
   "method %2 that has %3 parameter%s3|"
-  "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|"
+  "method %2 with %ordinal3 parameter of type %4|"
   "method %2 with %ordinal3 parameter named %4|"
   "method %2 with %ordinal3 parameter with %select{no |}4default argument|"
   "method %2 with %ordinal3 parameter with different default argument}1">;

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=298816&r1=298815&r2=298816&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Sun Mar 26 13:32:53 2017
@@ -330,10 +330,6 @@ public:
 Hash.AddQualType(T);
   }
 
-  void VisitQualifiers(Qualifiers Quals) {
-ID.AddInteger(Quals.getAsOpaqueValue());
-  }
-
   void Visit(const Type *T) {
 ID.AddInteger(T->getTypeClass());
 Inherited::Visit(T);
@@ -341,43 +337,6 @@ public:
 
   void VisitType(const Type *T) {}
 
-  void VisitAdjustedType(const AdjustedType *T) {
-AddQualType(T->getOriginalType());
-AddQualType(T->getAdjustedType());
-VisitType(T);
-  }
-
-  void VisitDecayedType(const DecayedType *T) {
-AddQualType(T->getDecayedType());
-AddQualType(T->getPointeeType());
-VisitAdjustedType(T);
-  }
-
-  void VisitArrayType(const ArrayType *T) {
-AddQualType(T->getElementType());
-ID.AddInteger(T->getSizeModifier());
-VisitQualifiers(T->getIndexTypeQualifiers());
-VisitType(T);
-  }
-  void VisitConstantArrayType(const ConstantArrayType *T) {
-T->getSize().Profile(ID);
-VisitArrayType(T);
-  }
-
-  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-AddStmt(T->getSizeExpr());
-VisitArrayType(T);
-  }
-
-  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
-VisitArrayType(T);
-  }
-
-  void VisitVariableArrayType(const VariableArrayType *T) {
-AddStmt(T->getSizeExpr());
-VisitArrayType(T);
-  }
-
   void VisitBuiltinType(const BuiltinType *T) {
 ID.AddInteger(T->getKind());
 VisitType(T);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=298816&r1=298815&r2=298816&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Mar 26 13:32:53 2017
@@ -9586,33 +9586,13 @@ void ASTReader::diagnoseOdrViolations()
 for (unsigned I = 0; I < FirstNumParameters; ++I) {
   const ParmVarDecl *FirstParam = FirstMethod->getParamDecl(I);
   const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
-
-  QualType FirstParamType = FirstParam->getType();
-  QualType SecondParamType = SecondParam->getType();
-  if (FirstParamType != SecondParamType) {
-if (const DecayedType *ParamDecayedType =
-FirstParamType->getAs()) {
-  ODRDiagError(FirstMethod->getLocation(),
-   FirstMethod->getSourceRange(), MethodParameterType)
-  << FirstName << (I + 1) << FirstParamType << true
-  << ParamDecayedType->getOriginalType();
-} else {
-  ODRDiagError(FirstMethod->getLocation(),
- 

Re: r298742 - [ODRHash] Add error messages for mismatched parameters in methods.

2017-03-26 Thread Vassil Vassilev via cfe-commits

Hi,

  This seems broke quite a lot of code, similarly to this: 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/5727/steps/compile.llvm.stage2/logs/stdio 
and also 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/4162


  Could we back that out as it broke our internal infrastructure, too.

Cheers, Vassil
On 24/03/17 22:17, Richard Trieu via cfe-commits wrote:

Author: rtrieu
Date: Fri Mar 24 16:17:48 2017
New Revision: 298742

URL: http://llvm.org/viewvc/llvm-project?rev=298742&view=rev
Log:
[ODRHash] Add error messages for mismatched parameters in methods.

Modified:
 cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
 cfe/trunk/lib/AST/ODRHash.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=298742&r1=298741&r2=298742&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Mar 24 
16:17:48 2017
@@ -146,7 +146,12 @@ def err_module_odr_violation_mismatch_de
"method %4 is %select{not static|static}5|"
"method %4 is %select{not volatile|volatile}5|"
"method %4 is %select{not const|const}5|"
-  "method %4 is %select{not inline|inline}5}3">;
+  "method %4 is %select{not inline|inline}5|"
+  "method %4 that has %5 parameter%s5|"
+  "method %4 with %ordinal5 parameter of type %6|"
+  "method %4 with %ordinal5 parameter named %6|"
+  "method %4 with %ordinal5 parameter with %select{no |}6default argument|"
+  "method %4 with %ordinal5 parameter with default argument}3">;
  
  def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "

"%select{"
@@ -166,7 +171,12 @@ def note_module_odr_violation_mismatch_d
"method %2 is %select{not static|static}3|"
"method %2 is %select{not volatile|volatile}3|"
"method %2 is %select{not const|const}3|"
-  "method %2 is %select{not inline|inline}3}1">;
+  "method %2 is %select{not inline|inline}3|"
+  "method %2 that has %3 parameter%s3|"
+  "method %2 with %ordinal3 parameter of type %4|"
+  "method %2 with %ordinal3 parameter named %4|"
+  "method %2 with %ordinal3 parameter with %select{no |}4default argument|"
+  "method %2 with %ordinal3 parameter with different default argument}1">;
  
  def warn_module_uses_date_time : Warning<

"%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=298742&r1=298741&r2=298742&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Mar 24 16:17:48 2017
@@ -169,6 +169,11 @@ public:
  Inherited::VisitValueDecl(D);
}
  
+  void VisitParmVarDecl(const ParmVarDecl *D) {

+AddStmt(D->getDefaultArg());
+Inherited::VisitParmVarDecl(D);
+  }
+
void VisitAccessSpecDecl(const AccessSpecDecl *D) {
  ID.AddInteger(D->getAccess());
  Inherited::VisitAccessSpecDecl(D);
@@ -202,6 +207,12 @@ public:
  Hash.AddBoolean(D->isPure());
  Hash.AddBoolean(D->isDeletedAsWritten());
  
+ID.AddInteger(D->param_size());

+
+for (auto *Param : D->parameters()) {
+  Hash.AddSubDecl(Param);
+}
+
  Inherited::VisitFunctionDecl(D);
}
  
@@ -315,6 +326,10 @@ public:

  }
}
  
+  void AddQualType(QualType T) {

+Hash.AddQualType(T);
+  }
+
void Visit(const Type *T) {
  ID.AddInteger(T->getTypeClass());
  Inherited::Visit(T);
@@ -327,6 +342,50 @@ public:
  VisitType(T);
}
  
+  void VisitFunctionType(const FunctionType *T) {

+AddQualType(T->getReturnType());
+T->getExtInfo().Profile(ID);
+Hash.AddBoolean(T->isConst());
+Hash.AddBoolean(T->isVolatile());
+Hash.AddBoolean(T->isRestrict());
+VisitType(T);
+  }
+
+  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
+VisitFunctionType(T);
+  }
+
+  void VisitFunctionProtoType(const FunctionProtoType *T) {
+ID.AddInteger(T->getNumParams());
+for (auto ParamType : T->getParamTypes())
+  AddQualType(ParamType);
+
+const auto &epi = T->getExtProtoInfo();
+ID.AddInteger(epi.Variadic);
+ID.AddInteger(epi.TypeQuals);
+ID.AddInteger(epi.RefQualifier);
+ID.AddInteger(epi.ExceptionSpec.Type);
+
+if (epi.ExceptionSpec.Type == EST_Dynamic) {
+  for (QualType Ex : epi.ExceptionSpec.Exceptions)
+AddQualType(Ex);
+} else if (epi.ExceptionSpec.Type == EST_ComputedNoexcept &&
+   epi.ExceptionSpec.NoexceptExpr) {
+  AddStmt(epi.ExceptionSpec.NoexceptExpr);
+} else if (epi.Exceptio

r298606 - Publish RAIIObjectsForParser.h for external usage.

2017-03-23 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Mar 23 10:11:07 2017
New Revision: 298606

URL: http://llvm.org/viewvc/llvm-project?rev=298606&view=rev
Log:
Publish RAIIObjectsForParser.h for external usage.

Some clients (eg the cling interpreter) need to recover their parser from
errors.

Patch by Axel Naumann (D31190)!

Added:
cfe/trunk/include/clang/Parse/RAIIObjectsForParser.h
  - copied unchanged from r298605, 
cfe/trunk/lib/Parse/RAIIObjectsForParser.h
Removed:
cfe/trunk/lib/Parse/RAIIObjectsForParser.h
Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=298606&r1=298605&r2=298606&view=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Mar 23 10:11:07 2017
@@ -12,9 +12,9 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Scope.h"
 using namespace clang;

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=298606&r1=298605&r2=298606&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Mar 23 10:11:07 2017
@@ -12,7 +12,7 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/AddressSpaces.h"

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=298606&r1=298605&r2=298606&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Mar 23 10:11:07 2017
@@ -12,7 +12,6 @@
 
//===--===//
 
 #include "clang/Parse/Parser.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/Attributes.h"
@@ -20,6 +19,7 @@
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/PrettyDeclStackTrace.h"

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298606&r1=298605&r2=298606&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Mar 23 10:11:07 2017
@@ -21,10 +21,10 @@
 ///
 
//===--===//
 
-#include "RAIIObjectsForParser.h"
+#include "clang/Parse/Parser.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/PrettyStackTrace.h"
-#include "clang/Parse/Parser.h"
+#include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=298606&r1=298605&r2=298606&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Mar 23 10:11:07 2017
@@ -10,13 +10,13 @@
 // This file implements the Expression parsing implementation for C++.
 //
 
//===--===//
+#include "clang/Parse/Parser.h"
 #include "clang/AST/ASTContext.h"
-#include "RAIIObjectsForParser.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Lex/

r297037 - [modules] Add missing test from r297030.

2017-03-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Mar  6 11:47:57 2017
New Revision: 297037

URL: http://llvm.org/viewvc/llvm-project?rev=297037&view=rev
Log:
[modules] Add missing test from r297030.

Added:
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h
cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap
cfe/trunk/test/Modules/gnumode-non-benign.cpp

Added: cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h (added)
+++ cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.h Mon Mar  6 
11:47:57 2017
@@ -0,0 +1,5 @@
+// Check for GNUMode = 1 by looking for the "linux" define which only exists
+// for GNUMode = 1.
+#ifdef linux
+ #error "Submodule has GNUMode=1"
+#endif

Added: cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/gnumode-non-benign/module.modulemap Mon Mar  
6 11:47:57 2017
@@ -0,0 +1 @@
+module "module.h" { header "module.h"}

Added: cfe/trunk/test/Modules/gnumode-non-benign.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/gnumode-non-benign.cpp?rev=297037&view=auto
==
--- cfe/trunk/test/Modules/gnumode-non-benign.cpp (added)
+++ cfe/trunk/test/Modules/gnumode-non-benign.cpp Mon Mar  6 11:47:57 2017
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -I%S/Inputs/gnumode-non-benign -verify %s
+
+// expected-no-diagnostics
+
+// This test ensures that submodules have the same GNUMode language option
+// setting as the main clang invocation.
+// Note that we set GNUMode = 0 with -std=c++11 for this file.
+
+// This module fails to compile with GNUMode = 1.
+#include "module.h"


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


r297030 - [modules] Make GNUMode a normal language option to fix module compilation.

2017-03-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Mar  6 10:54:40 2017
New Revision: 297030

URL: http://llvm.org/viewvc/llvm-project?rev=297030&view=rev
Log:
[modules] Make GNUMode a normal language option to fix module compilation.

GNUMode shouldn't be a benign language option because it influences the
resulting AST when checking for the existence of GNUMode-specific macro
"linux" (e.g. by having code inside #ifdef linux). This patch marks it as a
normal language option so it gets correctly passed to the compiler invocation
for the used modules.

The added test case illustrated this because it compiles without modules, but
fails when using modules.

Patch by Raphael Isemann (D30496)!

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=297030&r1=297029&r2=297030&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Mar  6 10:54:40 2017
@@ -107,7 +107,7 @@ LANGOPT(WChar , 1, CPlusPlus
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
 BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
-BENIGN_LANGOPT(GNUMode, 1, 1, "GNU extensions")
+LANGOPT(GNUMode   , 1, 1, "GNU extensions")
 LANGOPT(GNUKeywords   , 1, 1, "GNU keywords")
 BENIGN_LANGOPT(ImplicitInt, 1, !C99 && !CPlusPlus, "C89 implicit 'int'")
 LANGOPT(Digraphs  , 1, 0, "digraphs")


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


r296781 - Add coding and shebang.

2017-03-02 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Mar  2 12:47:22 2017
New Revision: 296781

URL: http://llvm.org/viewvc/llvm-project?rev=296781&view=rev
Log:
Add coding and shebang.

Reviewed by Artem Dergachev (D26030)!

Modified:
cfe/trunk/tools/scan-view/share/Reporter.py
cfe/trunk/tools/scan-view/share/startfile.py

Modified: cfe/trunk/tools/scan-view/share/Reporter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/Reporter.py?rev=296781&r1=296780&r2=296781&view=diff
==
--- cfe/trunk/tools/scan-view/share/Reporter.py (original)
+++ cfe/trunk/tools/scan-view/share/Reporter.py Thu Mar  2 12:47:22 2017
@@ -1,3 +1,6 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
 """Methods for reporting bugs."""
 
 import subprocess, sys, os

Modified: cfe/trunk/tools/scan-view/share/startfile.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/startfile.py?rev=296781&r1=296780&r2=296781&view=diff
==
--- cfe/trunk/tools/scan-view/share/startfile.py (original)
+++ cfe/trunk/tools/scan-view/share/startfile.py Thu Mar  2 12:47:22 2017
@@ -1,3 +1,6 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
 """Utility for opening a file using the default application in a cross-platform
 manner. Modified from http://code.activestate.com/recipes/511443/.
 """


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


r296779 - Mark function as llvm dump method.

2017-03-02 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Mar  2 12:13:19 2017
New Revision: 296779

URL: http://llvm.org/viewvc/llvm-project?rev=296779&view=rev
Log:
Mark function as llvm dump method.

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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296779&r1=296778&r2=296779&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Mar  2 12:13:19 2017
@@ -6523,12 +6523,6 @@ Decl *ASTReader::GetExternalDecl(uint32_
   return GetDecl(ID);
 }
 
-template
-static void completeRedeclChainForTemplateSpecialization(Decl *D) {
-  if (auto *TSD = dyn_cast(D))
-TSD->getSpecializedTemplate()->LoadLazySpecializations();
-}
-
 void ASTReader::CompleteRedeclChain(const Decl *D) {
   if (NumCurrentElementsDeserializing) {
 // We arrange to not care about the complete redeclaration chain while 
we're
@@ -7151,7 +7145,7 @@ void ASTReader::PrintStats() {
 }
 
 template
-static void
+LLVM_DUMP_METHOD static void
 dumpModuleIDMap(StringRef Name,
 const ContinuousRangeMap &Map) {


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


r294359 - Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules.

2017-02-07 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Feb  7 15:49:41 2017
New Revision: 294359

URL: http://llvm.org/viewvc/llvm-project?rev=294359&view=rev
Log:
Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules.

Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=294359&r1=294358&r2=294359&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Feb  7 15:49:41 2017
@@ -352,8 +352,9 @@ bool FrontendAction::BeginSourceFile(Com
 goto failure;
   CI.setModuleManager(static_cast(FinalReader.get()));
   CI.getASTContext().setExternalSource(source);
-} else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
-  // Use PCH.
+} else if (CI.getLangOpts().Modules ||
+   !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+  // Use PCM or PCH.
   assert(hasPCHSupport() && "This action does not have PCH support!");
   ASTDeserializationListener *DeserialListener =
   Consumer->GetASTDeserializationListener();
@@ -370,13 +371,24 @@ bool FrontendAction::BeginSourceFile(Com
 DeserialListener, DeleteDeserialListener);
 DeleteDeserialListener = true;
   }
-  CI.createPCHExternalASTSource(
-  CI.getPreprocessorOpts().ImplicitPCHInclude,
-  CI.getPreprocessorOpts().DisablePCHValidation,
+  if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+CI.createPCHExternalASTSource(
+CI.getPreprocessorOpts().ImplicitPCHInclude,
+CI.getPreprocessorOpts().DisablePCHValidation,
   CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, 
DeserialListener,
-  DeleteDeserialListener);
-  if (!CI.getASTContext().getExternalSource())
-goto failure;
+DeleteDeserialListener);
+if (!CI.getASTContext().getExternalSource())
+  goto failure;
+  }
+  // If modules are enabled, create the module manager before creating
+  // any builtins, so that all declarations know that they might be
+  // extended by an external source.
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
+CI.createModuleManager();
+CI.getModuleManager()->setDeserializationListener(DeserialListener,
+
DeleteDeserialListener);
+  }
 }
 
 CI.setASTConsumer(std::move(Consumer));
@@ -386,15 +398,9 @@ bool FrontendAction::BeginSourceFile(Com
 
   // Initialize built-in info as long as we aren't using an external AST
   // source.
-  if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+  !CI.getASTContext().getExternalSource()) {
 Preprocessor &PP = CI.getPreprocessor();
-
-// If modules are enabled, create the module manager before creating
-// any builtins, so that all declarations know that they might be
-// extended by an external source.
-if (CI.getLangOpts().Modules)
-  CI.createModuleManager();
-
 PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
PP.getLangOpts());
   } else {


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


Fwd: buildbot failure in LLVM on lldb-x86_64-ubuntu-14.04-cmake

2017-01-12 Thread Vassil Vassilev via cfe-commits

Hi Sean,

  I am wondering what is the policy when introducing clang API changes. 
Shall I commit a fix in LLDB?


Cheers, Vassil



 Forwarded Message 
Subject:buildbot failure in LLVM on lldb-x86_64-ubuntu-14.04-cmake
Date:   Thu, 12 Jan 2017 01:34:10 -0800
From:   llvm.buildmas...@lab.llvm.org
To: Vassil Vassilev 



The Buildbot has detected a new failure on builder 
lldb-x86_64-ubuntu-14.04-cmake while building cfe.
Full details are available at:
 http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/3269

Buildbot URL: http://lab.llvm.org:8011/

Buildslave for this Build: lldb-build1-ubuntu-1404

Build Reason: scheduler
Build Source Stamp: [branch trunk] 291753
Blamelist: vvassilev

BUILD FAILED: failed ninja build local

sincerely,
 -The Buildbot



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


r291753 - PR31469: Don't add friend template class decls to redecl chain in dependent contexts.

2017-01-12 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jan 12 03:16:26 2017
New Revision: 291753

URL: http://llvm.org/viewvc/llvm-project?rev=291753&view=rev
Log:
PR31469: Don't add friend template class decls to redecl chain in dependent 
contexts.

Fixes a crash in modules where the template class decl becomes the most recent
decl in the redeclaration chain and forcing the template instantiator try to
instantiate the friend declaration, rather than the template definition.

In practice, A::list produces a TemplateSpecializationType
A::__1::list >' failing to replace to
subsitute the default argument to allocator.

Kudos Richard Smith (D28399).

Added:
cfe/trunk/test/Modules/Inputs/PR31469/
cfe/trunk/test/Modules/Inputs/PR31469/empty.h
cfe/trunk/test/Modules/Inputs/PR31469/module.modulemap
cfe/trunk/test/Modules/Inputs/PR31469/textual.h
cfe/trunk/test/Modules/Inputs/PR31469/textual_file_shadow.h
cfe/trunk/test/Modules/pr31469.cpp
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/Misc/ast-dump-decl.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=291753&r1=291752&r2=291753&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Jan 12 03:16:26 2017
@@ -2028,8 +2028,7 @@ public:
SourceLocation L,
DeclarationName Name,
TemplateParameterList *Params,
-   NamedDecl *Decl,
-   ClassTemplateDecl *PrevDecl);
+   NamedDecl *Decl);
 
   /// \brief Create an empty class template node.
   static ClassTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=291753&r1=291752&r2=291753&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Jan 12 03:16:26 2017
@@ -4671,8 +4671,7 @@ Decl *ASTNodeImporter::VisitClassTemplat
 
   ClassTemplateDecl *D2 = ClassTemplateDecl::Create(Importer.getToContext(), 
DC, 
 Loc, Name, TemplateParams, 
-D2Templated, 
-/*PrevDecl=*/nullptr);
+D2Templated);
   D2Templated->setDescribedClassTemplate(D2);
   
   D2->setAccess(D->getAccess());

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=291753&r1=291752&r2=291753&view=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Jan 12 03:16:26 2017
@@ -297,12 +297,10 @@ ClassTemplateDecl *ClassTemplateDecl::Cr
  SourceLocation L,
  DeclarationName Name,
  TemplateParameterList *Params,
- NamedDecl *Decl,
- ClassTemplateDecl *PrevDecl) {
+ NamedDecl *Decl) {
   AdoptTemplateParameterList(Params, cast(Decl));
   ClassTemplateDecl *New = new (C, DC) ClassTemplateDecl(C, DC, L, Name,
  Params, Decl);
-  New->setPreviousDecl(PrevDecl);
   return New;
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=291753&r1=291752&r2=291753&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jan 12 03:16:26 2017
@@ -1224,9 +1224,17 @@ Sema::CheckClassTemplate(Scope *S, unsig
 }
   }
 
+  // If this is a templated friend in a dependent context we should not put it
+  // on the redecl chain. In some cases, the templated friend can be the most
+  // recent declaration tricking the template instantiator to make 
substitutions
+  // there.
+  // FIXME: Figure out how to combine with shouldLinkDependentDeclWithPrevious
+  bool ShouldAddRedecl
+= !(TUK == TUK_Friend && CurContext->isDependentContext());
+
   CXXRecordDecl *NewClass =
 CXXR

r291552 - Remove fixme, use ASTContext::getCanonicalTemplateSpecializationType.

2017-01-10 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Jan 10 03:09:09 2017
New Revision: 291552

URL: http://llvm.org/viewvc/llvm-project?rev=291552&view=rev
Log:
Remove fixme, use ASTContext::getCanonicalTemplateSpecializationType.

Reviewed by Richard Smith (D28306).

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=291552&r1=291551&r2=291552&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Jan 10 03:09:09 2017
@@ -2328,15 +2328,7 @@ QualType Sema::CheckTemplateIdType(Templ
 // A have identical types when A is declared as:
 //
 //   template struct A;
-TemplateName CanonName = Context.getCanonicalTemplateName(Name);
-CanonType = Context.getTemplateSpecializationType(CanonName,
-  Converted);
-
-// FIXME: CanonType is not actually the canonical type, and unfortunately
-// it is a TemplateSpecializationType that we will never use again.
-// In the future, we need to teach getTemplateSpecializationType to only
-// build the canonical type and return that to us.
-CanonType = Context.getCanonicalType(CanonType);
+CanonType = Context.getCanonicalTemplateSpecializationType(Name, 
Converted);
 
 // This might work out to be a current instantiation, in which
 // case the canonical type needs to be the InjectedClassNameType.
@@ -3444,7 +3436,7 @@ SubstDefaultTemplateArgument(Sema &SemaR
  SourceLocation TemplateLoc,
  SourceLocation RAngleLoc,
  TemplateTypeParmDecl *Param,
- SmallVectorImpl &Converted) {
+ SmallVectorImpl &Converted) {
   TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo();
 
   // If the argument type is dependent, instantiate it now based


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


Re: r253495 - [Sema] Don't work around a malformed AST

2017-01-10 Thread Vassil Vassilev via cfe-commits

On 18/11/15 20:49, David Majnemer via cfe-commits wrote:

Author: majnemer
Date: Wed Nov 18 13:49:19 2015
New Revision: 253495

URL: http://llvm.org/viewvc/llvm-project?rev=253495&view=rev
Log:
[Sema] Don't work around a malformed AST

We created a malformed TemplateSpecializationType: it was dependent but
had a RecordType as it's canonical type.  This would lead getAs to
crash.  r249090 worked around this but we should fix this for real by
providing a more appropriate template specialization type as the
canonical type.

This fixes PR24246.

Modified:
 cfe/trunk/lib/Sema/SemaLookup.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=253495&r1=253494&r2=253495&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Nov 18 13:49:19 2015
@@ -3890,8 +3890,6 @@ void TypoCorrectionConsumer::addNamespac
auto &Types = SemaRef.getASTContext().getTypes();
for (unsigned I = 0; I != Types.size(); ++I) {
  const auto *TI = Types[I];
-if (!TI->isClassType() && isa(TI))
-  continue;
  if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) {
CD = CD->getCanonicalDecl();
if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=253495&r1=253494&r2=253495&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Nov 18 13:49:19 2015
@@ -6408,7 +6408,17 @@ Sema::ActOnClassTemplateSpecialization(S
  if (!PrevDecl)
ClassTemplate->AddSpecialization(Specialization, InsertPos);
  
-CanonType = Context.getTypeDeclType(Specialization);

+if (CurContext->isDependentContext()) {
+  // -fms-extensions permits specialization of nested classes without
+  // fully specializing the outer class(es).
+  assert(getLangOpts().MicrosoftExt &&
+ "Only possible with -fms-extensions!");
+  TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
+  CanonType = Context.getTemplateSpecializationType(
Out of curiosity, could we use getCanonicalTemplateSpecializationType 
here and produce one less type?

+  CanonTemplate, Converted.data(), Converted.size());
+} else {
+  CanonType = Context.getTypeDeclType(Specialization);
+}
}
  
// C++ [temp.expl.spec]p6:



___
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] D27180: Testbed and skeleton of a new expression parser

2016-12-19 Thread Vassil Vassilev via cfe-commits

On 19/12/16 17:55, David Blaikie wrote:



On Thu, Dec 15, 2016 at 2:18 PM Sean Callanan via Phabricator via 
cfe-commits > wrote:


spyffe updated this revision to Diff 81661.
spyffe marked 2 inline comments as done.
spyffe added a comment.
Herald added a subscriber: jgosnell.

Applied Vassil and Vedant's comments.  I will commit this soon.


Was this change approved/accepted by anyone? "commit if no one has 
objections in " isn't generally how LLVM project changes 
are reviewed/committed.
I could have greenlit this (as I personally pinged Sean on this patch. I 
need some of it to make progress on the libInterpreter part) :(




Repository:
  rL LLVM

https://reviews.llvm.org/D27180

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

___
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


r289213 - Document and publish the useful module-file-info flag.

2016-12-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Dec  9 08:20:32 2016
New Revision: 289213

URL: http://llvm.org/viewvc/llvm-project?rev=289213&view=rev
Log:
Document and publish the useful module-file-info flag.

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=289213&r1=289212&r2=289213&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Dec  9 08:20:32 2016
@@ -1851,7 +1851,8 @@ def mno_odd_spreg : Flag<["-"], "mno-odd
   Flags<[HelpHidden]>;
 def mglibc : Flag<["-"], "mglibc">, Group, Flags<[HelpHidden]>;
 def muclibc : Flag<["-"], "muclibc">, Group, Flags<[HelpHidden]>;
-def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1Option]>, Group;
+def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1Option]>, Group,
+  HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group;
 def multi__module : Flag<["-"], "multi_module">;


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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-11-03 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

Could you include more context when creating the diff eg. git diff -U, or 
equivalent.




Comment at: include/clang/Lex/ModuleMap.h:278
+  /// headers.
+  static bool isBuiltinHeader(StringRef FileName);
+

It seems this is in the private section and it is accessed by 
FrontendActions.cpp:224.


https://reviews.llvm.org/D26267



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


[PATCH] D26030: Add shebang.

2016-10-27 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: NoQ, zaks.anna.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.

This is another home grown patch I'd like to upstream.


Repository:
  rL LLVM

https://reviews.llvm.org/D26030

Files:
  tools/scan-view/share/Reporter.py
  tools/scan-view/share/startfile.py


Index: tools/scan-view/share/startfile.py
===
--- tools/scan-view/share/startfile.py
+++ tools/scan-view/share/startfile.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """Utility for opening a file using the default application in a cross-platform
 manner. Modified from http://code.activestate.com/recipes/511443/.
 """
Index: tools/scan-view/share/Reporter.py
===
--- tools/scan-view/share/Reporter.py
+++ tools/scan-view/share/Reporter.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """Methods for reporting bugs."""
 
 import subprocess, sys, os


Index: tools/scan-view/share/startfile.py
===
--- tools/scan-view/share/startfile.py
+++ tools/scan-view/share/startfile.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """Utility for opening a file using the default application in a cross-platform
 manner. Modified from http://code.activestate.com/recipes/511443/.
 """
Index: tools/scan-view/share/Reporter.py
===
--- tools/scan-view/share/Reporter.py
+++ tools/scan-view/share/Reporter.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """Methods for reporting bugs."""
 
 import subprocess, sys, os
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25605: Empty the C/DtorLists once emitted. This is essential when running in incremental processing mode, because we don't want to reemit the 'tors over and over again.

2016-10-27 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r285277.


Repository:
  rL LLVM

https://reviews.llvm.org/D25605



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


r285277 - Empty the CtorLists/DtorLists once emitted.

2016-10-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Oct 27 04:12:20 2016
New Revision: 285277

URL: http://llvm.org/viewvc/llvm-project?rev=285277&view=rev
Log:
Empty the CtorLists/DtorLists once emitted.

This is essential when clang is running in incremental processing mode because
we don't want to reemit the 'tors over and over again.

Patch by Axel Naumann!

Reviewed by Richard Smith and me. (https://reviews.llvm.org/D25605)

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=285277&r1=285276&r2=285277&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct 27 04:12:20 2016
@@ -721,7 +721,7 @@ void CodeGenModule::AddGlobalDtor(llvm::
   GlobalDtors.push_back(Structor(Priority, Dtor, nullptr));
 }
 
-void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) {
+void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) {
   // Ctor function type is void()*.
   llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false);
   llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy);
@@ -749,6 +749,7 @@ void CodeGenModule::EmitCtorList(const C
  llvm::ConstantArray::get(AT, Ctors),
  GlobalName);
   }
+  Fns.clear();
 }
 
 llvm::GlobalValue::LinkageTypes

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=285277&r1=285276&r2=285277&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Oct 27 04:12:20 2016
@@ -1209,10 +1209,10 @@ private:
  llvm::Constant *AssociatedData = nullptr);
   void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
 
-  /// Generates a global array of functions and priorities using the given list
-  /// and name. This array will have appending linkage and is suitable for use
-  /// as a LLVM constructor or destructor array.
-  void EmitCtorList(const CtorList &Fns, const char *GlobalName);
+  /// EmitCtorList - Generates a global array of functions and priorities using
+  /// the given list and name. This array will have appending linkage and is
+  /// suitable for use as a LLVM constructor or destructor array. Clears Fns.
+  void EmitCtorList(CtorList &Fns, const char *GlobalName);
 
   /// Emit any needed decls for which code generation was deferred.
   void EmitDeferred();


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


[PATCH] D25604: Add support for Mageia Linux

2016-10-26 Thread Vassil Vassilev via cfe-commits
v.g.vassilev removed rL LLVM as the repository for this revision.
v.g.vassilev updated this revision to Diff 75868.
v.g.vassilev added a comment.

Add another triple we use.


https://reviews.llvm.org/D25604

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1521,6 +1521,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu", "x86_64-redhat-linux-gnu"
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1529,6 +1530,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu", "i586-redhat-linux-gnu"
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1521,6 +1521,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu", "x86_64-redhat-linux-gnu"
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1529,6 +1530,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu", "i586-redhat-linux-gnu"
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285184 - [modules] PR28812: Modules can return duplicate field decls.

2016-10-26 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Oct 26 05:24:29 2016
New Revision: 285184

URL: http://llvm.org/viewvc/llvm-project?rev=285184&view=rev
Log:
[modules] PR28812: Modules can return duplicate field decls.

If two modules contain duplicate class definitions the lookup result can contain
more than 2 elements. Sift the lookup results until we find a field decl.

It is not necessary to do ODR checks in place as they done elsewhere.

This should fix issues when compiling with libstdc++ 5.2 and 6.2.

Patch developed in collaboration with Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/PR28812/
cfe/trunk/test/Modules/Inputs/PR28812/Textual.h
cfe/trunk/test/Modules/Inputs/PR28812/a.h
cfe/trunk/test/Modules/Inputs/PR28812/b.h
cfe/trunk/test/Modules/Inputs/PR28812/module.modulemap
cfe/trunk/test/Modules/pr28812.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=285184&r1=285183&r2=285184&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Oct 26 05:24:29 2016
@@ -12321,13 +12321,20 @@ ExprResult Sema::BuildCXXDefaultInitExpr
 // Lookup can return at most two results: the pattern for the field, or the
 // injected class name of the parent record. No other member can have the
 // same name as the field.
-assert(!Lookup.empty() && Lookup.size() <= 2 &&
+// In modules mode, lookup can return multiple results (coming from
+// different modules).
+assert((getLangOpts().Modules || (!Lookup.empty() && Lookup.size() <= 2)) 
&&
"more than two lookup results for field name");
 FieldDecl *Pattern = dyn_cast(Lookup[0]);
 if (!Pattern) {
   assert(isa(Lookup[0]) &&
  "cannot have other non-field member with same name");
-  Pattern = cast(Lookup[1]);
+  for (auto L : Lookup)
+if (isa(L)) {
+  Pattern = cast(L);
+  break;
+}
+  assert(Pattern && "We must have set the Pattern!");
 }
 
 if (InstantiateInClassInitializer(Loc, Field, Pattern,

Added: cfe/trunk/test/Modules/Inputs/PR28812/Textual.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28812/Textual.h?rev=285184&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28812/Textual.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR28812/Textual.h Wed Oct 26 05:24:29 2016
@@ -0,0 +1,11 @@
+#ifndef T_H
+#define T_H
+
+template  struct VarStreamArray;
+
+template  struct VarStreamArrayIterator {
+  VarStreamArrayIterator(VarStreamArray) {}
+  bool HasError{};
+};
+
+#endif // T_H

Added: cfe/trunk/test/Modules/Inputs/PR28812/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28812/a.h?rev=285184&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28812/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR28812/a.h Wed Oct 26 05:24:29 2016
@@ -0,0 +1 @@
+#include "Textual.h"

Added: cfe/trunk/test/Modules/Inputs/PR28812/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28812/b.h?rev=285184&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28812/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR28812/b.h Wed Oct 26 05:24:29 2016
@@ -0,0 +1 @@
+#include "Textual.h"

Added: cfe/trunk/test/Modules/Inputs/PR28812/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28812/module.modulemap?rev=285184&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28812/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR28812/module.modulemap Wed Oct 26 05:24:29 
2016
@@ -0,0 +1,6 @@
+module "A" {
+  header "a.h"
+}
+module "B" { 
+  header "b.h"
+}

Added: cfe/trunk/test/Modules/pr28812.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr28812.cpp?rev=285184&view=auto
==
--- cfe/trunk/test/Modules/pr28812.cpp (added)
+++ cfe/trunk/test/Modules/pr28812.cpp Wed Oct 26 05:24:29 2016
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28812 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fimplicit-module-maps 
\
+// RUN:-fmodules-cache-path=%t -I%S/Inputs/PR28812 -verify %s
+
+template  struct VarStreamArrayIterator;
+template 
+struct VarStreamArray {
+  typedef VarStreamArrayIterator Iterator;
+  Iterator begin() { return Iterator(*this); }
+};
+
+#include "Textual.h"
+
+#include "a.h"
+#include "b.h"
+
+VarStreamArray a;
+auto b = a.begin();

Re: r284577 - [modules] Do not report missing definitions of demoted constexpr variable templates.

2016-10-21 Thread Vassil Vassilev via cfe-commits

On 21/10/16 00:19, Manman wrote:

On Oct 19, 2016, at 4:19 AM, Vassil Vassilev via cfe-commits 
 wrote:

Author: vvassilev
Date: Wed Oct 19 06:19:30 2016
New Revision: 284577

URL: http://llvm.org/viewvc/llvm-project?rev=284577&view=rev
Log:
[modules] Do not report missing definitions of demoted constexpr variable 
templates.

This is a followup to regression introduced in r284284.

This should fix our libstdc++ modules builds.

https://reviews.llvm.org/D25678

Reviewed by Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284577&r1=284576&r2=284577&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 19 06:19:30 2016
@@ -10124,7 +10124,11 @@ void Sema::ActOnUninitializedDecl(Decl *
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert((!Var->isThisDeclarationADemotedDefinition() ||
+  getLangOpts().Modules) &&
+ "Demoting decls is only in the contest of modules!”);

Just noticed the mismatch between this commit and the last reviewed patch :]
The assert is still here.

Good catch! Done in r284877.


Manman


   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,8 @@
+#ifndef A_H
+#define A_H
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,9 @@
+#ifndef B1_H
+#define B1_H
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#include "a.h"
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,9 @@
+#ifndef B2_H
+#define B2_H
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap 
(added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap Wed 
Oct 19 06:19:30 2016
@@ -0,0 +1,5 @@
+module a { header "a.h" export * }
+module b {
+  module b1 { header "b1.h" export * }
+  module b2 { header "b2.h" export * }
+}

Added: cfe/trunk/test/Modules/merge-var-template-def.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-var-template-def.cpp?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/merge-var-template-def.cpp (added)
+++ cfe/trunk/test/Modules/merge-var-template-def.cpp Wed Oct 19 06:19:30 2016
@@ -0,0 +1,7 @@
+//

r284877 - Remove accidentally checked in assert.

2016-10-21 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Oct 21 15:30:30 2016
New Revision: 284877

URL: http://llvm.org/viewvc/llvm-project?rev=284877&view=rev
Log:
Remove accidentally checked in assert.

Thanks to Manman for spotting this.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284877&r1=284876&r2=284877&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Oct 21 15:30:30 2016
@@ -10124,9 +10124,6 @@ void Sema::ActOnUninitializedDecl(Decl *
 // member.
 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
 !Var->isThisDeclarationADemotedDefinition()) {
-  assert((!Var->isThisDeclarationADemotedDefinition() ||
-  getLangOpts().Modules) &&
- "Demoting decls is only in the contest of modules!");
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.


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


[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-19 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a subscriber: rsmith.
v.g.vassilev added inline comments.



Comment at: clang-tidy/utils/UsingInserter.cpp:58
+  if (AlreadyHasUsingDecl) {
+AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
+return None;

bkramer wrote:
> v.g.vassilev wrote:
> > Using emplace seems to break our modules libstdc++ 4.7 builds: 
> > http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6066
> >  . Doesn't that break other 4.7 or earlier builds?
> GCC 4.7 isn't supported anymore by LLVM (rL284497) can we update that bot to 
> a newer version of GCC?
It is managed by @rsmith . He should be able to tell.


https://reviews.llvm.org/D24997



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


[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-19 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang-tidy/utils/UsingInserter.cpp:58
+  if (AlreadyHasUsingDecl) {
+AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
+return None;

Using emplace seems to break our modules libstdc++ 4.7 builds: 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6066
 . Doesn't that break other 4.7 or earlier builds?


https://reviews.llvm.org/D24997



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


Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

2016-10-19 Thread Vassil Vassilev via cfe-commits
I totally misinterpreted this revert. I was confused it reverted 
r284284. Sorry for the noise. With the fix introduced in r284577 our 
bots should be happy.

On 19/10/16 09:50, Vassil Vassilev wrote:


On 17/10/16 17:07, Benjamin Kramer wrote:

I'm running into something else and your patch doesn't fix it. It
boils down to 'std::is_nothrow_move_constructible' from libstdc++
not compiling because Foo is not visible inside the noexcept
specification of that template. I failed to come up with a small test
case so far as it involves at least 2 modules :[

Sigh... :(

Did you have the time to find a reproducer for this issue, we are very 
interested in relanding this patch.




On Mon, Oct 17, 2016 at 4:44 PM, Vassil Vassilev 
 wrote:

On 17/10/16 16:40, Benjamin Kramer wrote:

Too slow ;)

Do you have the fix somewhere, so I can try it?

That would be https://reviews.llvm.org/D25678

Do you run into something else than what I have as a test case (merging
templated constexpr variables)?

On Mon, Oct 17, 2016 at 4:38 PM, Vassil Vassilev 


wrote:

I was just to commit a fix :(

On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Mon Oct 17 08:00:44 2016
New Revision: 284382

URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev
Log:
Revert "Reinstate r281429, reverted in r281452, with a fix for its
mishandling of"

This reverts commit r284176. It still marks some modules as 
invisible
that should be visible. Will follow up with the author with a 
test case.


Removed:
cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h

cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap 


   cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
   cfe/trunk/include/clang/AST/ASTContext.h
   cfe/trunk/lib/AST/ASTContext.cpp
   cfe/trunk/lib/Serialization/ASTReader.cpp

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h
cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff 




== 


--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 
2016

@@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
  /// merged into.
  llvm::DenseMap MergedDecls;
-  /// The modules into which a definition has been merged, 
or a map

from a
-  /// merged definition to its canonical definition. This is 
really a

union of
-  /// a NamedDecl* and a vector of Module*.
-  struct MergedModulesOrCanonicalDef {
-llvm::TinyPtrVector MergedModules;
-NamedDecl *CanonicalDef = nullptr;
-  };
-
  /// \brief A mapping from a defining declaration to a list of
modules
(other
  /// than the owning module of the declaration) that contain 
merged

  /// definitions of that entity.
-  llvm::DenseMap
MergedDefModules;
+  llvm::DenseMap>
MergedDefModules;
/// \brief Initializers for a module, in order. Each Decl 
will be

either
  /// something that has a semantic effect on startup (such as a
variable with
@@ -891,7 +883,6 @@ public:
  /// and should be visible whenever \p M is visible.
  void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
 bool NotifyListeners = true);
-  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl 
*Other);
  /// \brief Clean up the merged definition list. Call this 
if you

might
have
  /// added duplicates into the list.
  void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -902,9 +893,7 @@ public:
auto MergedIt = MergedDefModules.find(Def);
if (MergedIt == MergedDefModules.end())
  return None;
-if (auto *CanonDef = MergedIt->second.CanonicalDef)
-  return getModulesWithMergedDefinition(CanonDef);
-return MergedIt->second.MergedModules;
+return MergedIt->second;
  }
/// Add a declaration to the list of declarations that are
initialized

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff 




== 


--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016
@@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu
if (auto *Listener = getASTMutationListener())
  Listener->RedefinedHiddenD

[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-19 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r284577.


https://reviews.llvm.org/D25678



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


r284577 - [modules] Do not report missing definitions of demoted constexpr variable templates.

2016-10-19 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Oct 19 06:19:30 2016
New Revision: 284577

URL: http://llvm.org/viewvc/llvm-project?rev=284577&view=rev
Log:
[modules] Do not report missing definitions of demoted constexpr variable 
templates.

This is a followup to regression introduced in r284284.

This should fix our libstdc++ modules builds.

https://reviews.llvm.org/D25678

Reviewed by Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284577&r1=284576&r2=284577&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 19 06:19:30 2016
@@ -10124,7 +10124,11 @@ void Sema::ActOnUninitializedDecl(Decl *
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert((!Var->isThisDeclarationADemotedDefinition() ||
+  getLangOpts().Modules) &&
+ "Demoting decls is only in the contest of modules!");
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,8 @@
+#ifndef A_H
+#define A_H
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,9 @@
+#ifndef B1_H
+#define B1_H
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#include "a.h"
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h Wed Oct 19 
06:19:30 2016
@@ -0,0 +1,9 @@
+#ifndef B2_H
+#define B2_H
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap 
(added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap Wed 
Oct 19 06:19:30 2016
@@ -0,0 +1,5 @@
+module a { header "a.h" export * }
+module b {
+  module b1 { header "b1.h" export * }
+  module b2 { header "b2.h" export * }
+}

Added: cfe/trunk/test/Modules/merge-var-template-def.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-var-template-def.cpp?rev=284577&view=auto
==
--- cfe/trunk/test/Modules/merge-var-template-def.cpp (added)
+++ cfe/trunk/test/Modules/merge-var-template-def.cpp Wed Oct 19 06:19:30 2016
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify 
-fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
+// expected-no-diagnostics
+
+#include "b2.h"
+const bool *y = &S::value;



Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

2016-10-19 Thread Vassil Vassilev via cfe-commits


On 17/10/16 17:07, Benjamin Kramer wrote:

I'm running into something else and your patch doesn't fix it. It
boils down to 'std::is_nothrow_move_constructible' from libstdc++
not compiling because Foo is not visible inside the noexcept
specification of that template. I failed to come up with a small test
case so far as it involves at least 2 modules :[

Sigh... :(

Did you have the time to find a reproducer for this issue, we are very 
interested in relanding this patch.




On Mon, Oct 17, 2016 at 4:44 PM, Vassil Vassilev  wrote:

On 17/10/16 16:40, Benjamin Kramer wrote:

Too slow ;)

Do you have the fix somewhere, so I can try it?

That would be https://reviews.llvm.org/D25678

Do you run into something else than what I have as a test case (merging
templated constexpr variables)?


On Mon, Oct 17, 2016 at 4:38 PM, Vassil Vassilev 
wrote:

I was just to commit a fix :(

On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Mon Oct 17 08:00:44 2016
New Revision: 284382

URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev
Log:
Revert "Reinstate r281429, reverted in r281452, with a fix for its
mishandling of"

This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

Removed:
   cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
   cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
   cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h

cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
   cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
   cfe/trunk/include/clang/AST/ASTContext.h
   cfe/trunk/lib/AST/ASTContext.cpp
   cfe/trunk/lib/Serialization/ASTReader.cpp

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h

cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h
   cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff


==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016
@@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
  /// merged into.
  llvm::DenseMap MergedDecls;
-  /// The modules into which a definition has been merged, or a map
from a
-  /// merged definition to its canonical definition. This is really a
union of
-  /// a NamedDecl* and a vector of Module*.
-  struct MergedModulesOrCanonicalDef {
-llvm::TinyPtrVector MergedModules;
-NamedDecl *CanonicalDef = nullptr;
-  };
-
  /// \brief A mapping from a defining declaration to a list of
modules
(other
  /// than the owning module of the declaration) that contain merged
  /// definitions of that entity.
-  llvm::DenseMap
MergedDefModules;
+  llvm::DenseMap>
MergedDefModules;
/// \brief Initializers for a module, in order. Each Decl will be
either
  /// something that has a semantic effect on startup (such as a
variable with
@@ -891,7 +883,6 @@ public:
  /// and should be visible whenever \p M is visible.
  void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
 bool NotifyListeners = true);
-  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
  /// \brief Clean up the merged definition list. Call this if you
might
have
  /// added duplicates into the list.
  void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -902,9 +893,7 @@ public:
auto MergedIt = MergedDefModules.find(Def);
if (MergedIt == MergedDefModules.end())
  return None;
-if (auto *CanonDef = MergedIt->second.CanonicalDef)
-  return getModulesWithMergedDefinition(CanonDef);
-return MergedIt->second.MergedModules;
+return MergedIt->second;
  }
/// Add a declaration to the list of declarations that are
initialized

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff


==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016
@@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu
if (auto *Listener = getASTMutationListener())
  Listener->RedefinedHiddenDefinition(ND, M);
-  auto *Merged = &MergedDefModules[ND];
-  if (auto *CanonDef = Merged->CanonicalDef) {
-ND = CanonDef;
-Merged = &MergedDefModules[ND];
-  }
-  assert(!Merged->CanonicalDef &

[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 75050.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Remove assert.


https://reviews.llvm.org/D25678

Files:
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/merge-var-template-def/a.h
  test/Modules/Inputs/merge-var-template-def/b1.h
  test/Modules/Inputs/merge-var-template-def/b2.h
  test/Modules/merge-var-template-def.cpp


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules 
-Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify 
-fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #include "a.h"
 #endif
Index: test/Modules/Inputs/merge-var-template-def/a.h
===
--- test/Modules/Inputs/merge-var-template-def/a.h
+++ test/Modules/Inputs/merge-var-template-def/a.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10124,7 +10124,8 @@
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+templat

[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

Also, creduce (I've specialized it a bit for modules) helps reducing the 
modules complexity 
(https://github.com/vgvassilev/creduce/blob/master/USAGE.md#reducing-clang-c-modules-bugs).
 After reduction, the debugger is much more useful.


https://reviews.llvm.org/D22638



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


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

I am not sure whether that's useful for debugging out-of-date issues but this 
is what I use and it is helpful.

Some debugging aids (suggested by Richard Smith):

  -fdiagnostics-show-note-include-stack will tell you which module a note comes 
from
  #pragma clang __debug dump X allows you to produce an AST dump from within a 
source file, so you can see which modules declare a given name
  #pragma clang __debug macro M allows you to dump a macro, which can be useful 
to see which module(s) export visible include guards for a header

If a name is not visible in a modules build but is visible in a non-modules 
build, i usually find that's due to one of two things

  some part of the machinery that provides it depends on macro definitions 
leaking into a modular header from outside, or
  there is an include cycle involving a modular header and a non-modular header


https://reviews.llvm.org/D22638



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


[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10129
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert(Var->isThisDeclarationADemotedDefinition() && 
getLangOpts().Modules
+ && "Demoting decls is only in the contest of modules!");

manmanren wrote:
> Is the logic correct here? The if statement says 
> !Var->isThisDeclarationADemotedDefinition(), and we then assert 
> Var->isThisDeclarationADemotedDefinition() && getLangOpts().Modules.
Oops, that is an old version of the patch. Uploading the new one.


https://reviews.llvm.org/D25678



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


[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev removed rL LLVM as the repository for this revision.
v.g.vassilev updated this revision to Diff 74955.
v.g.vassilev marked an inline comment as done.

https://reviews.llvm.org/D25678

Files:
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/merge-var-template-def/a.h
  test/Modules/Inputs/merge-var-template-def/b1.h
  test/Modules/Inputs/merge-var-template-def/b2.h
  test/Modules/merge-var-template-def.cpp


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules 
-Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify 
-fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #include "a.h"
 #endif
Index: test/Modules/Inputs/merge-var-template-def/a.h
===
--- test/Modules/Inputs/merge-var-template-def/a.h
+++ test/Modules/Inputs/merge-var-template-def/a.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10124,7 +10124,11 @@
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert((!Var->isThisDeclarationADemotedDefinition() ||
+  getLangOpts().Modules) &&
+ "Demoting decls is only in the contest of modules!");
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@

[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-17 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, bkramer.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D25678

Files:
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/merge-var-template-def/a.h
  test/Modules/Inputs/merge-var-template-def/b1.h
  test/Modules/Inputs/merge-var-template-def/b2.h
  test/Modules/merge-var-template-def.cpp


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules 
-Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify 
-fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #include "a.h"
 #endif
Index: test/Modules/Inputs/merge-var-template-def/a.h
===
--- test/Modules/Inputs/merge-var-template-def/a.h
+++ test/Modules/Inputs/merge-var-template-def/a.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10124,7 +10124,10 @@
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert(Var->isThisDeclarationADemotedDefinition() && 
getLangOpts().Modules
+ && "Demoting decls is only in the contest of modules!");
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/In

Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

2016-10-17 Thread Vassil Vassilev via cfe-commits

On 17/10/16 16:40, Benjamin Kramer wrote:

Too slow ;)

Do you have the fix somewhere, so I can try it?

That would be https://reviews.llvm.org/D25678

Do you run into something else than what I have as a test case (merging 
templated constexpr variables)?


On Mon, Oct 17, 2016 at 4:38 PM, Vassil Vassilev  wrote:

I was just to commit a fix :(

On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Mon Oct 17 08:00:44 2016
New Revision: 284382

URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev
Log:
Revert "Reinstate r281429, reverted in r281452, with a fix for its
mishandling of"

This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

Removed:
  cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
  cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
  cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
  cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
  cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
  cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
  cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h
  cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h
  cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff

==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016
@@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
 /// merged into.
 llvm::DenseMap MergedDecls;
   -  /// The modules into which a definition has been merged, or a map
from a
-  /// merged definition to its canonical definition. This is really a
union of
-  /// a NamedDecl* and a vector of Module*.
-  struct MergedModulesOrCanonicalDef {
-llvm::TinyPtrVector MergedModules;
-NamedDecl *CanonicalDef = nullptr;
-  };
-
 /// \brief A mapping from a defining declaration to a list of modules
(other
 /// than the owning module of the declaration) that contain merged
 /// definitions of that entity.
-  llvm::DenseMap
MergedDefModules;
+  llvm::DenseMap>
MergedDefModules;
   /// \brief Initializers for a module, in order. Each Decl will be
either
 /// something that has a semantic effect on startup (such as a
variable with
@@ -891,7 +883,6 @@ public:
 /// and should be visible whenever \p M is visible.
 void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
bool NotifyListeners = true);
-  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
 /// \brief Clean up the merged definition list. Call this if you might
have
 /// added duplicates into the list.
 void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -902,9 +893,7 @@ public:
   auto MergedIt = MergedDefModules.find(Def);
   if (MergedIt == MergedDefModules.end())
 return None;
-if (auto *CanonDef = MergedIt->second.CanonicalDef)
-  return getModulesWithMergedDefinition(CanonDef);
-return MergedIt->second.MergedModules;
+return MergedIt->second;
 }
   /// Add a declaration to the list of declarations that are
initialized

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff

==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016
@@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu
   if (auto *Listener = getASTMutationListener())
 Listener->RedefinedHiddenDefinition(ND, M);
   -  auto *Merged = &MergedDefModules[ND];
-  if (auto *CanonDef = Merged->CanonicalDef) {
-ND = CanonDef;
-Merged = &MergedDefModules[ND];
-  }
-  assert(!Merged->CanonicalDef && "canonical def not canonical");
-
-  Merged->MergedModules.push_back(M);
-
-  if (!getLangOpts().ModulesLocalVisibility)
+  if (getLangOpts().ModulesLocalVisibility)
+MergedDefModules[ND].push_back(M);
+  else
   ND->setHidden(false);
   }
   -void ASTContext::mergeDefinitionIntoModulesOf(NamedDecl *Def,
-  NamedDecl *Other) {
-  // We need to know the owning module of the merge source.
-  assert(Other->isFromASTFile() && "merge of non-imported decl not
supported");
-  assert(Def != Other

Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

2016-10-17 Thread Vassil Vassilev via cfe-commits

I was just to commit a fix :(
On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Mon Oct 17 08:00:44 2016
New Revision: 284382

URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev
Log:
Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling 
of"

This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

Removed:
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
 cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
 cfe/trunk/include/clang/AST/ASTContext.h
 cfe/trunk/lib/AST/ASTContext.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h
 cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016
@@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
/// merged into.
llvm::DenseMap MergedDecls;
  
-  /// The modules into which a definition has been merged, or a map from a

-  /// merged definition to its canonical definition. This is really a union of
-  /// a NamedDecl* and a vector of Module*.
-  struct MergedModulesOrCanonicalDef {
-llvm::TinyPtrVector MergedModules;
-NamedDecl *CanonicalDef = nullptr;
-  };
-
/// \brief A mapping from a defining declaration to a list of modules (other
/// than the owning module of the declaration) that contain merged
/// definitions of that entity.
-  llvm::DenseMap MergedDefModules;
+  llvm::DenseMap> MergedDefModules;
  
/// \brief Initializers for a module, in order. Each Decl will be either

/// something that has a semantic effect on startup (such as a variable with
@@ -891,7 +883,6 @@ public:
/// and should be visible whenever \p M is visible.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
   bool NotifyListeners = true);
-  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
/// \brief Clean up the merged definition list. Call this if you might have
/// added duplicates into the list.
void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -902,9 +893,7 @@ public:
  auto MergedIt = MergedDefModules.find(Def);
  if (MergedIt == MergedDefModules.end())
return None;
-if (auto *CanonDef = MergedIt->second.CanonicalDef)
-  return getModulesWithMergedDefinition(CanonDef);
-return MergedIt->second.MergedModules;
+return MergedIt->second;
}
  
/// Add a declaration to the list of declarations that are initialized


Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016
@@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu
  if (auto *Listener = getASTMutationListener())
Listener->RedefinedHiddenDefinition(ND, M);
  
-  auto *Merged = &MergedDefModules[ND];

-  if (auto *CanonDef = Merged->CanonicalDef) {
-ND = CanonDef;
-Merged = &MergedDefModules[ND];
-  }
-  assert(!Merged->CanonicalDef && "canonical def not canonical");
-
-  Merged->MergedModules.push_back(M);
-
-  if (!getLangOpts().ModulesLocalVisibility)
+  if (getLangOpts().ModulesLocalVisibility)
+MergedDefModules[ND].push_back(M);
+  else
  ND->setHidden(false);
  }
  
-void ASTContext::mergeDefinitionIntoModulesOf(NamedDecl *Def,

-  NamedDecl *Other) {
-  // We need to know the owning module of the merge source.
-  assert(Other->isFromASTFile() && "merge of non-imported decl not supported");
-  assert(Def != Other && "merging definition into itself");
-
-  if (!Other->isHidden()) {
-Def->setHidden(false);
-return;
-  }
-
-  assert(Other->getImportedOwningModule() &&
- "hidden, imported declaration has no owning module");
-
-  // Mark Def as the canonical definition of merged definition Other.
-  {
-auto &OtherMerged = MergedDefModul

[PATCH] D25602: Do not reset TUScope when we are in incremental processing mode.

2016-10-17 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r284372.


https://reviews.llvm.org/D25602



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


r284372 - Do not reset TUScope when we are in incremental processing mode.

2016-10-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Oct 17 05:15:25 2016
New Revision: 284372

URL: http://llvm.org/viewvc/llvm-project?rev=284372&view=rev
Log:
Do not reset TUScope when we are in incremental processing mode.

Patch by Axel Naumann!

Reviewed by Richard Smith and me.

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

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=284372&r1=284371&r2=284372&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Oct 17 05:15:25 2016
@@ -708,7 +708,8 @@ void Sema::ActOnEndOfTranslationUnit() {
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -908,7 +909,8 @@ void Sema::ActOnEndOfTranslationUnit() {
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 


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


Re: r284284 - Reinstate r284008 reverted in r284081, with two fixes:

2016-10-15 Thread Vassil Vassilev via cfe-commits
It seems that we are still missing a piece, because this broke the 
libstdc++ selfhost: 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/5891


On 14/10/16 23:41, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri Oct 14 16:41:24 2016
New Revision: 284284

URL: http://llvm.org/viewvc/llvm-project?rev=284284&view=rev
Log:
Reinstate r284008 reverted in r284081, with two fixes:

1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition).

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

Added:
 cfe/trunk/test/Modules/Inputs/PR28752/
   - copied from r284080, cfe/trunk/test/Modules/Inputs/PR28752/
 cfe/trunk/test/Modules/pr28752.cpp
   - copied, changed from r284080, cfe/trunk/test/Modules/pr28752.cpp
Modified:
 cfe/trunk/include/clang/AST/Decl.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/Decl.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
 cfe/trunk/lib/Sema/SemaType.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 14 16:41:24 2016
@@ -865,6 +865,11 @@ protected:
  
  unsigned : NumVarDeclBits;
  
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.

+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
  /// \brief Whether this variable is the exception variable in a C++ catch
  /// or an Objective-C @catch statement.
  unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
InitializationStyle getInitStyle() const {
  return static_cast(VarDeclBits.InitStyle);
}
-
/// \brief Whether the initializer is a direct-initializer (list or call).
bool isDirectInit() const {
  return getInitStyle() != CInit;
}
  
+  /// \brief If this definition should pretend to be a declaration.

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
/// \brief Determine whether this variable is the exception variable in a
/// C++ catch statememt or an Objective-C \@catch statement.
bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
  NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
}
  
+  /// \brief Retrieve the variable declaration from which this variable could

+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
/// \brief If this variable is an instantiated static data member of a
/// class template specialization, returns the templated static data member
/// from which it was instantiated.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 16:41:24 2016
@@ -2286,6 +2286,7 @@ public:
void MergeVarDecl(VarDecl *New, LookupResult &Previous);
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
+  bool c

Re: r284284 - Reinstate r284008 reverted in r284081, with two fixes:

2016-10-15 Thread Vassil Vassilev via cfe-commits

Thanks!

When calling makeMergedDefinitionVisible shouldn't we get the template 
instantiation pattern?

On 14/10/16 23:41, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri Oct 14 16:41:24 2016
New Revision: 284284

URL: http://llvm.org/viewvc/llvm-project?rev=284284&view=rev
Log:
Reinstate r284008 reverted in r284081, with two fixes:

1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition).

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

Added:
 cfe/trunk/test/Modules/Inputs/PR28752/
   - copied from r284080, cfe/trunk/test/Modules/Inputs/PR28752/
 cfe/trunk/test/Modules/pr28752.cpp
   - copied, changed from r284080, cfe/trunk/test/Modules/pr28752.cpp
Modified:
 cfe/trunk/include/clang/AST/Decl.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/Decl.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
 cfe/trunk/lib/Sema/SemaType.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 14 16:41:24 2016
@@ -865,6 +865,11 @@ protected:
  
  unsigned : NumVarDeclBits;
  
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.

+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
  /// \brief Whether this variable is the exception variable in a C++ catch
  /// or an Objective-C @catch statement.
  unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
InitializationStyle getInitStyle() const {
  return static_cast(VarDeclBits.InitStyle);
}
-
/// \brief Whether the initializer is a direct-initializer (list or call).
bool isDirectInit() const {
  return getInitStyle() != CInit;
}
  
+  /// \brief If this definition should pretend to be a declaration.

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
/// \brief Determine whether this variable is the exception variable in a
/// C++ catch statememt or an Objective-C \@catch statement.
bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
  NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
}
  
+  /// \brief Retrieve the variable declaration from which this variable could

+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
/// \brief If this variable is an instantiated static data member of a
/// class template specialization, returns the templated static data member
/// from which it was instantiated.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 16:41:24 2016
@@ -2286,6 +2286,7 @@ public:
void MergeVarDecl(VarDecl *New, LookupResult &Previous);
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
+  bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
bool

[PATCH] D25604: Add support for Mageia Linux

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: chandlerc, rsmith.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D25604

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25602: Do not reset TUScope when we are in incremental processing mode.

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: cfe-commits.

We are using this in the context of cling, where we keep the compiler instance 
alive after EOF.

The incremental processing part in clang was done mostly by me and this patch 
LGTM, but I'd like to go under a formal review procedure.


https://reviews.llvm.org/D25602

Files:
  lib/Sema/Sema.cpp


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Thanks I am closing it!


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

The print related changes were added in in r280240 
(https://reviews.llvm.org/D23319). Could you rebase the patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

This patch needs rebasing.


https://reviews.llvm.org/D7842



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


[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a subscriber: djasper.
v.g.vassilev added a comment.

I think @djasper could help with this review.


https://reviews.llvm.org/D7842



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


Re: r284008 - Reinstate r283887 and r283882.

2016-10-12 Thread Vassil Vassilev via cfe-commits

Hi Manman,
On 12/10/16 20:28, Manman wrote:

Hi Vassil,

Any change between this commit and “r283887 + r283882”?

The only extra change is in:

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }

The old patch failed because we read the 
IsThisDeclarationADemotedDefinition bit of ParmVarDecls. We allow 
demoting only VarDecls, which are not ParmVarDecls, and thus we 
serialize/deserialize this bit only for non ParmVarDecls. Reading the 
IsThisDeclarationADemotedDefinition of ParmVarDecls caused random behavior.


Cheers,
Vassil

And what was the issue that caused the revert?

Thanks,
Manman


On Oct 12, 2016, at 4:57 AM, Vassil Vassilev via cfe-commits 
 wrote:

Author: vvassilev
Date: Wed Oct 12 06:57:08 2016
New Revision: 284008

URL: http://llvm.org/viewvc/llvm-project?rev=284008&view=rev
Log:
Reinstate r283887 and r283882.

Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 12 06:57:08 2016
@@ -865,6 +865,11 @@ protected:

 unsigned : NumVarDeclBits;

+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }

+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }

+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Oct 12 06:57:08 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial sp

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-12 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Relanded in r284008.


https://reviews.llvm.org/D24508



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


r284008 - Reinstate r283887 and r283882.

2016-10-12 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Oct 12 06:57:08 2016
New Revision: 284008

URL: http://llvm.org/viewvc/llvm-project?rev=284008&view=rev
Log:
Reinstate r283887 and r283882.

Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 12 06:57:08 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Oct 12 06:57:08 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+   

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-12 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 74353.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

We should not access the IsThisDeclarationADemotedDefinition bits if the decl 
is ParmVarDecl.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -894,6 +894,7 @@
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
   if (!isa(D)) {
+Record.push_back(D->isThisDeclarationADemotedDefinition());
 Record.push_back(D->isExceptionVariable());
 Record.push_back(D->isNRVOVariable());
 Record.push_back(D->isCXXForRangeDecl());
@@ -998,6 +999,8 @@
   // Check things we know are true of *every* PARM_VAR_DECL, which is more than
   // just us assuming it.
   assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
+  assert(!D->isThisDeclarationADemotedDefinition()
+ && "PARM_VAR_DECL can't be demoted definition.");
   assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
   assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
   assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
@@ -1957,6 +1960,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/

r283890 - Revert r283887 and r283882, until the issue is understood and fixed.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:51:06 2016
New Revision: 283890

URL: http://llvm.org/viewvc/llvm-project?rev=283890&view=rev
Log:
Revert r283887 and r283882, until the issue is understood and fixed.

Removed:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 10:51:06 2016
@@ -865,11 +865,6 @@ protected:
 
 unsigned : NumVarDeclBits;
 
-// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
-/// \brief Whether this variable is a definition which was demoted due to
-/// module merge.
-unsigned IsThisDeclarationADemotedDefinition : 1;
-
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1203,27 +1198,12 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
+
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
-  /// \brief If this definition should pretend to be a declaration.
-  bool isThisDeclarationADemotedDefinition() const {
-return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
-  }
-
-  /// \brief This is a definition which should be demoted to a declaration.
-  ///
-  /// In some cases (mostly module merging) we can end up with two visible
-  /// definitions one of which needs to be demoted to a declaration to keep
-  /// the AST invariants.
-  void demoteThisDefinitionToDeclaration() {
-assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
-assert (isThisDeclarationADefinition() && "Not a definition!");
-NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
-  }
-
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1322,10 +1302,6 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
-  /// \brief Retrieve the variable declaration from which this variable could
-  /// be instantiated, if it is an instantiation (rather than a non-template).
-  VarDecl *getTemplateInstantiationPattern() const;
-
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 10:51:06 2016
@@ -1926,9 +1926,6 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
-  if (isThisDeclarationADemotedDefinition())
-return DeclarationOnly;
-
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2253,56 +2250,6 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
-VarDecl *VarDecl::getTemplateInstantiationPattern() const {
-  // If it's a variable template specialization, find the template or partial
-  // specialization from which it was instantiated.
-  if (auto *VDTemplSpec = dyn_cast(this)) {
-auto From = VDTemplSpec->getInstantiatedFrom();
-if (auto *VTD = From.dyn_cast()) {
-  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
-if (NewVTD->isMemberSpecialization())
-  break;
-VTD = NewVTD;
-  }
-  return VTD->getTemplatedDecl()->getDefinition();
-}
-if (auto *VTPSD =
-From.dyn_cast()) {
-  while (auto *NewVTPSD = VTPSD->getInstantiatedFromMember()) {
-if (NewVTPSD->isMemberSpecialization())
-  break;
-VTPSD = NewVTPSD;
-  }
-  return VTPSD->getDefinition();
-}
-  }
-
-  if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
-if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
-  VarDecl *VD = getInstantiatedFromStat

r283887 - r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:09:26 2016
New Revision: 283887

URL: http://llvm.org/viewvc/llvm-project?rev=283887&view=rev
Log:
r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=283887&r1=283886&r2=283887&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 11 10:09:26 2016
@@ -9709,20 +9709,22 @@ void Sema::AddInitializerToDecl(Decl *Re
   // The previous definition is hidden, and multiple definitions are
   // permitted (in separate TUs). Form another definition of it.
 
-  // Demote the newly parsed definition to a fake declaration.
-  if (!VDecl->isThisDeclarationADemotedDefinition())
-VDecl->demoteThisDefinitionToDeclaration();
+  if (!isa(VDecl)) {
+// Demote the newly parsed definition to a fake declaration.
+if (!VDecl->isThisDeclarationADemotedDefinition())
+  VDecl->demoteThisDefinitionToDeclaration();
 
-  // Make the definition visible from the point of the demotion on.
-  assert (!Hidden || Def == Hidden &&
-  "We were suggested another hidden definition!");
-  makeMergedDefinitionVisible(Def, VDecl->getLocation());
+// Make the definition visible from the point of the demotion on.
+assert (!Hidden || Def == Hidden &&
+"We were suggested another hidden definition!");
+makeMergedDefinitionVisible(Def, VDecl->getLocation());
 
-  // If this is a variable template definition, make its enclosing template
-  // visible.
-  if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
-if (VarPattern->isThisDeclarationADefinition())
-  makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+// If this is a variable template definition, make its enclosing 
template
+// visible.
+if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
+  if (VarPattern->isThisDeclarationADefinition())
+makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+  }
 } else {
   Diag(VDecl->getLocation(), diag::err_redefinition)
 << VDecl->getDeclName();


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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Landed in r283882.




Comment at: include/clang/AST/Decl.h:1222
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");

rsmith wrote:
> You can remove this; it's covered by the next line.
Ok. This would allow calling the method on already demoted definition. Do we 
want to allow that?



Comment at: lib/AST/Decl.cpp:2284
+  while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
+VD = NewVD;
+  return VD->getDefinition();

rsmith wrote:
> Missing a member specialization check here.
Isn't that covered by the cases above? It seems there is no API to make such 
check, here. The current state looks to me consistent with 
`CXXRecordDecl::getTemplateInstantiationPattern` and 
`FunctionDecl::getTemplateInstantiationPattern`.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3086-3090
+  if (CurD->isThisDeclarationADemotedDefinition()) {
+VD->demoteThisDefinitionToDeclaration();
+break;
+  }
+  if (CurD->isThisDeclarationADefinition()) {

rsmith wrote:
> Maybe combine these two `if`s into one, since their bodies are identical?
Good point ;)


https://reviews.llvm.org/D24508



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


r283882 - [modules] PR28752: Do not instantiate variable declarations which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 08:57:36 2016
New Revision: 283882

URL: http://llvm.org/viewvc/llvm-project?rev=283882&view=rev
Log:
[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 08:57:36 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,27 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1322,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 08:57:36 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+  }
+  return VTD->getTemplatedDecl()->getDefinition();
+ 

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-10 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 74129.
v.g.vassilev marked 3 inline comments as done.
v.g.vassilev added a comment.

Address comments.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -894,6 +894,7 @@
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
   if (!isa(D)) {
+Record.push_back(D->isThisDeclarationADemotedDefinition());
 Record.push_back(D->isExceptionVariable());
 Record.push_back(D->isNRVOVariable());
 Record.push_back(D->isCXXForRangeDecl());
@@ -998,6 +999,8 @@
   // Check things we know are true of *every* PARM_VAR_DECL, which is more than
   // just us assuming it.
   assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
+  assert(!D->isThisDeclarationADemotedDefinition()
+ && "PARM_VAR_DECL can't be demoted definition.");
   assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
   assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
   assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
@@ -1957,6 +1960,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1216,6 +1216,7 

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


> rsmith wrote in SemaTemplate.cpp:509
> This function still appears to be able to return true (indicating to the 
> caller that a diagnostic was produced) without actually producing a 
> diagnostic.

Is it better now?

> rsmith wrote in SemaTemplate.cpp:505
> Why do we not issue a diagnostic in this case for a `VarDecl` when `Complain` 
> is true and no definition is available? It seems like we should either be 
> diagnosing this or asserting that it can't happen.

I believe it is not implemented, i.e. we didn't have this diagnostics when 
`VarDecl::getInstantiatedFromStaticDataMember` is true. I added a FIXME: for a 
future enhancement.

> rsmith wrote in ASTWriterDecl.cpp:896-897
> Sink this flag into the "not for `ParmVarDecl`" block below.

I thought we might need this for c-style `void f(struct S arg)`-like constructs 
where we might need to demote if we merge ParmVarDecls.

> rsmith wrote in ASTWriterDecl.cpp:1965
> Hmm. The width of the `InitStyle` field is definitely wrong right now, but 
> should be fixed separately from this change. It looks like we don't hit this 
> today because we don't use this abbreviation for a variable with an 
> initializer. In addition to fixing the width of this field, we should also 
> remove the `getInit() == nullptr` check when selecting the abbreviation in 
> `ASTDeclWriter::VisitVarDecl`.

Committed in r283444.

https://reviews.llvm.org/D24508



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


<    2   3   4   5   6   7   8   9   >