Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

AV when reporting diagnostics in some code-completion results #9102

Closed Quuxplusone closed 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR8733
Status RESOLVED FIXED
Importance P normal
Reported by Paul Curtis (plc@rowley.co.uk)
Reported on 2010-12-03 09:25:22 -0800
Last modified on 2011-07-01 10:22:44 -0700
Version trunk
Hardware All Windows NT
CC akyrtzi@gmail.com, dgregor@apple.com, llvm-bugs@lists.llvm.org, plc@rowley.co.uk
Fixed by commit(s)
Attachments Debug.zip (340 bytes, application/x-zip-compressed)
Blocks
Blocked by
See also
Created attachment 5865
Contains repro case

Code completion generates an exception when reporting errors in #included macro
expansions with precompiled headers enabled.

> more pl230.h
#define __C(X)   (0xFFFFFFFFU >> (31-(X)))

enum {
  V  = __C(31),
};

> more lm3s_mac.c
#include "pl230.h"

static void
foo(void)
{
/
}

>set CINDEXTEST_EDITING=1
>c-index-test -code-completion-at=lm3s_mac.c:6:2 lm3s_mac.c -nostdinc -I.

[snip]

599B66BE (0x00000004 0x00EEDAC8 0x00BDF760 0x599B6796), clang::SourceManager::ge
tSLocEntry()+0142 bytes(s), e:\llvm\llvm\tools\clang\include\clang\basic\sourcem
anager.h, line 818+0022 byte(s)
599B660A (0x00000004 0x00BDFC20 0x00000004 0x00E6B620), clang::SourceManager::ge
tSLocEntry()+0026 bytes(s), e:\llvm\llvm\tools\clang\include\clang\basic\sourcem
anager.h, line 824

...and so on.

Actually, this bug is triggered *ONLY* by CXTranslationUnit_PrecompiledPreamble
as far as I can tell.  Turning precompiled preamble off and we're good.

You change getDefaultParsingOptions() in c-index-test, you provoke a crash or
not, which is what I did.

static unsigned getDefaultParsingOptions() {
  unsigned options = 0; // Nuke this one..
                        // CXTranslationUnit_DetailedPreprocessingRecord;

  if (getenv("CINDEXTEST_EDITING"))
    {
      // Figure out which option triggers fault: break them out...
      options |= CXTranslationUnit_PrecompiledPreamble;
      //      options |= CXTranslationUnit_CacheCompletionResults;
      //      options |= CXTranslationUnit_CXXPrecompiledPreamble;

      // was: options |= clang_defaultEditingTranslationUnitOptions();
    }
  if (getenv("CINDEXTEST_COMPLETION_CACHING"))
    options |= CXTranslationUnit_CacheCompletionResults;

  return options;
}

This may well affect released versions of clang, I have no idea.  I'm just
trunking at present.
Quuxplusone commented 13 years ago

Attached Debug.zip (340 bytes, application/x-zip-compressed): Contains repro case

Quuxplusone commented 13 years ago

This is fixed in top-of-tree Clang.