r340188 - Close FileEntries of cached files in ModuleManager::addModule().

2018-08-20 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 20 10:10:27 2018
New Revision: 340188

URL: http://llvm.org/viewvc/llvm-project?rev=340188&view=rev
Log:
Close FileEntries of cached files in ModuleManager::addModule().

While investigating why LLDB (which can build hundreds of clang
modules during one debug session) was getting "too many open files"
errors, I found that most of them are .pcm files that are kept open by
ModuleManager. Pretty much all of the open file dscriptors are
FileEntries that are refering to `.pcm` files for which a buffer
already exists in a CompilerInstance's PCMCache.

Before PCMCache was added it was necessary to hold on to open file
descriptors to ensure that all ModuleManagers using the same
FileManager read the a consistent version of a given `.pcm` file on
disk, even when a concurrent clang process overwrites the file halfway
through. The PCMCache makes this practice unnecessary, since it caches
the entire contents of a `.pcm` file, while the FileManager caches all
the stat() information.

This patch adds a call to FileEntry::closeFile() to the path where a
Buffer has already been created. This is necessary because even for a
freshly written `.pcm` file the file is stat()ed once immediately
after writing to generate a FileEntry in the FileManager. Because a
freshly-generated file's contents is stored in the PCMCache, it is
fine to close the file immediately thereafter.  The second change this
patch makes is to set the `ShouldClose` flag to true when reading a
`.pcm` file into the PCMCache for the first time.

[For reference, in 1 Clang instance there is
 - 1 FileManager and
 - n ModuleManagers with
 - n PCMCaches.]

rdar://problem/40906753

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

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

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=340188&r1=340187&r2=340188&view=diff
==
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Mon Aug 20 10:10:27 2018
@@ -161,21 +161,24 @@ ModuleManager::addModule(StringRef FileN
   if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
 // The buffer was already provided for us.
 NewModule->Buffer = &PCMCache->addBuffer(FileName, std::move(Buffer));
+// Since the cached buffer is reused, it is safe to close the file
+// descriptor that was opened while stat()ing the PCM in
+// lookupModuleFile() above, it won't be needed any longer.
+Entry->closeFile();
   } else if (llvm::MemoryBuffer *Buffer = PCMCache->lookupBuffer(FileName)) {
 NewModule->Buffer = Buffer;
+// As above, the file descriptor is no longer needed.
+Entry->closeFile();
   } else {
 // Open the AST file.
 llvm::ErrorOr> 
Buf((std::error_code()));
 if (FileName == "-") {
   Buf = llvm::MemoryBuffer::getSTDIN();
 } else {
-  // Leave the FileEntry open so if it gets read again by another
-  // ModuleManager it must be the same underlying file.
-  // FIXME: Because FileManager::getFile() doesn't guarantee that it will
-  // give us an open file, this may not be 100% reliable.
+  // Get a buffer of the file and close the file descriptor when done.
   Buf = FileMgr.getBufferForFile(NewModule->File,
  /*IsVolatile=*/false,
- /*ShouldClose=*/false);
+ /*ShouldClose=*/true);
 }
 
 if (!Buf) {


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


r314700 - Add a testcase to check that debug info is upgraded when compiling LLVM IR

2017-10-02 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct  2 11:31:52 2017
New Revision: 314700

URL: http://llvm.org/viewvc/llvm-project?rev=314700&view=rev
Log:
Add a testcase to check that debug info is upgraded when compiling LLVM IR
through clang.

Added:
cfe/trunk/test/CodeGen/verify-debuginfo.ll

Added: cfe/trunk/test/CodeGen/verify-debuginfo.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/verify-debuginfo.ll?rev=314700&view=auto
==
--- cfe/trunk/test/CodeGen/verify-debuginfo.ll (added)
+++ cfe/trunk/test/CodeGen/verify-debuginfo.ll Mon Oct  2 11:31:52 2017
@@ -0,0 +1,17 @@
+; REQUIRES: x86-registered-target
+; RUN: %clang_cc1 -triple i386-apple-darwin -disable-llvm-optzns -S %s -o - 
2>&1 \
+; RUN:   | FileCheck %s
+; CHECK: invalid global variable ref
+; CHECK: warning: ignoring invalid debug info in {{.*}}.ll
+
+@global = common global i32 0, align 4, !dbg !2
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!5, !6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: 
"adrian", emissionKind: FullDebug, globals: !{!3})
+!1 = !DIFile(filename: "broken.c", directory: "/")
+!2 = !DIGlobalVariableExpression(var: !3, expr: !DIExpression())
+!3 = !DIGlobalVariable(name: "g", scope: !0, file: !1, line: 1, type: !1, 
isLocal: false, isDefinition: true)
+!5 = !{i32 2, !"Dwarf Version", i32 4}
+!6 = !{i32 1, !"Debug Info Version", i32 3}


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


r315392 - Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Oct 10 16:54:21 2017
New Revision: 315392

URL: http://llvm.org/viewvc/llvm-project?rev=315392&view=rev
Log:
Include getting generated struct offsets in CodegenABITypes

This change adds a new function, CodeGen::getFieldNumber, that
enables a user of clang's code generation to get the field number
in a generated LLVM IR struct that corresponds to a particular field
in a C struct.

It is important to expose this information in Clang's code generation
interface because there is no reasonable way for users of Clang's code
generation to get this information. In particular:

LLVM struct types do not include field names.
Clang adds a non-trivial amount of logic to the code generation of LLVM IR 
types for structs, in particular to handle padding and bit fields.

Patch by Michael Ferguson!

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

Added:
cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=315392&r1=315391&r2=315392&view=diff
==
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Tue Oct 10 16:54:21 2017
@@ -72,12 +72,19 @@ const CGFunctionInfo &arrangeFreeFunctio
   FunctionType::ExtInfo info,
   RequiredArgs args);
 
-// Returns null if the function type is incomplete and can't be lowered.
+/// Returns null if the function type is incomplete and can't be lowered.
 llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM,
 const FunctionDecl *FD);
 
 llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
 
+/// Given a non-bitfield struct field, return its index within the elements of
+/// the struct's converted type.  The returned index refers to a field number 
in
+/// the complete object type which is returned by convertTypeForMemory.  FD 
must
+/// be a field in RD directly (i.e. not an inherited field).
+unsigned getLLVMFieldNumber(CodeGenModule &CGM,
+const RecordDecl *RD, const FieldDecl *FD);
+
 }  // end namespace CodeGen
 }  // end namespace clang
 

Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=315392&r1=315391&r2=315392&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Tue Oct 10 16:54:21 2017
@@ -17,6 +17,7 @@
 
//===--===//
 
 #include "clang/CodeGen/CodeGenABITypes.h"
+#include "CGRecordLayout.h"
 #include "CodeGenModule.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
@@ -80,3 +81,9 @@ llvm::Type *
 CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) {
   return CGM.getTypes().ConvertTypeForMem(T);
 }
+
+unsigned CodeGen::getLLVMFieldNumber(CodeGenModule &CGM,
+ const RecordDecl *RD,
+ const FieldDecl *FD) {
+  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
+}

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=315392&r1=315391&r2=315392&view=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Tue Oct 10 16:54:21 2017
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
   IncrementalProcessingTest.cpp
+  CodeGenExternalTest.cpp
   )
 
 target_link_libraries(ClangCodeGenTests

Added: cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp?rev=315392&view=auto
==
--- cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp (added)
+++ cfe/trunk/unittests/CodeGen/CodeGenExternalTest.cpp Tue Oct 10 16:54:21 2017
@@ -0,0 +1,302 @@
+//===- unittests/CodeGen/CodeGenExternalTest.cpp - test external CodeGen -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===/

r341842 - Remove all uses of DIFlagBlockByrefStruct

2018-09-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Sep 10 09:14:28 2018
New Revision: 341842

URL: http://llvm.org/viewvc/llvm-project?rev=341842&view=rev
Log:
Remove all uses of DIFlagBlockByrefStruct

This patch removes the last reason why DIFlagBlockByrefStruct from
Clang by directly implementing the drilling into the member type done
in DwarfDebug::DbgVariable::getType() into the frontend.

rdar://problem/31629055

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=341842&r1=341841&r2=341842&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 10 09:14:28 2018
@@ -3565,9 +3565,9 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
 DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
-llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
-uint64_t *XOffset) {
-
+CGDebugInfo::BlockByRefType
+CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
+  uint64_t *XOffset) {
   SmallVector EltTys;
   QualType FType;
   uint64_t FieldSize, FieldOffset;
@@ -3619,23 +3619,21 @@ llvm::DIType *CGDebugInfo::EmitTypeForVa
   }
 
   FType = Type;
-  llvm::DIType *FieldTy = getOrCreateType(FType, Unit);
+  llvm::DIType *WrappedTy = getOrCreateType(FType, Unit);
   FieldSize = CGM.getContext().getTypeSize(FType);
   FieldAlign = CGM.getContext().toBits(Align);
 
   *XOffset = FieldOffset;
-  FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit, 0, FieldSize,
-  FieldAlign, FieldOffset,
-  llvm::DINode::FlagZero, FieldTy);
+  llvm::DIType *FieldTy = DBuilder.createMemberType(
+  Unit, VD->getName(), Unit, 0, FieldSize, FieldAlign, FieldOffset,
+  llvm::DINode::FlagZero, WrappedTy);
   EltTys.push_back(FieldTy);
   FieldOffset += FieldSize;
 
   llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
-
-  llvm::DINode::DIFlags Flags = llvm::DINode::FlagBlockByrefStruct;
-
-  return DBuilder.createStructType(Unit, "", Unit, 0, FieldOffset, 0, Flags,
-   nullptr, Elements);
+  return {DBuilder.createStructType(Unit, "", Unit, 0, FieldOffset, 0,
+llvm::DINode::FlagZero, nullptr, Elements),
+  WrappedTy};
 }
 
 llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
@@ -3656,7 +3654,7 @@ llvm::DILocalVariable *CGDebugInfo::Emit
   llvm::DIType *Ty;
   uint64_t XOffset = 0;
   if (VD->hasAttr())
-Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset);
+Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset).WrappedType;
   else
 Ty = getOrCreateType(VD->getType(), Unit);
 
@@ -3794,7 +3792,7 @@ void CGDebugInfo::EmitDeclareOfBlockDecl
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
   llvm::DIType *Ty;
   if (isByRef)
-Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset);
+Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset).WrappedType;
   else
 Ty = getOrCreateType(VD->getType(), Unit);
 
@@ -3987,10 +3985,10 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
   auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
-
-  // FIXME: this creates a second copy of this type!
+  // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
-  fieldType = EmitTypeForVarWithBlocksAttr(variable, &xoffset);
+  fieldType =
+  EmitTypeForVarWithBlocksAttr(variable, &xoffset).BlockByRefWrapper;
   fieldType = DBuilder.createPointerType(fieldType, PtrInfo.Width);
   fieldType = DBuilder.createMemberType(tunit, name, tunit, line,
 PtrInfo.Width, Align, offsetInBits,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=341842&r1=341841&r2=341842&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Sep 10 09:14:28 2018
@@ -491,9 +491,16 @@ private:
  llvm::Optional ArgNo,
  CGBuilderTy &Builder);
 
+  struct BlockByRefType {
+/// The wrapper struct used inside the __block_literal struct.
+llvm::DIType *BlockByRefWrapper;
+/// The type as it appears in the source code.
+llvm::DIType *WrappedType;
+  };
+
   /// Build up structure info for the byref.  See \a BuildByRefT

r324761 - Introduce an API for LLDB to compute the default module cache path

2018-02-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb  9 10:43:10 2018
New Revision: 324761

URL: http://llvm.org/viewvc/llvm-project?rev=324761&view=rev
Log:
Introduce an API for LLDB to compute the default module cache path

LLDB creates Clang modules and had an incomplete copy of the clang
Driver code that compute the -fmodule-cache-path. This patch makes the
clang driver code accessible to LLDB.

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

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=324761&r1=324760&r2=324761&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Fri Feb  9 10:43:10 2018
@@ -572,6 +572,8 @@ public:
   /// no extra characters remaining at the end.
   static bool GetReleaseVersion(StringRef Str,
 MutableArrayRef Digits);
+  /// Compute the default -fmodule-cache-path.
+  static void getDefaultModuleCachePath(SmallVectorImpl &Result);
 };
 
 /// \return True if the last defined optimization level is -Ofast.

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324761&r1=324760&r2=324761&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Feb  9 10:43:10 2018
@@ -2500,6 +2500,13 @@ static void RenderBuiltinOptions(const T
 CmdArgs.push_back("-fno-math-builtin");
 }
 
+void Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
+  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Result);
+  llvm::sys::path::append(Result, "org.llvm.clang.");
+  appendUserToPath(Result);
+  llvm::sys::path::append(Result, "ModuleCache");
+}
+
 static void RenderModulesOptions(Compilation &C, const Driver &D,
  const ArgList &Args, const InputInfo &Input,
  const InputInfo &Output,
@@ -2560,10 +2567,7 @@ static void RenderModulesOptions(Compila
   llvm::sys::path::append(Path, "modules");
 } else if (Path.empty()) {
   // No module path was provided: use the default.
-  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Path);
-  llvm::sys::path::append(Path, "org.llvm.clang.");
-  appendUserToPath(Path);
-  llvm::sys::path::append(Path, "ModuleCache");
+  Driver::getDefaultModuleCachePath(Path);
 }
 
 const char Arg[] = "-fmodules-cache-path=";


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


r324917 - Add a unit test for Driver::getDefaultModuleCachePath().

2018-02-12 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Feb 12 09:59:54 2018
New Revision: 324917

URL: http://llvm.org/viewvc/llvm-project?rev=324917&view=rev
Log:
Add a unit test for Driver::getDefaultModuleCachePath().

Added:
cfe/trunk/unittests/Driver/ModuleCacheTest.cpp
Modified:
cfe/trunk/unittests/Driver/CMakeLists.txt

Modified: cfe/trunk/unittests/Driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/CMakeLists.txt?rev=324917&r1=324916&r2=324917&view=diff
==
--- cfe/trunk/unittests/Driver/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Driver/CMakeLists.txt Mon Feb 12 09:59:54 2018
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(ClangDriverTests
   DistroTest.cpp
   ToolChainTest.cpp
+  ModuleCacheTest.cpp
   MultilibTest.cpp
   )
 

Added: cfe/trunk/unittests/Driver/ModuleCacheTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/ModuleCacheTest.cpp?rev=324917&view=auto
==
--- cfe/trunk/unittests/Driver/ModuleCacheTest.cpp (added)
+++ cfe/trunk/unittests/Driver/ModuleCacheTest.cpp Mon Feb 12 09:59:54 2018
@@ -0,0 +1,28 @@
+//===- unittests/Driver/ModuleCacheTest.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for the LLDB module cache API.
+//
+//===--===//
+
+#include "clang/Driver/Driver.h"
+#include "gtest/gtest.h"
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+TEST(ModuleCacheTest, GetTargetAndMode) {
+  SmallString<128> Buf;
+  Driver::getDefaultModuleCachePath(Buf);
+  StringRef Path = Buf;
+  EXPECT_TRUE(Path.find("org.llvm.clang") != Path.npos);
+  EXPECT_TRUE(Path.endswith("ModuleCache"));  
+}
+} // end anonymous namespace.


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


Re: [PATCH] D43128: Introduce an API for LLDB to compute the default module cache path

2018-02-12 Thread Adrian Prantl via cfe-commits


> On Feb 12, 2018, at 8:32 AM, David Blaikie  wrote:
> 
> Unit test?

Added in r324917.

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


r321115 - Silence a bunch of implicit fallthrough warnings

2017-12-19 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Dec 19 14:06:11 2017
New Revision: 321115

URL: http://llvm.org/viewvc/llvm-project?rev=321115&view=rev
Log:
Silence a bunch of implicit fallthrough warnings

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/JumpDiagnostics.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=321115&r1=321114&r2=321115&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Dec 19 14:06:11 2017
@@ -1537,7 +1537,7 @@ void ASTDumper::VisitTemplateDeclSpecial
 case TSK_ExplicitInstantiationDefinition:
   if (!DumpExplicitInst)
 break;
