Bug in Location info in CTranslUnit?

Mark Tullsen tullsen at galois.com
Fri Oct 19 04:16:59 BST 2012


Here are my two input files (2 lines each):

  ================== exas/t5.c =================
  #include "../../tests/demo3/foo.h"
  int x;
  ================== exas/t6.c =================
  int x;
  #include "../../tests/demo3/foo.h"

Here's my simple code:

  parseFile :: FilePath -> IO CTranslUnit
  parseFile input_file =
    do parse_result <- parseCFile (newGCC "gcc")
                                  Nothing
                                  ["-U__BLOCKS__"]   -- objective C/Apple thing
                                  input_file
       case parse_result of
         Left parse_err -> error (show parse_err)
         Right ast      -> return ast

Here's what I get:

  *Debug> fmap posOf $ parseFile "exas/t5.c"
  ("exas/../../tests/demo3/foo.h": line 4)

  *Debug> fmap posOf $ parseFile "exas/t6.c"
  ("exas/t6.c": line 1)

I would expect the Position data for a CTranslUnit to contain the filename I'm compiling, not the filename associated with the first declaration in the file. 

Am I'm missing something here or is this just a bug?

Thanks,

Mark




More information about the Language-c mailing list