-  // Fall through.
+  LLVM_FALLTHROUGH;
 case TSK_Undeclared:
 case TSK_ImplicitInstantiation:
   if (DumpRefOnly)

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=321115&r1=321114&r2=321115&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Dec 19 14:06:11 2017
@@ -3116,7 +3116,8 @@ bool Expr::HasSideEffects(const ASTConte
 if (DCE->getTypeAsWritten()->isReferenceType() &&
 DCE->getCastKind() == CK_Dynamic)
   return true;
-  } // Fall through.
+}
+LLVM_FALLTHROUGH;
   case ImplicitCastExprClass:
   case CStyleCastExprClass:
   case CXXStaticCastExprClass:

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=321115&r1=321114&r2=321115&view=diff
==
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Dec 19 14:06:11 2017
@@ -857,7 +857,7 @@ LambdaCapture::LambdaCapture(SourceLocat
   switch (Kind) {
   case LCK_StarThis:
 Bits |= Capture_ByCopy;
-// Fall through
+LLVM_FALLTHROUGH;
   case LCK_This:
 assert(!Var && "'this' capture cannot have a variable!");
 Bits |= Capture_This;
@@ -865,7 +865,7 @@ LambdaCapture::LambdaCapture(SourceLocat
 
   case LCK_ByCopy:
 Bits |= Capture_ByCopy;
-// Fall through 
+LLVM_FALLTHROUGH;
   case LCK_ByRef:
 assert(Var && "capture must have a variable!");
 break;

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=321115&r1=321114&r2=321115&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 19 14:06:11 2017
@@ -5913,7 +5913,7 @@ bool PointerExprEvaluator::VisitBuiltinC
 << (std::string("'") + Info.Ctx.BuiltinInfo.getName(BuiltinOp) + "'");
 else
   Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
-// Fall through.
+LLVM_FALLTHROUGH;
   case Builtin::BI__builtin_strchr:
   case Builtin::BI__builtin_wcschr:
   case Builtin::BI__builtin_memchr:
@@ -5952,7 +5952,7 @@ bool PointerExprEvaluator::VisitBuiltinC
Desired))
 return ZeroInitialization(E);
   StopAtNull = true;
-  // Fall through.
+  LLVM_FALLTHROUGH;
 case Builtin::BImemchr:
 case Builtin::BI__builtin_memchr:
 case Builtin::BI__builtin_char_memchr:
@@ -5965,7 +5965,7 @@ bool PointerExprEvaluator::VisitBuiltinC
 case Builtin::BIwcschr:
 case Builtin::BI__builtin_wcschr:
   StopAtNull = true;
-  // Fall through.
+  LLVM_FALLTHROUGH;
 case Builtin::BIwmemchr:
 case Builtin::BI__builtin_wmemchr:
   // wcschr and wmemchr are given a wchar_t to look for. Just use it.
@@ -7209,6 +7209,7 @@ static int EvaluateBuiltinClassifyType(c
 case BuiltinType::Dependent:
   llvm_unreachable("Ca

r321116 - Add explicit break (PR35700).

2017-12-19 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Dec 19 14:21:48 2017
New Revision: 321116

URL: http://llvm.org/viewvc/llvm-project?rev=321116&view=rev
Log:
Add explicit break (PR35700).

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

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=321116&r1=321115&r2=321116&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Dec 19 14:21:48 2017
@@ -5431,6 +5431,7 @@ MarkUsedTemplateParameters(ASTContext &C
 MarkUsedTemplateParameters(Ctx,
cast(T)->getDeducedType(),
OnlyDeduced, Depth, Used);
+break;
 
   // None of these types have any template parameters in them.
   case Type::Builtin:


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


r321321 - Delete dead code.

2017-12-21 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 21 15:03:05 2017
New Revision: 321321

URL: http://llvm.org/viewvc/llvm-project?rev=321321&view=rev
Log:
Delete dead code.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321321&r1=321320&r2=321321&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 21 15:03:05 2017
@@ -2653,7 +2653,6 @@ llvm::DIModule *CGDebugInfo::getParentMo
 // file where the type's definition is located, so it might be
 // best to make this behavior a command line or debugger tuning
 // option.
-FullSourceLoc Loc(D->getLocation(), CGM.getContext().getSourceManager());
 if (Module *M = D->getOwningModule()) {
   // This is a (sub-)module.
   auto Info = ExternalASTSource::ASTSourceDescriptor(*M);


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


r321750 - Simplify code (NFC)

2018-01-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Jan  3 10:31:04 2018
New Revision: 321750

URL: http://llvm.org/viewvc/llvm-project?rev=321750&view=rev
Log:
Simplify code (NFC)

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=321750&r1=321749&r2=321750&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  3 
10:31:04 2018
@@ -71,9 +71,8 @@ class PCHContainerGenerator : public AST
 }
 
 bool VisitImportDecl(ImportDecl *D) {
-  auto *Import = cast(D);
-  if (!Import->getImportedOwningModule())
-DI.EmitImportDecl(*Import);
+  if (!D->getImportedOwningModule())
+DI.EmitImportDecl(*D);
   return true;
 }
 


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


r321754 - -gmodules: Emit debug info for implicit module imports via #include.

2018-01-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Jan  3 11:10:21 2018
New Revision: 321754

URL: http://llvm.org/viewvc/llvm-project?rev=321754&view=rev
Log:
-gmodules: Emit debug info for implicit module imports via #include.

When a type is only used as a template parameter and that type is the
only type imported from another #include'd module, no skeleton CU for
that module is generated, so a consumer doesn't know where to find the
type definition. By emitting an import declaration, we can force a
skeleton CU to be generated for each imported module.

rdar://problem/36266156

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=321754&r1=321753&r2=321754&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  3 
11:10:21 2018
@@ -228,6 +228,11 @@ public:
   Builder->getModuleDebugInfo()->completeRequiredType(RD);
   }
 
+  void HandleImplicitImportDecl(ImportDecl *D) override {
+if (!D->getImportedOwningModule())
+  Builder->getModuleDebugInfo()->EmitImportDecl(*D);
+  }
+
   /// Emit a container holding the serialized AST.
   void HandleTranslationUnit(ASTContext &Ctx) override {
 assert(M && VMContext && Builder);

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=321754&r1=321753&r2=321754&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Wed Jan  3 11:10:21 2018
@@ -187,7 +187,7 @@ void foo() {
 
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: 
![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
-// CHECK-SAME: line: 16
+// CHECK-SAME: line: 19
 
 // CHECK: !DIGlobalVariable(name: "GlobalUnion",
 // CHECK-SAME:  type: ![[GLOBAL_UNION:[0-9]+]]

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=321754&r1=321753&r2=321754&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  3 11:10:21 2018
@@ -1,4 +1,7 @@
 /* -*- C++ -*- */
+
+#include "dummy.h"
+
 namespace DebugCXX {
   // Records.
   struct Struct {

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=321754&r1=321753&r2=321754&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  3 11:10:21 2018
@@ -5,12 +5,13 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps 
-DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll 
-mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t 
-emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
 
 // PCH:
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
-debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
%S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
 // RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
@@ -18,6 +19,9 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
+// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
+
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
@@ -27,6 +31,8 @@
 // CHECK-SAME: 

r321845 - Debug Info: Support DW_AT_calling_convention on composite types.

2018-01-04 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Jan  4 17:13:52 2018
New Revision: 321845

URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev
Log:
Debug Info: Support DW_AT_calling_convention on composite types.
This implements the DWARF 5 feature described at
http://www.dwarfstd.org/ShowIssue.php?issue=141215.1

This allows a consumer to understand whether a composite data type is
trivially copyable and thus should be passed by value instead of by
reference. The canonical example is being able to distinguish the
following two types:

  // S is not trivially copyable because of the explicit destructor.
  struct S {
 ~S() {}
  };

  // T is a POD type.
  struct T {
~T() = default;
  };


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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018
@@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea
 
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
 
+  // Explicitly record the calling convention for C++ records.
+  auto Flags = llvm::DINode::FlagZero;
+  if (auto CXXRD = dyn_cast(RD)) {
+if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
+  Flags |= llvm::DINode::FlagTypePassByReference;
+else
+  Flags |= llvm::DINode::FlagTypePassByValue;
+  }
+
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,
-  llvm::DINode::FlagZero, FullName);
+  Flags, FullName);
 
   // Elements of composite types usually have back to the type, creating
   // uniquing cycles.  Distinct nodes are more efficient.

Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4 17:13:52 
2018
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple 
%itanium_abi_triple %s -o - | FileCheck %s
+
+// Not trivially copyable because of the explicit destructor.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: 
DIFlagTypePassByReference
+struct RefDtor {
+  int i;
+  ~RefDtor() {}
+} refDtor;
+
+// Not trivially copyable because of the explicit copy constructor.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: 
DIFlagTypePassByReference
+struct RefCopy {
+  int i;
+  RefCopy() = default;
+  RefCopy(RefCopy &Copy) {}
+} refCopy;
+
+// Not trivially copyable because of the explicit move constructor.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: 
DIFlagTypePassByReference
+struct RefMove {
+  int i;
+  RefMove() = default;
+  RefMove(RefMove &&Move) {}
+} refMove;
+
+// POD-like type even though it defines a destructor.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: 
DIFlagTypePassByValue
+struct Podlike {
+  int i;
+  Podlike() = default;
+  Podlike(Podlike &&Move) = default;
+  ~Podlike() = default;
+} podlike;
+
+
+// This is a POD type.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags: 
DIFlagTypePassByValue
+struct Pod {
+  int i;
+} pod;
+
+// This is definitely not a POD type.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags: 
DIFlagTypePassByReference
+struct Complex {
+  Complex() {}
+  Complex(Complex &Copy) : i(Copy.i) {};
+  int i;
+} complex;


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


r321846 - Remove redundant test

2018-01-04 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Jan  4 17:28:59 2018
New Revision: 321846

URL: http://llvm.org/viewvc/llvm-project?rev=321846&view=rev
Log:
Remove redundant test

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321846&r1=321845&r2=321846&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4 17:28:59 
2018
@@ -15,14 +15,6 @@ struct RefCopy {
   RefCopy(RefCopy &Copy) {}
 } refCopy;
 
-// Not trivially copyable because of the explicit move constructor.
-// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: 
DIFlagTypePassByReference
-struct RefMove {
-  int i;
-  RefMove() = default;
-  RefMove(RefMove &&Move) {}
-} refMove;
-
 // POD-like type even though it defines a destructor.
 // CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: 
DIFlagTypePassByValue
 struct Podlike {


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


Re: r321845 - Debug Info: Support DW_AT_calling_convention on composite types.

2018-01-08 Thread Adrian Prantl via cfe-commits


> On Jan 8, 2018, at 8:14 AM, David Blaikie  wrote:
> 
> Great - are you tracking/planning to implement this for trivial_abi once it's 
> in? (was mentioned in the code review, but not sure if it's on your 
> plate/plan or not (no worries if it isn't, just keeping these things in mind))

Yes, this was in fact my primary motivation for the feature. Since the code is 
asking the ABI object, it looks like this might work out of the box with the 
trivial_abi attribute, but I will definitely at least add a testcase once it's 
in.

-- adrian

> 
> On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Jan  4 17:13:52 2018
> New Revision: 321845
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=321845&view=rev>
> Log:
> Debug Info: Support DW_AT_calling_convention on composite types.
> This implements the DWARF 5 feature described at
> http://www.dwarfstd.org/ShowIssue.php?issue=141215.1 
> <http://www.dwarfstd.org/ShowIssue.php?issue=141215.1>
> 
> This allows a consumer to understand whether a composite data type is
> trivially copyable and thus should be passed by value instead of by
> reference. The canonical example is being able to distinguish the
> following two types:
> 
>   // S is not trivially copyable because of the explicit destructor.
>   struct S {
>  ~S() {}
>   };
> 
>   // T is a POD type.
>   struct T {
> ~T() = default;
>   };
> 
> 
> Differential Revision: https://reviews.llvm.org/D41039 
> <https://reviews.llvm.org/D41039>
> 
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018
> @@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea
> 
>SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
> 
> +  // Explicitly record the calling convention for C++ records.
> +  auto Flags = llvm::DINode::FlagZero;
> +  if (auto CXXRD = dyn_cast(RD)) {
> +if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
> +  Flags |= llvm::DINode::FlagTypePassByReference;
> +else
> +  Flags |= llvm::DINode::FlagTypePassByValue;
> +  }
> +
>llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
>getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,
> -  llvm::DINode::FlagZero, FullName);
> +  Flags, FullName);
> 
>// Elements of composite types usually have back to the type, creating
>// uniquing cycles.  Distinct nodes are more efficient.
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4 17:13:52 
> 2018
> @@ -0,0 +1,48 @@
> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple 
> %itanium_abi_triple %s -o - | FileCheck %s
> +
> +// Not trivially copyable because of the explicit destructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefDtor {
> +  int i;
> +  ~RefDtor() {}
> +} refDtor;
> +
> +// Not trivially copyable because of the explicit copy constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefCopy {
> +  int i;
> +  RefCopy() = default;
> +  RefCopy(RefCopy &Copy) {}
> +} refCopy;
> +
> +// Not trivially copyable because of the explicit move constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefMove {
> +  int i;
> +  

r327078 - Add a debug info testcase for the trvial_abi attribute.

2018-03-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Mar  8 15:11:46 2018
New Revision: 327078

URL: http://llvm.org/viewvc/llvm-project?rev=327078&view=rev
Log:
Add a debug info testcase for the trvial_abi attribute.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=327078&r1=327077&r2=327078&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Mar  8 15:11:46 
2018
@@ -38,3 +38,13 @@ struct Complex {
   Complex(Complex &Copy) : i(Copy.i) {};
   int i;
 } complex;
+
+// This type is manually marked as trivial_abi.
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Marked",{{.*}}flags: 
DIFlagTypePassByValue
+struct __attribute__((trivial_abi)) Marked {
+  int *p;
+  Marked();
+  ~Marked();
+  Marked(const Marked &) noexcept;
+  Marked &operator=(const Marked &);
+} marked;


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


r344915 - Ensure sanitizer check function calls have a !dbg location

2018-10-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct 22 09:27:41 2018
New Revision: 344915

URL: http://llvm.org/viewvc/llvm-project?rev=344915&view=rev
Log:
Ensure sanitizer check function calls have a !dbg location

Function calls without a !dbg location inside a function that has a
DISubprogram make it impossible to construct inline information and
are rejected by the verifier. This patch ensures that sanitizer check
function calls have a !dbg location, by carrying forward the location
of the preceding instruction or by inserting an artificial location if
necessary.

This fixes a crash when compiling the attached testcase with -Os.

rdar://problem/45311226

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

Added:
cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=344915&r1=344914&r2=344915&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 22 09:27:41 2018
@@ -2867,6 +2867,9 @@ static void emitCheckHandlerCall(CodeGen
  CheckRecoverableKind RecoverKind, bool 
IsFatal,
  llvm::BasicBlock *ContBB) {
   assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
+  auto *DI = CGF.getDebugInfo();
+  SourceLocation Loc = DI ? DI->getLocation() : SourceLocation();
+  auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
   bool NeedsAbortSuffix =
   IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
   bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;

Added: cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=344915&view=auto
==
--- cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp Mon Oct 22 09:27:41 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \
+// RUN:   -fsanitize=null %s -o - | FileCheck %s
+
+// Check that santizer check calls have a !dbg location.
+// CHECK: define {{.*}}acquire{{.*}} !dbg
+// CHECK-NOT: define
+// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1
+// CHECK-SAME: !dbg
+
+struct SourceLocation {
+  SourceLocation acquire() {};
+};
+extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);
+static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire(); }
+void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {
+  handleTypeMismatchImpl(Loc);
+}


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


r345071 - Fix doxygen comment.

2018-10-23 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Oct 23 12:39:02 2018
New Revision: 345071

URL: http://llvm.org/viewvc/llvm-project?rev=345071&view=rev
Log:
Fix doxygen comment.

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=345071&r1=345070&r2=345071&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Tue Oct 23 12:39:02 2018
@@ -1093,7 +1093,7 @@ public:
   /// template.
   ArrayRef getInjectedTemplateArgs();
 
-  /// Merge \param Prev with our RedeclarableTemplateDecl::Common.
+  /// Merge \p Prev with our RedeclarableTemplateDecl::Common.
   void mergePrevDecl(FunctionTemplateDecl *Prev);
 
   /// Create a function template node.


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


r345109 - Debug Info (-gmodules): emit full types for non-anchored template specializations

2018-10-23 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Oct 23 17:06:02 2018
New Revision: 345109

URL: http://llvm.org/viewvc/llvm-project?rev=345109&view=rev
Log:
Debug Info (-gmodules): emit full types for non-anchored template 
specializations

Before this patch, clang would emit a (module-)forward declaration for
template instantiations that are not anchored by an explicit template
instantiation, but still are guaranteed to be available in an imported
module. Unfortunately detecting the owning module doesn't reliably
work when local submodule visibility is enabled and the template is
inside a cross-module namespace.

This make clang debuggable again with -gmodules and LSV enabled.

rdar://problem/41552377

Added:
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap
cfe/trunk/test/Modules/lsv-debuginfo.cpp   (with props)
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Oct 23 17:06:02 2018
@@ -1955,8 +1955,17 @@ static bool isDefinedInClangModule(const
   if (auto *CXXDecl = dyn_cast(RD)) {
 if (!CXXDecl->isCompleteDefinition())
   return false;
+// Check wether RD is a template.
 auto TemplateKind = CXXDecl->getTemplateSpecializationKind();
 if (TemplateKind != TSK_Undeclared) {
+  // Unfortunately getOwningModule() isn't accurate enough to find the
+  // owning module of a ClassTemplateSpecializationDecl that is inside a
+  // namespace spanning multiple modules.
+  bool Explicit = false;
+  if (auto *TD = dyn_cast(CXXDecl))
+Explicit = TD->isExplicitInstantiationOrSpecialization();
+  if (!Explicit && CXXDecl->getEnclosingNamespaceContext())
+return false;
   // This is a template, check the origin of the first member.
   if (CXXDecl->field_begin() == CXXDecl->field_end())
 return TemplateKind == TSK_ExplicitInstantiationDeclaration;

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Oct 23 17:06:02 2018
@@ -83,11 +83,11 @@ void foo() {
 // CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]])
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX
 
-// This type is anchored in the module by an explicit template instantiation.
+// This type is not anchored in the module by an explicit template 
instantiation.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template >",
 // CHECK-SAME: scope: ![[NS]],
-// CHECK-SAME: flags: DIFlagFwdDecl,
+// CHECK-SAME: elements:
 // CHECK-SAME: identifier: 
"_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
 
 // This type is anchored in the module by an explicit template instantiation.

Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h?rev=345109&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h (added)
+++ cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h Tue Oct 23 17:06:02 2018
@@ -0,0 +1,45 @@
+#ifndef ADT
+#define ADT
+
+#ifdef WITH_NAMESPACE
+namespace llvm {
+#endif
+template 
+struct AlignedCharArray {
+  alignas(Alignment) char buffer[Size];
+};
+
+template 
+class AlignerImpl {
+  T1 t1;
+};
+
+template 
+union SizerImpl {
+  char arr1[sizeof(T1)];
+};
+
+template 
+struct AlignedCharArrayUnion
+: AlignedCharArray), sizeof(SizerImpl)> {};
+
+template 
+struct SmallVectorStorage {
+  AlignedCharArrayUnion InlineElts[N];
+};
+template 
+class SmallVector : SmallVectorStorage {};
+
+template 
+struct OptionalStorage {
+  AlignedCharArrayUnion storage;
+};
+template 
+class Optional {
+  OptionalStorage Storage;
+};
+
+#ifdef WITH_NAMESPACE
+} // namespace llvm
+#endif
+#endif

Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h?rev=345109&view=auto

Re: r345109 - Debug Info (-gmodules): emit full types for non-anchored template specializations

2018-10-29 Thread Adrian Prantl via cfe-commits


> On Oct 29, 2018, at 11:26 AM, David Blaikie  wrote:
> 
> Is this a workaround for now with the intent to fix this to allow such 
> implicit specializations to have their debug info modularized? I believe this 
> does work correctly in modular debug info with expliict modules, would 
> probably be sort of nice to have these things be consistent/similar?

It started as a workaround, but I reached the conclusion that it's not 
worthwhile pursuing a more space-efficient solution. Note that all this patch 
does is emit plain old non-modular debug info for non-explicit template 
specializations, so it is definitely safe & conservative. This increases the 
size of the clang module cache in a build of clang by 4MiB out of 1GiB total.

As you can read in my thread with Richard, it isn't possible in Clang to 
determine the clang module that contains the complete definition of a template 
specialization inside of a namespace for indirectly imported modules (such as 
in my testcase). That means that a consumer would have to look in every Clang 
module for complete types; not just in the transitive closure of imports of the 
.pcm that has the forward declaration. This lookup is expensive and difficult 
to implement in LLDB, so I decided not to pursue this further.

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


r346048 - Add an explicit -std=c++14 to this test.

2018-11-02 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Nov  2 15:19:02 2018
New Revision: 346048

URL: http://llvm.org/viewvc/llvm-project?rev=346048&view=rev
Log:
Add an explicit -std=c++14 to this test.

rdar://problem/45642490

Modified:
cfe/trunk/test/Modules/lsv-debuginfo.cpp

Modified: cfe/trunk/test/Modules/lsv-debuginfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lsv-debuginfo.cpp?rev=346048&r1=346047&r2=346048&view=diff
==
--- cfe/trunk/test/Modules/lsv-debuginfo.cpp (original)
+++ cfe/trunk/test/Modules/lsv-debuginfo.cpp Fri Nov  2 15:19:02 2018
@@ -1,7 +1,7 @@
 // Test C++ -gmodules debug info in the PCMs with local submodule visibility.
 // REQUIRES: asserts
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple\
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 \
 // RUN:   -fmodules-local-submodule-visibility %s \
 // RUN:   -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone \
 // RUN:   -dwarf-version=4 -fmodules -fimplicit-module-maps \
@@ -10,13 +10,13 @@
 // RUN: cat %t-mod.ll | FileCheck %s
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple\
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 \
 // RUN:   -fmodules-local-submodule-visibility %s \
 // RUN:   -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone \
 // RUN:   -dwarf-version=4 -fmodules -fimplicit-module-maps \
 // RUN:   -fmodules-cache-path="%t" -o %t.ll -I%S/Inputs/lsv-debuginfo \
-// RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll \
-// RUN:   -DWITH_NAMESPACE
+// RUN:   -DWITH_NAMESPACE \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 
 // ADT


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


r346454 - Fix a use-after-free introduced by r344915.

2018-11-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Nov  8 16:26:15 2018
New Revision: 346454

URL: http://llvm.org/viewvc/llvm-project?rev=346454&view=rev
Log:
Fix a use-after-free introduced by r344915.

r344915 added a call to ApplyDebugLocation to the sanitizer check
function emitter. Some of the sanitizers are emitted in the function
epilogue though and the LexicalScopeStack is emptied out before. By
detecting this situation and early-exiting from ApplyDebugLocation the
fallback location is used, which is equivalent to the return location.

rdar://problem/45859802

Added:
cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=346454&r1=346453&r2=346454&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov  8 16:26:15 2018
@@ -3538,7 +3538,7 @@ void CGDebugInfo::EmitLocation(CGBuilder
   // Update our current location
   setLocation(Loc);
 
-  if (CurLoc.isInvalid() || CurLoc.isMacroID())
+  if (CurLoc.isInvalid() || CurLoc.isMacroID() || LexicalBlockStack.empty())
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();

Added: cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-debuglog-return.c?rev=346454&view=auto
==
--- cfe/trunk/test/CodeGen/ubsan-debuglog-return.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-debuglog-return.c Thu Nov  8 16:26:15 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=line-tables-only -emit-llvm 
-fsanitize=returns-nonnull-attribute -o - %s | FileCheck %s
+// The UBSAN function call in the epilogue needs to have a debug location.
+
+__attribute__((returns_nonnull)) void *allocate() {}
+
+// CHECK: define nonnull i8* @allocate(){{.*}} !dbg
+// CHECK: call void @__ubsan_handle_nonnull_return_v1_abort
+// CHECK-SAME:  !dbg ![[LOC:[0-9]+]]
+// CHECK: ret i8*
+// CHECK-SAME:  !dbg ![[LOC]]


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


r346542 - Fix a nondeterminism in the debug info for VLA size expressions.

2018-11-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Nov  9 11:17:56 2018
New Revision: 346542

URL: http://llvm.org/viewvc/llvm-project?rev=346542&view=rev
Log:
Fix a nondeterminism in the debug info for VLA size expressions.

The artificial variable describing the array size is supposed to be
called "__vla_expr", but this was implemented by retrieving the name
of the associated alloca, which isn't a reliable source for the name,
since nonassert compilers may drop names from LLVM IR.

rdar://problem/45924808

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/debug-info-vla.c
cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=346542&r1=346541&r2=346542&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Nov  9 11:17:56 2018
@@ -1066,6 +1066,7 @@ void CodeGenFunction::EmitAndRegisterVar
   // For each dimension stores its QualType and corresponding
   // size-expression Value.
   SmallVector Dimensions;
+  SmallVector VLAExprNames;
 
   // Break down the array into individual dimensions.
   QualType Type1D = D.getType();
@@ -1074,8 +1075,14 @@ void CodeGenFunction::EmitAndRegisterVar
 if (auto *C = dyn_cast(VlaSize.NumElts))
   Dimensions.emplace_back(C, Type1D.getUnqualifiedType());
 else {
-  auto SizeExprAddr = CreateDefaultAlignTempAlloca(
-  VlaSize.NumElts->getType(), "__vla_expr");
+  // Generate a locally unique name for the size expression.
+  Twine Name = Twine("__vla_expr") + Twine(VLAExprCounter++);
+  SmallString<12> Buffer;
+  StringRef NameRef = Name.toStringRef(Buffer);
+  auto &Ident = getContext().Idents.getOwn(NameRef);
+  VLAExprNames.push_back(&Ident);
+  auto SizeExprAddr =
+  CreateDefaultAlignTempAlloca(VlaSize.NumElts->getType(), NameRef);
   Builder.CreateStore(VlaSize.NumElts, SizeExprAddr);
   Dimensions.emplace_back(SizeExprAddr.getPointer(),
   Type1D.getUnqualifiedType());
@@ -1089,20 +1096,20 @@ void CodeGenFunction::EmitAndRegisterVar
   // Register each dimension's size-expression with a DILocalVariable,
   // so that it can be used by CGDebugInfo when instantiating a DISubrange
   // to describe this array.
+  unsigned NameIdx = 0;
   for (auto &VlaSize : Dimensions) {
 llvm::Metadata *MD;
 if (auto *C = dyn_cast(VlaSize.NumElts))
   MD = llvm::ConstantAsMetadata::get(C);
 else {
   // Create an artificial VarDecl to generate debug info for.
-  IdentifierInfo &NameIdent = getContext().Idents.getOwn(
-  cast(VlaSize.NumElts)->getName());
+  IdentifierInfo *NameIdent = VLAExprNames[NameIdx++];
   auto VlaExprTy = VlaSize.NumElts->getType()->getPointerElementType();
   auto QT = getContext().getIntTypeForBitwidth(
   VlaExprTy->getScalarSizeInBits(), false);
   auto *ArtificialDecl = VarDecl::Create(
   getContext(), const_cast(D.getDeclContext()),
-  D.getLocation(), D.getLocation(), &NameIdent, QT,
+  D.getLocation(), D.getLocation(), NameIdent, QT,
   getContext().CreateTypeSourceInfo(QT), SC_Auto);
   ArtificialDecl->setImplicit();
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=346542&r1=346541&r2=346542&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Nov  9 11:17:56 2018
@@ -1197,6 +1197,8 @@ public:
 
 private:
   CGDebugInfo *DebugInfo;
+  /// Used to create unique names for artificial VLA size debug info variables.
+  unsigned VLAExprCounter = 0;
   bool DisableDebugInfo = false;
 
   /// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid

Modified: cfe/trunk/test/CodeGen/debug-info-vla.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-vla.c?rev=346542&r1=346541&r2=346542&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-vla.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-vla.c Fri Nov  9 11:17:56 2018
@@ -2,9 +2,9 @@
 
 void testVLAwithSize(int s)
 {
-// CHECK-DAG: dbg.declare({{.*}} %__vla_expr, metadata ![[VLAEXPR:[0-9]+]]
+// CHECK-DAG: dbg.declare({{.*}} %__vla_expr0, metadata ![[VLAEXPR:[0-9]+]]
 // CHECK-DAG: dbg.declare({{.*}} %vla, metadata ![[VAR:[0-9]+]]
-// CHECK-DAG: ![[VLAEXPR]] = !DILocalVariable(name: "__vla_expr", {{.*}} 
flags: DIFlagArtificial
+// CHECK-DAG: ![[VLAEXPR]] = !DILocalVariable(name: "__vla_expr0", {{.*}} 
flags: DIFlagArtificial
 // CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+2]]
 // 

r346556 - Revert "Revert rL346454: Fix a use-after-free introduced by r344915."

2018-11-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Nov  9 13:17:38 2018
New Revision: 346556

URL: http://llvm.org/viewvc/llvm-project?rev=346556&view=rev
Log:
Revert "Revert rL346454: Fix a use-after-free introduced by r344915."

This un-reverts commit 346454 with a relaxed CHECK for Windows.

Added:
cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=346556&r1=346555&r2=346556&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Nov  9 13:17:38 2018
@@ -3538,7 +3538,7 @@ void CGDebugInfo::EmitLocation(CGBuilder
   // Update our current location
   setLocation(Loc);
 
-  if (CurLoc.isInvalid() || CurLoc.isMacroID())
+  if (CurLoc.isInvalid() || CurLoc.isMacroID() || LexicalBlockStack.empty())
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();

Added: cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-debuglog-return.c?rev=346556&view=auto
==
--- cfe/trunk/test/CodeGen/ubsan-debuglog-return.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-debuglog-return.c Fri Nov  9 13:17:38 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=line-tables-only -emit-llvm 
-fsanitize=returns-nonnull-attribute -o - %s | FileCheck %s
+// The UBSAN function call in the epilogue needs to have a debug location.
+
+__attribute__((returns_nonnull)) void *allocate() {}
+
+// CHECK: define {{.*}}nonnull i8* @allocate(){{.*}} !dbg
+// CHECK: call void @__ubsan_handle_nonnull_return_v1_abort
+// CHECK-SAME:  !dbg ![[LOC:[0-9]+]]
+// CHECK: ret i8*
+// CHECK-SAME:  !dbg ![[LOC]]


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


r347810 - Ensure sanitizer check function calls have a !dbg location

2018-11-28 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Nov 28 13:44:06 2018
New Revision: 347810

URL: http://llvm.org/viewvc/llvm-project?rev=347810&view=rev
Log:
Ensure sanitizer check function calls have a !dbg location

Function calls without a !dbg location inside a function that has a
DISubprogram make it impossible to construct inline information and
are rejected by the verifier. This patch ensures that sanitizer check
function calls have a !dbg location, by carrying forward the location
of the preceding instruction or by inserting an artificial location if
necessary.

This fixes a crash when compiling the attached testcase with -Os.

rdar://problem/45311226

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

Note: This reapllies r344915, modified to reuse the IRBuilder's
DebugLoc if one exists instead of picking the one from CGDebugInfo
since the latter may get reset when emitting thunks such as block
helpers in the middle of emitting another function.

Added:
cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
cfe/trunk/test/CodeGenObjC/ubsan-check-debuglocs.m
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=347810&r1=347809&r2=347810&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Nov 28 13:44:06 2018
@@ -2879,6 +2879,11 @@ static void emitCheckHandlerCall(CodeGen
  CheckRecoverableKind RecoverKind, bool 
IsFatal,
  llvm::BasicBlock *ContBB) {
   assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
+  Optional DL;
+  if (!CGF.Builder.getCurrentDebugLocation()) {
+// Ensure that the call has at least an artificial debug location.
+DL.emplace(CGF, SourceLocation());
+  }
   bool NeedsAbortSuffix =
   IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
   bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;

Added: cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=347810&view=auto
==
--- cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp Wed Nov 28 13:44:06 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \
+// RUN:   -fsanitize=null %s -o - | FileCheck %s
+
+// Check that santizer check calls have a !dbg location.
+// CHECK: define {{.*}}acquire{{.*}} !dbg
+// CHECK-NOT: define
+// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1
+// CHECK-SAME: !dbg
+
+struct SourceLocation {
+  SourceLocation acquire() {};
+};
+extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);
+static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire(); }
+void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {
+  handleTypeMismatchImpl(Loc);
+}

Added: cfe/trunk/test/CodeGenObjC/ubsan-check-debuglocs.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ubsan-check-debuglocs.m?rev=347810&view=auto
==
--- cfe/trunk/test/CodeGenObjC/ubsan-check-debuglocs.m (added)
+++ cfe/trunk/test/CodeGenObjC/ubsan-check-debuglocs.m Wed Nov 28 13:44:06 2018
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -emit-llvm -fblocks -debug-info-kind=limited \
+// RUN:   -fsanitize=nullability-return %s -o - | FileCheck %s
+
+// Check that santizer check calls have a !dbg location.
+// CHECK: call void {{.*}}@__ubsan_handle_nullability_return_v1_abort
+// CHECK-SAME: !dbg
+
+@protocol NSObject
+@end
+
+@interface NSObject {}
+@end
+
+#pragma clang assume_nonnull begin
+@interface NSString : NSObject
++ (instancetype)stringWithFormat:(NSString *)format, ...;
+@end
+
+@interface NSIndexPath : NSObject {}
+@end
+#pragma clang assume_nonnull end
+
+@interface B : NSObject
+@end
+id foo(NSIndexPath *indexPath) {
+  return [B withBlock:^{
+return [NSString stringWithFormat:@"%ld",
+  (long)[indexPath indexAtPosition:1]];
+  }];
+}


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


r347926 - [-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs.

2018-11-29 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Nov 29 14:33:09 2018
New Revision: 347926

URL: http://llvm.org/viewvc/llvm-project?rev=347926&view=rev
Log:
[-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs.

This patch passes -fdebug-prefix-map (a feature for renaming source
paths in the debug info) through to the per-module codegen options and
adds the debug prefix map to the module hash.



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

Added:
cfe/trunk/test/Modules/module-debuginfo-prefix.m
Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=347926&r1=347925&r2=347926&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Thu Nov 29 
14:33:09 2018
@@ -156,6 +156,8 @@ public:
 LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+CodeGenOpts.DebugPrefixMap =
+CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
   }
 
   ~PCHContainerGenerator() override = default;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=347926&r1=347925&r2=347926&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Nov 29 14:33:09 2018
@@ -3264,6 +3264,12 @@ std::string CompilerInvocation::getModul
 code = ext->hashExtension(code);
   }
 
+  // When compiling with -gmodules, also hash -fdebug-prefix-map as it
+  // affects the debug info in the PCM.
+  if (getCodeGenOpts().DebugTypeExtRefs)
+for (const auto &KeyValue : getCodeGenOpts().DebugPrefixMap)
+  code = hash_combine(code, KeyValue.first, KeyValue.second);
+
   // Extend the signature with the enabled sanitizers, if at least one is
   // enabled. Sanitizers which cannot affect AST generation aren't hashed.
   SanitizerSet SanHash = LangOpts->Sanitize;

Added: cfe/trunk/test/Modules/module-debuginfo-prefix.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-debuginfo-prefix.m?rev=347926&view=auto
==
--- cfe/trunk/test/Modules/module-debuginfo-prefix.m (added)
+++ cfe/trunk/test/Modules/module-debuginfo-prefix.m Thu Nov 29 14:33:09 2018
@@ -0,0 +1,23 @@
+// REQUIRES: asserts
+
+// Modules:
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
+// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
+// RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: cat %t-mod.ll | FileCheck %s
+
+// PCH:
+// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
+// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
+// RUN: cat %t-pch.ll | FileCheck %s
+
+#ifdef MODULES
+@import DebugObjC;
+#endif
+
+// CHECK: !DIFile({{.*}}"/OVERRIDE/DebugObjC.h"


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


r348060 - Honor -fdebug-prefix-map when creating function names for the debug info.

2018-11-30 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Nov 30 16:24:27 2018
New Revision: 348060

URL: http://llvm.org/viewvc/llvm-project?rev=348060&view=rev
Log:
Honor -fdebug-prefix-map when creating function names for the debug info.

This adds a callback to PrintingPolicy to allow CGDebugInfo to remap
file paths according to -fdebug-prefix-map. Otherwise the debug info
(particularly function names for C++ lambdas) may contain paths that
should have been remapped in the debug info.



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

Added:
cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=348060&r1=348059&r2=348060&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Fri Nov 30 16:24:27 2018
@@ -38,21 +38,20 @@ public:
 struct PrintingPolicy {
   /// Create a default printing policy for the specified language.
   PrintingPolicy(const LangOptions &LO)
-: Indentation(2), SuppressSpecifiers(false),
-  SuppressTagKeyword(LO.CPlusPlus),
-  IncludeTagDefinition(false), SuppressScope(false),
-  SuppressUnwrittenScope(false), SuppressInitializers(false),
-  ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
-  SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
-  SuppressTemplateArgsInCXXConstructors(false),
-  Bool(LO.Bool), Restrict(LO.C99),
-  Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
-  UseVoidForZeroParams(!LO.CPlusPlus),
-  TerseOutput(false), PolishForDeclaration(false),
-  Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
-  IncludeNewlines(true), MSVCFormatting(false),
-  ConstantsAsWritten(false), SuppressImplicitBase(false),
-  FullyQualifiedName(false) { }
+  : Indentation(2), SuppressSpecifiers(false),
+SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
+SuppressScope(false), SuppressUnwrittenScope(false),
+SuppressInitializers(false), ConstantArraySizeAsWritten(false),
+AnonymousTagLocations(true), SuppressStrongLifetime(false),
+SuppressLifetimeQualifiers(false),
+SuppressTemplateArgsInCXXConstructors(false), Bool(LO.Bool),
+Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
+UseVoidForZeroParams(!LO.CPlusPlus), TerseOutput(false),
+PolishForDeclaration(false), Half(LO.Half),
+MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
+MSVCFormatting(false), ConstantsAsWritten(false),
+SuppressImplicitBase(false), FullyQualifiedName(false),
+RemapFilePaths(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -225,6 +224,12 @@ struct PrintingPolicy {
   /// When true, print the fully qualified name of function declarations.
   /// This is the opposite of SuppressScope and thus overrules it.
   unsigned FullyQualifiedName : 1;
+
+  /// Whether to apply -fdebug-prefix-map to any file paths.
+  unsigned RemapFilePaths : 1;
+
+  /// When RemapFilePaths is true, this function performs the action.
+  std::function remapPath;
 };
 
 } // end namespace clang

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=348060&r1=348059&r2=348060&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Nov 30 16:24:27 2018
@@ -1157,9 +1157,13 @@ void TypePrinter::printTag(TagDecl *D, r
   PresumedLoc PLoc = D->getASTContext().getSourceManager().getPresumedLoc(
   D->getLocation());
   if (PLoc.isValid()) {
-OS << " at " << PLoc.getFilename()
-   << ':' << PLoc.getLine()
-   << ':' << PLoc.getColumn();
+OS << " at ";
+StringRef File = PLoc.getFilename();
+if (Policy.RemapFilePaths)
+  OS << Policy.remapPath(File);
+else
+  OS << File;
+OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348060&r1=348059&r2=348060&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Nov 30 16:24:27 2018
@@ -235,6 +235,9 @@ PrintingPolicy CGDebugInfo::getPrintingP
   if (CGM.

r348062 - Relax test to also work on Windows.

2018-11-30 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Nov 30 17:30:00 2018
New Revision: 348062

URL: http://llvm.org/viewvc/llvm-project?rev=348062&view=rev
Log:
Relax test to also work on Windows.

Modified:
cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp?rev=348062&r1=348061&r2=348062&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp Fri Nov 30 17:30:00 
2018
@@ -4,7 +4,7 @@
 template  void b(T) {}
 void c() {
   // CHECK: !DISubprogram(name: "b<(lambda at
-  // CHECK-SAME:  /SOURCE_ROOT/debug-prefix-map-lambda.cpp
+  // CHECK-SAME:  SOURCE_ROOT
   // CHECK-SAME:  [[@LINE+1]]:{{[0-9]+}})>"
   b([]{});
 }


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


r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Dec  3 09:55:27 2018
New Revision: 348154

URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev
Log:
Avoid emitting redundant or unusable directories in DIFile metadata entries.

As discussed on llvm-dev recently, Clang currently emits redundant
directories in DIFile entries, such as

  .file  1 "/Volumes/Data/llvm" 
"/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

This patch looks at any common prefix between the compilation
directory and the (absolute) file path and strips the redundant
part. More importantly it leaves the compilation directory empty if
the two paths have no common prefix.

After this patch the above entry is (assuming a compilation dir of 
"/Volumes/Data/llvm/_build"):

  .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"

When building the FileCheck binary with debug info, this patch makes
the build artifacts ~1kb smaller.

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

Added:
cfe/trunk/test/CodeGen/debug-info-abspath.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/CodeGen/debug-prefix-map.c
cfe/trunk/test/Modules/module-debuginfo-prefix.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
@@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
   SourceManager &SM = CGM.getContext().getSourceManager();
   auto *Scope = cast(LexicalBlockStack.back());
   PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
-
-  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
+  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
 return;
 
   if (auto *LBF = dyn_cast(Scope)) {
@@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
-  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
+  StringRef FileName = PLoc.getFilename();
+  if (PLoc.isInvalid() || FileName.empty())
 // If the location is not valid then use main input file.
 return getOrCreateMainFile();
 
   // Cache the results.
-  const char *fname = PLoc.getFilename();
-  auto It = DIFileCache.find(fname);
+  auto It = DIFileCache.find(FileName.data());
 
   if (It != DIFileCache.end()) {
 // Verify that the information still exists.
@@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
 
-  llvm::DIFile *F = DBuilder.createFile(
-  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
CSInfo,
-  getSource(SM, SM.getFileID(Loc)));
+  StringRef Dir;
+  StringRef File;
+  std::string RemappedFile = remapDIPath(FileName);
+  std::string CurDir = remapDIPath(getCurrentDirname());
+  SmallString<128> DirBuf;
+  SmallString<128> FileBuf;
+  if (llvm::sys::path::is_absolute(RemappedFile)) {
+// Strip the common prefix (if it is more than just "/") from current
+// directory and FileName for a more space-efficient encoding.
+auto FileIt = llvm::sys::path::begin(RemappedFile);
+auto FileE = llvm::sys::path::end(RemappedFile);
+auto CurDirIt = llvm::sys::path::begin(CurDir);
+auto CurDirE = llvm::sys::path::end(CurDir);
+for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
+  llvm::sys::path::append(DirBuf, *CurDirIt);
+if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
+  // The common prefix only the root; stripping it would cause
+  // LLVM diagnostic locations to be more confusing.
+  Dir = {};
+  File = RemappedFile;
+} else {
+  for (; FileIt != FileE; ++FileIt)
+llvm::sys::path::append(FileBuf, *FileIt);
+  Dir = DirBuf;
+  File = FileBuf;
+}
+  } else {
+Dir = CurDir;
+File = RemappedFile;
+  }
+  llvm::DIFile *F =
+  DBuilder.createFile(File, Dir, CSInfo,
+  getSource(SM, SM.getFileID(Loc)));
 
-  DIFileCache[fname].reset(F);
+  DIFileCache[FileName.data()].reset(F);
   return F;
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=348154&r1=348153&r2=348154&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Dec  3 09:55:27 2018
@@ -549,12 +549,16 @@ const FullSourceLoc BackendConsumer::get
   SourceLocation DILoc;
 
   if (D.isLocationAvailable()) {
-D.getLocation(&Filename, &Line, &Column);
-const FileEntry *FE = File

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
I'll take a look right away. Thanks for letting me know!

-- adrian

> On Dec 3, 2018, at 1:26 PM, Vlad Tsyrklevich  wrote:
> 
> This change appears to have broken a number of compiler-rt coverage tests, 
> e.g. in this run 
> <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/17934/steps/test%20standalone%20compiler-rt/logs/stdio>.
>  The source of the error appears to be that llvm-cov is now trying to use a 
> relative path that's not relative to the directory it's in, though I'm not 
> familiar enough with debuginfo/coverage to understand what an appropriate fix 
> is. I've not yet reverted these changes to give you a chance to take a look.
> 
> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=348154&view=rev>
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata entries.
> 
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
> 
>   .file  1 "/Volumes/Data/llvm" 
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
> 
> After this patch the above entry is (assuming a compilation dir of 
> "/Volumes/Data/llvm/_build"):
> 
>   .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
> 
> Differential Revision: https://reviews.llvm.org/D55085 
> <https://reviews.llvm.org/D55085>
> 
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager &SM = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
> 
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager &SM = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
> 
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
> 
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
> 
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
> 
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc)));
> +  StringRef Dir;
> +  StringRef File;
> +  std::string RemappedFile = remapDIPath(FileName);
> +  std::string CurDir = remapDIPath(getCurrentDirname());
> +  SmallString<128> DirBuf;
> +  SmallString<128> FileBuf;
> +  if (llvm::sys::path::is_absolute(RemappedFile)) {
> +// Strip the common prefix (if it is more than just "/") from current
> +// direc

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
This should be fixed by LLVM r348203. Thanks for your patience!

-- adrian

> On Dec 3, 2018, at 1:27 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> I'll take a look right away. Thanks for letting me know!
> 
> -- adrian
> 
>> On Dec 3, 2018, at 1:26 PM, Vlad Tsyrklevich  wrote:
>> 
>> This change appears to have broken a number of compiler-rt coverage tests, 
>> e.g. in this run. The source of the error appears to be that llvm-cov is now 
>> trying to use a relative path that's not relative to the directory it's in, 
>> though I'm not familiar enough with debuginfo/coverage to understand what an 
>> appropriate fix is. I've not yet reverted these changes to give you a chance 
>> to take a look.
>> 
>> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
>>  wrote:
>> Author: adrian
>> Date: Mon Dec  3 09:55:27 2018
>> New Revision: 348154
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev
>> Log:
>> Avoid emitting redundant or unusable directories in DIFile metadata entries.
>> 
>> As discussed on llvm-dev recently, Clang currently emits redundant
>> directories in DIFile entries, such as
>> 
>>   .file  1 "/Volumes/Data/llvm" 
>> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> This patch looks at any common prefix between the compilation
>> directory and the (absolute) file path and strips the redundant
>> part. More importantly it leaves the compilation directory empty if
>> the two paths have no common prefix.
>> 
>> After this patch the above entry is (assuming a compilation dir of 
>> "/Volumes/Data/llvm/_build"):
>> 
>>   .file 1 "/Volumes/Data/llvm" 
>> "tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> When building the FileCheck binary with debug info, this patch makes
>> the build artifacts ~1kb smaller.
>> 
>> Differential Revision: https://reviews.llvm.org/D55085
>> 
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-abspath.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/test/CodeGen/debug-prefix-map.c
>> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
>> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>>SourceManager &SM = CGM.getContext().getSourceManager();
>>auto *Scope = cast(LexicalBlockStack.back());
>>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
>> -
>> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
>> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>>  return;
>> 
>>if (auto *LBF = dyn_cast(Scope)) {
>> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>SourceManager &SM = CGM.getContext().getSourceManager();
>>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>> 
>> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
>> +  StringRef FileName = PLoc.getFilename();
>> +  if (PLoc.isInvalid() || FileName.empty())
>>  // If the location is not valid then use main input file.
>>  return getOrCreateMainFile();
>> 
>>// Cache the results.
>> -  const char *fname = PLoc.getFilename();
>> -  auto It = DIFileCache.find(fname);
>> +  auto It = DIFileCache.find(FileName.data());
>> 
>>if (It != DIFileCache.end()) {
>>  // Verify that the information still exists.
>> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>if (CSKind)
>>  CSInfo.emplace(*CSKind, Checksum);
>> 
>> -  llvm::DIFile *F = DBuilder.createFile(
>> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
>> CSInfo,
>> -  getSource(SM, SM.getFileID(Loc)));
>> +  StringRef Dir;
>> +  StringRef File;
>> +  std::string RemappedFile = remapDIPath(FileName);
>> +  std::string CurDir = remapDIPath(getCurrentDirname());
>> +  SmallString<128> DirBuf;
>> +  SmallString<128> FileBuf;
>> +  if (llvm::sys::path::is_absolute(Rem

Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
No, your failures are Windows-specific (/ vs \), and I haven't fixed them yet. 
Thanks for letting me know!

-- adrian

> On Dec 3, 2018, at 3:06 PM, Galina Kistanova  wrote:
> 
> Adrian, did not see your response, please ignore my email.
> 
> Thanks
> 
> Galina
> 
> On Mon, Dec 3, 2018 at 3:04 PM Galina Kistanova  <mailto:gkistan...@gmail.com>> wrote:
> Hello Adrian,
> 
> This commit broke tests on couple of our builders:
> 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
>  
> <http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>  
> <http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast>
> 
> . . .
> Failing Tests (2):
> Clang :: CodeGen/debug-prefix-map.c
> Clang :: Modules/module-debuginfo-prefix.m
> 
> The builders were already red and no notifications were sent on this.
> Please have a look?
> 
> Thanks
> 
> Galina
> 
> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Dec  3 09:55:27 2018
> New Revision: 348154
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=348154&view=rev>
> Log:
> Avoid emitting redundant or unusable directories in DIFile metadata entries.
> 
> As discussed on llvm-dev recently, Clang currently emits redundant
> directories in DIFile entries, such as
> 
>   .file  1 "/Volumes/Data/llvm" 
> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> This patch looks at any common prefix between the compilation
> directory and the (absolute) file path and strips the redundant
> part. More importantly it leaves the compilation directory empty if
> the two paths have no common prefix.
> 
> After this patch the above entry is (assuming a compilation dir of 
> "/Volumes/Data/llvm/_build"):
> 
>   .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"
> 
> When building the FileCheck binary with debug info, this patch makes
> the build artifacts ~1kb smaller.
> 
> Differential Revision: https://reviews.llvm.org/D55085 
> <https://reviews.llvm.org/D55085>
> 
> Added:
> cfe/trunk/test/CodeGen/debug-info-abspath.c
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/test/CodeGen/debug-prefix-map.c
> cfe/trunk/test/Modules/module-debuginfo-prefix.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>SourceManager &SM = CGM.getContext().getSourceManager();
>auto *Scope = cast(LexicalBlockStack.back());
>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
> -
> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>  return;
> 
>if (auto *LBF = dyn_cast(Scope)) {
> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>SourceManager &SM = CGM.getContext().getSourceManager();
>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
> 
> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
> +  StringRef FileName = PLoc.getFilename();
> +  if (PLoc.isInvalid() || FileName.empty())
>  // If the location is not valid then use main input file.
>  return getOrCreateMainFile();
> 
>// Cache the results.
> -  const char *fname = PLoc.getFilename();
> -  auto It = DIFileCache.find(fname);
> +  auto It = DIFileCache.find(FileName.data());
> 
>if (It != DIFileCache.end()) {
>  // Verify that the information still exists.
> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>if (CSKind)
>  CSInfo.emplace(*CSKind, Checksum);
> 
> -  llvm::DIFile *F = DBuilder.createFile(
> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
> CSInfo,
> -  getSource(SM, SM.getFileID(Loc

r348211 - Relax tests to also work on Windows

2018-12-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Dec  3 15:11:19 2018
New Revision: 348211

URL: http://llvm.org/viewvc/llvm-project?rev=348211&view=rev
Log:
Relax tests to also work on Windows

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c
cfe/trunk/test/Modules/module-debuginfo-prefix.m

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348211&r1=348210&r2=348211&view=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Mon Dec  3 15:11:19 2018
@@ -18,19 +18,21 @@ void test_rewrite_includes() {
 
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{/|\\5C}}"
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// Dir should always be empty, but on Windows we can't recognize /var
+// as being an absolute path.
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/var/empty{{[/\\]}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
 // CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}"
 // CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "")
+// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
 // CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
 // CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "")
+// CHECK-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty")

Modified: cfe/trunk/test/Modules/module-debuginfo-prefix.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-debuginfo-prefix.m?rev=348211&r1=348210&r2=348211&view=diff
==
--- cfe/trunk/test/Modules/module-debuginfo-prefix.m (original)
+++ cfe/trunk/test/Modules/module-debuginfo-prefix.m Mon Dec  3 15:11:19 2018
@@ -20,4 +20,6 @@
 @import DebugObjC;
 #endif
 
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "")
+// Dir should always be empty, but on Windows we can't recognize /var
+// as being an absolute path.
+// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")


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


Re: r348154 - Avoid emitting redundant or unusable directories in DIFile metadata entries.

2018-12-03 Thread Adrian Prantl via cfe-commits
Should be fixed in r348211.

-- adrian

> On Dec 3, 2018, at 3:07 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> No, your failures are Windows-specific (/ vs \), and I haven't fixed them 
> yet. Thanks for letting me know!
> 
> -- adrian
> 
>> On Dec 3, 2018, at 3:06 PM, Galina Kistanova  wrote:
>> 
>> Adrian, did not see your response, please ignore my email.
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Mon, Dec 3, 2018 at 3:04 PM Galina Kistanova  wrote:
>> Hello Adrian,
>> 
>> This commit broke tests on couple of our builders:
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14371
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>> 
>> . . .
>> Failing Tests (2):
>> Clang :: CodeGen/debug-prefix-map.c
>> Clang :: Modules/module-debuginfo-prefix.m
>> 
>> The builders were already red and no notifications were sent on this.
>> Please have a look?
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Mon, Dec 3, 2018 at 9:58 AM Adrian Prantl via cfe-commits 
>>  wrote:
>> Author: adrian
>> Date: Mon Dec  3 09:55:27 2018
>> New Revision: 348154
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=348154&view=rev
>> Log:
>> Avoid emitting redundant or unusable directories in DIFile metadata entries.
>> 
>> As discussed on llvm-dev recently, Clang currently emits redundant
>> directories in DIFile entries, such as
>> 
>>   .file  1 "/Volumes/Data/llvm" 
>> "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> This patch looks at any common prefix between the compilation
>> directory and the (absolute) file path and strips the redundant
>> part. More importantly it leaves the compilation directory empty if
>> the two paths have no common prefix.
>> 
>> After this patch the above entry is (assuming a compilation dir of 
>> "/Volumes/Data/llvm/_build"):
>> 
>>   .file 1 "/Volumes/Data/llvm" 
>> "tools/clang/test/CodeGen/debug-info-abspath.c"
>> 
>> When building the FileCheck binary with debug info, this patch makes
>> the build artifacts ~1kb smaller.
>> 
>> Differential Revision: https://reviews.llvm.org/D55085
>> 
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-abspath.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/test/CodeGen/debug-prefix-map.c
>> cfe/trunk/test/Modules/module-debuginfo-prefix.m
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348154&r1=348153&r2=348154&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec  3 09:55:27 2018
>> @@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
>>SourceManager &SM = CGM.getContext().getSourceManager();
>>auto *Scope = cast(LexicalBlockStack.back());
>>PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
>> -
>> -  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
>> +  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
>>  return;
>> 
>>if (auto *LBF = dyn_cast(Scope)) {
>> @@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>SourceManager &SM = CGM.getContext().getSourceManager();
>>PresumedLoc PLoc = SM.getPresumedLoc(Loc);
>> 
>> -  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
>> +  StringRef FileName = PLoc.getFilename();
>> +  if (PLoc.isInvalid() || FileName.empty())
>>  // If the location is not valid then use main input file.
>>  return getOrCreateMainFile();
>> 
>>// Cache the results.
>> -  const char *fname = PLoc.getFilename();
>> -  auto It = DIFileCache.find(fname);
>> +  auto It = DIFileCache.find(FileName.data());
>> 
>>if (It != DIFileCache.end()) {
>>  // Verify that the information still exists.
>> @@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
>>if (CSKind)
>>  CSInfo.emplace(*CSKind, Checksum);
>> 
>> -  llvm::DIFile *F = DBuilder.createFile(
>> -  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
>> CSInfo,
>> -  

r348213 - Relax test even more for Windows

2018-12-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Dec  3 15:40:51 2018
New Revision: 348213

URL: http://llvm.org/viewvc/llvm-project?rev=348213&view=rev
Log:
Relax test even more for Windows

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348213&r1=348212&r2=348213&view=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Mon Dec  3 15:40:51 2018
@@ -36,5 +36,5 @@ void test_rewrite_includes() {
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty")
-// CHECK-COMPILATION-DIR: !DIFile(filename: "Inputs/stdio.h", directory: 
"/var/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/var/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:


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


r348397 - Honor -fdebug-prefix-map when creating function names for the debug info.

2018-12-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Dec  5 10:37:44 2018
New Revision: 348397

URL: http://llvm.org/viewvc/llvm-project?rev=348397&view=rev
Log:
Honor -fdebug-prefix-map when creating function names for the debug info.

This adds a callback to PrintingPolicy to allow CGDebugInfo to remap
file paths according to -fdebug-prefix-map. Otherwise the debug info
(particularly function names for C++ lambdas) may contain paths that
should have been remapped in the debug info.



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

Added:
cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Wed Dec  5 10:37:44 2018
@@ -50,7 +50,8 @@ struct PrintingPolicy {
 PolishForDeclaration(false), Half(LO.Half),
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
-SuppressImplicitBase(false), FullyQualifiedName(false) {}
+SuppressImplicitBase(false), FullyQualifiedName(false),
+RemapFilePaths(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -223,6 +224,12 @@ struct PrintingPolicy {
   /// When true, print the fully qualified name of function declarations.
   /// This is the opposite of SuppressScope and thus overrules it.
   unsigned FullyQualifiedName : 1;
+
+  /// Whether to apply -fdebug-prefix-map to any file paths.
+  unsigned RemapFilePaths : 1;
+
+  /// When RemapFilePaths is true, this function performs the action.
+  std::function remapPath;
 };
 
 } // end namespace clang

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Dec  5 10:37:44 2018
@@ -1157,9 +1157,13 @@ void TypePrinter::printTag(TagDecl *D, r
   PresumedLoc PLoc = D->getASTContext().getSourceManager().getPresumedLoc(
   D->getLocation());
   if (PLoc.isValid()) {
-OS << " at " << PLoc.getFilename()
-   << ':' << PLoc.getLine()
-   << ':' << PLoc.getColumn();
+OS << " at ";
+StringRef File = PLoc.getFilename();
+if (Policy.RemapFilePaths)
+  OS << Policy.remapPath(File);
+else
+  OS << File;
+OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Dec  5 10:37:44 2018
@@ -235,6 +235,9 @@ PrintingPolicy CGDebugInfo::getPrintingP
   if (CGM.getCodeGenOpts().EmitCodeView)
 PP.MSVCFormatting = true;
 
+  // Apply -fdebug-prefix-map.
+  PP.RemapFilePaths = true;
+  PP.remapPath = [this](StringRef Path) { return remapDIPath(Path); };
   return PP;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Dec  5 10:37:44 2018
@@ -341,6 +341,9 @@ public:
 
   void finalize();
 
+  /// Remap a given path with the current debug prefix map
+  std::string remapDIPath(StringRef) const;
+
   /// Register VLA size expression debug node with the qualified type.
   void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr) {
 SizeExprCache[Ty] = SizeExpr;
@@ -528,9 +531,6 @@ private:
   /// Create new compile unit.
   void CreateCompileUnit();
 
-  /// Remap a given path with the current debug prefix map
-  std::string remapDIPath(StringRef) const;
-
   /// Compute the file checksum debug info for input file ID.
   Optional
   computeChecksum(FileID FID, SmallString<32> &Checksum) const;

Added: cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp?rev=348397&view=auto
==

r348513 - Reapply "Avoid emitting redundant or unusable directories in DIFile metadata entries.""

2018-12-06 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec  6 10:44:50 2018
New Revision: 348513

URL: http://llvm.org/viewvc/llvm-project?rev=348513&view=rev
Log:
Reapply "Avoid emitting redundant or unusable directories in DIFile metadata 
entries.""

This reverts commit r348280 and reapplies D55085 without modifications.

Original commit message:

Avoid emitting redundant or unusable directories in DIFile metadata entries.

As discussed on llvm-dev recently, Clang currently emits redundant
directories in DIFile entries, such as

  .file  1 "/Volumes/Data/llvm" 
"/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

This patch looks at any common prefix between the compilation
directory and the (absolute) file path and strips the redundant
part. More importantly it leaves the compilation directory empty if
the two paths have no common prefix.

After this patch the above entry is (assuming a compilation dir of 
"/Volumes/Data/llvm/_build"):

  .file 1 "/Volumes/Data/llvm" 
"tools/clang/test/CodeGen/debug-info-abspath.c"

When building the FileCheck binary with debug info, this patch makes
the build artifacts ~1kb smaller.

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

Added:
cfe/trunk/test/CodeGen/debug-info-abspath.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/CodeGen/debug-prefix-map.c
cfe/trunk/test/Modules/module-debuginfo-prefix.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348513&r1=348512&r2=348513&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec  6 10:44:50 2018
@@ -181,8 +181,7 @@ void CGDebugInfo::setLocation(SourceLoca
   SourceManager &SM = CGM.getContext().getSourceManager();
   auto *Scope = cast(LexicalBlockStack.back());
   PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
-
-  if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
+  if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
 return;
 
   if (auto *LBF = dyn_cast(Scope)) {
@@ -410,13 +409,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
-  if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
+  StringRef FileName = PLoc.getFilename();
+  if (PLoc.isInvalid() || FileName.empty())
 // If the location is not valid then use main input file.
 return getOrCreateMainFile();
 
   // Cache the results.
-  const char *fname = PLoc.getFilename();
-  auto It = DIFileCache.find(fname);
+  auto It = DIFileCache.find(FileName.data());
 
   if (It != DIFileCache.end()) {
 // Verify that the information still exists.
@@ -431,11 +430,41 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
 
-  llvm::DIFile *F = DBuilder.createFile(
-  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
CSInfo,
-  getSource(SM, SM.getFileID(Loc)));
+  StringRef Dir;
+  StringRef File;
+  std::string RemappedFile = remapDIPath(FileName);
+  std::string CurDir = remapDIPath(getCurrentDirname());
+  SmallString<128> DirBuf;
+  SmallString<128> FileBuf;
+  if (llvm::sys::path::is_absolute(RemappedFile)) {
+// Strip the common prefix (if it is more than just "/") from current
+// directory and FileName for a more space-efficient encoding.
+auto FileIt = llvm::sys::path::begin(RemappedFile);
+auto FileE = llvm::sys::path::end(RemappedFile);
+auto CurDirIt = llvm::sys::path::begin(CurDir);
+auto CurDirE = llvm::sys::path::end(CurDir);
+for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
+  llvm::sys::path::append(DirBuf, *CurDirIt);
+if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
+  // The common prefix only the root; stripping it would cause
+  // LLVM diagnostic locations to be more confusing.
+  Dir = {};
+  File = RemappedFile;
+} else {
+  for (; FileIt != FileE; ++FileIt)
+llvm::sys::path::append(FileBuf, *FileIt);
+  Dir = DirBuf;
+  File = FileBuf;
+}
+  } else {
+Dir = CurDir;
+File = RemappedFile;
+  }
+  llvm::DIFile *F =
+  DBuilder.createFile(File, Dir, CSInfo,
+  getSource(SM, SM.getFileID(Loc)));
 
-  DIFileCache[fname].reset(F);
+  DIFileCache[FileName.data()].reset(F);
   return F;
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=348513&r1=348512&r2=348513&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/Cod

r348612 - Make testcase more robust for completely-out-of-tree builds.

2018-12-07 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Dec  7 09:04:26 2018
New Revision: 348612

URL: http://llvm.org/viewvc/llvm-project?rev=348612&view=rev
Log:
Make testcase more robust for completely-out-of-tree builds.

Thats to Dave Zarzycki for reprorting this!

Modified:
cfe/trunk/test/CodeGen/debug-info-abspath.c

Modified: cfe/trunk/test/CodeGen/debug-info-abspath.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-abspath.c?rev=348612&r1=348611&r2=348612&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-abspath.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-abspath.c Fri Dec  7 09:04:26 2018
@@ -1,15 +1,19 @@
+// RUN: mkdir -p %t/UNIQUEISH_SENTINEL
+// RUN: cp %s %t/UNIQUEISH_SENTINEL/debug-info-abspath.c
+
 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -emit-llvm -o - | FileCheck %s
+// RUN:   %t/UNIQUEISH_SENTINEL/debug-info-abspath.c -emit-llvm -o - \
+// RUN:   | FileCheck %s
 
 // RUN: cp %s %t.c
 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
 // RUN:   %t.c -emit-llvm -o - | FileCheck %s --check-prefix=INTREE
 void foo() {}
 
-// Since %s is an absolute path, directory should be a nonempty
-// prefix, but the CodeGen part should be part of the filename.
+// Since %s is an absolute path, directory should be the common
+// prefix, but the directory part should be part of the filename.
 
-// CHECK: DIFile(filename: "{{.*}}CodeGen{{.*}}debug-info-abspath.c"
-// CHECK-SAME:   directory: "{{.+}}")
+// CHECK: DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL{{.*}}debug-info-abspath.c"
+// CHECK-NOT:directory: "{{.*}}UNIQUEISH_SENTINEL
 
 // INTREE: DIFile({{.*}}directory: "{{.+}}CodeGen{{.*}}")


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


r348618 - Make testcase more robust for bots actually building in /var

2018-12-07 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Dec  7 09:57:44 2018
New Revision: 348618

URL: http://llvm.org/viewvc/llvm-project?rev=348618&view=rev
Log:
Make testcase more robust for bots actually building in /var

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348618&r1=348617&r2=348618&view=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Fri Dec  7 09:57:44 2018
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/var/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/var=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/var/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/var/empty %s -emit-llvm -o - -fdebug-compilation-dir %p 
| FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
 
 #include "Inputs/stdio.h"
 
@@ -16,25 +16,25 @@ void test_rewrite_includes() {
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{/|\\5C}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}",
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|\\5C}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}",
+// On POSIX systems "Dir" should actually be empty, but on Windows we
+// can't recognize "/UNLIKELY_PATH" as being an absolute path.
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/var/empty{{[/\\]}}Inputs/stdio.h",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}Inputs/stdio.h",
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}Inputs/stdio.h",
+// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}Inputs/stdio.h",
 // CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
-// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}Inputs/stdio.h",
+// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}"
+// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}Inputs/stdio.h",
 // CHECK-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty")
-// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/var/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"/UNLIKELY_PATH/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: 
"/UNLIKELY_PATH/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:


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


r348865 - Reuse code from CGDebugInfo::getOrCreateFile() when creating the file

2018-12-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Dec 11 08:58:43 2018
New Revision: 348865

URL: http://llvm.org/viewvc/llvm-project?rev=348865&view=rev
Log:
Reuse code from CGDebugInfo::getOrCreateFile() when creating the file
for the DICompileUnit.

This addresses post-commit feedback for D55085. Without this patch, a
main source file with an absolute paths may appear in different
DIFiles, once with the absolute path and once with the common prefix
between the absolute path and the current working directory.

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGen/debug-info-compilation-dir.c
cfe/trunk/test/PCH/debug-info-pch-path.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348865&r1=348864&r2=348865&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 11 08:58:43 2018
@@ -429,7 +429,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
+  return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
+}
 
+llvm::DIFile *
+CGDebugInfo::createFile(StringRef FileName,
+Optional> CSInfo,
+Optional Source) {
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
@@ -460,16 +466,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
 Dir = CurDir;
 File = RemappedFile;
   }
-  llvm::DIFile *F =
-  DBuilder.createFile(File, Dir, CSInfo,
-  getSource(SM, SM.getFileID(Loc)));
-
+  llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);
   DIFileCache[FileName.data()].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
-  return DBuilder.createFile(
+  return createFile(
   remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()),
   TheCU->getFile()->getChecksum(),
   CGM.getCodeGenOpts().EmbedSource ? TheCU->getSource() : None);
@@ -607,9 +610,7 @@ void CGDebugInfo::CreateCompileUnit() {
   auto &CGOpts = CGM.getCodeGenOpts();
   TheCU = DBuilder.createCompileUnit(
   LangTag,
-  DBuilder.createFile(remapDIPath(MainFileName),
-  remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID())),
+  createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID())),
   CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=348865&r1=348864&r2=348865&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Dec 11 08:58:43 2018
@@ -538,9 +538,16 @@ private:
   /// Get the source of the given file ID.
   Optional getSource(const SourceManager &SM, FileID FID);
 
-  /// Get the file debug info descriptor for the input location.
+  /// Convenience function to get the file debug info descriptor for the input
+  /// location.
   llvm::DIFile *getOrCreateFile(SourceLocation Loc);
 
+  /// Create a file debug info descriptor for a source file.
+  llvm::DIFile *
+  createFile(StringRef FileName,
+ Optional> CSInfo,
+ Optional Source);
+
   /// Get the file info for main compile unit.
   llvm::DIFile *getOrCreateMainFile();
 

Modified: cfe/trunk/test/CodeGen/debug-info-compilation-dir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-compilation-dir.c?rev=348865&r1=348864&r2=348865&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-compilation-dir.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-compilation-dir.c Tue Dec 11 08:58:43 2018
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
+// RUN: mkdir -p %t.dir && cd %t.dir
+// RUN: cp %s rel.c
+// RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm 
-debug-info-kind=limited rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
 // CHECK-NONSENSE: nonsense
 
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck 
-check-prefix=CHECK-DIR %s

Modified: cfe/trunk/test/PCH/debug-info-pch-path.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/debug-info-pch-path.c?rev=348865&r1=348864&r2=348865&view=diff
==
--- cfe/trunk

r348866 - Remove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly.

2018-12-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Dec 11 08:58:46 2018
New Revision: 348866

URL: http://llvm.org/viewvc/llvm-project?rev=348866&view=rev
Log:
Remove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348866&r1=348865&r2=348866&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 11 08:58:46 2018
@@ -220,7 +220,7 @@ llvm::DIScope *CGDebugInfo::getContextDe
   if (const auto *RDecl = dyn_cast(Context))
 if (!RDecl->isDependentType())
   return getOrCreateType(CGM.getContext().getTypeDeclType(RDecl),
- getOrCreateMainFile());
+ TheCU->getFile());
   return Default;
 }
 
@@ -404,7 +404,7 @@ Optional CGDebugInfo::getSour
 llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
   if (!Loc.isValid())
 // If Location is not valid then use main input file.
-return getOrCreateMainFile();
+return TheCU->getFile();
 
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
@@ -412,7 +412,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   StringRef FileName = PLoc.getFilename();
   if (PLoc.isInvalid() || FileName.empty())
 // If the location is not valid then use main input file.
-return getOrCreateMainFile();
+return TheCU->getFile();
 
   // Cache the results.
   auto It = DIFileCache.find(FileName.data());
@@ -471,13 +471,6 @@ CGDebugInfo::createFile(StringRef FileNa
   return F;
 }
 
-llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
-  return createFile(
-  remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()),
-  TheCU->getFile()->getChecksum(),
-  CGM.getCodeGenOpts().EmbedSource ? TheCU->getSource() : None);
-}
-
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
   for (const auto &Entry : DebugPrefixMap)
 if (Path.startswith(Entry.first))
@@ -641,9 +634,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
 return nullptr;
   case BuiltinType::ObjCClass:
 if (!ClassTy)
-  ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
-   "objc_class", TheCU,
-   getOrCreateMainFile(), 0);
+  ClassTy =
+  DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
+ "objc_class", TheCU, TheCU->getFile(), 0);
 return ClassTy;
   case BuiltinType::ObjCId: {
 // typedef struct objc_class *Class;
@@ -655,21 +648,21 @@ llvm::DIType *CGDebugInfo::CreateType(co
   return ObjTy;
 
 if (!ClassTy)
-  ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
-   "objc_class", TheCU,
-   getOrCreateMainFile(), 0);
+  ClassTy =
+  DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
+ "objc_class", TheCU, TheCU->getFile(), 0);
 
 unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy);
 
 auto *ISATy = DBuilder.createPointerType(ClassTy, Size);
 
-ObjTy = DBuilder.createStructType(
-TheCU, "objc_object", getOrCreateMainFile(), 0, 0, 0,
-llvm::DINode::FlagZero, nullptr, llvm::DINodeArray());
+ObjTy = DBuilder.createStructType(TheCU, "objc_object", TheCU->getFile(), 
0,
+  0, 0, llvm::DINode::FlagZero, nullptr,
+  llvm::DINodeArray());
 
 DBuilder.replaceArrays(
 ObjTy, DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
-   ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0,
+   ObjTy, "isa", TheCU->getFile(), 0, Size, 0, 0,
llvm::DINode::FlagZero, ISATy)));
 return ObjTy;
   }
@@ -677,7 +670,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
 if (!SelTy)
   SelTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
  "objc_selector", TheCU,
- getOrCreateMainFile(), 0);
+ TheCU->getFile(), 0);
 return SelTy;
   }
 
@@ -998,7 +991,7 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   if (Cache)
 return Cache;
   Cache = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name,
- TheCU, getOrCreateMainFile(), 0);
+ TheCU, TheCU->getFile(), 0);
   unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy);
   Cache = DBuilder.createPointerType(C

Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Adrian Prantl via cfe-commits
IIRC, the dwarf version on Darwin depends on the deployment target and is 2 for 
earlier versions of macOS and and 4 for newer ones (I need to dig through the 
driver code to determine the exact version).

I can take a look at this tomorrow morning.

-- adrian

> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
> 
> Hi Stephen,
> 
> It looks like your change has caused the 'debug-options.c' test to start 
> failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and 
> not 2. Could you please take a look.
> 
> Here's a link to a latest build on the public LLVM CI that contains the 
> failure:
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
>  
> 
> 
> Here's the failure itself:
> Command Output (stderr):
> --
>  
> <>/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
>  error: G_DWARF2: expected string not found in input
> // G_DWARF2: "-dwarf-version=2"
>  ^
> :5:515: note: scanning from here
>  
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
>  "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage" 
> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" "-disable-free" 
> "-main-file-name" "debug-options.c" "-mrelocation-model" "pic" "-pic-level" 
> "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" 
> "-munwind-tables" "-faligned-alloc-unavailable" "-target-cpu" "penryn" 
> "-dwarf-column-info" "-debug-info-kind=standalone" "-dwarf-version=4" 
> "-debugger-tuning=lldb" "-ggnu-pubnames" "-target-linker-version" "351.8" 
> "-coverage-notes-file" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
>  "-resource-dir" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
>  "-fdebug-compilation-dir" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
>  "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1" 
> "-fblocks" "-fencode-extended-block-signature" 
> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0" 
> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o" "-x" 
> "c" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
>   
>   
>   
>   
>   
>   
>   ^
> 
> 
> Adrian, I've looped you in since you reviewed the commit it looks like. Do 
> you know if that's expected behavior on Darwin?
> 
> Cheers,
> Alex
> 
> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: srhines
> Date: Thu Apr  4 11:17:46 2019
> New Revision: 357713
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=357713&view=rev 
> 
> Log:
> Verify that Android targets generate DWARF 4 by default.
> 
> Summary:
> In the future, Android releases will support DWARF 5, but we need to
> ensure that older targets only have DWARF 4 generated for them. This
> patch inserts that verification for all Android releases now. The patch
> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
> missing G_DWARF2 check label).
> 
> Reviewers: aprantl
> 
> Reviewed By: aprantl
> 
> Subscribers: chh, pirama, cfe-commits
> 
> Tags: #clang
> 
> Differential Revision: https://reviews.llvm.org/D60238 
> 
> 
> Modified:
> cfe/trunk/test/Driver/debug-options.c
> 
> Modified: cfe/trunk/test/Driver/debug-options.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713&r1=357712&r2=357713&view=diff
>  
> 
> ==
> --- cfe/trunk/test/Driver/debug-options.c (original)
> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
> @@ -17,9 +17,14 @@
>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
> +// RUN: 

r353219 - Fix a missing word in comment

2019-02-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Feb  5 13:21:01 2019
New Revision: 353219

URL: http://llvm.org/viewvc/llvm-project?rev=353219&view=rev
Log:
Fix a missing word in comment

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=353219&r1=353218&r2=353219&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  5 13:21:01 2019
@@ -450,8 +450,8 @@ CGDebugInfo::createFile(StringRef FileNa
 for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
   llvm::sys::path::append(DirBuf, *CurDirIt);
 if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
-  // The common prefix only the root; stripping it would cause
-  // LLVM diagnostic locations to be more confusing.
+  // Don't strip the common prefix if it is only the root "/"
+  // since that would make LLVM diagnostic locations confusing.
   Dir = {};
   File = RemappedFile;
 } else {


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


r353568 - Fix typo

2019-02-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb  8 13:13:25 2019
New Revision: 353568

URL: http://llvm.org/viewvc/llvm-project?rev=353568&view=rev
Log:
Fix typo

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

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=353568&r1=353567&r2=353568&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Fri Feb  8 13:13:25 2019
@@ -215,7 +215,7 @@ public:
   /// If none is specified, abort (GCC-compatible behaviour).
   std::string OverflowHandler;
 
-  /// The module currently being compiled as speficied by -fmodule-name.
+  /// The module currently being compiled as specified by -fmodule-name.
   std::string ModuleName;
 
   /// The name of the current module, of which the main source file


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


r353578 - -gmodules: Don't emit incomplete breadcrumbs pointing to nonexistant PCM files.

2019-02-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb  8 15:15:42 2019
New Revision: 353578

URL: http://llvm.org/viewvc/llvm-project?rev=353578&view=rev
Log:
-gmodules: Don't emit incomplete breadcrumbs pointing to nonexistant PCM files.

When a module name is specified as -fmodule-name, that module gets a
clang::Module object, but it won't actually be built or imported; it
will be textual. CGDebugInfo wouldn't detect this and them emit a
DICompileUnit that had a hash but no name and that confused both
dsymutil, LLDB, and myself.

rdar://problem/47926508

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

Added:
cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=353578&r1=353577&r2=353578&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb  8 15:15:42 2019
@@ -2296,7 +2296,14 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   }
 
   bool IsRootModule = M ? !M->Parent : true;
-  if (CreateSkeletonCU && IsRootModule) {
+  // When a module name is specified as -fmodule-name, that module gets a
+  // clang::Module object, but it won't actually be built or imported; it will
+  // be textual.
+  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty())
+assert((!M || (M->Name == CGM.getLangOpts().ModuleName)) &&
+   "clang module without ASTFile must be specified by -fmodule-name");
+
+  if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
@@ -2313,6 +2320,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   Signature);
 DIB.finalize();
   }
+
   llvm::DIModule *Parent =
   IsRootModule ? nullptr
: getOrCreateModuleRef(

Added: cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfo-fmodule-name.c?rev=353578&view=auto
==
--- cfe/trunk/test/Modules/DebugInfo-fmodule-name.c (added)
+++ cfe/trunk/test/Modules/DebugInfo-fmodule-name.c Fri Feb  8 15:15:42 2019
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=F \
+// RUN: -debug-info-kind=limited -dwarf-ext-refs \
+// RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -F %S/Inputs \
+// RUN: %s -S -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
+
+#include "F/F.h"
+
+// CHECK: !DICompileUnit
+// CHECK-NOT: dwoId:
+
+// We still want the import, but no skeleton CU, since no PCM was built.
+
+// CHECK: !DIModule({{.*}}, name: "F"
+// CHECK-NOT: !DICompileUnit
+// CHECK-NOT: dwoId:


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


r354165 - Relax assertion to account for private framework modules, too.

2019-02-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb 15 12:24:26 2019
New Revision: 354165

URL: http://llvm.org/viewvc/llvm-project?rev=354165&view=rev
Log:
Relax assertion to account for private framework modules, too.

rdar://problem/48116069

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/DebugInfo-fmodule-name.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb 15 12:24:26 2019
@@ -2299,8 +2299,8 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   // When a module name is specified as -fmodule-name, that module gets a
   // clang::Module object, but it won't actually be built or imported; it will
   // be textual.
-  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty())
-assert((!M || (M->Name == CGM.getLangOpts().ModuleName)) &&
+  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty() && M)
+assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
 
   if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {

Modified: cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfo-fmodule-name.c?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/test/Modules/DebugInfo-fmodule-name.c (original)
+++ cfe/trunk/test/Modules/DebugInfo-fmodule-name.c Fri Feb 15 12:24:26 2019
@@ -1,16 +1,16 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=F \
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=MainA \
 // RUN: -debug-info-kind=limited -dwarf-ext-refs \
 // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -F %S/Inputs \
 // RUN: %s -S -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
 
-#include "F/F.h"
+#include "MainA/MainPriv.h"
 
 // CHECK: !DICompileUnit
 // CHECK-NOT: dwoId:
 
 // We still want the import, but no skeleton CU, since no PCM was built.
 
-// CHECK: !DIModule({{.*}}, name: "F"
+// CHECK: !DIModule({{.*}}, name: "APriv"
 // CHECK-NOT: !DICompileUnit
 // CHECK-NOT: dwoId:


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


Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-28 Thread Adrian Prantl via cfe-commits
It's possible that this testcase can be golfed some more. I copied it almost 
verbatim from the PR. I'll see what I can do. The important thing is that it 
needs to trigger the situation where the frontend is creating an inlined 
function.

-- adrian
> On Aug 28, 2017, at 4:43 PM, David Blaikie  wrote:
> 
> Seems like a rather complex test case - could you explain what's going on 
> there? (maybe in the form of a comment in the code - what path through all 
> those classes is required to tickle this)
> 
> On Wed, Aug 23, 2017 at 2:25 PM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Wed Aug 23 14:24:12 2017
> New Revision: 311601
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=311601&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=311601&view=rev>
> Log:
> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be
> parented in function declarations.
> 
> Fixes PR33997.
> https://bugs.llvm.org/show_bug.cgi?id=33997 
> <https://bugs.llvm.org/show_bug.cgi?id=33997>
> 
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601&r1=311600&r2=311601&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601&r1=311600&r2=311601&view=diff>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>llvm::DISubprogram *SP = nullptr;
>if (FI != SPCache.end())
>  SP = dyn_cast_or_null(FI->second);
> -  if (!SP)
> +  if (!SP || !SP->isDefinition())
>  SP = getFunctionStub(GD);
>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>LexicalBlockStack.emplace_back(SP);
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601&view=auto
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601&view=auto>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12 2017
> @@ -0,0 +1,45 @@
> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 
> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
> +// PR33997.
> +struct already_AddRefed {
> +  ~already_AddRefed();
> +};
> +struct RefPtr {
> +  operator int *();
> +};
> +struct ServoCssRulesStrong {
> +  already_AddRefed Consume();
> +};
> +struct GroupRule {
> +  GroupRule(already_AddRefed);
> +};
> +class ConditionRule : GroupRule {
> +  using GroupRule::GroupRule;
> +};
> +class CSSMediaRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class CSSMozDocumentRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class ServoDocumentRule : CSSMozDocumentRule {
> +  ServoDocumentRule(RefPtr);
> +};
> +class ServoMediaRule : CSSMediaRule {
> +  ServoMediaRule(RefPtr);
> +};
> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
> +: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
> +
> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
> +
> +// CHECK: define{{.*}}ServoMediaRule
> +// CHECK-NOT: {{ ret }}
> +// CHECK: store %class.ConditionRule* %
> +// CHECK-SAME: %class.ConditionRule** %
> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
> +
> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", 
> {{.*}}isDefinition: true
> 
> 
> ___
> 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


r312148 - Adapt testcases to LLVM change r312144 in DIGlobalVariableExpression

2017-08-30 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 30 11:22:23 2017
New Revision: 312148

URL: http://llvm.org/viewvc/llvm-project?rev=312148&view=rev
Log:
Adapt testcases to LLVM change r312144 in DIGlobalVariableExpression

Modified:
cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
cfe/trunk/test/CodeGen/debug-info-static.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/debug-info.cpp
cfe/trunk/test/CodeGenCXX/inline-dllexport-member.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl

Modified: cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c?rev=312148&r1=312147&r2=312148&view=diff
==
--- cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c (original)
+++ cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c Wed Aug 30 11:22:23 2017
@@ -10,11 +10,11 @@ int main() {
   return 0;
 }
 
-// CHECK: [[L]] = !DIGlobalVariableExpression(var: [[LV:.*]])
+// CHECK: [[L]] = !DIGlobalVariableExpression(var: [[LV:.*]], expr: 
!DIExpression())
 // CHECK: [[LV]] = distinct !DIGlobalVariable(name: "localstatic"
 // CHECK-NOT: linkageName:
 // CHECK-SAME:line: 9,
-// CHECK: [[G]] = !DIGlobalVariableExpression(var: [[GV:.*]])
+// CHECK: [[G]] = !DIGlobalVariableExpression(var: [[GV:.*]], expr: 
!DIExpression())
 // CHECK: [[GV]] = distinct !DIGlobalVariable(name: "global"
 // CHECK-NOT: linkageName:
 // CHECK-SAME:line: 7,

Modified: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=312148&r1=312147&r2=312148&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Wed Aug 30 11:22:23 2017
@@ -46,6 +46,6 @@ int main() {
 // CHECK-SAME:  isLocal: true, isDefinition: 
true
 
 // CHECK-LDlg-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", 
{{.*}}, isLocal: true, isDefinition: true)
-// CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]])
+// CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr: 
!DIExpression())
 // CHECK-LDsm-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", 
{{.*}}, isLocal: true, isDefinition: true)
 // CHECK-LDsm-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr:

Modified: cfe/trunk/test/CodeGen/debug-info-static.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static.c?rev=312148&r1=312147&r2=312148&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static.c Wed Aug 30 11:22:23 2017
@@ -2,7 +2,7 @@
 
 // CHECK: @f.xyzzy = internal global i32 0, align 4, !dbg [[XYZZY:![0-9]+]]
 
-// CHECK: [[XYZZY]] = !DIGlobalVariableExpression(var: [[VAR:.*]])
+// CHECK: [[XYZZY]] = !DIGlobalVariableExpression(var: [[VAR:.*]], expr: 
!DIExpression())
 // CHECK: [[VAR]] = distinct !DIGlobalVariable
 void f(void)
 {

Modified: cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp?rev=312148&r1=312147&r2=312148&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp Wed Aug 30 11:22:23 
2017
@@ -32,7 +32,7 @@ public:
 // why the definition of "a" comes before the declarations while
 // "b" and "c" come after.
 
-// CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AV:.*]])
+// CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AV:.*]], expr: 
!DIExpression())
 // CHECK: [[AV]] = distinct !DIGlobalVariable(name: "a",
 // CHECK-SAME:declaration: ![[DECL_A:[0-9]+]])
 //
@@ -45,7 +45,7 @@ public:
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_decl_templ_var"
 
 int C::a = 4;
-// CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BV:.*]])
+// CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BV:.*]], expr: 
!DIExpression())
 // CHECK: [[BV]] = distinct !DIGlobalVariable(name: "b",
 // CHECK-SAME:declaration: ![[DECL_B:[0-9]+]])
 // CHECK: ![[DECL_B]] = !DIDerivedType(tag: DW_TAG_member, name: "b"
@@ -93,7 +93,7 @@ int C::a = 4;
 // CHECK-SAME:   flags: DIFlagPublic | DIFlagStaticMember)
 
 int C::b 

r312175 - Test-case golfing.

2017-08-30 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 30 14:31:16 2017
New Revision: 312175

URL: http://llvm.org/viewvc/llvm-project?rev=312175&view=rev
Log:
Test-case golfing.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=312175&r1=312174&r2=312175&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 30 14:31:16 2017
@@ -1,45 +1,29 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 
-gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
 // PR33997.
-struct already_AddRefed {
-  ~already_AddRefed();
+struct WithDtor {
+  ~WithDtor();
 };
-struct RefPtr {
-  operator int *();
+struct Base {
+  Base(WithDtor);
 };
-struct ServoCssRulesStrong {
-  already_AddRefed Consume();
+class Forward : Base {
+  using Base::Base;
 };
-struct GroupRule {
-  GroupRule(already_AddRefed);
+class A : Forward {
+  A();
 };
-class ConditionRule : GroupRule {
-  using GroupRule::GroupRule;
+class B : Forward {
+  B();
 };
-class CSSMediaRule : ConditionRule {
-  using ConditionRule::ConditionRule;
-};
-class CSSMozDocumentRule : ConditionRule {
-  using ConditionRule::ConditionRule;
-};
-class ServoDocumentRule : CSSMozDocumentRule {
-  ServoDocumentRule(RefPtr);
-};
-class ServoMediaRule : CSSMediaRule {
-  ServoMediaRule(RefPtr);
-};
-ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
-ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
-ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
-: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
+A::A() : Forward(WithDtor()) {}
 
-ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
-: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
+B::B() : Forward(WithDtor()) {}
 
-// CHECK: define{{.*}}ServoMediaRule
+// CHECK: define{{.*}}A
 // CHECK-NOT: {{ ret }}
-// CHECK: store %class.ConditionRule* %
-// CHECK-SAME: %class.ConditionRule** %
+// CHECK: store %class.Forward* %
+// CHECK-SAME: %class.Forward** %
 // CHECK-SAME: !dbg ![[INL:[0-9]+]]
 
-// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
-// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", 
{{.*}}isDefinition: true
+// CHECK: ![[INL]] = !DILocation(line: 10, scope: ![[SP:[0-9]+]], inlinedAt:
+// CHECK: ![[SP]] = distinct !DISubprogram(name: "Base", {{.*}}isDefinition: 
true


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


Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-30 Thread Adrian Prantl via cfe-commits
Reduced in r312175.

-- adrian


> On Aug 28, 2017, at 4:47 PM, David Blaikie  wrote:
> 
> *nod* Thanks - let me know if you have trouble simplifying or explaining it & 
> I'll see if fresh eyes help :)
> 
> On Mon, Aug 28, 2017 at 4:46 PM Adrian Prantl  wrote:
> It's possible that this testcase can be golfed some more. I copied it almost 
> verbatim from the PR. I'll see what I can do. The important thing is that it 
> needs to trigger the situation where the frontend is creating an inlined 
> function.
> 
> -- adrian
> 
>> On Aug 28, 2017, at 4:43 PM, David Blaikie  wrote:
>> 
>> Seems like a rather complex test case - could you explain what's going on 
>> there? (maybe in the form of a comment in the code - what path through all 
>> those classes is required to tickle this)
>> 
>> On Wed, Aug 23, 2017 at 2:25 PM Adrian Prantl via cfe-commits 
>>  wrote:
>> Author: adrian
>> Date: Wed Aug 23 14:24:12 2017
>> New Revision: 311601
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=311601&view=rev
>> Log:
>> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be
>> parented in function declarations.
>> 
>> Fixes PR33997.
>> https://bugs.llvm.org/show_bug.cgi?id=33997
>> 
>> Added:
>> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601&r1=311600&r2=311601&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
>> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>>llvm::DISubprogram *SP = nullptr;
>>if (FI != SPCache.end())
>>  SP = dyn_cast_or_null(FI->second);
>> -  if (!SP)
>> +  if (!SP || !SP->isDefinition())
>>  SP = getFunctionStub(GD);
>>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>>LexicalBlockStack.emplace_back(SP);
>> 
>> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601&view=auto
>> ==
>> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
>> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12 2017
>> @@ -0,0 +1,45 @@
>> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 
>> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
>> +// PR33997.
>> +struct already_AddRefed {
>> +  ~already_AddRefed();
>> +};
>> +struct RefPtr {
>> +  operator int *();
>> +};
>> +struct ServoCssRulesStrong {
>> +  already_AddRefed Consume();
>> +};
>> +struct GroupRule {
>> +  GroupRule(already_AddRefed);
>> +};
>> +class ConditionRule : GroupRule {
>> +  using GroupRule::GroupRule;
>> +};
>> +class CSSMediaRule : ConditionRule {
>> +  using ConditionRule::ConditionRule;
>> +};
>> +class CSSMozDocumentRule : ConditionRule {
>> +  using ConditionRule::ConditionRule;
>> +};
>> +class ServoDocumentRule : CSSMozDocumentRule {
>> +  ServoDocumentRule(RefPtr);
>> +};
>> +class ServoMediaRule : CSSMediaRule {
>> +  ServoMediaRule(RefPtr);
>> +};
>> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
>> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
>> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
>> +: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
>> +
>> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
>> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
>> +
>> +// CHECK: define{{.*}}ServoMediaRule
>> +// CHECK-NOT: {{ ret }}
>> +// CHECK: store %class.ConditionRule* %
>> +// CHECK-SAME: %class.ConditionRule** %
>> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
>> +
>> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
>> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", 
>> {{.*}}isDefinition: true
>> 
>> 
>> ___
>> 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] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Adrian Prantl via cfe-commits

> On Sep 8, 2017, at 10:54 AM, Paul Robinson via Phabricator 
>  wrote:
> 
> probinson added a comment.
> 
> In https://reviews.llvm.org/D37604#864187, @aprantl wrote:
> 
>> This seems reasonable to me, thanks!
>> When you commit this, could you please double-check that the tests are still 
>> running on the green dragon builders? I'll also keep an eye on them.

> 
> I was able to google "llvm green dragon" and find what looks like the right 
> page, but I kind of would have expected to see a link on the llvm.org front 
> page?  Am I just not looking in the right place?

This is our canonical url: http://green.lab.llvm.org/green/
I've CC'ed Mike, perhaps he can work with Tanya to feature the link more 
prominently?

I just checked and the tests are running in the first green build after your 
commit:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/35303/consoleFull

PASS: Clang :: debuginfo-tests/aggregate-indirect-arg.cpp (11846 of 39540)
PASS: Clang :: debuginfo-tests/vla.c (11847 of 39540)
PASS: Clang :: debuginfo-tests/dbg-arg.c (11848 of 39540)
PASS: Clang :: debuginfo-tests/sret.cpp (11849 of 39540)
PASS: Clang :: debuginfo-tests/ctor.cpp (11850 of 39540)
PASS: Clang :: debuginfo-tests/stack-var.c (11851 of 39540)

...

thanks for checking!
adrian
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Adrian Prantl via cfe-commits

> On Sep 8, 2017, at 11:43 AM, Adrian Prantl  wrote:
> 
> 
>> On Sep 8, 2017, at 10:54 AM, Paul Robinson via Phabricator 
>>  wrote:
>> 
>> probinson added a comment.
>> 
>> In https://reviews.llvm.org/D37604#864187, @aprantl wrote:
>> 
>>> This seems reasonable to me, thanks!
>>> When you commit this, could you please double-check that the tests are 
>>> still running on the green dragon builders? I'll also keep an eye on them.
> 
>> 
>> I was able to google "llvm green dragon" and find what looks like the right 
>> page, but I kind of would have expected to see a link on the llvm.org front 
>> page?  Am I just not looking in the right place?
> 
> This is our canonical url: http://green.lab.llvm.org/green/
> I've CC'ed Mike, perhaps he can work with Tanya to feature the link more 
> prominently?
> 
> I just checked and the tests are running in the first green build after your 
> commit:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/35303/consoleFull
> 

Sorry — there was an infrastructure issue this morning, that caused those 
builds to not finish chronologically, The run of the tests after your commit 
hasn't started yet. I'll watch out for it.

-- adrian

> PASS: Clang :: debuginfo-tests/aggregate-indirect-arg.cpp (11846 of 39540)
> PASS: Clang :: debuginfo-tests/vla.c (11847 of 39540)
> PASS: Clang :: debuginfo-tests/dbg-arg.c (11848 of 39540)
> PASS: Clang :: debuginfo-tests/sret.cpp (11849 of 39540)
> PASS: Clang :: debuginfo-tests/ctor.cpp (11850 of 39540)
> PASS: Clang :: debuginfo-tests/stack-var.c (11851 of 39540)
> 
> ...
> 
> thanks for checking!
> adrian

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


r349065 - Reinstate DW_AT_comp_dir support after D55519.

2018-12-13 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 13 09:53:29 2018
New Revision: 349065

URL: http://llvm.org/viewvc/llvm-project?rev=349065&view=rev
Log:
Reinstate DW_AT_comp_dir support after D55519.

The DIFile used by the CU is special and distinct from the main source
file. Its directory part specifies what becomes the DW_AT_comp_dir
(the compilation directory), even if the source file was specified
with an absolute path.

To support the .dwo workflow, a valid DW_AT_comp_dir is necessary even
if source files were specified with an absolute path.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info-abspath.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=349065&r1=349064&r2=349065&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 13 09:53:29 2018
@@ -416,7 +416,6 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
 
   // Cache the results.
   auto It = DIFileCache.find(FileName.data());
-
   if (It != DIFileCache.end()) {
 // Verify that the information still exists.
 if (llvm::Metadata *V = It->second)
@@ -595,22 +594,27 @@ void CGDebugInfo::CreateCompileUnit() {
 break;
   }
 
+  uint64_t DwoId = 0;
+  auto &CGOpts = CGM.getCodeGenOpts();
+  // The DIFile used by the CU is distinct from the main source
+  // file. Its directory part specifies what becomes the
+  // DW_AT_comp_dir (the compilation directory), even if the source
+  // file was specified with an absolute path.
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
+  llvm::DIFile *CUFile = DBuilder.createFile(
+  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
+  getSource(SM, SM.getMainFileID()));
 
   // Create new compile unit.
-  // FIXME - Eliminate TheCU.
-  auto &CGOpts = CGM.getCodeGenOpts();
   TheCU = DBuilder.createCompileUnit(
-  LangTag,
-  createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID())),
-  CGOpts.EmitVersionIdentMetadata ? Producer : "",
+  LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers,
   (CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
   ? ""
   : CGOpts.SplitDwarfFile,
-  EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining,
+  EmissionKind, DwoId, CGOpts.SplitDwarfInlining,
   CGOpts.DebugInfoForProfiling,
   CGM.getTarget().getTriple().isNVPTX()
   ? llvm::DICompileUnit::DebugNameTableKind::None

Modified: cfe/trunk/test/CodeGen/debug-info-abspath.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-abspath.c?rev=349065&r1=349064&r2=349065&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-abspath.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-abspath.c Thu Dec 13 09:53:29 2018
@@ -8,12 +8,29 @@
 // RUN: cp %s %t.c
 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
 // RUN:   %t.c -emit-llvm -o - | FileCheck %s --check-prefix=INTREE
+
+// RUN: cd %t/UNIQUEISH_SENTINEL
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   debug-info-abspath.c -emit-obj -o /tmp/t.o
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   debug-info-abspath.c -emit-llvm -o - \
+// RUN:   | FileCheck %s --check-prefix=CURDIR
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -emit-llvm -o - | FileCheck %s --check-prefix=CURDIR
+
 void foo() {}
 
 // Since %s is an absolute path, directory should be the common
 // prefix, but the directory part should be part of the filename.
 
-// CHECK: DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL{{.*}}debug-info-abspath.c"
-// CHECK-NOT:directory: "{{.*}}UNIQUEISH_SENTINEL
+// CHECK: = distinct !DISubprogram({{.*}}file: ![[SPFILE:[0-9]+]]
+// CHECK: ![[SPFILE]] = !DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL
+// CHECK-SAME:  debug-info-abspath.c"
+// CHECK-NOT:   directory: "{{.*}}UNIQUEISH_SENTINEL
 
+// INTREE: = distinct !DISubprogram({{.*}}![[SPFILE:[0-9]+]]
 // INTREE: DIFile({{.*}}directory: "{{.+}}CodeGen{{.*}}")
+
+// CURDIR: = distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
+// CURDIR: ![[CUFILE]] = !DIFile({{.*}}directory: "{{.+}}UNIQUEISH_SENTINEL")
+


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


Re: r349065 - Reinstate DW_AT_comp_dir support after D55519.

2018-12-13 Thread Adrian Prantl via cfe-commits


> On Dec 13, 2018, at 1:18 PM, Reid Kleckner  wrote:
> 
> On Thu, Dec 13, 2018 at 9:56 AM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
> +// RUN: cd %t/UNIQUEISH_SENTINEL
> +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
> +// RUN:   debug-info-abspath.c -emit-obj -o /tmp/t.o
> 
> Do you need to create this /tmp/t.o file? This doesn't work on Windows. It 
> doesn't seem used, so I'm going to remove this RUN line on the assumption 
> that it's left over. Feel free to replace it with %t.o if you still need it.

Sorry.. I accidentally left this in. This is a leftover from debugging. Thanks 
for removing the line!

-- adrian

> 
> +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
> +// RUN:   debug-info-abspath.c -emit-llvm -o - \
> +// RUN:   | FileCheck %s --check-prefix=CURDIR
> +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
> +// RUN:   %s -emit-llvm -o - | FileCheck %s --check-prefix=CURDIR
> +
>  void foo() {}

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


r371530 - Don't emit .gnu_pubnames when tuning for LLDB.

2019-09-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Sep 10 08:53:18 2019
New Revision: 371530

URL: http://llvm.org/viewvc/llvm-project?rev=371530&view=rev
Log:
Don't emit .gnu_pubnames when tuning for LLDB.

LLDB reads the various .apple* accelerator tables (and in the near
future: the DWARF 5 accelerator tables) which should make
.gnu_pubnames redundant. This changes the Clang driver to no longer
pass -ggnu-pubnames when tuning for LLDB.

Thanks to David Blaikie for pointing this out!
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/thread.html#646062

rdar://problem/50142073

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371530&r1=371529&r2=371530&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep 10 08:53:18 2019
@@ -3397,7 +3397,6 @@ static void RenderDebugOptions(const Too
   Args.getLastArg(options::OPT_ggnu_pubnames, 
options::OPT_gno_gnu_pubnames,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
-  DebuggerTuning == llvm::DebuggerKind::LLDB ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
 if (!PubnamesArg ||
 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=371530&r1=371529&r2=371530&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Tue Sep 10 08:53:18 2019
@@ -197,7 +197,7 @@
 // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
 // RUN: %clang -### -c -fdebug-ranges-base-address 
-fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
 //
-// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s
+// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s


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


r372663 - Support for DWARF-5 C++ language tags.

2019-09-23 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Sep 23 15:01:49 2019
New Revision: 372663

URL: http://llvm.org/viewvc/llvm-project?rev=372663&view=rev
Log:
Support for DWARF-5 C++ language tags.

This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaModule.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372663&r1=372662&r2=372663&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 23 15:01:49 2019
@@ -42,6 +42,7 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
@@ -2941,8 +2942,10 @@ public:
   /// ensure a stable ABI for this, we choose the DW_LANG_ encodings
   /// from the dwarf standard.
   enum LanguageIDs {
-lang_c = /* DW_LANG_C */ 0x0002,
-lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004
+lang_c = llvm::dwarf::DW_LANG_C,
+lang_cxx = llvm::dwarf::DW_LANG_C_plus_plus,
+lang_cxx_11 = llvm::dwarf::DW_LANG_C_plus_plus_11,
+lang_cxx_14 = llvm::dwarf::DW_LANG_C_plus_plus_14
   };
 
 private:

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=372663&r1=372662&r2=372663&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Sep 23 15:01:49 2019
@@ -1001,12 +1001,19 @@ void DeclPrinter::VisitCXXRecordDecl(CXX
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
   const char *l;
-  if (D->getLanguage() == LinkageSpecDecl::lang_c)
+  switch (D->getLanguage()) {
+  case LinkageSpecDecl::lang_c:
 l = "C";
-  else {
-assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
-   "unknown language in linkage specification");
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+l = "C++14";
+break;
+  case LinkageSpecDecl::lang_cxx_11:
+l = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx:
 l = "C++";
+break;
   }
 
   Out << "extern \"" << l << "\" ";

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=372663&r1=372662&r2=372663&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon Sep 23 15:01:49 2019
@@ -850,6 +850,12 @@ void JSONNodeDumper::VisitLinkageSpecDec
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
+  case LinkageSpecDecl::lang_cxx_11:
+Lang = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+Lang = "C++14";
+break;
   }
   JOS.attribute("language", Lang);
   attributeOnlyIfTrue("hasBraces", LSD->hasBraces());

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=372663&r1=372662&r2=372663&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Sep 23 15:01:49 2019
@@ -1766,6 +1766,12 @@ void TextNodeDumper::VisitLinkageSpecDec
   case LinkageSpecDecl::lang_cxx:
 OS << " C++";
 break;
+  case LinkageSpecDecl::lang_cxx_11:
+OS << " C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+OS << " C++14";
+break;
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=372663&r1=372662&r2=372663&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 23 15:01:49 2019
@@ -561,6 +561,10 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
+else if (LO.CPlusPlus14)
+  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
+else if (LO.CPlusPlus11)
+  LangTag = llvm::dwarf

r372681 - Support for DWARF-5 C++ language tags.

2019-09-23 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Sep 23 17:38:49 2019
New Revision: 372681

URL: http://llvm.org/viewvc/llvm-project?rev=372681&view=rev
Log:
Support for DWARF-5 C++ language tags.

This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

Reapplies r372663 after adapting a failing test in the LLDB testsuite.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaModule.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372681&r1=372680&r2=372681&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 23 17:38:49 2019
@@ -42,6 +42,7 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
@@ -2941,8 +2942,10 @@ public:
   /// ensure a stable ABI for this, we choose the DW_LANG_ encodings
   /// from the dwarf standard.
   enum LanguageIDs {
-lang_c = /* DW_LANG_C */ 0x0002,
-lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004
+lang_c = llvm::dwarf::DW_LANG_C,
+lang_cxx = llvm::dwarf::DW_LANG_C_plus_plus,
+lang_cxx_11 = llvm::dwarf::DW_LANG_C_plus_plus_11,
+lang_cxx_14 = llvm::dwarf::DW_LANG_C_plus_plus_14
   };
 
 private:

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=372681&r1=372680&r2=372681&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Sep 23 17:38:49 2019
@@ -1001,12 +1001,19 @@ void DeclPrinter::VisitCXXRecordDecl(CXX
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
   const char *l;
-  if (D->getLanguage() == LinkageSpecDecl::lang_c)
+  switch (D->getLanguage()) {
+  case LinkageSpecDecl::lang_c:
 l = "C";
-  else {
-assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
-   "unknown language in linkage specification");
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+l = "C++14";
+break;
+  case LinkageSpecDecl::lang_cxx_11:
+l = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx:
 l = "C++";
+break;
   }
 
   Out << "extern \"" << l << "\" ";

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=372681&r1=372680&r2=372681&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon Sep 23 17:38:49 2019
@@ -850,6 +850,12 @@ void JSONNodeDumper::VisitLinkageSpecDec
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
+  case LinkageSpecDecl::lang_cxx_11:
+Lang = "C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+Lang = "C++14";
+break;
   }
   JOS.attribute("language", Lang);
   attributeOnlyIfTrue("hasBraces", LSD->hasBraces());

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=372681&r1=372680&r2=372681&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Sep 23 17:38:49 2019
@@ -1766,6 +1766,12 @@ void TextNodeDumper::VisitLinkageSpecDec
   case LinkageSpecDecl::lang_cxx:
 OS << " C++";
 break;
+  case LinkageSpecDecl::lang_cxx_11:
+OS << " C++11";
+break;
+  case LinkageSpecDecl::lang_cxx_14:
+OS << " C++14";
+break;
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=372681&r1=372680&r2=372681&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 23 17:38:49 2019
@@ -561,6 +561,10 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
+else if (LO.CPlusPlus14)
+  LangTag = llvm::dwarf::DW_LANG_C_

Re: r372681 - Support for DWARF-5 C++ language tags.

2019-10-02 Thread Adrian Prantl via cfe-commits


> On Oct 1, 2019, at 6:40 PM, David Blaikie  wrote:
> 
> This broke gnu_pubnames and other forms of DWARF index of C++ code - fixed in 
> r373420 (feel free to post-comimt review, etc, of course)
> 

Thanks!

-- adrian

> On Mon, Sep 23, 2019 at 5:36 PM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Sep 23 17:38:49 2019
> New Revision: 372681
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=372681&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=372681&view=rev>
> Log:
> Support for DWARF-5 C++ language tags.
> 
> This patch provides support for DW_LANG_C_plus_plus_11,
> DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.
> 
> Patch by Sourabh Singh Tomar!
> Differential Revision: https://reviews.llvm.org/D67613 
> <https://reviews.llvm.org/D67613>
> 
> Reapplies r372663 after adapting a failing test in the LLDB testsuite.
> 
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/AST/DeclPrinter.cpp
> cfe/trunk/lib/AST/JSONNodeDumper.cpp
> cfe/trunk/lib/AST/TextNodeDumper.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaModule.cpp
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> 
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372681&r1=372680&r2=372681&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372681&r1=372680&r2=372681&view=diff>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 23 17:38:49 2019
> @@ -42,6 +42,7 @@
>  #include "llvm/ADT/PointerUnion.h"
>  #include "llvm/ADT/STLExtras.h"
>  #include "llvm/ADT/iterator_range.h"
> +#include "llvm/BinaryFormat/Dwarf.h"
>  #include "llvm/Support/Casting.h"
>  #include "llvm/Support/Compiler.h"
>  #include "llvm/Support/PointerLikeTypeTraits.h"
> @@ -2941,8 +2942,10 @@ public:
>/// ensure a stable ABI for this, we choose the DW_LANG_ encodings
>/// from the dwarf standard.
>enum LanguageIDs {
> -lang_c = /* DW_LANG_C */ 0x0002,
> -lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004
> +lang_c = llvm::dwarf::DW_LANG_C,
> +lang_cxx = llvm::dwarf::DW_LANG_C_plus_plus,
> +lang_cxx_11 = llvm::dwarf::DW_LANG_C_plus_plus_11,
> +lang_cxx_14 = llvm::dwarf::DW_LANG_C_plus_plus_14
>};
> 
>  private:
> 
> Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=372681&r1=372680&r2=372681&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=372681&r1=372680&r2=372681&view=diff>
> ==
> --- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Sep 23 17:38:49 2019
> @@ -1001,12 +1001,19 @@ void DeclPrinter::VisitCXXRecordDecl(CXX
> 
>  void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
>const char *l;
> -  if (D->getLanguage() == LinkageSpecDecl::lang_c)
> +  switch (D->getLanguage()) {
> +  case LinkageSpecDecl::lang_c:
>  l = "C";
> -  else {
> -assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
> -   "unknown language in linkage specification");
> +break;
> +  case LinkageSpecDecl::lang_cxx_14:
> +l = "C++14";
> +break;
> +  case LinkageSpecDecl::lang_cxx_11:
> +l = "C++11";
> +break;
> +  case LinkageSpecDecl::lang_cxx:
>  l = "C++";
> +break;
>}
> 
>Out << "extern \"" << l << "\" ";
> 
> Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=372681&r1=372680&r2=372681&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=372681&r1=372680&r2=372681&view=diff>
> ==
> --- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
> +++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon Sep 23 17:38:49 2019
> @@ -850,6 +850,12 @@ void JSONNodeDumper::VisitLinkageSpecDec
>switch

Re: r372681 - Support for DWARF-5 C++ language tags.

2019-10-02 Thread Adrian Prantl via cfe-commits

>> On Oct 1, 2019, at 6:40 PM, David Blaikie  wrote:
>> 
>> This broke gnu_pubnames and other forms of DWARF index of C++ code - fixed 
>> in r373420 (feel free to post-comimt review, etc, of course)
>> 
> 

patch for reference:

>case dwarf::DW_TAG_union_type:
>case dwarf::DW_TAG_enumeration_type:
>  return dwarf::PubIndexEntryDescriptor(
> -dwarf::GIEK_TYPE, CU->getLanguage() != dwarf::DW_LANG_C_plus_plus
> -  ? dwarf::GIEL_STATIC
> -  : dwarf::GIEL_EXTERNAL);
> +dwarf::GIEK_TYPE,
> +dwarf::isCPlusPlus((dwarf::SourceLanguage)CU->getLanguage())
> +? dwarf::GIEL_EXTERNAL
> +: dwarf::GIEL_STATIC);
>case dwarf::DW_TAG_typedef:
>case dwarf::DW_TAG_base_type:
>case dwarf::DW_TAG_subrange_type:

> On Oct 2, 2019, at 8:32 AM, David Blaikie  wrote:
> 
> Out of curiosity, should/would this've shown up for you Apple folks too? (as 
> a failure in the apple/lldb accelerator tables - because the names would be 
> similarly incorrect) had it just not got to the necessary testing yet?
> 

+Jonas who knows the accelerator tables better than me.

It certainly didn't show up in our LLDB bots. I'm not familiar with GIEL_STATIC 
vs. GIEL_EXTERNAL; are those linkage specifiers? I don't think we have an 
equivalent in the Apple accelerator tables or .debug_names.

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


Re: r374484 - Move most CXXRecordDecl::DefinitionData bit-fields out into a separate

2019-10-10 Thread Adrian Prantl via cfe-commits
Hi Richard,

it's possible that this broke the module build

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2482/consoleFull#-432653710a1ca8a51-895e-46c6-af87-ce24fa4cd561
 


/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++  
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/Parse 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include 
-Itools/clang/include 
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
 -Iinclude 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include 
-Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++14 -fmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache
 -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common 
-Woverloaded-virtual -Wno-nested-anon-types -O3  -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
   -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o -MF 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o.d -o 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseAST.cpp.o -c 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
While building module 'Clang_AST' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:16:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:20:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclVisitor.h:18:
 
<>/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclCXX.h:282:5:
 fatal error: import of module 'Clang_AST.CXXRecordDeclDefinitionBits' appears 
within 'clang::CXXRecordDecl::DefinitionData'
#include "CXXRecordDeclDefinitionBits.def"
^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/AST/DeclCXX.h:279:3:
 note: 'clang::CXXRecordDecl::DefinitionData' begins here
  struct DefinitionData {
  ^
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/RAIIObjectsForParser.h:18:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:16:10:
 fatal error: could not build module 'Clang_AST'
#include "clang/AST/OpenMPClause.h"
 ^~
While building module 'Clang_Parse' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:
While building module 'Clang_Sema' imported from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Parse/Parser.h:24:
In file included from :1:
In file included from 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/MultiplexExternalSemaSource.h:15:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/include/clang/Sema/ExternalSemaSource.h:15:10:
 fatal error: could not build module 'Clang_AST'
#include "clang/AST/ExternalASTSource.h"
 ^~~
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Parse/ParseAST.cpp:13:10:
 fatal error: could not build module 'Clang_Parse'
#include "clang/Parse/ParseAST.h"
 ^~~~
4 errors generated.

> On Oct 10, 2019, at 5:29 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Thu Oct 10 17:29:04 2019
> New Revision: 374484
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=374484&view=rev
> Log:
> Move most CXXRecordDecl::DefinitionData bit-fields out into a separate
> file.
> 
> Reduces duplication and thereby reduces the risk that someone will
> forget to update one of these places, as I did when adding
> DefaultedDestructorIsConstexpr (though I've been unable to produce
> a testcase for which that matters so 

r375012 - [DWARF5] Added support for DW_AT_noreturn attribute to be emitted for

2019-10-16 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Oct 16 09:30:38 2019
New Revision: 375012

URL: http://llvm.org/viewvc/llvm-project?rev=375012&view=rev
Log:
[DWARF5] Added support for DW_AT_noreturn attribute to be emitted for
C++ class member functions.

Patch by Sourabh Singh Tomar!

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-noreturn.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=375012&r1=375011&r2=375012&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Oct 16 09:30:38 2019
@@ -1605,6 +1605,8 @@ llvm::DISubprogram *CGDebugInfo::CreateC
 ContainingType = RecordTy;
   }
 
+  if (Method->isNoReturn())
+Flags |= llvm::DINode::FlagNoReturn;
   if (Method->isStatic())
 Flags |= llvm::DINode::FlagStaticMember;
   if (Method->isImplicit())

Added: cfe/trunk/test/CodeGenCXX/debug-info-noreturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-noreturn.cpp?rev=375012&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-noreturn.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-noreturn.cpp Wed Oct 16 09:30:38 2019
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -fcxx-exceptions 
-debug-info-kind=standalone  %s -o - | FileCheck %s
+// Test for NoReturn flags in debug info.
+
+// CHECK: DISubprogram(name: "f", {{.*}}, flags: DIFlagPrototyped | 
DIFlagNoReturn, spFlags: DISPFlagDefinition
+// CHECK: DISubprogram(name: "foo_member", {{.*}}, flags: DIFlagPrototyped | 
DIFlagNoReturn, spFlags: 0
+// CHECK-NOT: DISubprogram(name: "func",{{.*}}, flags: DIFlagPrototyped | 
DIFlagNoReturn, spFlags: DISPFlagDefinition
+
+class foo {
+
+  [[noreturn]] void foo_member() { throw 1; }
+};
+
+[[noreturn]] void f() {
+  throw 1;
+}
+
+void func() {
+  foo object;
+}


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


r375423 - PCH debug info: Avoid appending the source directory to an absolute path

2019-10-21 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct 21 09:44:37 2019
New Revision: 375423

URL: http://llvm.org/viewvc/llvm-project?rev=375423&view=rev
Log:
PCH debug info: Avoid appending the source directory to an absolute path

When building a precompiled header in -fmodule-format=obj (i.e.,
`-gmodules) in an absolute path, the locig in
CGDebugInfo::createCompileUnit would unconditionally append the source
directory to the -main-file-name. This patch avoids that behavior for
absolute paths.

rdar://problem/46045865

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

Added:
cfe/trunk/test/PCH/debug-info-pch-container-path.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=375423&r1=375422&r2=375423&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 21 09:44:37 2019
@@ -539,11 +539,11 @@ void CGDebugInfo::CreateCompileUnit() {
   // file to determine the real absolute path for the file.
   std::string MainFileDir;
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-MainFileDir = remapDIPath(MainFile->getDir()->getName());
-if (MainFileDir != ".") {
+MainFileDir = MainFile->getDir()->getName();
+if (!llvm::sys::path::is_absolute(MainFileName)) {
   llvm::SmallString<1024> MainFileDirSS(MainFileDir);
   llvm::sys::path::append(MainFileDirSS, MainFileName);
-  MainFileName = MainFileDirSS.str();
+  MainFileName = llvm::sys::path::remove_leading_dotslash(MainFileDirSS);
 }
 // If the main file name provided is identical to the input file name, and
 // if the input file is a preprocessed source, use the module name for

Added: cfe/trunk/test/PCH/debug-info-pch-container-path.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/debug-info-pch-container-path.c?rev=375423&view=auto
==
--- cfe/trunk/test/PCH/debug-info-pch-container-path.c (added)
+++ cfe/trunk/test/PCH/debug-info-pch-container-path.c Mon Oct 21 09:44:37 2019
@@ -0,0 +1,22 @@
+// REQUIRES: asserts
+
+// Modules:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -fmodule-format=obj -emit-pch\
+// RUN: -triple %itanium_abi_triple \
+// RUN: -fdebug-prefix-map=%t=BUILD \
+// RUN: -fdebug-prefix-map=%S=SOURCE\
+// RUN: -o %t/prefix.ll %S/debug-info-limited-struct.h  \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-container.ll
+// RUN: cat %t-container.ll | FileCheck %s
+
+// CHECK: distinct !DICompileUnit(
+// CHECK-SAME:language: DW_LANG_C99,
+// CHECK-SAME:file: ![[FILE:[0-9]+]],
+// CHECK: ![[FILE]] = !DIFile(
+// CHECK-SAME:filename: "SOURCE/debug-info-limited-struct.h",
+// CHECK-SAME:directory: "BUILD"
+


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


Re: [PATCH] D67723: [DebugInfo] Add option to disable inline line tables.

2019-10-24 Thread Adrian Prantl via cfe-commits


> On Oct 24, 2019, at 3:02 PM, David Blaikie via Phabricator 
>  wrote:
> 
> dblaikie added a comment.
> 
> In D67723#1720509 , @aprantl wrote:
> 
>> In D67723#1720353 , @rnk wrote:
>> 
>>> In D67723#1717468 , @aprantl wrote:
>>> 
 I agree that it would make sense to have a 
 `-ginline-info-threshold=<#insns>` or `-gno-small-inline-functions` with a 
 hardcoded threshold to implement the feature Paul described, and this 
 patch seems to be a step in that direction, with the threshold being 
 hardcoded to 0.
>>> 
>>> 
>>> OK. :)
>>> 
> We are motivated by one tool in particular at the moment, but if we're 
> going to take the time to add a knob, we might as well make it work for 
> DWARF.
 
 Here you got me confused: When I read "we might as well make it work for 
 DWARF", I read that as "we should emit the inlined instructions with line 
 0 under a DWARF debugger tuning". But that reading seems to to contradict 
 your next sentence:
 
> If the user cares enough to find this flag, it seems more user friendly 
> to make it behave the same rather than making it format-dependent.
 
 Can you clarify?
>>> 
>>> If we use line zero for DWARF, gdb will not behave in the way documented by 
>>> the function attribute in LangRef. I was the one who suggested the wording 
>>> there, so maybe we could come up with new wording that describes what the 
>>> user should expect in the debugger when using line zero. However, given the 
>>> behavior I show below, I have a hard time imagining the use case for it.
>> 
>> 
>> I didn't realize that GDB also had problems; I thought that this was a 
>> problem that only affected Windows debuggers.
> 
> 
> I don't think the behavior Reid described would be a "problem" - it seems to 
> me like the only behavior the debugger could provide if those instructions 
> are attributed to line zero.
> 
>> 
>> 
>>> I applied the version of this patch that uses getMergedLocation, compiled 
>>> this program, and ran it under gdb:
>>> 
>>>  volatile int x;
>>>  static inline void foo() {
>>>++x;
>>>*(volatile int*)0 = 42; // crash
>>>++x;
>>>  }
>>>  int main() {
>>>++x;  // line 8
>>>foo();  // line 9
>>>++x;
>>>return x;
>>>  }
>>> 
>>> 
>>> If we apply line zero, the debugger stops on line 8:
>>> 
>>>  Program received signal SIGSEGV, Segmentation fault.
>>>  0x0040111e in main () at t.cpp:8
>>>  8 ++x;
>>>  (gdb) bt
>>>  #0  0x0040111e in main () at t.cpp:8
>>> 
>>> 
>>> The inline frame is gone, as expected for this flag, but the current 
>>> location does not reflect the site of the call to `foo`. So, if we want it 
>>> to behave as documented, we have to put the call site location on some 
>>> instructions.
>>> 
>>> Alternatively, if I arrange things like this, the crash is attributed to 
>>> line `return x`, which is completely unrelated to the inline call site:
>>> 
>>>  static inline void foo() {
>>>++x;
>>>if (x) {
>>>  *(volatile int*)0 = 42; // crash
>>>  __builtin_unreachable();
>>>}
>>>++x;
>>>  }
>>> 
>>> 
>>> This means that if line zero is used, the source location shown in the 
>>> debugger becomes sensitive to code layout, which is arbitrary.
>>> 
>>> These experiments are convincing me that, in general, line zero isn't that 
>>> helpful for DWARF consumers. If the goal is to get smooth stepping, we may 
>>> want to refocus on getting reliable is_stmt bits in the line table.
>> 
>> The Swift compiler is far more aggressive in using line 0 than Clang, and 
>> consequently LLDB is much better at handling line 0 than even GDB, and that 
>> can skew my perception :-)
> 
> What behavior does LLDB have in the example Reid gave?

I short-circuited a little by marking the function always_inline and putting a 
.loc 1 0 0  before the inlined instructions, so I hope that didn't butcher the 
example, but I didn't want to wait for clang to compile. LLDB says

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS 
(code=1, address=0x0)
frame #0: 0x00010f9f a.out`main at reid.c:0 [opt]

If the intended behavior is to show the crash at the call site like LangRef in 
the patch suggest then line 0 will certainly not achieve that. I implicitly 
assumed the wording in LangRef would follow the implementation if we switched 
to line 0. 

-- adrian

> 
>> Give how popular GDB is, I don't want to intentionally break compatibility 
>> with it, so I think this patch is okay. If we wanted we can put an 
>> if-debugger-tuning-is-LLDB-getMergedLocation condition in. Otherwise 
>> documenting that this is necessary for compatibility with popular debuggers, 
>> seems fine to me, too.
> 
> 
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D67723/new/
> 

[clang] 6b7d51a - Add missing forward decl to unbreak the modular build

2020-05-26 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-05-26T09:08:27-07:00
New Revision: 6b7d51ad4a16579b0a7d41c77715be4d9e266d8c

URL: 
https://github.com/llvm/llvm-project/commit/6b7d51ad4a16579b0a7d41c77715be4d9e266d8c
DIFF: 
https://github.com/llvm/llvm-project/commit/6b7d51ad4a16579b0a7d41c77715be4d9e266d8c.diff

LOG: Add missing forward decl to unbreak the modular build

Added: 


Modified: 
clang/include/clang/Index/IndexingOptions.h

Removed: 




diff  --git a/clang/include/clang/Index/IndexingOptions.h 
b/clang/include/clang/Index/IndexingOptions.h
index 2dd276998abf..9f5c03d1b3b9 100644
--- a/clang/include/clang/Index/IndexingOptions.h
+++ b/clang/include/clang/Index/IndexingOptions.h
@@ -14,6 +14,7 @@
 #include 
 
 namespace clang {
+class Decl;
 namespace index {
 
 struct IndexingOptions {



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


[clang] b59b364 - Debug Info: Mark os_log helper functions as artificial

2020-05-26 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-05-26T09:08:27-07:00
New Revision: b59b3640bcbdfc6cf4b35ff3a6ad5f524a073b45

URL: 
https://github.com/llvm/llvm-project/commit/b59b3640bcbdfc6cf4b35ff3a6ad5f524a073b45
DIFF: 
https://github.com/llvm/llvm-project/commit/b59b3640bcbdfc6cf4b35ff3a6ad5f524a073b45.diff

LOG: Debug Info: Mark os_log helper functions as artificial

The os_log helper functions are linkonce_odr and supposed to be
uniqued across TUs, so attachine a DW_AT_decl_line on it is highly
misleading. By setting the function decl to implicit, CGDebugInfo
properly marks the functions as artificial and uses a default file /
line 0 location for the function.

rdar://problem/63450824

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

Added: 
clang/test/CodeGen/debug-info-oslog.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ddd9a68a8edb..bef0ad27145f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1271,6 +1271,8 @@ llvm::Function 
*CodeGenFunction::generateBuiltinOSLogHelperFunction(
   FunctionDecl *FD = FunctionDecl::Create(
   Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), 
II,
   FuncionTy, nullptr, SC_PrivateExtern, false, false);
+  // Avoid generating debug location info for the function.
+  FD->setImplicit();
 
   StartFunction(FD, ReturnTy, Fn, FI, Args);
 

diff  --git a/clang/test/CodeGen/debug-info-oslog.c 
b/clang/test/CodeGen/debug-info-oslog.c
new file mode 100644
index ..c32c79eb8a6f
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-oslog.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -debug-info-kind=limited \
+// RUN:   %s -emit-llvm -o -  | FileCheck %s
+void test_builtin_os_log(void *buf, int i, const char *data) {
+  __builtin_os_log_format(buf, "%d", i);
+}
+
+// CHECK: define linkonce_odr {{.*}}@__os_log_helper_1_0_1_4_0(
+// CHECK-SAME:   !dbg ![[OS_LOG_HELPER:[0-9]+]]
+
+// This helper is going to be uniqued, so it should not have a line
+// number between file and type.
+
+// CHECK: distinct !DISubprogram(name: "__os_log_helper_1_0_1_4_0",
+// CHECK-SAME:   file: !{{[0-9+]}}, type
+// CHECK-SAME:   flags: DIFlagArtificial



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


[clang] b907ad5 - [NFC] Clean up doc comment and implementation for Module::isSubModuleOf.

2020-07-21 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-07-21T16:23:36-07:00
New Revision: b907ad539a900279443dc8ef8816b6b5a76b1ea1

URL: 
https://github.com/llvm/llvm-project/commit/b907ad539a900279443dc8ef8816b6b5a76b1ea1
DIFF: 
https://github.com/llvm/llvm-project/commit/b907ad539a900279443dc8ef8816b6b5a76b1ea1.diff

LOG: [NFC] Clean up doc comment and implementation for Module::isSubModuleOf.

Patch by Varun Gandhi!

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

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/Basic/Module.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 6b932a9a84d0..94dd21537966 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@ class Module {
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// The 'A is a submodule of B' relation is a partial order based on the
+  /// the parent-child relationship between individual modules.
+  ///
+  /// Returns \c false if \p Other is \c nullptr.
   bool isSubModuleOf(const Module *Other) const;
 
   /// Determine whether this module is a part of a framework,

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index b3daaa3a4442..b25248de6832 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@ bool Module::isAvailable(const LangOptions &LangOpts, 
const TargetInfo &Target,
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
-if (This == Other)
+  for (auto *Parent = this; Parent; Parent = Parent->Parent) {
+if (Parent == Other)
   return true;
-
-This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 



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


Re: [PATCH] D24820: Add -stats-file option

2016-09-22 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:111
@@ -110,1 +110,3 @@
+def warn_fe_unable_to_open_stats_file : Warning<
+"unable to open statistic output file '%0': '%1'">;
 def err_fe_no_pch_in_dir : Error<

statstic"s"? not sure.


Comment at: lib/Driver/Tools.cpp:6093
@@ -6092,1 +6092,3 @@
 
+  // Setup statistic file output.
+  if (const Arg *A = Args.getLastArg(options::OPT_save_stats_EQ)) {

ditto :-)


Comment at: test/Driver/save-stats.c:12
@@ +11,3 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o 
obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats"
+// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o"

This is up to taste, but just accepting {{.}} as the path separator would be 
sufficient IMO and might be more readable.


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



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


Re: [PATCH] D24820: Add -stats-stats option

2016-09-26 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Awesome. Sorry!


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



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


[PATCH] D22227: [ubsan] Disable bounds-check for flexible array ivars

2016-10-03 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Not knowing the specifics of the ObjC class layout: Does this work correctly 
with private ivars (i.e.: Does this need an extra check that there are no extra 
ivars in a later @implementation)?


https://reviews.llvm.org/D7



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


[PATCH] D22227: [ubsan] Disable bounds-check for flexible array ivars

2016-10-04 Thread Adrian Prantl via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Can you double-check that the memory layout is actually what we think it is by 
inspecting the generated IR? Otherwise this LGTM.


https://reviews.llvm.org/D7



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


[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-06 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


> ReachableCode.cpp:64
> +const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
> +return FDecl && FDecl->getIdentifier() &&
> +   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;

Maybe also wrap the inner dyn_cast in an if for symmetry?

  static bool isBuiltinUnreachable(const Stmt *S) {
if (const auto *DRE = dyn_cast(S))
  if (const auto *FDecl = dyn_cast(DRE->getDecl()))
return FDecl->getIdentifier() &&
   FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
return false;
  }

Repository:
  rL LLVM

https://reviews.llvm.org/D25321



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


[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2016-10-07 Thread Adrian Prantl via cfe-commits
aprantl accepted this revision.
aprantl added a reviewer: aprantl.
aprantl added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D25321



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


r283810 - [Driver] Let -gline-tables-only win when it comes after -gmodules.

2016-10-10 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct 10 16:56:20 2016
New Revision: 283810

URL: http://llvm.org/viewvc/llvm-project?rev=283810&view=rev
Log:
[Driver] Let -gline-tables-only win when it comes after -gmodules.
The -gmodules option is all about putting debug type info into clang
modules and for line tables the type information is irrelevant, so
combining these two options makes no sense.
This commmit fixes the behavior to match the one  documented on the
clang man page: the last -g... option wins.



Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=283810&r1=283809&r2=283810&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 10 16:56:20 2016
@@ -1344,7 +1344,7 @@ def gno_column_info : Flag<["-"], "gno-c
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
-def gmodules : Flag <["-"], "gmodules">, Group,
+def gmodules : Flag <["-"], "gmodules">, Group,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283810&r1=283809&r2=283810&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 10 16:56:20 2016
@@ -4703,7 +4703,9 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-dwarf-column-info");
 
   // FIXME: Move backend command line options to the module.
-  if (Args.hasArg(options::OPT_gmodules)) {
+  // If -gline-tables-only is the last option it wins.
+  if (DebugInfoKind != codegenoptions::DebugLineTablesOnly &&
+  Args.hasArg(options::OPT_gmodules)) {
 DebugInfoKind = codegenoptions::LimitedDebugInfo;
 CmdArgs.push_back("-dwarf-ext-refs");
 CmdArgs.push_back("-fmodule-format=obj");

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=283810&r1=283809&r2=283810&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Mon Oct 10 16:56:20 2016
@@ -109,6 +109,15 @@
 // RUN: %clang -### -gmodules %s 2>&1 \
 // RUN:| FileCheck -check-prefix=GEXTREFS %s
 //
+// RUN: %clang -### -gmodules -g %s 2>&1 \
+// RUN:| FileCheck -check-prefix=GEXTREFS %s
+//
+// RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \
+// RUN:| FileCheck -check-prefix=GEXTREFS %s
+//
+// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \
+// RUN:| FileCheck -check-prefix=GLTO_ONLY %s
+//
 // G: "-cc1"
 // G: "-debug-info-kind=limited"
 //
@@ -131,7 +140,9 @@
 // G_NO-NOT: -debug-info-kind=
 //
 // GLTO_ONLY: "-cc1"
+// GLTO_ONLY-NOT: "-dwarf-ext-refs"
 // GLTO_ONLY: "-debug-info-kind=line-tables-only"
+// GLTO_ONLY-NOT: "-dwarf-ext-refs"
 //
 // GLTO_ONLY_DWARF2: "-cc1"
 // GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"


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


[PATCH] D25621: DebugInfo: use DIAlignment type.

2016-10-14 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/ASTContext.h:83
 uint64_t Width;
-unsigned Align;
+llvm::DIAlignment Align;
 bool AlignIsRequired : 1;

I'm not sure we want to use a debug info type inside the AST. I think we only 
want to use them in CGDebugInfo.cpp.


https://reviews.llvm.org/D25621



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


[clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

2023-11-10 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl edited 
https://github.com/llvm/llvm-project/pull/71780
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

2023-11-10 Thread Adrian Prantl via cfe-commits


@@ -5596,6 +5587,42 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl 
*VD, const APValue &Init) {
   TemplateParameters, Align));
 }
 
+void CGDebugInfo::EmitGlobalVariable(const VarDecl *VD) {
+  assert(VD->hasInit());
+  assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
+  if (VD->hasAttr())
+return;
+
+  auto &GV = DeclCache[VD];

adrian-prantl wrote:

is it intentional that we cache nullptr here if the next condition fails?

https://github.com/llvm/llvm-project/pull/71780
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

2023-11-10 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.

Minor comments inside.

https://github.com/llvm/llvm-project/pull/71780
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

2023-11-10 Thread Adrian Prantl via cfe-commits


@@ -5800,6 +5827,18 @@ void CGDebugInfo::setDwoId(uint64_t Signature) {
 }
 
 void CGDebugInfo::finalize() {
+  for (auto const *VD : StaticDataMemberDefinitionsToEmit) {
+assert(VD->isStaticDataMember());
+
+if (DeclCache.contains(VD))
+  continue;
+
+if (!VD->hasInit())

adrian-prantl wrote:

it's non-obvious why this skip exists, can you add a comment here?

https://github.com/llvm/llvm-project/pull/71780
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [lldb] [clang] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

2023-12-05 Thread Adrian Prantl via cfe-commits

adrian-prantl wrote:

Is this a performance optimization or a function al change?

https://github.com/llvm/llvm-project/pull/73067
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [lldb] [llvm] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

2023-12-05 Thread Adrian Prantl via cfe-commits

adrian-prantl wrote:

SGTM, maybe wait one more day for @JDevlieghere to chime in.

https://github.com/llvm/llvm-project/pull/73067
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl edited 
https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits


@@ -1315,17 +1315,15 @@ LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef 
Builder, const char *Name,
   return wrap(unwrap(Builder)->createUnspecifiedType({Name, NameLen}));
 }
 
-LLVMMetadataRef
-LLVMDIBuilderCreateStaticMemberType(
+LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType(
 LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
 size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
 LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal,
-uint32_t AlignInBits) {
+unsigned Tag, uint32_t AlignInBits) {

adrian-prantl wrote:

Somebody might complain if we change the C API, but I don't think we guarantee 
compatibility.

https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl requested changes to this pull request.

I think this is missing a test in clang/test/CodeGenCXX that verifies Clang 
generates the expected LLVM IR.

https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits


@@ -1681,7 +1681,8 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, 
llvm::DIType *RecordTy,
   llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
   auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
   llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
-  RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr, 
Align);
+  RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr,
+  llvm::dwarf::DW_TAG_member, Align);

adrian-prantl wrote:

Assuming this _changes_ the IR.

https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [llvm][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72234)

2023-11-14 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.

LGTM, then

https://github.com/llvm/llvm-project/pull/72234
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [flang] [clang] [clang-tools-extra] [llvm] [mlir] [compiler-rt] [CodeGen][DebugInfo] Add missing debug info for jump table BB (PR #71021)

2023-11-15 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/71021
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1adb898 - Mark headers as textual and unbreak the modules build

2023-10-31 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2023-10-31T09:10:50-07:00
New Revision: 1adb898e2db980fc402b8eac7ebc762c75d05826

URL: 
https://github.com/llvm/llvm-project/commit/1adb898e2db980fc402b8eac7ebc762c75d05826
DIFF: 
https://github.com/llvm/llvm-project/commit/1adb898e2db980fc402b8eac7ebc762c75d05826.diff

LOG: Mark headers as textual and unbreak the modules build

Added: 


Modified: 
clang/include/module.modulemap

Removed: 




diff  --git a/clang/include/module.modulemap b/clang/include/module.modulemap
index 6ea613c70306fa1..7dbb7cf02b4f82c 100644
--- a/clang/include/module.modulemap
+++ b/clang/include/module.modulemap
@@ -49,6 +49,9 @@ module Clang_Basic {
   textual header "clang/Basic/BuiltinsHexagonDep.def"
   textual header "clang/Basic/BuiltinsHexagonMapCustomDep.def"
   textual header "clang/Basic/BuiltinsLoongArch.def"
+  textual header "clang/Basic/BuiltinsLoongArchBase.def"
+  textual header "clang/Basic/BuiltinsLoongArchLSX.def"
+  textual header "clang/Basic/BuiltinsLoongArchLASX.def"
   textual header "clang/Basic/BuiltinsMips.def"
   textual header "clang/Basic/BuiltinsNEON.def"
   textual header "clang/Basic/BuiltinsNVPTX.def"



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


[clang] [llvm] [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (PR #75385)

2023-12-15 Thread Adrian Prantl via cfe-commits


@@ -238,6 +238,13 @@ void llvm::CloneFunctionInto(Function *NewFunc, const 
Function *OldFunc,
   }
 }
 
+// Avoid cloning local variables of subprograms that won't be cloned.

adrian-prantl wrote:

Can you add a sentence explaining why some subprograms won't be cloned? Is it 
because they are inlined and a copy already exists?

https://github.com/llvm/llvm-project/pull/75385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (PR #75385)

2023-12-15 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl commented:

I think this LGTM, but it would be good if someone else also took a look.

https://github.com/llvm/llvm-project/pull/75385
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Remove unused argument. NFC. (PR #73594)

2023-11-28 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.

I can't even remember what this was supposed to do.

https://github.com/llvm/llvm-project/pull/73594
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][DebugInfo] Improve heuristic to determine whether to evaluate a static variable's initializer (PR #72974)

2023-11-29 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/72974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-11-30 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl edited 
https://github.com/llvm/llvm-project/pull/70749
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-11-30 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.

Debug info part looks good!

https://github.com/llvm/llvm-project/pull/70749
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-11-30 Thread Adrian Prantl via cfe-commits


@@ -0,0 +1,255 @@
+
+Implementation plans for ``-fbounds-safety``
+
+
+.. contents::
+   :local:
+
+External bounds annotations
+===
+
+The bounds annotations are C type attributes appertaining to pointer types. If
+an attribute is added to the position of a declaration attribute, e.g., ``int
+*ptr __counted_by(size)``, the attribute appertains to the outermost pointer
+type of the declaration (``int *``).
+
+New sugar types
+===
+
+An external bounds annotation creates a type sugar of the underlying pointer
+types. We will introduce a new sugar type, ``DynamicBoundsPointerType`` to
+represent ``__counted_by`` or ``__sized_by``. Using ``AttributedType`` would 
not
+be sufficient because the type needs to hold the count or size expression as
+well as some metadata necessary for analysis, while this type may be 
implemented
+through inheritance from ``AttributedType``. Treating the annotations as type
+sugars means two types with incompatible external bounds annotations may be
+considered canonically the same types. This is sometimes necessary, for 
example,
+to make the ``__counted_by`` and friends not participate in function
+overloading. However, this design requires a separate logic to walk through the
+entire type hierarchy to check type compatibility of bounds annotations.
+
+Late parsing for C
+==
+
+A bounds annotation such as ``__counted_by(count)`` can be added to type of a
+struct field declaration where count is another field of the same struct
+declared later. Similarly, the annotation may apply to type of a function
+parameter declaration which precedes the parameter count in the same function.
+This means parsing the argument of bounds annotations must be done after the
+parser has the whole context of a struct or a function declaration. Clang has
+late parsing logic for C++ declaration attributes that require late parsing,
+while the C declaration attributes and C/C++ type attributes do not have the
+same logic. This requires introducing late parsing logic for C/C++ type
+attributes.
+
+Internal bounds annotations
+===
+
+``__indexable`` and ``__bidi_indexable`` alter pointer representations to be
+equivalent to a struct with the pointer and the corresponding bounds fields.
+Despite this difference in their representations, they are still pointers in
+terms of types of operations that are allowed and their semantics. For 
instance,
+a pointer dereference on a ``__bidi_indexable`` pointer will return the
+dereferenced value same as plain C pointers, modulo the extra bounds checks
+being performed before dereferencing the wide pointer. This means mapping the
+wide pointers to struct types with equivalent layout won’t be sufficient. To
+represent the wide pointers in Clang AST, we add an extra field in the
+PointerType class to indicate the internal bounds of the pointer. This ensures
+pointers of different representations are mapped to different canonical types
+while they are still treated as pointers.
+
+In LLVM IR, wide pointers will be emitted as structs of equivalent
+representations. Clang CodeGen will handle them as Aggregate in
+``TypeEvaluationKind (TEK)``. ``AggExprEmitter`` was extended to handle pointer
+operations returning wide pointers. Alternatively, a new ``TEK`` and an
+expression emitter dedicated to wide pointers could be introduced.
+
+Default bounds annotations
+==
+
+The model may implicitly add ``__bidi_indexable`` or ``__single`` depending on
+the context of the declaration that has the pointer type. ``__bidi_indexable``
+implicitly adds to local variables, while ``__single`` implicitly adds to
+pointer types specifying struct fields, function parameters, or global
+variables. This means the parser may first create the pointer type without any
+default pointer attribute and then recreate the type once the parser has the
+declaration context and determined the default attribute accordingly.
+
+This also requires the parser to reset the type of the declaration with the
+newly created type with the right default attribute.
+
+Promotion expression
+
+
+A new expression will be introduced to represent the conversion from a pointer
+with an external bounds annotation, such as ``__counted_by``, to
+``__bidi_indexable``. This type of conversion cannot be handled by normal
+CastExprs because it requires an extra subexpression(s) to provide the bounds
+information necessary to create a wide pointer.
+
+Bounds check expression
+===
+
+Bounds checks are part of semantics defined in the ``-fbounds-safety`` language
+model. Hence, exposing the bounds checks and other semantic actions in the AST
+is desirable. A new expression for bounds checks has been added to the AST. The
+bounds check expression has a ``BoundsCheckKind`` to indicate the ki

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-01 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/74006
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ASTImporter] Only reorder fields of RecordDecls (PR #77079)

2024-01-05 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.

Test would be nice, but generally this looks like a reasonable modification.

https://github.com/llvm/llvm-project/pull/77079
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] baac665 - Revert "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"

2022-02-11 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2022-02-11T13:07:23-08:00
New Revision: baac665adf324672802dcc7037a25468e9569c95

URL: 
https://github.com/llvm/llvm-project/commit/baac665adf324672802dcc7037a25468e9569c95
DIFF: 
https://github.com/llvm/llvm-project/commit/baac665adf324672802dcc7037a25468e9569c95.diff

LOG: Revert "[lld/coff] Make lld-link work in a non-MSVC shell, add 
/winsysroot:"

This reverts commit b3b2538df100ec7f6587b0ee70819a3c8ee2c27e,
it introduced a cycklic module depenency that broke the -DLLVM_ENABLE_MODULES=1 
build.

Added: 
clang/lib/Driver/ToolChains/MSVCSetupApi.h

Modified: 
clang/docs/tools/clang-formatted-files.txt
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
lld/COFF/Driver.cpp
lld/COFF/Driver.h
lld/COFF/Options.td
lld/COFF/SymbolTable.cpp
lld/docs/ReleaseNotes.rst
llvm/lib/Support/CMakeLists.txt
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Removed: 
lld/test/COFF/winsysroot.test
llvm/include/llvm/Support/MSVCPaths.h
llvm/include/llvm/Support/MSVCSetupApi.h
llvm/lib/Support/MSVCPaths.cpp



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 5666ad499d791..c7defa9cd88c6 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -285,6 +285,7 @@ clang/lib/Driver/ToolChains/InterfaceStubs.h
 clang/lib/Driver/ToolChains/Minix.h
 clang/lib/Driver/ToolChains/MipsLinux.cpp
 clang/lib/Driver/ToolChains/MSP430.h
+clang/lib/Driver/ToolChains/MSVCSetupApi.h
 clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
 clang/lib/Driver/ToolChains/PPCFreeBSD.h
 clang/lib/Driver/ToolChains/PPCLinux.h
@@ -5149,8 +5150,6 @@ llvm/include/llvm/Support/MemoryBufferRef.h
 llvm/include/llvm/Support/MSP430AttributeParser.h
 llvm/include/llvm/Support/MSP430Attributes.h
 llvm/include/llvm/Support/MSVCErrorWorkarounds.h
-llvm/include/llvm/Support/MSVCPaths.h
-llvm/include/llvm/Support/MSVCSetupApi.h
 llvm/include/llvm/Support/Parallel.h
 llvm/include/llvm/Support/PGOOptions.h
 llvm/include/llvm/Support/PointerLikeTypeTraits.h
@@ -5841,7 +5840,6 @@ llvm/lib/Support/Memory.cpp
 llvm/lib/Support/MemoryBufferRef.cpp
 llvm/lib/Support/MSP430AttributeParser.cpp
 llvm/lib/Support/MSP430Attributes.cpp
-llvm/lib/Support/MSVCPaths.cpp
 llvm/lib/Support/Optional.cpp
 llvm/lib/Support/Parallel.cpp
 llvm/lib/Support/Program.cpp

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 36e190f69154b..9f4751167ac12 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -25,7 +25,6 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/MSVCPaths.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
@@ -41,12 +40,91 @@
   #include 
 #endif
 
+#ifdef _MSC_VER
+// Don't support SetupApi on MinGW.
+#define USE_MSVC_SETUP_API
+
+// Make sure this comes before MSVCSetupApi.h
+#include 
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+#include "MSVCSetupApi.h"
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+#include "llvm/Support/COM.h"
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration, __uuidof(ISetupConfiguration));
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration2, __uuidof(ISetupConfiguration2));
+_COM_SMARTPTR_TYPEDEF(ISetupHelper, __uuidof(ISetupHelper));
+_COM_SMARTPTR_TYPEDEF(IEnumSetupInstances, __uuidof(IEnumSetupInstances));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance, __uuidof(ISetupInstance));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance2, __uuidof(ISetupInstance2));
+#endif
+
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
 using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
+// Windows SDKs and VC Toolchains group their contents into subdirectories 
based
+// on the target architecture. This function converts an llvm::Triple::ArchType
+// to the corresponding subdirectory name.
+static const char *llvmArchToWindowsSDKArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+return "x86";
+  case ArchType::x86_64:
+return "x64";
+  case ArchType::arm:
+return "arm";
+  case ArchType::aarch64:
+return "arm64";
+  default:
+return "";
+  }
+}
+
+// Similar to the above function, but for Visual Studios before VS2017.
+static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+// x86 is default in legacy VC toolchains.
+// e.g. x86 libs are directly in /lib as opposed to /lib/x86.
+return

[clang] 0604d86 - Darwin: introduce a global override for debug prefix map entries.

2022-02-16 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2022-02-16T08:36:26-08:00
New Revision: 0604d86c07ab8a28b95df689aff4ddd26347f35f

URL: 
https://github.com/llvm/llvm-project/commit/0604d86c07ab8a28b95df689aff4ddd26347f35f
DIFF: 
https://github.com/llvm/llvm-project/commit/0604d86c07ab8a28b95df689aff4ddd26347f35f.diff

LOG: Darwin: introduce a global override for debug prefix map entries.

This patch adds a new Darwin clang driver environment variable in the
spirit of RC_DEBUG_OPTIONS, called RC_DEBUG_PREFIX_MAP, which allows a
meta build tool to add one additional -fdebug-prefix-map entry without
the knowledge of the build system.

rdar://85224675

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

Added: 
clang/test/Driver/darwin-debug-prefix-map.c
clang/test/Driver/darwin-debug-prefix-map.s

Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index bfc46af002657..adf1753e8d3a6 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -513,6 +513,9 @@ class ToolChain {
   /// compile unit information.
   virtual bool UseDwarfDebugFlags() const { return false; }
 
+  /// Add an additional -fdebug-prefix-map entry.
+  virtual std::string GetGlobalDebugPathRemapping() const { return {}; }
+  
   // Return the DWARF version to emit, in the absence of arguments
   // to the contrary.
   virtual unsigned GetDefaultDwarfVersion() const { return 5; }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 945f626977799..de289683596be 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -668,17 +668,24 @@ static void addDebugObjectName(const ArgList &Args, 
ArgStringList &CmdArgs,
 }
 
 /// Add a CC1 and CC1AS option to specify the debug file path prefix map.
-static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, 
ArgStringList &CmdArgs) {
-  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
-options::OPT_fdebug_prefix_map_EQ)) {
-StringRef Map = A->getValue();
+static void addDebugPrefixMapArg(const Driver &D, const ToolChain &TC,
+ const ArgList &Args, ArgStringList &CmdArgs) {
+  auto AddOneArg = [&](StringRef Map, StringRef Name) {
 if (!Map.contains('='))
-  D.Diag(diag::err_drv_invalid_argument_to_option)
-  << Map << A->getOption().getName();
+  D.Diag(diag::err_drv_invalid_argument_to_option) << Map << Name;
 else
   CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
+  };
+
+  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
+options::OPT_fdebug_prefix_map_EQ)) {
+AddOneArg(A->getValue(), A->getOption().getName());
 A->claim();
   }
+  std::string GlobalRemapEntry = TC.GetGlobalDebugPathRemapping();
+  if (GlobalRemapEntry.empty())
+return;
+  AddOneArg(GlobalRemapEntry, "environment");
 }
 
 /// Add a CC1 and CC1AS option to specify the macro file path prefix map.
@@ -5717,7 +5724,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   const char *DebugCompilationDir =
   addDebugCompDirArg(Args, CmdArgs, D.getVFS());
 
-  addDebugPrefixMapArg(D, Args, CmdArgs);
+  addDebugPrefixMapArg(D, TC, Args, CmdArgs);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_,
options::OPT_ftemplate_depth_EQ)) {
@@ -7785,7 +7792,8 @@ void ClangAs::ConstructJob(Compilation &C, const 
JobAction &JA,
 DebugInfoKind = (WantDebug ? codegenoptions::DebugInfoConstructor
: codegenoptions::NoDebugInfo);
 
-addDebugPrefixMapArg(getToolChain().getDriver(), Args, CmdArgs);
+addDebugPrefixMapArg(getToolChain().getDriver(), getToolChain(), Args,
+ CmdArgs);
 
 // Set the AT_producer to the clang version when using the integrated
 // assembler on assembly source files.

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 3c408010b5b19..dc75b2b4621bb 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2843,6 +2843,12 @@ bool MachO::UseDwarfDebugFlags() const {
   return false;
 }
 
+std::string MachO::GetGlobalDebugPathRemapping() const {
+  if (const char *S = ::getenv("RC_DEBUG_PREFIX_MAP"))
+return S;
+  return {};
+}
+
 llvm::ExceptionHandling Darwin::GetExceptionModel(const ArgList &Args) const {
   // Darwin uses SjLj exceptions on ARM.
   if (getTriple().getArch() != llvm::Triple::arm &&

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 

[clang] [clang] Move CCC_OVERRIDE_OPTIONS implementation to Driver (PR #85425)

2024-03-15 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl approved this pull request.


https://github.com/llvm/llvm-project/pull/85425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   >